From 175d176236c76bf4943a6888be3070e639350474 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Fri, 2 Sep 2022 19:55:44 +0530 Subject: [PATCH] refactor: drop file upload plugin Cypress supports this natively now! (cherry picked from commit c400e189796c0eb1fe3fc93ae1aeaba7e942a179) --- cypress/integration/control_markdown_editor.js | 9 ++++++--- cypress/integration/file_uploader.js | 16 ++++++++++------ cypress/integration/sidebar.js | 8 +++++--- cypress/support/commands.js | 1 - frappe/commands/utils.py | 3 --- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/cypress/integration/control_markdown_editor.js b/cypress/integration/control_markdown_editor.js index 16c3dac51f..24ab32f48a 100644 --- a/cypress/integration/control_markdown_editor.js +++ b/cypress/integration/control_markdown_editor.js @@ -7,9 +7,12 @@ context("Control Markdown Editor", () => { it("should allow inserting images by drag and drop", () => { cy.visit("/app/web-page/new"); cy.fill_field("content_type", "Markdown", "Select"); - cy.get_field("main_section_md", "Markdown Editor").attachFile("sample_image.jpg", { - subjectType: "drag-n-drop", - }); + cy.get_field("main_section_md", "Markdown Editor").selectFile( + "cypress/fixtures/sample_image.jpg", + { + action: "drag-drop", + } + ); cy.click_modal_primary_button("Upload"); cy.get_field("main_section_md", "Markdown Editor").should( "contain", diff --git a/cypress/integration/file_uploader.js b/cypress/integration/file_uploader.js index 669f9ba385..e1cf91d043 100644 --- a/cypress/integration/file_uploader.js +++ b/cypress/integration/file_uploader.js @@ -21,9 +21,11 @@ context("FileUploader", () => { it("should accept dropped files", () => { open_upload_dialog(); - cy.get_open_dialog().find(".file-upload-area").attachFile("example.json", { - subjectType: "drag-n-drop", - }); + cy.get_open_dialog() + .find(".file-upload-area") + .selectFile("cypress/fixtures/example.json", { + action: "drag-drop", + }); cy.get_open_dialog().find(".file-name").should("contain", "example.json"); cy.intercept("POST", "/api/method/upload_file").as("upload_file"); @@ -64,9 +66,11 @@ context("FileUploader", () => { it("should allow cropping and optimization for valid images", () => { open_upload_dialog(); - cy.get_open_dialog().find(".file-upload-area").attachFile("sample_image.jpg", { - subjectType: "drag-n-drop", - }); + 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(); diff --git a/cypress/integration/sidebar.js b/cypress/integration/sidebar.js index ee724ffda2..147d425aa2 100644 --- a/cypress/integration/sidebar.js +++ b/cypress/integration/sidebar.js @@ -4,9 +4,11 @@ const verify_attachment_visibility = (document, is_private) => { const assertion = is_private ? "be.checked" : "not.be.checked"; cy.findByRole("button", { name: "Attach File" }).click(); - cy.get_open_dialog().find(".file-upload-area").attachFile("sample_image.jpg", { - subjectType: "drag-n-drop", - }); + cy.get_open_dialog() + .find(".file-upload-area") + .selectFile("cypress/fixtures/sample_image.jpg", { + action: "drag-drop", + }); cy.get_open_dialog().findByRole("checkbox", { name: "Private" }).should(assertion); }; diff --git a/cypress/support/commands.js b/cypress/support/commands.js index fb1ff99678..c8757ffed5 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -1,4 +1,3 @@ -import "cypress-file-upload"; import "@testing-library/cypress/add-commands"; import "@4tw/cypress-drag-drop"; import "cypress-real-events/support"; diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index c875667c82..36ad9debb1 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -860,7 +860,6 @@ def run_ui_tests( node_bin = subprocess.getoutput("npm bin") cypress_path = f"{node_bin}/cypress" - plugin_path = f"{node_bin}/../cypress-file-upload" drag_drop_plugin_path = f"{node_bin}/../@4tw/cypress-drag-drop" real_events_plugin_path = f"{node_bin}/../cypress-real-events" testing_library_path = f"{node_bin}/../@testing-library" @@ -869,7 +868,6 @@ def run_ui_tests( # check if cypress in path...if not, install it. if not ( os.path.exists(cypress_path) - and os.path.exists(plugin_path) and os.path.exists(drag_drop_plugin_path) and os.path.exists(real_events_plugin_path) and os.path.exists(testing_library_path) @@ -880,7 +878,6 @@ def run_ui_tests( packages = " ".join( [ "cypress@^10", - "cypress-file-upload@^5", "@4tw/cypress-drag-drop@^2", "cypress-real-events", "@testing-library/cypress@^8",