Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOUR-19767: Clipboard isn't cleared after add a new control #1757

Merged
merged 3 commits into from
Oct 25, 2024
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
4 changes: 4 additions & 0 deletions src/components/vue-form-builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
v-if="isClipboardPage(tabPage)"
variant="link"
@click="clearClipboard"
class="no-text-transform"
>
{{ $t('Clear All') }}
</b-button>
Expand Down Expand Up @@ -1745,4 +1746,7 @@ $side-bar-font-size: 0.875rem;
cursor: not-allowed; /* Cambia el cursor cuando se pasa por encima */
pointer-events: all; /* Permite que el pseudo-elemento reciba eventos del ratón */
}
.no-text-transform {
text-transform: none;
}
</style>
1 change: 1 addition & 0 deletions src/mixins/Clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export default {
}
);
if (confirm) {
this.clipboardPage.items = [];
this.$store.dispatch("clipboardModule/clearClipboard");
this.$root.$emit('update-clipboard');
}
Expand Down
42 changes: 42 additions & 0 deletions tests/e2e/specs/ClipboardTabClearAll.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
describe("Clipboard Page and Clear All Functionality", () => {

it("should remove all controls in the clipboard page when 'Clear All' is confirmed", () => {
// Clear local storage to ensure a clean test environment
cy.clearLocalStorage();

// Visit the home page
cy.visit("/");

// Open the 'Input Fields' accordion section
cy.openAcordeonByLabel("Input Fields");

// Navigate to the clipboard page
cy.get("[data-test=page-dropdown]").click();
cy.get("[data-test=clipboard]").should("exist").click({ force: true });

// Step 1: Dragging controls to the screen drop zone in the clipboard
cy.get("[data-cy=controls-FormInput]").drag("[data-cy=editor-content]", { 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" });

// Verify that all controls have been successfully added
cy.get('[data-cy="screen-element-container"]').children().should('have.length', 6);

// Step 2: Attempt to clear all controls but cancel the action
cy.contains('button', 'Clear All').click();
cy.contains('button', 'Cancel').click();

// Ensure controls are still present after canceling
cy.get('[data-cy="screen-element-container"]').children().should('have.length', 6);

// Step 3: Confirm clearing all controls
cy.contains('button', 'Clear All').click();
cy.contains('button', 'Confirm').click();

// Validate that all controls have been removed
cy.get('[data-cy="editor-content"]').children().should('have.length', 0);
});
});
Loading