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
29 changes: 29 additions & 0 deletions tests/cypress/e2e/Forms/bulkDeleteForms.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
describe("Bulk delete forms from the form list page", () => {
beforeEach(() => {
cy.login();
cy.visit('/wp-admin/admin.php?page=formidable');
});

it("should create multiple forms and bulk delete them", () => {
cy.log("Create 5 new forms");
for (let i = 0; i < 5; i++) {
cy.createNewForm();
}

cy.log("Bulk delete all 5 new forms");
cy.get('tr').filter((index, element) => {
return Cypress.$(element).text().includes('Test Form');
}).each(($row) => {
cy.wrap($row).find('.check-column input[type="checkbox"]').check();
});

cy.log("Click on Bulk Actions and select the Move to Trash option")
cy.get('#bulk-action-selector-top').select("Move to Trash");
cy.get('#doaction').should("contain", "Apply").click();

cy.get('.frm_updated_message').should("contain", "forms moved to the Trash.");



})
})
26 changes: 4 additions & 22 deletions tests/cypress/e2e/Forms/duplicateForm.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ describe("Duplicating a form from the form list page", () => {

it("should create a duplicate form", () => {
// Create a blank form
cy.log("Create a blank form");
cy.contains(".frm_nav_bar .button-primary", "Add New").click();
cy.get(".frm-form-templates-grid-layout #frm-form-templates-create-form").should("contain", "Create a blank form").click();
cy.get("#frm_submit_side_top").should("contain", "Save").click();
cy.get("#frm-form-templates-modal").should("exist");
cy.get(".frm-modal-title").should("contain", "Name your form");
cy.get("#frm_new_form_name_input").type("Test Form");
cy.get("#frm-save-form-name-button").should("contain", "Save").click();
cy.get("a[aria-label='Close']", { timeout: 5000 }).click();
cy.createNewForm();

// Duplicate the newly created form
cy.log("Duplicate the newly created form");
Expand All @@ -36,25 +28,15 @@ describe("Duplicating a form from the form list page", () => {

// Teardown: Delete Test Form and its duplicate
cy.log("Teardown");
cy.log("Delete Test Form and its duplicate");
cy.contains('#the-list tr', 'Test Form').trigger('mouseover').then(($row) => {
console.log('Hovered Row:', $row);
cy.deleteForm();

// Find the visible element with class "trash" within the hovered row and click it
cy.log("Delete duplicated form")
cy.contains('#the-list tr', 'Test Form').trigger('mouseover').then(($row) => {
cy.wrap($row).within(() => {
cy.get('.row-actions .trash .frm-trash-link').should('be.visible').click({ force: true });
});
cy.get("div[role='dialog']").should("contain", "Do you want to move this form to the trash?");
cy.xpath("//a[@id='frm-confirmed-click']").should("contain", "Confirm").click({ force: true });

// To ensure elements are not chained from previous action's results
cy.contains('#the-list tr', 'Test Form').trigger('mouseover').then(($row) => {
cy.wrap($row).within(() => {
cy.get('.row-actions .trash .frm-trash-link').should('be.visible').click({ force: true });
});
cy.get("div[role='dialog']").should("contain", "Do you want to move this form to the trash?");
cy.xpath("//a[@id='frm-confirmed-click']").should("contain", "Confirm").click({ force: true });
});
});
});
});
31 changes: 30 additions & 1 deletion tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,33 @@
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

Cypress.Commands.add("createNewForm", () => {
cy.log("Create a blank form");
cy.contains(".frm_nav_bar .button-primary", "Add New").click();
cy.get(".frm-form-templates-grid-layout #frm-form-templates-create-form").should("contain", "Create a blank form").click();
cy.get("#frm_submit_side_top", { timeout: 5000 }).should("contain", "Save").click();
cy.get("#frm-form-templates-modal").should("exist");
cy.get(".frm-modal-title").should("contain", "Name your form");
cy.get("#frm_new_form_name_input").type("Test Form");
cy.get("#frm-save-form-name-button").should("contain", "Save").click();
cy.get("a[aria-label='Close']", { timeout: 7000 }).click();
})

Cypress.Commands.add("deleteForm", () => {

cy.log("Delete Test Form and its duplicate");
cy.contains('#the-list tr', 'Test Form').trigger('mouseover').then(($row) => {
console.log('Hovered Row:', $row);
// Find the visible element with class "trash" within the hovered row and click it
cy.wrap($row).within(() => {
cy.get('.row-actions .trash .frm-trash-link').should('be.visible').click({ force: true });
});
cy.get("div[role='dialog']").should("contain", "Do you want to move this form to the trash?");
cy.xpath("//a[@id='frm-confirmed-click']").should("contain", "Confirm").click({ force: true });
})
})



2 changes: 1 addition & 1 deletion tests/cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
import './commands';

// Alternatively you can use CommonJS syntax:
// require('./commands')
Expand Down