diff --git a/cypress/integration/web_form.js b/cypress/integration/web_form.js index 53f72ab013..8dd16389e7 100644 --- a/cypress/integration/web_form.js +++ b/cypress/integration/web_form.js @@ -6,7 +6,7 @@ context("Web Form", () => { .window() .its("frappe") .then((frappe) => { - return frappe.xcall("frappe.tests.ui_test_helpers.clear_notes"); + return frappe.xcall("frappe.tests.ui_test_helpers.prepare_webform_test"); }); }); @@ -99,7 +99,7 @@ context("Web Form", () => { cy.visit("/note"); cy.url().should("include", "/note/list"); - cy.get(".web-list-table thead th").contains("Name"); + cy.get(".web-list-table thead th").contains("Sr."); cy.get(".web-list-table thead th").contains("Title"); cy.visit("/app/web-form/note"); @@ -133,13 +133,17 @@ context("Web Form", () => { cy.visit("/note"); cy.url().should("include", "/note/list"); + cy.get(".web-list-table thead th").contains("Sr."); cy.get(".web-list-table thead th").contains("Title"); cy.get(".web-list-table thead th").contains("Public"); cy.get(".web-list-table thead th").contains("Content"); }); it("Breadcrumbs", () => { - cy.visit("/note/Note 1"); + cy.visit("/note"); + cy.url().should("include", "/note/list"); + cy.get(".web-list-table tbody tr:last").click(); + cy.get(".breadcrumb-container .breadcrumb .breadcrumb-item:first a") .should("contain.text", "Note") .click(); @@ -154,7 +158,9 @@ context("Web Form", () => { cy.get(".form-tabs .nav-item .nav-link").contains("Customization").click(); cy.save(); - cy.visit("/note/Note 1"); + cy.visit("/note"); + cy.url().should("include", "/note/list"); + cy.get(".web-list-table tbody tr:last").click(); cy.get(".breadcrumb-container .breadcrumb .breadcrumb-item:first a").should( "contain.text", "Notes" @@ -167,7 +173,7 @@ context("Web Form", () => { cy.url().should("include", "/note/list"); // Read Only Field - cy.get('.web-list-table tbody tr[id="Note 1"]').click(); + cy.get(".web-list-table tbody tr:last").click(); cy.get('.frappe-control[data-fieldname="title"] .control-input').should( "have.css", "display", @@ -183,11 +189,12 @@ context("Web Form", () => { cy.save(); - cy.visit("/note/Note 1"); - cy.url().should("include", "/note/Note%201"); + cy.visit("/note"); + cy.url().should("include", "/note/list"); + cy.get(".web-list-table tbody tr:last").click(); cy.get(".web-form-actions a").contains("Edit Response").click(); - cy.url().should("include", "/note/Note%201/edit"); + cy.url().should("include", "/edit"); // Editable Field cy.get_field("title").should("have.value", "Note 1"); @@ -227,16 +234,16 @@ context("Web Form", () => { cy.visit("/note"); cy.url().should("include", "/note/list"); - cy.get('.web-list-table tbody tr[id="Note 1"] .list-col-checkbox input').click(); - cy.get('.web-list-table tbody tr[id="Note 2"] .list-col-checkbox input').click(); + cy.get(".web-list-table tbody tr:nth-child(1) .list-col-checkbox input").click(); + cy.get(".web-list-table tbody tr:nth-child(2) .list-col-checkbox input").click(); cy.get(".web-list-actions button:visible").contains("Delete").click({ force: true }); cy.get(".web-list-actions button").contains("Delete").should("not.be.visible"); cy.visit("/note"); - cy.get('.web-list-table tbody tr[id="Note 1"]').should("not.exist"); - cy.get('.web-list-table tbody tr[id="Note 2"]').should("not.exist"); - cy.get('.web-list-table tbody tr[id="Guest Note 1"]').should("exist"); + cy.get(".web-list-table tbody tr:nth-child(1)").should("exist"); + cy.get(".web-list-table tbody tr:nth-child(2)").should("not.exist"); + cy.get(".web-list-table tbody tr:nth-child(3)").should("not.exist"); }); it("Navigate and Submit a WebForm", () => { diff --git a/frappe/tests/ui_test_helpers.py b/frappe/tests/ui_test_helpers.py index 2846b33eb9..26d6b2d5da 100644 --- a/frappe/tests/ui_test_helpers.py +++ b/frappe/tests/ui_test_helpers.py @@ -77,10 +77,12 @@ def create_todo_records(): @whitelist_for_tests -def clear_notes(): +def prepare_webform_test(): for note in frappe.get_all("Note", pluck="name"): frappe.delete_doc("Note", note, force=True) + frappe.delete_doc_if_exists("Web Form", "note") + @whitelist_for_tests def create_communication_record():