Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakePT committed Sep 26, 2023
1 parent 609e244 commit abbbaea
Showing 1 changed file with 18 additions and 31 deletions.
49 changes: 18 additions & 31 deletions tests/cypress/integration/dashboard-sync.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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.
Expand All @@ -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', () => {
Expand All @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -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();
Expand All @@ -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');
});
});

0 comments on commit abbbaea

Please sign in to comment.