From 48d26de2b93fb8b79e25675d05962017b21538f5 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Fri, 15 Mar 2024 11:53:59 -0400 Subject: [PATCH 1/2] break into multiple test files for better isolation --- .../{staging.cy.js => staging-prod.cy.js} | 88 +------------------ .../cypress/integration/staging-staging.cy.js | 85 ++++++++++++++++++ 2 files changed, 87 insertions(+), 86 deletions(-) rename tests/cypress/integration/{staging.cy.js => staging-prod.cy.js} (74%) create mode 100644 tests/cypress/integration/staging-staging.cy.js diff --git a/tests/cypress/integration/staging.cy.js b/tests/cypress/integration/staging-prod.cy.js similarity index 74% rename from tests/cypress/integration/staging.cy.js rename to tests/cypress/integration/staging-prod.cy.js index 100172a..235a843 100644 --- a/tests/cypress/integration/staging.cy.js +++ b/tests/cypress/integration/staging-prod.cy.js @@ -4,10 +4,8 @@ const stagingCloneFixture = require( '../fixtures/stagingClone.json' ); const stagingDeleteFixture = require( '../fixtures/stagingDelete.json' ); const stagingCreateFixture = require( '../fixtures/stagingCreate.json' ); const stagingSwitchFixture = require( '../fixtures/stagingSwitch.json' ); -const stagingStagingFixture = require( '../fixtures/stagingStaging.json' ); -const stagingDeployFixture = require( '../fixtures/stagingDeploy.json' ); -describe( 'Staging Page', function () { +describe( 'Staging Page - Production Environment', function () { const appClass = '.' + Cypress.env( 'appId' ); before( () => { @@ -236,86 +234,4 @@ describe( 'Staging Page', function () { // actual reload cancelled by fixture containing a load_page value of `#` } ); -} ); - -describe( 'Staging Page - Staging environmant', function () { - const appClass = '.' + Cypress.env( 'appId' ); - - before( () => { - cy.intercept( - { - method: 'GET', - url: /newfold-staging(\/|%2F)v1(\/|%2F)staging/, - }, - stagingStagingFixture - ); - cy.visit( - '/wp-admin/admin.php?page=' + - Cypress.env( 'pluginId' ) + - '#/staging' - ); - } ); - - it( 'Displays staging environemnt properly', () => { - cy.get( '#newfold-production-toggle' ).should( 'not.be.checked' ); - cy.get( '.newfold-staging-prod' ) - .contains( 'h3', 'Production Site' ) - .should( 'be.visible' ); - cy.get( '.newfold-staging-prod' ) - .contains( - 'label[for="newfold-production-toggle"]', - 'Not currently editing' - ) - .should( 'be.visible' ); - - cy.get( '#newfold-staging-toggle' ).should( 'be.checked' ); - cy.get( '.newfold-staging-staging' ) - .contains( 'h3', 'Staging Site' ) - .should( 'be.visible' ); - cy.get( '.newfold-staging-staging' ) - .contains( - 'label[for="newfold-staging-toggle"]', - 'Currently editing' - ) - .should( 'be.visible' ); - - cy.get( '#staging-clone-button' ).should( 'be.disabled' ); - cy.get( '#staging-delete-button' ).should( 'be.disabled' ); - cy.get( '#staging-deploy-button' ).should( 'not.be.disabled' ); - } ); - - it( 'Deploy Works', () => { - cy.intercept( - { - method: 'POST', - url: /newfold-staging(\/|%2F)v1(\/|%2F)staging(\/|%2F)deploy/, - }, - { - body: stagingDeployFixture, - delay: 500, - } - ).as( 'stagingDeploy' ); - - cy.get( '#staging-deploy-button' ).click(); - cy.get( '.nfd-modal' ) - .contains( 'h1', 'Confirm Deployment' ) - .should( 'be.visible' ); - cy.get( '.nfd-modal .nfd-button--error' ) - .contains( 'Cancel' ) - .should( 'be.visible' ); - cy.get( '.nfd-modal .nfd-button--primary' ) - .contains( 'Deploy' ) - .should( 'be.visible' ) - .click(); - - cy.get( '.nfd-notifications' ) - .contains( 'p', 'Working...' ) - .should( 'be.visible' ); - - cy.wait( '@stagingDeploy' ); - - cy.get( '.nfd-notifications' ) - .contains( 'p', 'Deployed' ) - .should( 'be.visible' ); - } ); -} ); +} ); \ No newline at end of file diff --git a/tests/cypress/integration/staging-staging.cy.js b/tests/cypress/integration/staging-staging.cy.js new file mode 100644 index 0000000..43a9d1d --- /dev/null +++ b/tests/cypress/integration/staging-staging.cy.js @@ -0,0 +1,85 @@ +// +const stagingStagingFixture = require( '../fixtures/stagingStaging.json' ); +const stagingDeployFixture = require( '../fixtures/stagingDeploy.json' ); + +describe( 'Staging Page - Staging Environmant', function () { + const appClass = '.' + Cypress.env( 'appId' ); + + before( () => { + cy.intercept( + { + method: 'GET', + url: /newfold-staging(\/|%2F)v1(\/|%2F)staging/, + }, + stagingStagingFixture + ); + cy.visit( + '/wp-admin/admin.php?page=' + + Cypress.env( 'pluginId' ) + + '#/staging' + ); + } ); + + it( 'Displays staging environemnt properly', () => { + cy.get( '#newfold-production-toggle' ).should( 'not.be.checked' ); + cy.get( '.newfold-staging-prod' ) + .contains( 'h3', 'Production Site' ) + .should( 'be.visible' ); + cy.get( '.newfold-staging-prod' ) + .contains( + 'label[for="newfold-production-toggle"]', + 'Not currently editing' + ) + .should( 'be.visible' ); + + cy.get( '#newfold-staging-toggle' ).should( 'be.checked' ); + cy.get( '.newfold-staging-staging' ) + .contains( 'h3', 'Staging Site' ) + .should( 'be.visible' ); + cy.get( '.newfold-staging-staging' ) + .contains( + 'label[for="newfold-staging-toggle"]', + 'Currently editing' + ) + .should( 'be.visible' ); + + cy.get( '#staging-clone-button' ).should( 'be.disabled' ); + cy.get( '#staging-delete-button' ).should( 'be.disabled' ); + cy.get( '#staging-deploy-button' ).should( 'not.be.disabled' ); + } ); + + it( 'Deploy Works', () => { + cy.intercept( + { + method: 'POST', + url: /newfold-staging(\/|%2F)v1(\/|%2F)staging(\/|%2F)deploy/, + }, + { + body: stagingDeployFixture, + delay: 500, + } + ).as( 'stagingDeploy' ); + + cy.get( '#staging-deploy-button' ).click(); + cy.get( '.nfd-modal' ) + .contains( 'h1', 'Confirm Deployment' ) + .should( 'be.visible' ); + cy.get( '.nfd-modal .nfd-button--error' ) + .contains( 'Cancel' ) + .should( 'be.visible' ); + cy.get( '.nfd-modal .nfd-button--primary' ) + .contains( 'Deploy' ) + .should( 'be.visible' ) + .click(); + + cy.get( '.nfd-notifications' ) + .contains( 'p', 'Working...' ) + .should( 'be.visible' ); + + cy.wait( '@stagingDeploy' ); + + cy.get( '.nfd-notifications' ) + .contains( 'p', 'Deployed' ) + .should( 'be.visible' ); + } ); +} ); From e9c6ea862c05db5d3fd35122ec9b531df8350696 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Fri, 15 Mar 2024 11:54:30 -0400 Subject: [PATCH 2/2] use full staging page path --- tests/cypress/fixtures/stagingSwitch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/fixtures/stagingSwitch.json b/tests/cypress/fixtures/stagingSwitch.json index 904d34a..70c3c6f 100644 --- a/tests/cypress/fixtures/stagingSwitch.json +++ b/tests/cypress/fixtures/stagingSwitch.json @@ -1,4 +1,4 @@ { "status": "success", - "load_page": "#" + "load_page": "#/staging" } \ No newline at end of file