Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/mixins/Clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ export default {
}
);
if (confirm) {
this.clipboardPage.items = [];
this.$store.dispatch("clipboardModule/clearClipboard");
this.$root.$emit('update-clipboard');
// Update the clipboard page with the new clipboard items
this.clipboardPage.items = this.$store.getters["clipboardModule/clipboardItems"];
}
},

Expand Down
55 changes: 55 additions & 0 deletions tests/e2e/specs/ClipboardTabClearAll.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,59 @@ describe("Clipboard Page and Clear All Functionality", () => {
// Validate that all controls have been removed
cy.get('[data-cy="editor-content"]').children().should('have.length', 0);
});

it("should allow adding elements after clearing clipboard", () => {
// Clear local storage and visit home page
cy.clearLocalStorage();
cy.visit("/");
cy.openAcordeonByLabel("Input Fields");

// Add initial controls to default page
cy.get("[data-cy=controls-FormInput]").drag("[data-cy=editor-content]", { position: "bottom" });
cy.get("[data-cy=controls-FormButton]").drag("[data-cy=screen-element-container]", { position: "top" });

// Verify initial controls were added
cy.get('[data-cy="screen-element-container"]').children()
.should('have.length', 2)
.and('be.visible');

// Add both controls to clipboard
const addControlToClipboard = (index) => {
cy.get(`:nth-child(${index}) > [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('[data-cy="copied-badge"]').should("exist");
};

addControlToClipboard(1);
addControlToClipboard(2);

// Navigate to clipboard and verify controls were copied
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)
.and('be.visible');

// Clear clipboard and verify it's empty
cy.contains('button', 'Clear All').click();
cy.contains('button', 'Confirm').click();
cy.get('[data-cy="editor-content"]').children().should('have.length', 0);

// Return to default page and add controls to clipboard again
cy.get("[data-test=page-dropdown]").click();
cy.get("[data-test=page-Default]").click({ force: true });

addControlToClipboard(1);
addControlToClipboard(2);

// Navigate back to clipboard and verify new controls were added
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)
.and('be.visible');
});
});
Loading