Skip to content

Commit

Permalink
Merge pull request #17 from newfold-labs/add/brand-plugin-test-workflow
Browse files Browse the repository at this point in the history
Add/brand plugin test workflow
  • Loading branch information
wpscholar authored Dec 15, 2023
2 parents 7b066d4 + c93a912 commit 468f05a
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 100 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/brand-plugin-test.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16
235 changes: 135 additions & 100 deletions tests/cypress/integration/coming-soon.cy.js
Original file line number Diff line number Diff line change
@@ -1,127 +1,162 @@
// <reference types="Cypress" />

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' );
} );
} );

0 comments on commit 468f05a

Please sign in to comment.