Bladeren bron

test: Simplify phone control test

version-14
Suraj Shetty 3 jaren geleden
bovenliggende
commit
a0e9b61e04
1 gewijzigde bestanden met toevoegingen van 8 en 29 verwijderingen
  1. +8
    -29
      cypress/integration/control_phone.js

+ 8
- 29
cypress/integration/control_phone.js Bestand weergeven

@@ -18,8 +18,9 @@ context("Control Phone", () => {

it("should set flag and data", () => {
get_dialog_with_phone().as("dialog");
cy.get(".selected-phone > svg").click();
cy.get(".selected-phone").click();
cy.get(".phone-picker .phone-wrapper[id='afghanistan']").click();
cy.get(".selected-phone").click();
cy.get(".phone-picker .phone-wrapper[id='india']").click();
cy.get(".selected-phone .country").should("have.text", "+91");
cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/in.svg");
@@ -35,9 +36,8 @@ context("Control Phone", () => {
.type(phone_number, {force: true});

cy.get_field("phone").first().should("have.value", phone_number);
cy.wait(1000);
cy.get_field("phone").first().blur({force: true});
cy.wait(100);
cy.get("@dialog").then(dialog => {
let value = dialog.get_value("phone");
expect(value).to.equal("+91-" + phone_number);
@@ -46,7 +46,7 @@ context("Control Phone", () => {

it("case insensitive search for country and clear search", () => {
let search_text = "india";
cy.get(".selected-phone > img").click().first();
cy.get(".selected-phone").click().first();
cy.get(".phone-picker").findByRole("searchbox").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 => {
@@ -58,7 +58,7 @@ context("Control Phone", () => {
cy.get(".phone-section .phone-wrapper").should("not.have.class", "hidden");
});

it("Already existing docs with phone field", () => {
it("existing document should render phone field with data", () => {
cy.visit("/app/doctype");
cy.insert_doc("DocType", doctype_with_phone, true);
cy.clear_cache();
@@ -68,7 +68,7 @@ context("Control Phone", () => {
cy.visit("/app/doctype-with-phone");
cy.click_listview_primary_button("Add Doctype With Phone");

//Adding a new entry for the created custom doctype
// create a record
cy.fill_field("title", "Test Phone 1");
cy.fill_field("phone", "+91-9823341234");
cy.get_field("phone").should("have.value", "9823341234");
@@ -77,35 +77,14 @@ context("Control Phone", () => {
let value = doc.data.phone;
expect(value).to.equal("+91-9823341234");
});
cy.go_to_list("Doctype With Phone");
cy.click_listview_primary_button("Add Doctype With Phone");
// Field should be empty on new doc
cy.get_field("phone").should("have.value", "");
cy.get(".selected-phone .country").should("have.text", "");
cy.fill_field("title", "Test Phone 2");
cy.fill_field("phone", "+91-9823341291");
cy.get_field("phone").should("have.value", "9823341291");
cy.intercept("POST", "/api/method/frappe.desk.form.save.savedocs").as("save_form");
cy.click_doc_primary_button("Save");
cy.wait("@save_form");

// open the doc from list view
cy.go_to_list("Doctype With Phone");
cy.clear_cache();
cy.click_listview_row_item(0);
cy.title().should("eq", "Test Phone 2");
cy.get(".selected-phone .country").should("have.text", "+91");
cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/in.svg");
cy.get_field("phone").should("have.value", "9823341291");
cy.go_to_list("Doctype With Phone");
cy.click_listview_row_item(1);
cy.title().should("eq", "Test Phone 1");
cy.get(".selected-phone .country").should("have.text", "+91");
cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/in.svg");
cy.get_field("phone").should("have.value", "9823341234");
cy.get_doc("Doctype With Phone", "Test Phone 2").then((doc) => {
let value = doc.data.phone;
expect(value).to.equal("+91-9823341291");
cy.remove_doc("Doctype With Phone", "Test Phone 1", true);
cy.remove_doc("Doctype With Phone", "Test Phone 2", true);
});
});
});

Laden…
Annuleren
Opslaan