Skip to content

Commit

Permalink
Merge pull request #281 from 10up/upkeep/280
Browse files Browse the repository at this point in the history
Upgrade Cypress to version 13
  • Loading branch information
iamdharmesh authored Sep 4, 2023
2 parents 1c640b9 + d50d6a7 commit e6303cf
Show file tree
Hide file tree
Showing 11 changed files with 266 additions and 255 deletions.
243 changes: 111 additions & 132 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,17 @@
},
"homepage": "https://github.com/10up/autoshare#readme",
"devDependencies": {
"@10up/cypress-wp-utils": "^0.1.0",
"@10up/cypress-wp-utils": "^0.2.0",
"@10up/eslint-config": "^1.0.9",
"@babel/core": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0",
"@wordpress/env": "^5.7.0",
"@wordpress/env": "^8.6.0",
"@wordpress/eslint-plugin": "^3.0.0",
"@wordpress/prettier-config": "^1.1.1",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"cypress": "^11.2.0",
"cypress-iframe": "^1.0.1",
"cypress": "^13.0.0",
"cypress-mochawesome-reporter": "^3.5.1",
"eslint": "^6.3.0",
"husky": "^3.0.5",
Expand Down
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/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({
chromeWebSecurity: false,
Expand Down Expand Up @@ -37,7 +38,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
10 changes: 9 additions & 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 make sure plugin is activated', () => {
before(() => {
beforeEach(() => {
cy.login();
cy.clearPluginSettings();
});
Expand All @@ -14,6 +14,10 @@ describe('Admin can login and make sure plugin is activated', () => {
});

describe('Plugin settings page has the necessary fields', () => {
beforeEach(() => {
cy.login();
});

it('Can see all the fields on the settings page', () => {
cy.visit('/wp-admin/options-general.php?page=autoshare-for-twitter');
cy.get('input[name="autoshare-for-twitter[api_key]"]').should('be.visible');
Expand All @@ -22,6 +26,10 @@ describe('Plugin settings page has the necessary fields', () => {
});

describe('Configure the plugin', () => {
beforeEach(() => {
cy.login();
});

it('Configure the plugin settings and Twitter accounts', () => {
cy.visit('/wp-admin/options-general.php?page=autoshare-for-twitter');
cy.get('.large-text:nth-child(1) .large-text').clear().type( 'TEST_TWITTER_API_KEY' );
Expand Down
5 changes: 3 additions & 2 deletions tests/cypress/e2e/block-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('Test Autoshare for Twitter with Block Editor.', () => {
});

beforeEach(() => {
cy.login();
// Enable Autoshare on account.
cy.markAccountForAutoshare();
});
Expand Down Expand Up @@ -178,7 +179,7 @@ describe('Test Autoshare for Twitter with Block Editor.', () => {
cy.get('.editor-post-publish-panel button[aria-label="Close panel"]').click();
cy.openDocumentSettingsPanel('Autotweet');
cy.get('.autoshare-for-twitter-editor-panel button.autoshare-for-twitter-tweet-now').click();
cy.get('.autoshare-for-twitter-editor-panel .autoshare-for-twitter-tweet-text textarea').clear().type(`Random Tweet ${getRandomText(6)}`);
cy.get('.autoshare-for-twitter-editor-panel .autoshare-for-twitter-tweet-text textarea').clear().type(`Random Tweet ${getRandomText(6)}`, {force: true});
cy.get('.autoshare-for-twitter-editor-panel button.autoshare-for-twitter-re-tweet').click();
cy.get('.autoshare-for-twitter-log a').contains('Tweeted on');
});
Expand All @@ -192,7 +193,7 @@ describe('Test Autoshare for Twitter with Block Editor.', () => {
// Open AutoTweet Panel and set custom tweet message.
cy.openDocumentSettingsPanel('Autotweet enabled');
cy.get('.autoshare-for-twitter-prepublish__override-row button').click();
cy.get('.autoshare-for-twitter-tweet-text textarea').clear().type(customTweetBody);
cy.get('.autoshare-for-twitter-tweet-text textarea').clear().type(customTweetBody, {force: true});

// Save Draft
cy.get('.editor-post-save-draft').should('be.visible');
Expand Down
27 changes: 18 additions & 9 deletions tests/cypress/e2e/classic-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('Test Autoshare for Twitter with Classic Editor.', () => {
});

beforeEach(() => {
cy.login();
// Enable Autoshare on account.
cy.markAccountForAutoshare();
});
Expand All @@ -35,7 +36,8 @@ describe('Test Autoshare for Twitter with Classic Editor.', () => {
cy.enableCheckbox('#autoshare-for-twitter-enable', defaultBehavior, false);

// publish
cy.get('#publish').should('be.visible').click({force: true});
cy.get('#publish').should('not.be.disabled');
cy.get('#publish').should('be.visible').click();

// Post-publish.
cy.get('#autoshare_for_twitter_metabox').should('be.visible');
Expand All @@ -49,7 +51,8 @@ describe('Test Autoshare for Twitter with Classic Editor.', () => {

// Check enable checkbox for auto-share.
cy.enableCheckbox('#autoshare-for-twitter-enable', defaultBehavior, true);
cy.get('#publish').should('be.visible').click({force: true});
cy.get('#publish').should('not.be.disabled');
cy.get('#publish').should('be.visible').click();

// Post-publish.
cy.get('#autoshare_for_twitter_metabox',).should('be.visible');
Expand All @@ -66,7 +69,8 @@ describe('Test Autoshare for Twitter with Classic Editor.', () => {

// Uncheck the checkbox and publish
cy.enableCheckbox('#autoshare-for-twitter-enable', defaultBehavior, false);
cy.get('#publish').should('be.visible').click({force: true});
cy.get('#publish').should('not.be.disabled');
cy.get('#publish').should('be.visible').click();

// Post-publish.
cy.get('#autoshare_for_twitter_metabox').should('be.visible');
Expand All @@ -83,7 +87,8 @@ describe('Test Autoshare for Twitter with Classic Editor.', () => {

// Check the checkbox and publish
cy.enableCheckbox('#autoshare-for-twitter-enable', defaultBehavior, true);
cy.get('#publish').should('be.visible').click({force: true});
cy.get('#publish').should('not.be.disabled');
cy.get('#publish').should('be.visible').click();

// Post-publish.
cy.get('#autoshare_for_twitter_metabox').should('be.visible');
Expand All @@ -98,8 +103,9 @@ describe('Test Autoshare for Twitter with Classic Editor.', () => {
cy.enableCheckbox('#autoshare-for-twitter-enable', defaultBehavior, true);
cy.enableTweetAccount('input.autoshare-for-twitter-account-checkbox', false);

// publish
cy.get('#publish').should('be.visible').click({force: true});
// publish.
cy.get('#publish').should('not.be.disabled');
cy.get('#publish').should('be.visible').click();

// Post-publish.
cy.get('#autoshare_for_twitter_metabox').should('be.visible');
Expand All @@ -118,7 +124,8 @@ describe('Test Autoshare for Twitter with Classic Editor.', () => {
cy.enableTweetAccount('input.autoshare-for-twitter-account-checkbox', true);

// publish
cy.get('#publish').should('be.visible').click({force: true});
cy.get('#publish').should('not.be.disabled');
cy.get('#publish').should('be.visible').click();

// Post-publish.
cy.get('#autoshare_for_twitter_metabox',).should('be.visible');
Expand All @@ -134,7 +141,8 @@ describe('Test Autoshare for Twitter with Classic Editor.', () => {

// Uncheck the checkbox and publish
cy.enableCheckbox('#autoshare-for-twitter-enable', defaultBehavior, false);
cy.get('#publish').should('be.visible').click({force: true});
cy.get('#publish').should('not.be.disabled');
cy.get('#publish').should('be.visible').click();

// Post-publish.
cy.get('#autoshare_for_twitter_metabox').should('be.visible');
Expand Down Expand Up @@ -166,7 +174,8 @@ describe('Test Autoshare for Twitter with Classic Editor.', () => {
cy.get('textarea#autoshare-for-twitter-text').should('have.value', customTweetBody);

// publish
cy.get('#publish').should('be.visible').click({force: true});
cy.get('#publish').should('not.be.disabled');
cy.get('#publish').should('be.visible').click();

// Post-publish.
cy.get('#autoshare_for_twitter_metabox',).should('be.visible');
Expand Down
4 changes: 4 additions & 0 deletions tests/cypress/e2e/disconnect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ describe('Admin can disconnect connected Twitter accounts', () => {
cy.configurePlugin();
});

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

it('Admin can disconnect connected Twitter accounts', () => {
cy.visit('/wp-admin/options-general.php?page=autoshare-for-twitter');
cy.get('.twitter_accounts #the-list tr').should('be.visible').should('have.length', 2);
Expand Down
4 changes: 4 additions & 0 deletions tests/cypress/e2e/mutli-accounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ describe('Twitter accounts should visible in Autotweet Panel and should respect
cy.configurePlugin();
});

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

it('Can see Twitter accounts in Block editor', () => {
//Block editor.
cy.enableEditor('block');
Expand Down
Loading

0 comments on commit e6303cf

Please sign in to comment.