fix: cypress attach control library button

*   As on clear of attach field file is deleted as well
    in `Checking functionality for "Link"` test.

*   Instead of assuming that file is present from previous test.

*   create a new doc and attach a file (link) to it.
    then create another doc and check library button functionality
    and then delete both docs.
This commit is contained in:
Maharshi Patel 2023-10-18 12:35:52 +05:30
parent a67f1fafcd
commit 1d4936b7e2

View file

@ -65,6 +65,25 @@ context("Attach Control", () => {
//Clicking on the attach button which is displayed as part of creating a doctype with "Attach" fieldtype
cy.findByRole("button", { name: "Attach" }).click();
//Clicking on "Link" button to attach a file using the "Link" button
cy.findByRole("button", { name: "Link" }).click();
cy.findByPlaceholderText("Attach a web link").type(
"https://wallpaperplay.com/walls/full/8/2/b/72402.jpg",
{ force: true }
);
//Clicking on the Upload button to upload the file
cy.intercept("POST", "/api/method/upload_file").as("upload_image");
cy.get(".modal-footer").findByRole("button", { name: "Upload" }).click({ delay: 500 });
cy.wait("@upload_image");
cy.findByRole("button", { name: "Save" }).click();
//Navigating to the new form for the newly created doctype to check Library button
cy.new_form("Test Attach Control");
//Clicking on the attach button which is displayed as part of creating a doctype with "Attach" fieldtype
cy.findByRole("button", { name: "Attach" }).click();
//Clicking on "Library" button to attach a file using the "Library" button
cy.findByRole("button", { name: "Library" }).click();
cy.contains("72402.jpg").click();
@ -86,9 +105,10 @@ context("Attach Control", () => {
//Checking if clicking on the clear button clears the field of the doctype form and again displays the attach button
cy.get(".control-input > .btn-sm").should("contain", "Attach");
//Deleting the doc
//Deleting both docs
cy.go_to_list("Test Attach Control");
cy.get(".list-row-checkbox").eq(0).click();
cy.get(".list-row-checkbox").eq(1).click();
cy.get(".actions-btn-group > .btn").contains("Actions").click();
cy.get('.actions-btn-group > .dropdown-menu [data-label="Delete"]').click();
cy.click_modal_primary_button("Yes");