From bc4248fde86ed81df6fd7666354b0cbc4a692c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernd=20Oliver=20S=C3=BCnderhauf?= <46800703+bosue@users.noreply.github.com> Date: Sun, 3 Dec 2023 07:26:46 +0100 Subject: [PATCH] test: Make control_phone UI test idempotent and a bit more reliable. (#23569) * test(control_phone.js): Add a little waiting time before switching country. * test(control_phone.js): Harden by removing fuzzy 'force' and 'multiple' qualifiers. * test(control_phone.js): Make idempotent by removing dialog even after failure. --- cypress/integration/control_phone.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cypress/integration/control_phone.js b/cypress/integration/control_phone.js index 955678a2d6..103b813013 100644 --- a/cypress/integration/control_phone.js +++ b/cypress/integration/control_phone.js @@ -6,6 +6,10 @@ context("Control Phone", () => { cy.visit("/app/website"); }); + afterEach(() => { + cy.clear_dialogs(); + }); + function get_dialog_with_phone() { return cy.dialog({ title: "Phone", @@ -20,31 +24,37 @@ context("Control Phone", () => { it("should set flag and data", () => { get_dialog_with_phone().as("dialog"); + cy.get(".selected-phone").click(); + cy.wait(100); cy.get(".phone-picker .phone-wrapper[id='afghanistan']").click(); + cy.wait(100); + cy.get(".selected-phone .country").should("have.text", "+93"); + cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/af.svg"); + cy.get(".selected-phone").click(); + cy.wait(100); cy.get(".phone-picker .phone-wrapper[id='india']").click(); + cy.wait(100); cy.get(".selected-phone .country").should("have.text", "+91"); cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/in.svg"); let phone_number = "9312672712"; cy.get(".selected-phone > img").click().first(); - cy.get_field("phone").first().click({ multiple: true }); + cy.get_field("phone").first().click(); cy.get(".frappe-control[data-fieldname=phone]") .findByRole("textbox") .first() - .type(phone_number, { force: true }); + .type(phone_number); cy.get_field("phone").first().should("have.value", phone_number); - cy.get_field("phone").first().blur({ force: true }); + cy.get_field("phone").first().blur(); cy.wait(100); cy.get("@dialog").then((dialog) => { let value = dialog.get_value("phone"); expect(value).to.equal("+91-" + phone_number); }); - }); - it("case insensitive search for country and clear search", () => { let search_text = "india"; cy.get(".selected-phone").click().first(); cy.get(".phone-picker").get(".search-phones").click().type(search_text);