From abbbaeab5b77a96386f0b8756084e8d1a309ed1a Mon Sep 17 00:00:00 2001 From: Jacob Peattie Date: Wed, 27 Sep 2023 07:01:10 +1000 Subject: [PATCH] Update tests. --- .../cypress/integration/dashboard-sync.cy.js | 49 +++++++------------ 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/tests/cypress/integration/dashboard-sync.cy.js b/tests/cypress/integration/dashboard-sync.cy.js index 2cd0e11555..99a98edce7 100644 --- a/tests/cypress/integration/dashboard-sync.cy.js +++ b/tests/cypress/integration/dashboard-sync.cy.js @@ -13,7 +13,7 @@ describe('Dashboard Sync', () => { } function resumeAndWait() { - cy.get('.ep-sync-button--resume').click(); + cy.get('.components-button').contains('Resume sync').click(); cy.get('.ep-sync-progress strong', { timeout: Cypress.config('elasticPressIndexTimeout'), }).should('contain.text', 'Sync complete'); @@ -40,14 +40,11 @@ describe('Dashboard Sync', () => { cy.get('.setup-message a').contains('Skip Install').click(); /** - * If a sync has not been performed the sync page should only show a - * single sync panel. + * If a sync has not been performed the "Delete all data and start + * fresh sync" checkbox should not appear. */ cy.visitAdminPage('admin.php?page=elasticpress-sync'); - cy.get('.ep-sync-panel') - .should('have.length', 1) - .as('syncPanel') - .should('contain.text', 'Run a sync to index your existing content'); + cy.get('.components-checkbox-control').contains('Delete all data').should('not.exist'); /** * Perform an initial sync. @@ -65,13 +62,10 @@ describe('Dashboard Sync', () => { .should('contain.text', 'Sync complete'); /** - * After the initial sync is complete there should be 2 sync panels - * and the second should contain the delete & sync option. + * After the initial sync is complete the "Delete all data and start + * fresh sync" checkbox should appear. */ - cy.get('.ep-sync-panel') - .should('have.length', 2) - .last() - .should('contain.text', 'If you are still having issues with your search results'); + cy.get('.components-checkbox-control').contains('Delete all data').should('exist'); }); it('Can sync via Dashboard when activated in single site', () => { @@ -84,7 +78,7 @@ describe('Dashboard Sync', () => { ); cy.visitAdminPage('admin.php?page=elasticpress-sync'); - cy.get('.ep-sync-button--sync').click(); + cy.get('.components-button').contains('Start sync').click(); cy.get('.ep-sync-progress strong', { timeout: Cypress.config('elasticPressIndexTimeout'), }).should('contain.text', 'Sync complete'); @@ -112,7 +106,7 @@ describe('Dashboard Sync', () => { ); cy.visitAdminPage('network/admin.php?page=elasticpress-sync'); - cy.get('.ep-sync-button--sync').click(); + cy.get('.components-button').contains('Start sync').click(); cy.get('.ep-sync-progress strong', { timeout: Cypress.config('elasticPressIndexTimeout'), }).should('contain.text', 'Sync complete'); @@ -146,9 +140,9 @@ describe('Dashboard Sync', () => { // Start sync via dashboard and pause it cy.intercept('POST', '/wp-json/elasticpress/v1/sync*').as('apiRequest'); - cy.get('.ep-sync-button--sync').click(); + cy.get('.components-button').contains('Resume sync').click(); cy.wait('@apiRequest').its('response.statusCode').should('eq', 200); - cy.get('.ep-sync-button--pause').should('be.visible'); + cy.get('.components-button').contains('Pause sync').click(); // Can not activate a feature. cy.visitAdminPage('admin.php?page=elasticpress'); @@ -161,7 +155,7 @@ describe('Dashboard Sync', () => { // Check if it is paused cy.visitAdminPage('admin.php?page=elasticpress-sync'); - cy.get('.ep-sync-button--resume').should('be.visible'); + cy.get('.components-button').contains('Resume sync').should('be.visible'); cy.get('.ep-sync-progress strong').should('contain.text', 'Sync paused'); resumeAndWait(); @@ -179,26 +173,19 @@ describe('Dashboard Sync', () => { cy.wpCli('wp elasticpress activate-feature terms', true); /** - * The sync page should only show a - * single sync panel. + * If an index is missing the "Delete all data and start fresh sync" + * checkbox should not appear. */ cy.visitAdminPage('admin.php?page=elasticpress-sync'); - cy.get('.ep-sync-panel') - .should('have.length', 1) - .as('syncPanel') - .should('contain.text', 'Run a sync to index your existing content'); + cy.get('.components-checkbox-control').contains('Delete all data').should('not.exist'); // Send mapping of the deleted index cy.wpCli('wp elasticpress put-mapping --indexables=term'); /** - * After the mapping is sent there should be 2 sync panels - * and the second should contain the delete & sync option. + * After the mapping is sent the "Delete all data and start fresh + * sync" checkbox should appear. */ - cy.visitAdminPage('admin.php?page=elasticpress-sync'); - cy.get('.ep-sync-panel') - .should('have.length', 2) - .last() - .should('contain.text', 'If you are still having issues with your search results'); + cy.get('.components-checkbox-control').contains('Delete all data').should('exist'); }); });