test: fix form_builder UI test

This commit is contained in:
Shariq Ansari 2023-07-16 13:01:56 +05:30
parent a7eb3a452b
commit 686589d3ee

View file

@ -9,38 +9,23 @@ context("Form Builder", () => {
it("Open Form Builder for Web Form Doctype/Customize Form", () => {
// doctype
cy.visit("/app/form-builder/Web Form");
cy.visit("/app/doctype/Web Form");
cy.findByRole("tab", { name: "Form" }).click();
cy.get(".form-builder-container").should("exist");
// customize form
cy.visit("/app/form-builder/Web Form/customize");
cy.visit("/app/customize-form?doc_type=Web%20Form");
cy.findByRole("tab", { name: "Form" }).click();
cy.get(".form-builder-container").should("exist");
});
it("Change Doctype using page title dialog", () => {
cy.intercept("POST", "/api/method/frappe.desk.search.search_link").as("search_link");
cy.visit(`/app/form-builder/Web Form`);
cy.get(".form-builder-container").should("exist");
cy.get(".page-title").click();
cy.get(".frappe-control[data-fieldname='doctype'] input").click().as("input");
cy.get("@input").type("{rightArrow}Web Form Field", { delay: 200 });
cy.wait("@search_link");
cy.get("@input").type("{enter}").blur();
cy.click_modal_primary_button("Edit");
cy.get(".page-title .title-text").should("have.text", "Web Form Field");
});
it("Save without change, check form dirty and reset changes", () => {
cy.visit(`/app/form-builder/${doctype_name}`);
it("Save without change, check form dirty", () => {
cy.visit(`/app/doctype/${doctype_name}`);
cy.findByRole("tab", { name: "Form" }).click();
// Save without change
cy.click_doc_primary_button("Save");
cy.get(".desk-alert.orange .alert-message").should("have.text", "No changes to save");
cy.get(".desk-alert.orange .alert-message").should("have.text", "No changes in document");
// Check form dirty
cy.get(".tab-content.active .section-columns-container:first .column:first .field:first")
@ -48,14 +33,11 @@ context("Form Builder", () => {
.dblclick()
.type("Dirty");
cy.get(".title-area .indicator-pill.orange").should("have.text", "Not Saved");
// Reset changes
cy.get(".page-actions .custom-actions .btn").contains("Reset Changes").click();
cy.get(".title-area .indicator-pill.orange").should("not.exist");
});
it("Add empty section and save", () => {
cy.visit(`/app/form-builder/${doctype_name}`);
cy.visit(`/app/doctype/${doctype_name}`);
cy.findByRole("tab", { name: "Form" }).click();
let first_section = ".tab-content.active .form-section-container:first";
@ -71,7 +53,8 @@ context("Form Builder", () => {
it("Add Table field and check if columns are rendered", () => {
cy.intercept("POST", "/api/method/frappe.desk.search.search_link").as("search_link");
cy.visit(`/app/form-builder/${doctype_name}`);
cy.visit(`/app/doctype/${doctype_name}`);
cy.findByRole("tab", { name: "Form" }).click();
let first_field =
".tab-content.active .section-columns-container:first .column:first .field:first";
@ -126,20 +109,23 @@ context("Form Builder", () => {
});
it("Drag Field/Column/Section & Tab", () => {
cy.visit(`/app/form-builder/${doctype_name}`);
cy.visit(`/app/doctype/${doctype_name}`);
cy.findByRole("tab", { name: "Form" }).click();
let first_column = ".tab-content.active .section-columns-container:first .column:first";
let first_field = first_column + " .field:first";
let label = "div[title='Double click to edit label'] span:first";
cy.get(".tab-header .tabs .tab:first").click();
// drag first tab to second position
cy.get(".tabs .tab:first").drag(".tabs .tab:nth-child(2)", {
cy.get(".tab-header .tabs .tab:first").drag(".tab-header .tabs .tab:nth-child(2)", {
target: { x: 10, y: 10 },
force: true,
});
cy.get(".tabs .tab:first").find(label).should("have.text", "Tab 2");
cy.get(".tab-header .tabs .tab:first").find(label).should("have.text", "Tab 2");
cy.get(".tabs .tab:first").click();
cy.get(".tab-header .tabs .tab:first").click();
cy.get(".sidebar-container .tab:first").click();
// drag check field to first column
@ -151,7 +137,7 @@ context("Form Builder", () => {
cy.get(first_field)
.find("div[title='Double click to edit label']")
.dblclick()
.type("Test Check{enter}");
.type("Test Check");
cy.get(first_field).find(label).should("have.text", "Test Check");
// drag the first field to second position
@ -184,13 +170,14 @@ context("Form Builder", () => {
});
it("Add New Tab/Section/Column to Form", () => {
cy.visit(`/app/form-builder/${doctype_name}`);
cy.visit(`/app/doctype/${doctype_name}`);
cy.findByRole("tab", { name: "Form" }).click();
let first_section = ".tab-content.active .form-section-container:first";
// add new tab
cy.get(".tab-header").realHover().find(".tab-actions .new-tab-btn").click();
cy.get(".tabs .tab").should("have.length", 3);
cy.get(".tab-header .tabs .tab").should("have.length", 3);
// add new section
cy.get(first_section).click(15, 10);
@ -218,11 +205,12 @@ context("Form Builder", () => {
// remove tab
cy.get(".tab-header").realHover().find(".tab-actions .remove-tab-btn").click();
cy.get(".tabs .tab").should("have.length", 2);
cy.get(".tab-header .tabs .tab").should("have.length", 2);
});
it("Update Title field Label to New Title through Customize Form", () => {
cy.visit(`/app/form-builder/${doctype_name}`);
cy.visit(`/app/doctype/${doctype_name}`);
cy.findByRole("tab", { name: "Form" }).click();
let first_field =
".tab-content.active .section-columns-container:first .column:first .field:first";
@ -239,7 +227,8 @@ context("Form Builder", () => {
});
it("Validate Duplicate Name & reqd + hidden without default logic", () => {
cy.visit(`/app/form-builder/${doctype_name}`);
cy.visit(`/app/doctype/${doctype_name}`);
cy.findByRole("tab", { name: "Form" }).click();
let first_field =
".tab-content.active .section-columns-container:first .column:first .field:first";
@ -275,10 +264,11 @@ context("Form Builder", () => {
});
it("Undo/Redo", () => {
cy.visit(`/app/form-builder/${doctype_name}`);
cy.visit(`/app/doctype/${doctype_name}`);
cy.findByRole("tab", { name: "Form" }).click();
// click on second tab
cy.get(".tabs .tab:last").click();
cy.get(".tab-header .tabs .tab:last").click();
let first_column = ".tab-content.active .section-columns-container:first .column:first";
let first_field = first_column + " .field:first";