Skip to content

Commit

Permalink
Update tests to make it run with cypress 13
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Sep 12, 2023
1 parent 1c8517f commit 022290b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
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
6 changes: 4 additions & 2 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 @@ -24,7 +25,8 @@ module.exports = defineConfig({
* @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
2 changes: 1 addition & 1 deletion tests/cypress/e2e/admin.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe("Admin can login and open dashboard", () => {
before(() => {
beforeEach(() => {
cy.login();
});

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

Expand All @@ -8,18 +8,21 @@ describe('Configure admin settings', () => {
});

it( 'Enter settings and save', () => {
cy.visit('wp-admin/options-general.php?page=windows-azure-storage-plugin-options');
cy.get('input[name="azure_storage_account_name"]').clear().type(Cypress.env('MICROSOFT_AZURE_ACCOUNT_NAME'));
cy.get('input[name="azure_storage_account_primary_access_key"]').clear().type(Cypress.env('MICROSOFT_AZURE_ACCOUNT_KEY'));
cy.get('input[name="azure-submit-button"]').click();
});

it( 'Select container after page reload', () => {
cy.visit('wp-admin/options-general.php?page=windows-azure-storage-plugin-options');
cy.get('select[name="default_azure_storage_account_container_name"]').select(Cypress.env('MICROSOFT_AZURE_CONTAINER'));
cy.get('input[name="azure_storage_use_for_default_upload"]').click();
cy.get('input[name="azure-submit-button"]').click();
});

it( 'Upload file and verify location', () => {
cy.visit('wp-admin/options-general.php?page=windows-azure-storage-plugin-options');
cy.uploadMedia( 'tests/cypress/fixtures/image.jpg' );
cy.visit('wp-admin/upload.php');
cy.get('.thumbnail img').should('have.attr', 'src').should('include',Cypress.env('MICROSOFT_AZURE_ACCOUNT_NAME'));
Expand Down
9 changes: 1 addition & 8 deletions tests/cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,4 @@
import "@10up/cypress-wp-utils";

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

// Preserve WP cookies.
beforeEach(() => {
Cypress.Cookies.defaults({
preserve: /^wordpress.*?/,
});
});
import "./commands";

0 comments on commit 022290b

Please sign in to comment.