test: file uploader flaky test (#26254)
Previous window left open kills all other tests with no way to know which one
This commit is contained in:
parent
ba2715582b
commit
9567efe20b
1 changed files with 4 additions and 36 deletions
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue