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.
This commit is contained in:
parent
8fea592f00
commit
bc4248fde8
1 changed files with 15 additions and 5 deletions
|
|
@ -6,6 +6,10 @@ context("Control Phone", () => {
|
||||||
cy.visit("/app/website");
|
cy.visit("/app/website");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
cy.clear_dialogs();
|
||||||
|
});
|
||||||
|
|
||||||
function get_dialog_with_phone() {
|
function get_dialog_with_phone() {
|
||||||
return cy.dialog({
|
return cy.dialog({
|
||||||
title: "Phone",
|
title: "Phone",
|
||||||
|
|
@ -20,31 +24,37 @@ context("Control Phone", () => {
|
||||||
|
|
||||||
it("should set flag and data", () => {
|
it("should set flag and data", () => {
|
||||||
get_dialog_with_phone().as("dialog");
|
get_dialog_with_phone().as("dialog");
|
||||||
|
|
||||||
cy.get(".selected-phone").click();
|
cy.get(".selected-phone").click();
|
||||||
|
cy.wait(100);
|
||||||
cy.get(".phone-picker .phone-wrapper[id='afghanistan']").click();
|
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.get(".selected-phone").click();
|
||||||
|
cy.wait(100);
|
||||||
cy.get(".phone-picker .phone-wrapper[id='india']").click();
|
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 .country").should("have.text", "+91");
|
||||||
cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/in.svg");
|
cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/in.svg");
|
||||||
|
|
||||||
let phone_number = "9312672712";
|
let phone_number = "9312672712";
|
||||||
cy.get(".selected-phone > img").click().first();
|
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]")
|
cy.get(".frappe-control[data-fieldname=phone]")
|
||||||
.findByRole("textbox")
|
.findByRole("textbox")
|
||||||
.first()
|
.first()
|
||||||
.type(phone_number, { force: true });
|
.type(phone_number);
|
||||||
|
|
||||||
cy.get_field("phone").first().should("have.value", 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.wait(100);
|
||||||
cy.get("@dialog").then((dialog) => {
|
cy.get("@dialog").then((dialog) => {
|
||||||
let value = dialog.get_value("phone");
|
let value = dialog.get_value("phone");
|
||||||
expect(value).to.equal("+91-" + phone_number);
|
expect(value).to.equal("+91-" + phone_number);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it("case insensitive search for country and clear search", () => {
|
|
||||||
let search_text = "india";
|
let search_text = "india";
|
||||||
cy.get(".selected-phone").click().first();
|
cy.get(".selected-phone").click().first();
|
||||||
cy.get(".phone-picker").get(".search-phones").click().type(search_text);
|
cy.get(".phone-picker").get(".search-phones").click().type(search_text);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue