Skip to content

Commit

Permalink
Merge pull request #1739 from ProcessMaker/feature/FOUR-19016
Browse files Browse the repository at this point in the history
FOUR-19016: Add more unit tests and Feature tests for the "Clipboard" feature based on FOUR-18582
  • Loading branch information
ryancooley authored Oct 16, 2024
2 parents 8683126 + 7681d98 commit b5e4f5f
Show file tree
Hide file tree
Showing 12 changed files with 19,132 additions and 0 deletions.
10,252 changes: 10,252 additions & 0 deletions tests/e2e/fixtures/TCP4-4444.json

Large diffs are not rendered by default.

1,255 changes: 1,255 additions & 0 deletions tests/e2e/fixtures/TCP4-4446.json

Large diffs are not rendered by default.

3,401 changes: 3,401 additions & 0 deletions tests/e2e/fixtures/TCP4-4452.json

Large diffs are not rendered by default.

3,066 changes: 3,066 additions & 0 deletions tests/e2e/fixtures/TCP4-4454.json

Large diffs are not rendered by default.

631 changes: 631 additions & 0 deletions tests/e2e/fixtures/screen2TCP4-4446.json

Large diffs are not rendered by default.

195 changes: 195 additions & 0 deletions tests/e2e/specs/ClipboardTestCases.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
describe("Clipboard Button Actions", () => {

it("TCP4-4441: Verify clipboard in section column and dropdown menu", () => {
// Clear local storage
cy.clearLocalStorage();
cy.visit("/");
cy.openAcordeonByLabel("Clipboard");
cy.get("[data-cy=screen-drop-zone]").should(
"contain.text",
"Place your controls here."
);

// Step 1: Verify Drag & Paste component existe in clipboard control section
cy.get("[data-cy=controls-Clipboard]").should("exist");
// Step 2: Verify clipboard is present in dopdown pages menu
cy.get("[data-test=page-dropdown").click();
cy.get("[data-test=clipboard]").should("exist");
cy.wait(1000);
// Step 3: Verify Clipboard open like page in new tab
cy.get("[data-test=clipboard]").should("exist").click({ force: true });
cy.get('a[role="tab"]')
.contains('Clipboard')
.should('have.class', 'active')
.and('be.visible');

// Step 4: Check if the 'Clipboard' tab is opened (active)
cy.get('div[role="tabpanel"][name="clipboard"]')
.should('have.class', 'active')
.and('be.visible')
.within(() => {
// Step 5: Check if it contains the 'Clear All' button
cy.contains('button', 'Clear All').should('exist');
});

//Step 6: Verify that when the Clipboard page is opened the buttons: undo, redo, calculations, observers and options are disabled
cy.get('button[data-cy="toolbar-undo"]').should('be.disabled');
cy.get('button[data-cy="toolbar-redo"]').should('be.disabled');
cy.get('button[data-cy="topbar-calcs"]').should('be.disabled');
cy.get('button[data-cy="topbar-css"]').should('be.disabled');
cy.get('button[data-cy="topbar-watchers"]').should('be.disabled');
cy.get('div[data-cy="topbar-options"]').find('button')
.should('exist')
.and('be.disabled');
});

it("TCP4-4443: Verify that the controls from the INPUT FIELDS section have been added to the clipboard ", () => {
// Clear local storage
cy.clearLocalStorage();
cy.visit("/");
cy.openAcordeonByLabel("Input Fields");
// Step 1: Dragging controls to screen drop zone
cy.get("[data-cy=controls-FormInput]").drag("[data-cy=screen-drop-zone]", { position: "bottom" });
cy.get("[data-cy=controls-FormSelectList]").drag("[data-cy=screen-element-container]", { position: "top" });
cy.get("[data-cy=controls-FormButton]").drag("[data-cy=screen-element-container]", { position: "top" });
cy.get("[data-cy=controls-FormTextArea]").drag("[data-cy=screen-element-container]", { position: "top" });
cy.get("[data-cy=controls-FormDatePicker]").drag("[data-cy=screen-element-container]", { position: "top" });
cy.get("[data-cy=controls-FormCheckbox]").drag("[data-cy=screen-element-container]", { position: "top" });

//Step 2: test add to clipboard button
cy.get(':nth-child(1) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(2) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(3) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(4) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(5) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(6) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get("[data-test=page-dropdown").click();
cy.get("[data-test=clipboard]").should("exist").click({ force: true });
cy.get('[data-cy="screen-element-container"]')
.children()
.should('have.length', 6);
});

it("TCP4-4443: Verify that the controls from the CONTENT FIELDS section have been added to the clipboard ", () => {
// Clear local storage
cy.clearLocalStorage();
cy.visit("/");
cy.openAcordeonByLabel("Content Fields");

cy.get("[data-cy=controls-FormHtmlViewer]").drag("[data-cy=screen-drop-zone]", { position: "bottom" });
cy.get("[data-cy=controls-FormImage]").drag("[data-cy=screen-element-container]", { position: "top" });
cy.get("[data-cy=controls-FormRecordList]").drag("[data-cy=screen-element-container]", { position: "top" });
cy.get("[data-cy=controls-FormLoop]").drag("[data-cy=screen-element-container]", { position: "top" });
cy.get("[data-cy=controls-FormNestedScreen]").drag("[data-cy=screen-element-container]", { position: "top" });
cy.get("[data-cy=controls-FormMultiColumn]").drag("[data-cy=screen-element-container]", { position: "top" });

cy.get(':nth-child(1) > [data-cy="screen-element-container"]').click();
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(2) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(3) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(4) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(5) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(6) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");


cy.get("[data-test=page-dropdown").click();
cy.get("[data-test=clipboard]").should("exist").click({ force: true });
cy.get('[data-cy="screen-element-container"]')
.children()
.should('have.length', 6);
});

it("TCP4-4443: Verify that the control from the NAVIGATION section have been added to the clipboard", () => {
cy.clearLocalStorage();
cy.visit("/");
cy.openAcordeonByLabel("Navigation");
cy.wait(1000);


cy.get('[data-cy=controls-FormButton]:contains("Page")').drag("[data-cy=screen-drop-zone]", { position: "bottom" });

cy.get(':nth-child(1) > [data-cy="screen-element-container"]').click();
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get("[data-test=page-dropdown").click();
cy.get("[data-test=clipboard]").should("exist").click({ force: true });
cy.get('[data-cy="screen-element-container"]')
.children()
.should('have.length', 1);
});

it("TCP4-4443: Verify that the control from the FILES section have been added to the clipboard", () => {
cy.clearLocalStorage();
cy.visit("/");
cy.openAcordeonByLabel("Files");
cy.wait(1000);
cy.get('[data-cy="controls"] > [data-cy="controls-FileUpload"]').drag("[data-cy=screen-drop-zone]", { position: "bottom" });
cy.get('[data-cy="controls"] > [data-cy="controls-FileDownload"]').drag("[data-cy=screen-element-container]", { position: "bottom" });

cy.get(':nth-child(1) > [data-cy="screen-element-container"]').click();
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(2) > [data-cy="screen-element-container"]').click();
cy.get('[data-cy="addToClipboard"]').should("be.visible");
cy.get('[data-cy="addToClipboard"]').click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");


cy.get("[data-test=page-dropdown").click();
cy.get("[data-test=clipboard]").should("exist").click({ force: true });
cy.get('[data-cy="screen-element-container"]')
.children()
.should('have.length', 2);

});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
describe("Verify Adding Multiple Content To The Clipboard", () => {
beforeEach(() => {
cy.visit("/");
cy.showValidationOnLoad();
cy.clearLocalStorage();
});

it("TCP4-4446: Content selected should remain flagged as selected for pasting", () => {
// Step 1: Load the initial JSON data and check screen content
cy.loadFromJson("TCP4-4446.json", 0);
cy.get("[data-cy=screen-drop-zone]").should("not.contain.text", "Place your controls here.");

cy.get(':nth-child(1) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible").click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

// Step 2: Load a new screen and repeat the process for adding to clipboard
cy.loadFromJson("screen2TCP4-4446.json", 0);
cy.wait(100);
cy.get(':nth-child(1) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible").click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

// Step 3: Reload the first screen and verify that the element is flagged as selected
cy.loadFromJson("TCP4-4446.json", 0);
cy.wait(100);
cy.get(':nth-child(1) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("not.exist");

// Step 4: Reload the second screen and verify clipboard status remains unchanged
cy.loadFromJson("screen2TCP4-4446.json", 0);
cy.wait(100);
cy.get(':nth-child(1) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("not.exist");
});
});
109 changes: 109 additions & 0 deletions tests/e2e/specs/TCP4-4446VerifyMulticolumnControlsClipboard.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
describe("Verify that controls that are within multicolumn can be added to the clipboard", () => {
beforeEach(() => {
cy.clearLocalStorage();
cy.visit("/");
cy.showValidationOnLoad();
cy.intercept(
"GET",
"http://localhost:5173/api/1.0/screens/2576",
{
"id": 2576,
"uuid": "9d3e5c56-0208-4c55-80bf-c2fa643d6c67",
"screen_category_id": "1",
"title": "screenToNestedTCP4-4443",
"description": "Test",
"type": "FORM",
"config": [
{
"name": "screenToNestedTCP4-4443",
"items": [
{
"label": "Line Input",
"config": {
"icon": "far fa-square",
"name": "form_input_1",
"type": "text",
"label": "New Input",
"helper": null,
"dataFormat": "string",
"validation": null,
"placeholder": null
},
"component": "FormInput",

"editor-control": "FormInput",
"editor-component": "FormInput"
},
{
"label": "Submit Button",
"config": {
"icon": "fas fa-share-square",
"name": null,
"event": "submit",
"label": "New Submit",
"loading": false,
"tooltip": [],
"variant": "primary",
"fieldValue": null,
"loadingLabel": "Loading...",
"defaultSubmit": true
},
"component": "FormButton",

"editor-control": "FormSubmit",
"editor-component": "FormButton"
}
],
"order": 1
}
],
"computed": [],
"custom_css": null,
"created_at": "2024-09-18T01:37:43+00:00",
"updated_at": "2024-10-14T13:13:46+00:00",
"status": "ACTIVE",
"key": null,
"watchers": null,
"translations": null,
"is_template": 0,
"asset_type": null,
"projects": "[]"
}
);
});

it("TCP4-4446: Content selected should remain flagged as selected for pasting", () => {
// Step 1: Load the initial JSON data and check screen content
cy.loadFromJson("TCP4-4444.json", 0);
// cy.get("[data-cy=screen-drop-zone]").should("not.contain.text", "Place your controls here.");

cy.get(':nth-child(1) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible").click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");


cy.get(':nth-child(2) > [data-cy="screen-element-container"]').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible").click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(3) > [data-cy="screen-element-container"]').scrollIntoView({ offset: { top: -20, left: 0 } }).click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible").click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(4) > [data-cy="screen-element-container"]').scrollIntoView({ offset: { top: -20, left: 0 } }).click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible").click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(5) > [data-cy="screen-element-container"]').scrollIntoView({ offset: { top: -20, left: 0 } }).click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible").click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");


cy.get("[data-test=page-dropdown").click();
cy.get("[data-test=clipboard]").should("exist").click({ force: true });
cy.get('[data-cy="screen-element-container"]')
.children()
.should('have.length', 5);

});
});
34 changes: 34 additions & 0 deletions tests/e2e/specs/TCP4-4452VerifyReloadPageClipboard.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
describe("TCP4-4452 Verify reload page, remove button still present in the copied elements", () => {
beforeEach(() => {
cy.visit("/");
cy.showValidationOnLoad();
cy.clearLocalStorage();
});

it("Verify that after reloading the page, all controls within each page are displayed with (-) button", () => {
// Step 1: Load the initial JSON data and check screen content
cy.loadFromJson("TCP4-4452.json", 0);
cy.get(':nth-child(1) > :nth-child(1) > :nth-child(1) > .m-2 > .form-group').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible").click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(1) > :nth-child(2) > :nth-child(1) > .m-2').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible").click();
cy.get('[data-cy="addToClipboard"]').should("not.exist");


cy.get('#form_record_list_1 > .m-2').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("be.visible").click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("not.exist");
// reload page
cy.loadFromJson("TCP4-4452.json", 0);
cy.get(':nth-child(1) > :nth-child(1) > :nth-child(1) > .m-2 > .form-group').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get(':nth-child(1) > :nth-child(2) > :nth-child(1) > .m-2').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("not.exist");

cy.get('#form_record_list_1 > .m-2').click({ force: true });
cy.get('[data-cy="addToClipboard"]').should("not.exist");
});
});
Loading

0 comments on commit b5e4f5f

Please sign in to comment.