Skip to content

Commit

Permalink
Merge pull request #172 from 10up/fix/166
Browse files Browse the repository at this point in the history
Cypress integration migrated to 11+
  • Loading branch information
faisal-alvi authored Jan 11, 2023
2 parents e4ffe2f + d327aa3 commit 965584c
Show file tree
Hide file tree
Showing 9 changed files with 4,488 additions and 3,572 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ Desktop.ini
# Cypress
tests/cypress/screenshots
tests/cypress/videos
tests/cypress/downloads
tests/cypress/reports
7,992 changes: 4,453 additions & 3,539 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"start": "wp-scripts start",
"test:e2e": "wp-scripts test-e2e",
"test:unit": "wp-scripts test-unit-js",
"cypress:open": "cypress open --config-file tests/cypress/config.json",
"cypress:run": "cypress run --config-file tests/cypress/config.json",
"cypress:open": "cypress open --config-file tests/cypress/config.config.js",
"cypress:run": "cypress run --config-file tests/cypress/config.config.js",
"env": "wp-env",
"env:start": "wp-env start",
"env:stop": "wp-env stop",
Expand All @@ -36,7 +36,7 @@
"@10up/cypress-wp-utils": "github:10up/cypress-wp-utils#build",
"@wordpress/env": "^5.2.0",
"@wordpress/scripts": "^23.0.0",
"cypress": "^9.5.4",
"cypress": "^11.2.0",
"cypress-file-upload": "^5.0.8",
"cypress-mochawesome-reporter": "^3.0.1"
}
Expand Down
22 changes: 22 additions & 0 deletions tests/cypress/config.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
fixturesFolder: __dirname+'/fixtures',
screenshotsFolder: __dirname+'/screenshots',
videosFolder: __dirname+'/videos',
downloadsFolder: __dirname+'/downloads',
video: false,
reporter: 'mochawesome',
reporterOptions: {
reportDir: __dirname+'/reports'
},
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require(__dirname+'/plugins/index.js')(on, config)
},
specPattern: __dirname+'/integration/*.test.js',
supportFile: __dirname+'/support/index.js',
},
})
25 changes: 0 additions & 25 deletions tests/cypress/config.json

This file was deleted.

8 changes: 5 additions & 3 deletions tests/cypress/integration/admin.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {deactivatePlugin} from "@10up/cypress-wp-utils/lib/commands/deactivate-plugin";

describe('Admin can login and make sure plugin is activated', () => {
before(() => {
cy.login();
});

it('Can activate plugin if it is deactivated', () => {
cy.activatePlugin('simple-local-avatars');
cy.deactivatePlugin('simple-local-avatars');
cy.activatePlugin('simple-local-avatars');
});
});
2 changes: 1 addition & 1 deletion tests/cypress/integration/delete-avatar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Check if admin can delete avatar', () => {
cy.visit('/wp-admin/profile.php');
cy.get('body').then($body => {
if (0 !== $body.find('#simple-local-avatar-remove').length) {
cy.get('#simple-local-avatar-remove').click();
cy.get('#simple-local-avatar-remove').click({force: true});
}
});

Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = async (on, config) => {
const port = wpEnvConfig.env.tests.port || null;

if (port) {
config.baseUrl = 'http://localhost:8889/';
config.baseUrl = wpEnvConfig.env.tests.config.WP_SITEURL;
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

import 'cypress-file-upload';

Cypress.Commands.add( 'visitAdminPage', ( page = 'index.php' ) => {
cy.login();
if ( page.includes( 'http' ) ) {
Expand Down

0 comments on commit 965584c

Please sign in to comment.