From 9a963bedb5c3c99feb73366f959762aba6c4c4a9 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 16 Jun 2023 10:23:05 +0530 Subject: [PATCH 1/7] test: Fix failing test for icon & phone - for some reason findBYRole("searchbox") stopped working - there are no changes to related DOM recently - There's pending issue related to this https://github.com/testing-library/cypress-testing-library/issues/205#issuecomment-1572230102 --- cypress/integration/control_icon.js | 4 ++-- cypress/integration/control_phone.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress/integration/control_icon.js b/cypress/integration/control_icon.js index a965ed0f9e..406e9f1162 100644 --- a/cypress/integration/control_icon.js +++ b/cypress/integration/control_icon.js @@ -42,14 +42,14 @@ context("Control Icon", () => { it("search for icon and clear search input", () => { let search_text = "ed"; - cy.get(".icon-picker").findByRole("searchbox").click().type(search_text); + cy.get(".icon-picker").get(".search-icons > input").click().type(search_text); cy.get(".icon-section .icon-wrapper:not(.hidden)").then((i) => { cy.get(`.icon-section .icon-wrapper[id*='${search_text}']`).then((icons) => { expect(i.length).to.equal(icons.length); }); }); - cy.get(".icon-picker").findByRole("searchbox").clear().blur(); + cy.get(".icon-picker").get(".search-icons > input").clear().blur(); cy.get(".icon-section .icon-wrapper").should("not.have.class", "hidden"); }); }); diff --git a/cypress/integration/control_phone.js b/cypress/integration/control_phone.js index b56343c2d8..b5b29fe758 100644 --- a/cypress/integration/control_phone.js +++ b/cypress/integration/control_phone.js @@ -47,7 +47,7 @@ context("Control Phone", () => { it("case insensitive search for country and clear search", () => { let search_text = "india"; cy.get(".selected-phone").click().first(); - cy.get(".phone-picker").findByRole("searchbox").click().type(search_text); + cy.get(".phone-picker").get(".search-phones").click().type(search_text); cy.get(".phone-section .phone-wrapper:not(.hidden)").then((i) => { cy.get(`.phone-section .phone-wrapper[id*="${search_text.toLowerCase()}"]`).then( (countries) => { @@ -56,7 +56,7 @@ context("Control Phone", () => { ); }); - cy.get(".phone-picker").findByRole("searchbox").clear().blur(); + cy.get(".phone-picker").get(".search-phones").clear(); cy.get(".phone-section .phone-wrapper").should("not.have.class", "hidden"); }); From e8ebf19308310b08f9c09a6b05dd4dfa0eb72ab0 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 16 Jun 2023 10:30:02 +0530 Subject: [PATCH 2/7] style: Fix formatting issue --- frappe/public/js/frappe/model/create_new.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/model/create_new.js b/frappe/public/js/frappe/model/create_new.js index e313f76113..5deccaeb9b 100644 --- a/frappe/public/js/frappe/model/create_new.js +++ b/frappe/public/js/frappe/model/create_new.js @@ -163,7 +163,7 @@ $.extend(frappe.model, { if (!user_default) { user_default = frappe.defaults.get_user_default(df.fieldname); - } + } if ( !user_default && df.remember_last_selected_value && From 91afe51c7c67d59235bbbd5bad8679dbc1c346ea Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 16 Jun 2023 10:58:27 +0530 Subject: [PATCH 3/7] test: Make folder navigation test less flaky --- cypress/integration/folder_navigation.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cypress/integration/folder_navigation.js b/cypress/integration/folder_navigation.js index ba65454ef6..4a32c16516 100644 --- a/cypress/integration/folder_navigation.js +++ b/cypress/integration/folder_navigation.js @@ -11,9 +11,9 @@ context("Folder Navigation", () => { cy.click_filter_button(); cy.get(".filter-action-buttons > .text-muted").findByText("+ Add a Filter").click(); cy.get(".fieldname-select-area > .awesomplete > .form-control:last").type("Fol{enter}"); - cy.get( - ".filter-field > .form-group > .link-field > .awesomplete > .input-with-feedback" - ).type("Home{enter}"); + cy.get(".filter-field > .form-group > .link-field > .awesomplete > .input-with-feedback") + .first() + .type("Home{enter}"); cy.get(".filter-action-buttons > div > .btn-primary").findByText("Apply Filters").click(); //Adding folder (Test Folder) @@ -24,6 +24,7 @@ context("Folder Navigation", () => { it("Navigating the nested folders, checking if the URL formed is correct, checking if the added content in the child folder is correct", () => { //Navigating inside the Attachments folder + cy.clear_filters(); cy.wait(500); cy.get('[title="Attachments"] > span').click(); From 6c3957aa302f4b2ea42ae6757f577015bda7a616 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 16 Jun 2023 11:01:21 +0530 Subject: [PATCH 4/7] test: Return cy.request promise from login - to make cypress wait for the promise. --- cypress/support/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 4b44a24598..3ad9aa090a 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -34,7 +34,7 @@ Cypress.Commands.add("login", (email, password) => { if (!password) { password = Cypress.env("adminPassword"); } - cy.request({ + return cy.request({ url: "/api/method/login", method: "POST", body: { From 49d7f132dad3e99e4bfff6c773bcf05d0f6f9a9a Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 16 Jun 2023 11:32:55 +0530 Subject: [PATCH 5/7] test: Fix control link flaky test --- cypress/integration/control_link.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cypress/integration/control_link.js b/cypress/integration/control_link.js index d3462492f6..0746f4460e 100644 --- a/cypress/integration/control_link.js +++ b/cypress/integration/control_link.js @@ -133,8 +133,7 @@ context("Control Link", () => { true ); - cy.clear_cache(); - cy.wait(500); + cy.reload(); get_dialog_with_link().as("dialog"); cy.window() @@ -177,7 +176,7 @@ context("Control Link", () => { cy.intercept("POST", "/api/method/frappe.client.validate_link").as("validate_link"); cy.get(".frappe-control[data-fieldname=assigned_by] input").focus().as("input"); - cy.get("@input").type(cy.config("testUser"), { delay: 100 }).blur(); + cy.get("@input").clear().type(cy.config("testUser"), { delay: 300 }).blur(); cy.wait("@validate_link"); cy.get(".frappe-control[data-fieldname=assigned_by_full_name] .control-value").should( "contain", From 8008afaf779482ed94b11bfdb5f6d7615b16dedc Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 16 Jun 2023 11:53:35 +0530 Subject: [PATCH 6/7] test: Fix Kanban test --- cypress/support/commands.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 3ad9aa090a..319d6d5840 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -374,6 +374,7 @@ Cypress.Commands.add("update_doc", (doctype, docname, args) => { Cypress.Commands.add("switch_to_user", (user) => { cy.call("logout"); cy.login(user); + cy.reload(); }); Cypress.Commands.add("add_role", (user, role) => { From 821f75c3ad43fab3e79cfed6c46b8d60add74bc6 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 16 Jun 2023 12:47:39 +0530 Subject: [PATCH 7/7] fix: Try waiting for logout --- cypress/integration/kanban.js | 10 +++++----- cypress/support/commands.js | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cypress/integration/kanban.js b/cypress/integration/kanban.js index f14c991c7c..12c5e7e8bd 100644 --- a/cypress/integration/kanban.js +++ b/cypress/integration/kanban.js @@ -100,15 +100,15 @@ context("Kanban Board", () => { it("Checks if Kanban Board edits are blocked for non-System Manager and non-owner of the Board", () => { cy.switch_to_user("Administrator"); - const noSystemManager = "nosysmanager@example.com"; + const not_system_manager = "nosysmanager@example.com"; cy.call("frappe.tests.ui_test_helpers.create_test_user", { - username: noSystemManager, + username: not_system_manager, }); - cy.remove_role(noSystemManager, "System Manager"); + cy.remove_role(not_system_manager, "System Manager"); cy.call("frappe.tests.ui_test_helpers.create_todo", { description: "Frappe User ToDo" }); cy.call("frappe.tests.ui_test_helpers.create_admin_kanban"); - cy.switch_to_user(noSystemManager); + cy.switch_to_user(not_system_manager); cy.visit("/app/todo/view/kanban/Admin Kanban"); @@ -125,7 +125,7 @@ context("Kanban Board", () => { cy.get(".kanban .column-options").should("have.length", 0); cy.switch_to_user("Administrator"); - cy.call("frappe.client.delete", { doctype: "User", name: noSystemManager }); + cy.call("frappe.client.delete", { doctype: "User", name: not_system_manager }); }); after(() => { diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 319d6d5840..23b03549fa 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -373,6 +373,7 @@ Cypress.Commands.add("update_doc", (doctype, docname, args) => { Cypress.Commands.add("switch_to_user", (user) => { cy.call("logout"); + cy.wait(200); cy.login(user); cy.reload(); });