Переглянути джерело

refactor: drop file upload plugin

Cypress supports this natively now!

(cherry picked from commit c400e18979)
version-14
Ankush Menat 2 роки тому
committed by Ankush Menat
джерело
коміт
175d176236
5 змінених файлів з 21 додано та 16 видалено
  1. +6
    -3
      cypress/integration/control_markdown_editor.js
  2. +10
    -6
      cypress/integration/file_uploader.js
  3. +5
    -3
      cypress/integration/sidebar.js
  4. +0
    -1
      cypress/support/commands.js
  5. +0
    -3
      frappe/commands/utils.py

+ 6
- 3
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",


+ 10
- 6
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();


+ 5
- 3
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);
};


+ 0
- 1
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";


+ 0
- 3
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",


Завантаження…
Відмінити
Зберегти