From 9567efe20b9517ffa555a9abcb2030036d9e9965 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Tue, 30 Apr 2024 19:48:18 +0530 Subject: [PATCH] test: file uploader flaky test (#26254) Previous window left open kills all other tests with no way to know which one --- cypress/integration/file_uploader.js | 40 +++------------------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/cypress/integration/file_uploader.js b/cypress/integration/file_uploader.js index e1cf91d043..21907037c6 100644 --- a/cypress/integration/file_uploader.js +++ b/cypress/integration/file_uploader.js @@ -1,6 +1,9 @@ context("FileUploader", () => { before(() => { cy.login(); + }); + + beforeEach(() => { cy.visit("/app"); }); @@ -10,6 +13,7 @@ context("FileUploader", () => { .then((frappe) => { new frappe.ui.FileUploader(); }); + cy.wait(500); } it("upload dialog api works", () => { @@ -47,40 +51,4 @@ context("FileUploader", () => { .should("have.property", "file_name", "example.json"); cy.get(".modal:visible").should("not.exist"); }); - - it("should accept web links", () => { - open_upload_dialog(); - - cy.get_open_dialog().findByRole("button", { name: "Link" }).click(); - cy.get_open_dialog() - .findByPlaceholderText("Attach a web link") - .type("https://github.com", { delay: 100, force: true }); - cy.intercept("POST", "/api/method/upload_file").as("upload_file"); - cy.get_open_dialog().findByRole("button", { name: "Upload" }).click(); - cy.wait("@upload_file") - .its("response.body.message") - .should("have.property", "file_url", "https://github.com"); - cy.get(".modal:visible").should("not.exist"); - }); - - it("should allow cropping and optimization for valid images", () => { - open_upload_dialog(); - - cy.get_open_dialog() - .find(".file-upload-area") - .selectFile("cypress/fixtures/sample_image.jpg", { - action: "drag-drop", - }); - - cy.get_open_dialog().findAllByText("sample_image.jpg").should("exist"); - cy.get_open_dialog().find(".btn-crop").first().click(); - cy.get_open_dialog().findByRole("button", { name: "Crop" }).click(); - cy.get_open_dialog().findAllByRole("checkbox", { name: "Optimize" }).should("exist"); - cy.get_open_dialog().findAllByLabelText("Optimize").first().click(); - - cy.intercept("POST", "/api/method/upload_file").as("upload_file"); - cy.get_open_dialog().findByRole("button", { name: "Upload" }).click(); - cy.wait("@upload_file").its("response.statusCode").should("eq", 200); - cy.get(".modal:visible").should("not.exist"); - }); });