Skip to content

Commit

Permalink
cypress fixes? maybe? unclear
Browse files Browse the repository at this point in the history
  • Loading branch information
pcraig3 committed Feb 14, 2022
1 parent 912117c commit 8456901
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"core": "WordPress/WordPress#5.8.3",
"themes": [
"./wordpress/wp-content/themes/cds-default"
"./wordpress/wp-content/themes/cds-default",
"./wordpress/wp-content/themes/cds-redirector"
],
"mappings": {
"wp-content/mu-plugins": "./wordpress/wp-content/mu-plugins",
Expand Down
38 changes: 38 additions & 0 deletions cypress/integration/redirector.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { addArticle } from "./util";

/// <reference types="Cypress" />

describe('Switch theme', () => {
before(() => {
cy.testSetup({theme: 'cds-redirector'});
});

it('CDS Redirector theme', async () => {
const redirectUrl = "https://example.com"

cy.login();

// set redirect url
cy.visit("/wp-admin/admin.php?page=theme-settings");
cy.get('input[name*="redirect_url"]').type(redirectUrl);
cy.get('input#submit').click();
cy.get('input[name*="redirect_url"]').should('have.value', redirectUrl);

// create post
const text = "Hello from GC Admin";
addArticle(text)

// preview > check URL
cy.get('a.editor-post-preview').should($a => {
expect($a.attr('href'), 'href').to.contain('preview=true')
}).invoke('attr', 'href').then(href => {
cy.request({
url: href,
followRedirect: false,
}).then(resp => {
expect(resp.status).to.eq(302)
expect(resp.redirectedToUrl).to.eq("https://example.com/?lang=en")
})
});
});
});
2 changes: 1 addition & 1 deletion cypress/support/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import './visit-profile';
import './add-user';
import './login-user';
import './add-user-cap';
import './test-setup';
import './test-setup';
5 changes: 3 additions & 2 deletions cypress/support/commands/test-setup.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
Cypress.Commands.add('testSetup', (index = 0) => {
Cypress.Commands.add('testSetup', ({ theme = 'cds-default' }) => {
const options = { failOnNonZeroExit: false }

cy.exec('wp-env run tests-cli wp db import "test_run_dump.sql"', options).then((result) => {
cy.log(result.code);
cy.log(result.stdout);

cy.exec(`wp-env run tests-cli wp theme activate ${theme}`, options)

if(result.code === 0) {
return;
}

cy.exec('npm run wp-env:clean', options);
cy.exec('wp-env run tests-cli wp option delete list_values', options);
cy.exec('wp-env run tests-cli wp option set list_values --format=json < ./cypress/fixtures/notify-list-data.json', options)
cy.exec('wp-env run tests-cli wp theme activate cds-default', options)
cy.exec('wp-env run tests-cli wp plugin activate sitepress-multilingual-cms cds-base two-factor;', options)
cy.exec('wp-env run tests-cli wp plugin activate s3-uploads disable-user-login;', options) // wps-hide-login
cy.exec('wp-env run tests-cli wp plugin activate wordpress-seo wordpress-seo-premium wp-rest-api-v2-menus;', options)
Expand Down
2 changes: 1 addition & 1 deletion cypress/videos/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/*
!.gitignore
!.gitignore

0 comments on commit 8456901

Please sign in to comment.