Skip to content

Commit

Permalink
fix cypress test
Browse files Browse the repository at this point in the history
test must start with coming soon active
  • Loading branch information
circlecube committed Aug 15, 2023
1 parent a521f43 commit 5f0365f
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions tests/cypress/integration/coming-soon.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,42 @@ describe('Coming Soon', function () {
cy.injectAxe();
});

it('Coming Soon Toggle Exists', () => {
it('Coming Soon Toggle Functions', () => {

// Initial Coming Soon State
cy.get('#wp-toolbar #wp-admin-bar-site-status')
.contains('div', 'Site Status')
.contains('span', 'Coming Soon')
.should('be.visible');

cy.get( appClass + '-app-settings-coming-soon').contains('h3', 'Maintenance Mode')
.scrollIntoView()
.should('be.visible');

cy.get( appClass + '-app-settings-coming-soon').contains('label', 'Coming soon')
.scrollIntoView()
.should('be.visible');

cy.get('[data-id="coming-soon-toggle"]').should('have.attr', 'aria-checked').and('include', 'true');

// Deactivate coming soon - Launch Site
cy.get('[data-id="coming-soon-toggle"]').click();
cy.wait(500);

cy.get('[data-id="coming-soon-toggle"]').should('have.attr', 'aria-checked').and('include', 'false');
cy.get('#wp-toolbar #wp-admin-bar-site-status')
.contains('span', 'Live')
.should('be.visible');
cy.get('.yst-notifications').contains('.yst-notification', 'Coming soon deactivated').should('be.visible');

// Activate Coming Soon - Unlaunch Site
cy.get('[data-id="coming-soon-toggle"]').click();
cy.wait(100);
cy.wait(500);

cy.get('[data-id="coming-soon-toggle"]').should('have.attr', 'aria-checked').and('include', 'true');
cy.get('.yst-notifications').contains('.yst-notification', 'Coming soon').should('be.visible');
cy.get('#wp-toolbar #wp-admin-bar-site-status')
.contains('span', 'Coming Soon')
.should('be.visible');
cy.get('.yst-notifications').contains('.yst-notification', 'Coming soon activated').should('be.visible');

// Protip was removed in redesign, should reimplement
// cy
Expand All @@ -40,6 +57,11 @@ describe('Coming Soon', function () {
});

it('Displays Coming Soon in Site Status Admin Toolbar', () => {
// Admin bar contains label
cy.get('#wp-toolbar #wp-admin-bar-site-status')
.contains('div', 'Site Status')
.should('be.visible');
// Admin bar contains status
cy.get('#wp-toolbar #wp-admin-bar-site-status')
.contains('span', 'Coming Soon')
.should('be.visible');
Expand Down Expand Up @@ -100,6 +122,14 @@ describe('Coming Soon', function () {
.should('not.exist');

cy.login(Cypress.env('wpUsername'), Cypress.env('wpPassword'));

cy.visit('/wp-admin/admin.php?page=' + Cypress.env('pluginId') + '#/settings');

cy.get('[data-id="coming-soon-toggle"]').should('have.attr', 'aria-checked').and('include', 'false');
// Re-Activate Coming Soon
cy.get('[data-id="coming-soon-toggle"]').click();
cy.wait(500);
cy.get('[data-id="coming-soon-toggle"]').should('have.attr', 'aria-checked').and('include', 'true');

})
});

0 comments on commit 5f0365f

Please sign in to comment.