From 47a4c383d688135f445ac5b1ea47db5c768baa52 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Wed, 13 Dec 2023 16:23:10 -0500 Subject: [PATCH 1/6] fix autofixable lint issues in test file --- tests/cypress/integration/coming-soon.cy.js | 235 +++++++++++--------- 1 file changed, 135 insertions(+), 100 deletions(-) diff --git a/tests/cypress/integration/coming-soon.cy.js b/tests/cypress/integration/coming-soon.cy.js index 0a0d9c8..cd63007 100644 --- a/tests/cypress/integration/coming-soon.cy.js +++ b/tests/cypress/integration/coming-soon.cy.js @@ -1,127 +1,162 @@ // -describe('Coming Soon', function () { - let appClass = '.' + Cypress.env('appId'); +describe( 'Coming Soon', function () { + const appClass = '.' + Cypress.env( 'appId' ); - before(() => { + before( () => { // Set coming soon to true - cy.exec(`npx wp-env run cli wp option update nfd_coming_soon true`); + cy.exec( `npx wp-env run cli wp option update nfd_coming_soon true` ); - cy.visit('/wp-admin/admin.php?page=' + Cypress.env('pluginId') + '#/settings'); + cy.visit( + '/wp-admin/admin.php?page=' + + Cypress.env( 'pluginId' ) + + '#/settings' + ); cy.injectAxe(); - }); - - it('Coming Soon Toggle Functions', () => { + } ); + it( 'Coming Soon Toggle Functions', () => { // Initial Coming Soon State - cy.get('#wp-toolbar #wp-admin-bar-site-status') - .contains('span', 'Coming Soon') - .should('be.visible'); + cy.get( '#wp-toolbar #wp-admin-bar-site-status' ) + .contains( 'span', 'Coming Soon' ) + .should( 'be.visible' ); - cy.get( appClass + '-app-settings-coming-soon').contains('h3', 'Site Status') + cy.get( appClass + '-app-settings-coming-soon' ) + .contains( 'h3', 'Site Status' ) .scrollIntoView() - .should('be.visible'); + .should( 'be.visible' ); - cy.get( appClass + '-app-settings-coming-soon').contains('label', 'Coming soon') + cy.get( appClass + '-app-settings-coming-soon' ) + .contains( 'label', 'Coming soon' ) .scrollIntoView() - .should('be.visible'); + .should( 'be.visible' ); - cy.get('[data-id="coming-soon-toggle"]').should('have.attr', 'aria-checked').and('include', 'true'); + 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('.nfd-notifications').contains('.nfd-notification', 'Coming soon deactivated').should('be.visible'); + 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( '.nfd-notifications' ) + .contains( '.nfd-notification', 'Coming soon deactivated' ) + .should( 'be.visible' ); // Activate Coming Soon - Unlaunch 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', 'true'); - cy.get('#wp-toolbar #wp-admin-bar-site-status') - .contains('span', 'Coming Soon') - .should('be.visible'); - cy.get('.nfd-notifications').contains('.nfd-notification', 'Coming soon activated').should('be.visible'); - - }); - - it('Displays Coming Soon in Site Status Admin Toolbar', () => { + 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' ); + cy.get( '#wp-toolbar #wp-admin-bar-site-status' ) + .contains( 'span', 'Coming Soon' ) + .should( 'be.visible' ); + cy.get( '.nfd-notifications' ) + .contains( '.nfd-notification', 'Coming soon activated' ) + .should( 'be.visible' ); + } ); + + 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'); + 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'); - }); - - it('Has Coming Soon Section on Home', () => { - cy.visit('/wp-admin/admin.php?page=' + Cypress.env('pluginId') + '#/home'); - cy.get( appClass + '-home .nfd-app-section-content').first() + cy.get( '#wp-toolbar #wp-admin-bar-site-status' ) + .contains( 'span', 'Coming Soon' ) + .should( 'be.visible' ); + } ); + + it( 'Has Coming Soon Section on Home', () => { + cy.visit( + '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home' + ); + cy.get( appClass + '-home .nfd-app-section-content' ) + .first() .scrollIntoView() - .contains('h1', 'Ready to go live?') - .should('be.visible'); - - cy.get( appClass + '-home .nfd-app-section-content') - .contains('a.nfd-button', 'iew your s').first() - .should('exist'); - - cy.get( appClass + '-home .nfd-app-section-content').first() - .contains('button', 'Launch') - .should('exist'); - - }); - - it('Displays admin coming soon notice', () => { - cy.visit('/wp-admin/index.php'); - cy.get('.notice-warning') - .contains('p', 'coming') - .should('be.visible'); - }); - - it('Displays Coming Soon on Frontend', () => { + .contains( 'h1', 'Ready to go live?' ) + .should( 'be.visible' ); + + cy.get( appClass + '-home .nfd-app-section-content' ) + .contains( 'a.nfd-button', 'iew your s' ) + .first() + .should( 'exist' ); + + cy.get( appClass + '-home .nfd-app-section-content' ) + .first() + .contains( 'button', 'Launch' ) + .should( 'exist' ); + } ); + + it( 'Displays admin coming soon notice', () => { + cy.visit( '/wp-admin/index.php' ); + cy.get( '.notice-warning' ) + .contains( 'p', 'coming' ) + .should( 'be.visible' ); + } ); + + it( 'Displays Coming Soon on Frontend', () => { cy.logout(); - cy.visit('/'); - cy.title().should('include', 'Coming Soon'); - cy.get('#wrap').contains('Coming Soon').should('exist'); - }); - - it('Launching launches site', () => { - 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', 'true'); - - cy.visit('/wp-admin/admin.php?page=' + Cypress.env('pluginId') + '#/home'); - - cy.get( appClass + '-home .nfd-app-section-content').first() - .contains('button', 'Launch your') + cy.visit( '/' ); + cy.title().should( 'include', 'Coming Soon' ); + cy.get( '#wrap' ).contains( 'Coming Soon' ).should( 'exist' ); + } ); + + it( 'Launching launches site', () => { + 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', 'true' ); + + cy.visit( + '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home' + ); + + cy.get( appClass + '-home .nfd-app-section-content' ) + .first() + .contains( 'button', 'Launch your' ) .click(); - cy.wait(100); - - cy.get( appClass + '-home .nfd-app-section-content').first() - .contains('button', 'Launch your') - .should('not.exist'); + cy.wait( 100 ); + + cy.get( appClass + '-home .nfd-app-section-content' ) + .first() + .contains( 'button', 'Launch your' ) + .should( 'not.exist' ); cy.logout(); - cy.visit('/'); - cy.title().should('not.include', 'Coming Soon'); - cy.get('body').contains('Coming Soon').should('not.exist'); + cy.visit( '/' ); + cy.title().should( 'not.include', 'Coming Soon' ); + cy.get( 'body' ).contains( 'Coming Soon' ).should( 'not.exist' ); - cy.login(Cypress.env('wpUsername'), Cypress.env('wpPassword')); + 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'); + 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' ); + } ); +} ); From 596cd104297cb297afd47af9ebd288c100bf76d6 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Wed, 13 Dec 2023 16:23:24 -0500 Subject: [PATCH 2/6] add brand plugin test workflow --- .github/workflows/brand-plugin-test.yml | 74 +++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/brand-plugin-test.yml diff --git a/.github/workflows/brand-plugin-test.yml b/.github/workflows/brand-plugin-test.yml new file mode 100644 index 0000000..f31d801 --- /dev/null +++ b/.github/workflows/brand-plugin-test.yml @@ -0,0 +1,74 @@ +name: Build and Test Module Updates in Brand Plugins +on: + pull_request: + types: [ opened, reopened, ready_for_review, synchronize ] + branches: + - main + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + setup: + name: Setup + runs-on: ubuntu-latest + outputs: + branch: ${{ steps.extract_branch.outputs.branch }} + steps: + + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + bluehost: + name: Bluehost Build and Test + needs: setup + uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main + with: + module-repo: ${{ github.repository }} + module-branch: ${{ needs.setup.outputs.branch }} + plugin-repo: 'bluehost/bluehost-wordpress-plugin' + secrets: inherit + + hostgator: + name: HostGator Build and Test + needs: setup + uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main + with: + module-repo: ${{ github.repository }} + module-branch: ${{ needs.setup.outputs.branch }} + plugin-repo: 'newfold-labs/wp-plugin-hostgator' + secrets: inherit + + web: + name: Web.com Build and Test + needs: setup + uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main + with: + module-repo: ${{ github.repository }} + module-branch: ${{ needs.setup.outputs.branch }} + plugin-repo: 'newfold-labs/wp-plugin-web' + secrets: inherit + + crazydomains: + name: Crazy Domains Build and Test + needs: setup + uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main + with: + module-repo: ${{ github.repository }} + module-branch: ${{ needs.setup.outputs.branch }} + plugin-repo: 'newfold-labs/wp-plugin-crazy-domains' + secrets: inherit + + mojo: + name: Mojo Build and Test + needs: setup + uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main + with: + module-repo: ${{ github.repository }} + module-branch: ${{ needs.setup.outputs.branch }} + plugin-repo: 'newfold-labs/wp-plugin-mojo' + secrets: inherit From 0245ffa30a24f655a4fcbea21d21e5cfbf623013 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 14 Dec 2023 16:08:13 -0500 Subject: [PATCH 3/6] add .nvmrc as v16 --- .nvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..6f7f377 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v16 From 31e7e9ef62ae5a76e2a6a3c8348fcfeed6a5f0fd Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 14 Dec 2023 17:38:09 -0500 Subject: [PATCH 4/6] test `only-module-tests` workflow flag --- .github/workflows/brand-plugin-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/brand-plugin-test.yml b/.github/workflows/brand-plugin-test.yml index f31d801..eed61be 100644 --- a/.github/workflows/brand-plugin-test.yml +++ b/.github/workflows/brand-plugin-test.yml @@ -31,6 +31,7 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'bluehost/bluehost-wordpress-plugin' + only-module-tests: true secrets: inherit hostgator: From cc1b9148c7e9df567d36065de362165121a7d722 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 14 Dec 2023 18:33:21 -0500 Subject: [PATCH 5/6] test only-module-tests in all cases --- .github/workflows/brand-plugin-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/brand-plugin-test.yml b/.github/workflows/brand-plugin-test.yml index eed61be..3f9d664 100644 --- a/.github/workflows/brand-plugin-test.yml +++ b/.github/workflows/brand-plugin-test.yml @@ -42,6 +42,7 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'newfold-labs/wp-plugin-hostgator' + only-module-tests: true secrets: inherit web: @@ -52,6 +53,7 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'newfold-labs/wp-plugin-web' + only-module-tests: true secrets: inherit crazydomains: @@ -62,6 +64,7 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'newfold-labs/wp-plugin-crazy-domains' + only-module-tests: true secrets: inherit mojo: @@ -72,4 +75,5 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'newfold-labs/wp-plugin-mojo' + only-module-tests: true secrets: inherit From c93a9127043b720898469ea5401864347b394539 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 14 Dec 2023 18:42:42 -0500 Subject: [PATCH 6/6] remove only-module-tests flags --- .github/workflows/brand-plugin-test.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/brand-plugin-test.yml b/.github/workflows/brand-plugin-test.yml index 3f9d664..f31d801 100644 --- a/.github/workflows/brand-plugin-test.yml +++ b/.github/workflows/brand-plugin-test.yml @@ -31,7 +31,6 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'bluehost/bluehost-wordpress-plugin' - only-module-tests: true secrets: inherit hostgator: @@ -42,7 +41,6 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'newfold-labs/wp-plugin-hostgator' - only-module-tests: true secrets: inherit web: @@ -53,7 +51,6 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'newfold-labs/wp-plugin-web' - only-module-tests: true secrets: inherit crazydomains: @@ -64,7 +61,6 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'newfold-labs/wp-plugin-crazy-domains' - only-module-tests: true secrets: inherit mojo: @@ -75,5 +71,4 @@ jobs: module-repo: ${{ github.repository }} module-branch: ${{ needs.setup.outputs.branch }} plugin-repo: 'newfold-labs/wp-plugin-mojo' - only-module-tests: true secrets: inherit