Skip to content

Commit

Permalink
Merge pull request #181 from 10up/upkeep/178
Browse files Browse the repository at this point in the history
Fix E2E tests
  • Loading branch information
jeffpaul authored Oct 10, 2023
2 parents bc5690c + 479f1f1 commit 9b490cc
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 136 deletions.
249 changes: 135 additions & 114 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
"node": ">=12.0"
},
"devDependencies": {
"@10up/cypress-wp-utils": "github:10up/cypress-wp-utils#build",
"@wordpress/env": "^5.6.0",
"@10up/cypress-wp-utils": "^0.2.0",
"@wordpress/env": "^8.7.0",
"@wordpress/eslint-plugin": "^10.0.1",
"@wordpress/scripts": "^24.6.0",
"cypress": "^13.1.0",
"cypress-mochawesome-reporter": "^3.4.0"
"cypress": "^13.2.0",
"cypress-mochawesome-reporter": "^3.6.0"
}
}
4 changes: 2 additions & 2 deletions tests/bin/initialize.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
npm run env run tests-wordpress "chmod -c ugo+w /var/www/html"
npm run env run tests-cli "wp rewrite structure '/%postname%/' --hard"
wp-env run tests-wordpress chmod -c ugo+w /var/www/html
wp-env run tests-cli wp rewrite structure '/%postname%/' --hard
8 changes: 5 additions & 3 deletions tests/cypress/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { defineConfig } = require('cypress');
const { readConfig } = require('@wordpress/env/lib/config');
const { loadConfig } = require( '@wordpress/env/lib/config' );
const getCacheDirectory = require( '@wordpress/env/lib/config/get-cache-directory' );

module.exports = defineConfig({
fixturesFolder: 'tests/cypress/fixtures',
Expand All @@ -26,13 +27,14 @@ module.exports = defineConfig({

/**
* Set WP URL as baseUrl in Cypress config.
*
*
* @param {Function} on function that used to register listeners on various events.
* @param {object} config Cypress Config object.
* @returns config Updated Cypress Config object.
*/
const setBaseUrl = async (on, config) => {
const wpEnvConfig = await readConfig('wp-env');
const cacheDirectory = await getCacheDirectory();
const wpEnvConfig = await loadConfig( cacheDirectory );

if (wpEnvConfig) {
const port = wpEnvConfig.env.tests.port || null;
Expand Down
5 changes: 1 addition & 4 deletions tests/cypress/e2e/block.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
describe("Test block functions", () => {
before(() => {
cy.login();
});

beforeEach(() => {
cy.login();
cy.mapsBlockSaveSettings();
});

Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/e2e/settings.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe("Settings", () => {
before(() => {
beforeEach(() => {
cy.login();
});

Expand Down
8 changes: 0 additions & 8 deletions tests/cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,3 @@ import "@10up/cypress-wp-utils";

// Import commands.js using ES2015 syntax:
import "./commands";

// Alternatively you can use CommonJS syntax:
// require('./commands')
beforeEach(() => {
Cypress.Cookies.defaults({
preserve: /^wordpress.*?/,
});
});

0 comments on commit 9b490cc

Please sign in to comment.