forked from newfold-labs/wp-module-deactivation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request newfold-labs#5 from newfold-labs/add/plugin-test-w…
…orklfow Add/plugin test worklfow
- Loading branch information
Showing
3 changed files
with
189 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,132 @@ | ||
// <reference types="Cypress" /> | ||
|
||
describe('Plugin Deactivation Survey', () => { | ||
describe( 'Plugin Deactivation Survey', () => { | ||
before( () => { | ||
cy.visit( '/wp-admin/plugins.php' ); | ||
|
||
before(() => { | ||
cy.visit('/wp-admin/plugins.php'); | ||
// ignore notifications errors if there are any | ||
cy.intercept( | ||
{ | ||
method: 'GET', | ||
url: /newfold-notifications/, | ||
}, | ||
{ body: {} } | ||
); | ||
} ); | ||
|
||
// ignore notifications errors if there are any | ||
cy.intercept({ | ||
method: 'GET', | ||
url: /newfold-notifications/, | ||
}, { body: {} }); | ||
it( 'Plugin deactivate link opens modal', () => { | ||
// body does not have no scroll class | ||
cy.get( 'body' ).should( 'not.have.class', 'nfd-noscroll' ); | ||
cy.get( '.nfd-deactivation-survey__content' ).should( 'not.exist' ); | ||
|
||
}); | ||
// click link | ||
cy.get( | ||
'.deactivate a[id*="' + Cypress.env( 'pluginId' ) + '"]' | ||
).click(); | ||
|
||
it('Plugin deactivate link opens modal', () => { | ||
// body does not have no scroll class | ||
cy.get('body').should('not.have.class', 'nfd-noscroll'); | ||
cy.get('.nfd-deactivation-survey__content').should('not.exist'); | ||
// body has no scroll class | ||
cy.get( 'body' ).should( 'have.class', 'nfd-noscroll' ); | ||
|
||
// click link | ||
cy.get('.deactivate a[id*="' + Cypress.env('pluginId') + '"]').click(); | ||
// modal exists | ||
cy.get( '.nfd-deactivation-survey__content' ) | ||
.scrollIntoView() | ||
.should( 'be.visible' ); | ||
} ); | ||
|
||
// body has no scroll class | ||
cy.get('body').should('have.class', 'nfd-noscroll'); | ||
|
||
// modal exists | ||
cy.get('.nfd-deactivation-survey__content') | ||
.scrollIntoView() | ||
.should('be.visible'); | ||
}); | ||
it( 'Cancel button exists and exits modal', () => { | ||
cy.get( 'button[nfd-deactivation-survey-destroy]' ).should( | ||
'be.visible' | ||
); | ||
cy.get( 'button[nfd-deactivation-survey-destroy]' ).click(); | ||
|
||
it('Cancel button exists and exits modal', () => { | ||
cy.get('button[nfd-deactivation-survey-destroy]') | ||
.should('be.visible'); | ||
cy.get('button[nfd-deactivation-survey-destroy]').click(); | ||
cy.get( 'body' ).should( 'not.have.class', 'nfd-noscroll' ); | ||
cy.get( '.nfd-deactivation-survey__content' ).should( 'not.exist' ); | ||
} ); | ||
|
||
cy.get('body').should('not.have.class', 'nfd-noscroll'); | ||
cy.get('.nfd-deactivation-survey__content').should('not.exist'); | ||
}); | ||
|
||
it('Skip button deactivates plugin', () => { | ||
// ignore notifications errors if there are any | ||
cy.intercept({ | ||
method: 'GET', | ||
url: /newfold-notifications/, | ||
}, { body: {} }); | ||
cy.intercept({ | ||
it( 'Skip button deactivates plugin', () => { | ||
// ignore notifications errors if there are any | ||
cy.intercept( | ||
{ | ||
method: 'GET', | ||
url: /newfold-notifications/, | ||
}, | ||
{ body: {} } | ||
); | ||
cy.intercept( { | ||
method: 'POST', | ||
url: /newfold-data(\/|%2F)v1(\/|%2F)events/, | ||
}).as('surveyEvent'); | ||
} ).as( 'surveyEvent' ); | ||
|
||
// reopen modal | ||
cy.get('.deactivate a[id*="' + Cypress.env('pluginId') + '"]').click(); | ||
// skip & deactivate functions | ||
// reopen modal | ||
cy.get( | ||
'.deactivate a[id*="' + Cypress.env( 'pluginId' ) + '"]' | ||
).click(); | ||
// skip & deactivate functions | ||
|
||
cy.get('button[nfd-deactivation-survey-skip]') | ||
.should('be.visible'); | ||
cy.get('button[nfd-deactivation-survey-skip]').click(); | ||
cy.wait('@surveyEvent') | ||
// .its('request.body.action').should('eq', 'deactivation_survey_freeform') | ||
.its('request.body.data.survey_input').should('eq', 'No input'); | ||
// verify modal closed | ||
cy.get('.nfd-deactivation-survey__content').should('not.exist'); | ||
// verify plugin is deactivated | ||
cy.get('.deactivate a[id*="' + Cypress.env('pluginId') + '"]').should('not.exist'); | ||
cy.get('.activate a[id*="' + Cypress.env('pluginId') + '"]').should('exist'); | ||
// reactivate plugin | ||
cy.get('.activate a[id*="' + Cypress.env('pluginId') + '"]').click(); | ||
cy.wait(500); | ||
}); | ||
cy.get( 'button[nfd-deactivation-survey-skip]' ).should( 'be.visible' ); | ||
cy.get( 'button[nfd-deactivation-survey-skip]' ).click(); | ||
cy.wait( '@surveyEvent' ) | ||
// .its('request.body.action').should('eq', 'deactivation_survey_freeform') | ||
.its( 'request.body.data.survey_input' ) | ||
.should( 'eq', 'No input' ); | ||
// verify modal closed | ||
cy.get( '.nfd-deactivation-survey__content' ).should( 'not.exist' ); | ||
// verify plugin is deactivated | ||
cy.get( | ||
'.deactivate a[id*="' + Cypress.env( 'pluginId' ) + '"]' | ||
).should( 'not.exist' ); | ||
cy.get( '.activate a[id*="' + Cypress.env( 'pluginId' ) + '"]' ).should( | ||
'exist' | ||
); | ||
// reactivate plugin | ||
cy.get( | ||
'.activate a[id*="' + Cypress.env( 'pluginId' ) + '"]' | ||
).click(); | ||
cy.wait( 500 ); | ||
} ); | ||
|
||
it('Survey successfully deactivates plugin', () => { | ||
// ignore notifications errors if there are any | ||
cy.intercept({ | ||
method: 'GET', | ||
url: /newfold-notifications/, | ||
}, { body: {} }); | ||
cy.intercept({ | ||
it( 'Survey successfully deactivates plugin', () => { | ||
// ignore notifications errors if there are any | ||
cy.intercept( | ||
{ | ||
method: 'GET', | ||
url: /newfold-notifications/, | ||
}, | ||
{ body: {} } | ||
); | ||
cy.intercept( { | ||
method: 'POST', | ||
url: /newfold-data(\/|%2F)v1(\/|%2F)events/, | ||
}).as('surveyEvent'); | ||
|
||
// reopen modal | ||
cy.get('.deactivate a[id*="' + Cypress.env('pluginId') + '"]').click(); | ||
// can enter reason | ||
const ugcReason = 'automated testing'; | ||
cy.get('#nfd-deactivation-survey__input').type(ugcReason); | ||
// submit and deactivate works | ||
cy.get('input[nfd-deactivation-survey-submit]') | ||
.should('be.visible'); | ||
cy.get('input[nfd-deactivation-survey-submit]').click(); | ||
cy.wait('@surveyEvent') | ||
// .its('request.body.action').should('eq', 'deactivation_survey_freeform') | ||
.its('request.body.data.survey_input').should('eq', ugcReason); | ||
cy.wait(500); | ||
// verify plugin is deactivated | ||
cy.get('.deactivate a[id*="' + Cypress.env('pluginId') + '"]').should('not.exist'); | ||
cy.get('.activate a[id*="' + Cypress.env('pluginId') + '"]').should('exist'); | ||
// reactivate plugin | ||
cy.get('.activate a[id*="' + Cypress.env('pluginId') + '"]').click(); | ||
cy.wait(500); | ||
}); | ||
} ).as( 'surveyEvent' ); | ||
|
||
}); | ||
// reopen modal | ||
cy.get( | ||
'.deactivate a[id*="' + Cypress.env( 'pluginId' ) + '"]' | ||
).click(); | ||
// can enter reason | ||
const ugcReason = 'automated testing'; | ||
cy.get( '#nfd-deactivation-survey__input' ).type( ugcReason ); | ||
// submit and deactivate works | ||
cy.get( 'input[nfd-deactivation-survey-submit]' ).should( | ||
'be.visible' | ||
); | ||
cy.get( 'input[nfd-deactivation-survey-submit]' ).click(); | ||
cy.wait( '@surveyEvent' ) | ||
// .its('request.body.action').should('eq', 'deactivation_survey_freeform') | ||
.its( 'request.body.data.survey_input' ) | ||
.should( 'eq', ugcReason ); | ||
cy.wait( 500 ); | ||
// verify plugin is deactivated | ||
cy.get( | ||
'.deactivate a[id*="' + Cypress.env( 'pluginId' ) + '"]' | ||
).should( 'not.exist' ); | ||
cy.get( '.activate a[id*="' + Cypress.env( 'pluginId' ) + '"]' ).should( | ||
'exist' | ||
); | ||
// reactivate plugin | ||
cy.get( | ||
'.activate a[id*="' + Cypress.env( 'pluginId' ) + '"]' | ||
).click(); | ||
cy.wait( 500 ); | ||
} ); | ||
} ); |