diff --git a/cypress/integration/control_link.js b/cypress/integration/control_link.js index 240515be45..a5281d9b09 100644 --- a/cypress/integration/control_link.js +++ b/cypress/integration/control_link.js @@ -177,14 +177,14 @@ 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("Administrator", { delay: 100 }).blur(); + cy.get("@input").type(cy.config("testUser"), { delay: 100 }).blur(); cy.wait("@validate_link"); cy.get(".frappe-control[data-fieldname=assigned_by_full_name] .control-value").should( "contain", - "Administrator" + "Frappe" ); - cy.window().its("cur_frm.doc.assigned_by").should("eq", "Administrator"); + cy.window().its("cur_frm.doc.assigned_by").should("eq", cy.config("testUser")); // invalid input cy.get("@input").clear().type("invalid input", { delay: 100 }).blur(); @@ -198,10 +198,10 @@ context("Control Link", () => { // set valid value again cy.get("@input").clear().focus(); cy.wait("@search_link"); - cy.get("@input").type("Administrator", { delay: 100 }).blur(); + cy.get("@input").type(cy.config("testUser"), { delay: 100 }).blur(); cy.wait("@validate_link"); - cy.window().its("cur_frm.doc.assigned_by").should("eq", "Administrator"); + cy.window().its("cur_frm.doc.assigned_by").should("eq", cy.config("testUser")); // clear input cy.get("@input").clear().blur(); diff --git a/cypress/integration/dashboard_links.js b/cypress/integration/dashboard_links.js index 995f8d0d9f..061899ec95 100644 --- a/cypress/integration/dashboard_links.js +++ b/cypress/integration/dashboard_links.js @@ -8,7 +8,7 @@ const child_table_doctype_name = child_table_doctype.name; context("Dashboard links", () => { before(() => { cy.visit("/login"); - cy.login(); + cy.login("Administrator"); cy.insert_doc("DocType", child_table_doctype, true); cy.insert_doc("DocType", child_table_doctype_1, true); cy.insert_doc("DocType", doctype_with_child_table, true); @@ -27,8 +27,7 @@ context("Dashboard links", () => { cy.visit("/app/contact"); cy.clear_filters(); - cy.visit("/app/user"); - cy.get(".list-row-col > .level-item > .ellipsis").eq(0).click({ force: true }); + cy.visit(`/app/user/${cy.config("testUser")}`); //To check if initially the dashboard contains only the "Contact" link and there is no counter cy.select_form_tab("Connections"); @@ -41,12 +40,11 @@ context("Dashboard links", () => { cy.findByRole("button", { name: "Add Contact" }).click(); cy.get('[data-doctype="Contact"][data-fieldname="first_name"]').type("Admin"); cy.findByRole("button", { name: "Save" }).click(); - cy.visit("/app/user"); - cy.get(".list-row-col > .level-item > .ellipsis").eq(0).click({ force: true }); + cy.visit(`/app/user/${cy.config("testUser")}`); - //To check if the counter for contact doc is "1" after adding the contact + //To check if the counter for contact doc is "2" after adding additional contact cy.select_form_tab("Connections"); - cy.get('[data-doctype="Contact"] > .count').should("contain", "1"); + cy.get('[data-doctype="Contact"] > .count').should("contain", "2"); cy.get('[data-doctype="Contact"]').contains("Contact").click(); //Deleting the newly created contact @@ -64,8 +62,7 @@ context("Dashboard links", () => { }); it("Report link in dashboard", () => { - cy.visit("/app/user"); - cy.visit("/app/user/Administrator"); + cy.visit(`/app/user/${cy.config("testUser")}`); cy.select_form_tab("Connections"); cy.get('.document-link[data-doctype="Contact"]').contains("Contact"); cy.window() diff --git a/cypress/integration/sidebar.js b/cypress/integration/sidebar.js index 147d425aa2..6a23d88662 100644 --- a/cypress/integration/sidebar.js +++ b/cypress/integration/sidebar.js @@ -72,7 +72,7 @@ context("Sidebar", () => { cy.get(".condition").should("have.value", "like"); cy.get(".filter-field > .form-group > .input-with-feedback").should( "have.value", - "%Administrator%" + `%${cy.config("testUser")}%` ); cy.click_filter_button(); diff --git a/cypress/integration/table_multiselect.js b/cypress/integration/table_multiselect.js index 4f95b50147..8261b5b384 100644 --- a/cypress/integration/table_multiselect.js +++ b/cypress/integration/table_multiselect.js @@ -13,7 +13,9 @@ context("Table MultiSelect", () => { cy.fill_field("assign_condition", 'status=="Open"', "Code"); cy.get('input[data-fieldname="users"]').focus().as("input"); cy.get('input[data-fieldname="users"] + ul').should("be.visible"); - cy.get("@input").type("test{enter}", { delay: 100 }); + cy.get("@input").type("test@erpnext", { delay: 100 }); + cy.wait(500); + cy.get("@input").type("{enter}"); cy.get( '.frappe-control[data-fieldname="users"] .form-control .tb-selected-value .btn-link-to-form' ).as("selected-value"); diff --git a/cypress/integration/timeline.js b/cypress/integration/timeline.js index 5841891af6..7835819334 100644 --- a/cypress/integration/timeline.js +++ b/cypress/integration/timeline.js @@ -72,14 +72,14 @@ context("Timeline", () => { cy.click_listview_row_item(0); //To check if the submission of the documemt is visible in the timeline content - cy.get(".timeline-content").should("contain", "Administrator submitted this document"); + cy.get(".timeline-content").should("contain", "Frappe submitted this document"); cy.get('[id="page-Custom Submittable DocType"] .page-actions') .findByRole("button", { name: "Cancel" }) .click(); cy.get_open_dialog().findByRole("button", { name: "Yes" }).click(); //To check if the cancellation of the documemt is visible in the timeline content - cy.get(".timeline-content").should("contain", "Administrator cancelled this document"); + cy.get(".timeline-content").should("contain", "Frappe cancelled this document"); //Deleting the document cy.visit("/app/custom-submittable-doctype"); diff --git a/cypress/integration/web_form.js b/cypress/integration/web_form.js index d7f210e7d2..53f72ab013 100644 --- a/cypress/integration/web_form.js +++ b/cypress/integration/web_form.js @@ -1,6 +1,13 @@ context("Web Form", () => { before(() => { - cy.login(); + cy.login("Administrator"); + cy.visit("/app/"); + return cy + .window() + .its("frappe") + .then((frappe) => { + return frappe.xcall("frappe.tests.ui_test_helpers.clear_notes"); + }); }); it("Create Web Form", () => { @@ -42,7 +49,7 @@ context("Web Form", () => { }); it("Login Required", () => { - cy.login(); + cy.login("Administrator"); cy.visit("/app/web-form/note"); cy.findByRole("tab", { name: "Settings" }).click(); @@ -51,7 +58,6 @@ context("Web Form", () => { cy.save(); cy.visit("/note"); - cy.url().should("include", "/note/Note%201"); cy.call("logout"); @@ -62,7 +68,7 @@ context("Web Form", () => { }); it("Show List", () => { - cy.login(); + cy.login("Administrator"); cy.visit("/app/web-form/note"); cy.findByRole("tab", { name: "Settings" }).click(); @@ -156,7 +162,7 @@ context("Web Form", () => { }); it("Read Only", () => { - cy.login(); + cy.login("Administrator"); cy.visit("/note"); cy.url().should("include", "/note/list"); diff --git a/frappe/tests/ui_test_helpers.py b/frappe/tests/ui_test_helpers.py index f014cf379e..7b0bc01252 100644 --- a/frappe/tests/ui_test_helpers.py +++ b/frappe/tests/ui_test_helpers.py @@ -54,6 +54,15 @@ def create_todo_records(): ).insert() +@frappe.whitelist() +def clear_notes(): + if not frappe.local.dev_server: + frappe.throw(_("Not allowed"), frappe.PermissionError) + + for note in frappe.get_all("Note", pluck="name"): + frappe.delete_doc("Note", note, force=True) + + @frappe.whitelist() def create_communication_record(): doc = frappe.get_doc( @@ -408,6 +417,7 @@ def create_test_user(): user.first_name = "Frappe" user.new_password = frappe.local.conf.admin_password user.send_welcome_email = 0 + user.time_zone = "Asia/Kolkata" user.flags.ignore_password_policy = True user.insert(ignore_if_duplicate=True)