Skip to content
Open
13,633 changes: 7,366 additions & 6,267 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,12 @@
},
"devDependencies": {
"@10up/cypress-wp-utils": "^0.6.0",
"@wordpress/env": "^10.37.0",
"@wordpress/eslint-plugin": "^23.0.0",
"@wordpress/plugins": "^6.2.0",
"@wordpress/prettier-config": "^2.2.0",
"@wordpress/scripts": "^31.2.0",
"@wordpress/env": "^11.14.0",
"@wordpress/scripts": "^34.2.0",
"ansi-regex": ">=6.0.1",
"copy-webpack-plugin": "^11.0.0",
"cypress-file-upload": "^5.0.8",
"cypress-localstorage-commands": "^2.2.4",
"cypress-mochawesome-reporter": "^3.6.0",
"eslint-import-resolver-typescript": "3.5.5",
"eslint-plugin-cypress": "^3.6.0",
"husky": "^8.0.1",
"json-schema": ">=0.4.0",
"lint-staged": "^13.0.3",
Expand Down
36 changes: 18 additions & 18 deletions tests/bin/set-wp-config.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
#!/usr/bin/env node

const fs = require('fs');
const fs = require( 'fs' );

const path = `${process.cwd()}/.wp-env.override.json`;
const path = `${ process.cwd() }/.wp-env.override.json`;

let config = fs.existsSync(path) ? require(path) : { plugins: ['.'] };
let config = fs.existsSync( path ) ? require( path ) : { plugins: [ '.' ] };

const args = {};
process.argv.slice(2, process.argv.length).forEach((arg) => {
if (arg.slice(0, 2) === '--') {
const param = arg.split('=');
const paramName = param[0].slice(2, param[0].length);
const paramValue = param.length > 1 ? param[1] : true;
args[paramName] = paramValue;
process.argv.slice( 2, process.argv.length ).forEach( ( arg ) => {
if ( arg.slice( 0, 2 ) === '--' ) {
const param = arg.split( '=' );
const paramName = param[ 0 ].slice( 2, param[ 0 ].length );
const paramValue = param.length > 1 ? param[ 1 ] : true;
args[ paramName ] = paramValue;
}
});
} );

if (!args.core && !args.plugins) {
if ( ! args.core && ! args.plugins ) {
return;
}

if ('latest' === args.core) {
if ( 'latest' === args.core ) {
delete args.core;
}

if (Object.keys(args).length === 0) {
if ( Object.keys( args ).length === 0 ) {
return;
}

if (args.plugins) {
args.plugins = args.plugins.split(',');
if ( args.plugins ) {
args.plugins = args.plugins.split( ',' );
}

config = {
Expand All @@ -38,7 +38,7 @@ config = {
};

try {
fs.writeFileSync(path, JSON.stringify(config));
} catch (err) {
console.error(err);
fs.writeFileSync( path, JSON.stringify( config ) );
} catch ( err ) {
console.error( err );
}
10 changes: 5 additions & 5 deletions tests/cypress/config.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { defineConfig } = require('cypress');
const { defineConfig } = require( 'cypress' );

module.exports = defineConfig({
module.exports = defineConfig( {
fixturesFolder: __dirname + '/fixtures',
screenshotsFolder: __dirname + '/screenshots',
videosFolder: __dirname + '/videos',
Expand All @@ -21,8 +21,8 @@ module.exports = defineConfig({
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);
setupNodeEvents( on, config ) {
return require( __dirname + '/plugins/index.js' )( on, config );
},
supportFile: __dirname + '/support/index.js',
specPattern: [
Expand All @@ -33,4 +33,4 @@ module.exports = defineConfig({
'tests/cypress/integration/podcast-setting-panel.test.js',
],
},
});
} );
6 changes: 3 additions & 3 deletions tests/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
16 changes: 8 additions & 8 deletions tests/cypress/integration/admin.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
describe('Admin can login and make sure plugin is activated', () => {
beforeEach(() => {
describe( 'Admin can login and make sure plugin is activated', () => {
beforeEach( () => {
cy.login();
});
} );

it('Can activate plugin if it is deactivated', () => {
cy.deactivatePlugin('simple-podcasting');
cy.activatePlugin('simple-podcasting');
});
});
it( 'Can activate plugin if it is deactivated', () => {
cy.deactivatePlugin( 'simple-podcasting' );
cy.activatePlugin( 'simple-podcasting' );
} );
} );
93 changes: 48 additions & 45 deletions tests/cypress/integration/block.test.js
Original file line number Diff line number Diff line change
@@ -1,91 +1,94 @@
import 'cypress-localstorage-commands';
const { populatePodcast } = require('../support/functions');
const { populatePodcast } = require( '../support/functions' );

describe('Admin can publish posts with podcast block', () => {
describe( 'Admin can publish posts with podcast block', () => {
const taxonomy = 'Remote work';

before(() => {
before( () => {
const userId = '1';
cy.setLocalStorage(
`WP_DATA_USER_${userId}`,
JSON.stringify({
`WP_DATA_USER_${ userId }`,
JSON.stringify( {
'core/edit-post': {
preferences: {
features: {
welcomeGuide: false,
},
},
},
})
} )
);
});
} );

if (Cypress.env('HAS_BLOCK_EDITOR')) {
it('Can insert the block and publish the post', () => {
if ( Cypress.env( 'HAS_BLOCK_EDITOR' ) ) {
it( 'Can insert the block and publish the post', () => {
cy.login();
cy.uploadMedia('tests/cypress/fixtures/example.jpg');
cy.createTerm(taxonomy, 'podcasting_podcasts', {
cy.uploadMedia( 'tests/cypress/fixtures/example.jpg' );
cy.createTerm( taxonomy, 'podcasting_podcasts', {
beforeSave: () => {
populatePodcast({
populatePodcast( {
author: 'Person Doe',
summary: 'Lorem ipsum dolor',
category: 'arts:food',
});
} );
},
});
} );

cy.visit('/wp-admin/post-new.php');
cy.visit( '/wp-admin/post-new.php' );
cy.closeWelcomeGuide();
cy.getBlockEditor()
.find('h1.editor-post-title__input, #post-title-0')
.find( 'h1.editor-post-title__input, #post-title-0' )
.first()
.as('title-input');
cy.get('@title-input').click().type('Test episode');
.as( 'title-input' );
cy.get( '@title-input' ).click().type( 'Test episode' );
cy.get(
'.edit-post-header-toolbar__inserter-toggle, .editor-document-tools__inserter-toggle'
).click();
cy.get(
'#components-search-control-0, #block-editor-inserter__search-0'
)
.first()
.as('block-search');
cy.get('@block-search').click().type('Podcast');
cy.get('.editor-block-list-item-podcasting-podcast', {
.as( 'block-search' );
cy.get( '@block-search' ).click().type( 'Podcast' );
cy.get( '.editor-block-list-item-podcasting-podcast', {
timeout: 4000,
}).click();
} ).click();
cy.get(
'.edit-post-header-toolbar__inserter-toggle, .editor-document-tools__inserter-toggle'
).click();
cy.get(
'.wp-block-podcasting-podcast input[type="file"]'
).attachFile('example.mp3');
cy.get('.wp-block-podcasting-podcast audio')
.should('have.attr', 'src')
.and('include', 'example');
cy.getBlockEditor()
.find( '.wp-block-podcasting-podcast input[type="file"]' )
.attachFile( 'example.mp3' );
cy.getBlockEditor()
.find( '.wp-block-podcasting-podcast audio' )
.should( 'have.attr', 'src' )
.and( 'include', 'example' );
cy.openDocumentSettingsSidebar();
cy.openDocumentSettingsPanel('Podcasts');
cy.get('.components-panel__body')
.contains('Podcasts')
.parents('.components-panel__body')
.find('.components-checkbox-control__label')
.contains(taxonomy)
cy.openDocumentSettingsPanel( 'Podcasts' );
cy.get( '.components-panel__body' )
.contains( 'Podcasts' )
.parents( '.components-panel__body' )
.find( '.components-checkbox-control__label' )
.contains( taxonomy )
.click();
cy.get('.editor-post-publish-panel__toggle').click();
cy.get('.editor-post-publish-button').click();
cy.get('.components-snackbar', { timeout: 10000 }).should(
cy.get( '.editor-post-publish-panel__toggle' ).click();
cy.get( '.editor-post-publish-button' ).click();
cy.get( '.components-snackbar', { timeout: 10000 } ).should(
'be.visible'
);
cy.get(
'a.components-snackbar__action:is(.components-button, .components-external-link)'
).click();
cy.get('.wp-block-podcasting-podcast audio')
.should('have.attr', 'src')
.and('include', 'example');
cy.visit('/wp-admin/edit.php');
cy.get('.column-taxonomy-podcasting_podcasts').should(
)
.invoke( 'removeAttr', 'target' )
.click();
cy.get( '.wp-block-podcasting-podcast audio' )
.should( 'have.attr', 'src' )
.and( 'include', 'example' );
cy.visit( '/wp-admin/edit.php' );
cy.get( '.column-taxonomy-podcasting_podcasts' ).should(
'contain.text',
taxonomy
);
});
} );
}
});
} );
72 changes: 36 additions & 36 deletions tests/cypress/integration/onboarding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,74 @@ const {
randomName,
populatePodcast,
deleteAllTerms,
} = require('../support/functions');
} = require( '../support/functions' );

describe('Onboarding tests', () => {
beforeEach(() => {
describe( 'Onboarding tests', () => {
beforeEach( () => {
cy.login();
cy.uploadMedia('tests/cypress/fixtures/example.jpg');
cy.activatePlugin('simple-podcasting');
cy.uploadMedia( 'tests/cypress/fixtures/example.jpg' );
cy.activatePlugin( 'simple-podcasting' );
cy.visit(
'/wp-admin/edit-tags.php?taxonomy=podcasting_podcasts&podcasts=true'
);
deleteAllTerms();
cy.deactivatePlugin('simple-podcasting');
cy.visit('/wp-admin/options.php');
cy.get('body').then(($body) => {
if ($body.find('#simple_podcasting_onboarding').length !== 0) {
cy.get('#simple_podcasting_onboarding')
cy.deactivatePlugin( 'simple-podcasting' );
cy.visit( '/wp-admin/options.php' );
cy.get( 'body' ).then( ( $body ) => {
if ( $body.find( '#simple_podcasting_onboarding' ).length !== 0 ) {
cy.get( '#simple_podcasting_onboarding' )
.click()
.type('{selectAll}no');
cy.get('.submit input[type=submit]').click();
.type( '{selectAll}no' );
cy.get( '.submit input[type=submit]' ).click();
}
});
cy.activatePlugin('simple-podcasting');
});
} );
cy.activatePlugin( 'simple-podcasting' );
} );

it('Should indicate errors', () => {
cy.url().should('include', 'simple-podcasting-onboarding');
cy.url().should('include', 'step=1');
it( 'Should indicate errors', () => {
cy.url().should( 'include', 'simple-podcasting-onboarding' );
cy.url().should( 'include', 'step=1' );

cy.get('#simple-podcasting__create-podcast-button')
.closest('form')
cy.get( '#simple-podcasting__create-podcast-button' )
.closest( 'form' )
.submit();

cy.get('.notice-error').should(
cy.get( '.notice-error' ).should(
'contain',
'A podcast name is required.'
);
});
} );

it('Should pass onboarding', () => {
cy.url().should('include', 'simple-podcasting-onboarding');
cy.url().should('include', 'step=1');
it( 'Should pass onboarding', () => {
cy.url().should( 'include', 'simple-podcasting-onboarding' );
cy.url().should( 'include', 'step=1' );

const podcastName = 'Onboarding ' + randomName();
cy.get('input[name=podcast-name]').click().type(podcastName);
populatePodcast({
cy.get( 'input[name=podcast-name]' ).click().type( podcastName );
populatePodcast( {
author: 'Person Doe',
summary: 'Lorem ipsum dolor',
category: 'Arts',
onboarding: true,
});
cy.get('#simple-podcasting__create-podcast-button')
.closest('form')
} );
cy.get( '#simple-podcasting__create-podcast-button' )
.closest( 'form' )
.submit();

cy.url().should('include', 'step=2');
cy.url().should( 'include', 'step=2' );

cy.visit(
'/wp-admin/edit-tags.php?taxonomy=podcasting_podcasts&podcasts=true'
);

// Podcast was created.
cy.contains(podcastName);
cy.contains( podcastName );

// Option was saved.
cy.visit('/wp-admin/options.php');
cy.get('#simple_podcasting_onboarding').should(
cy.visit( '/wp-admin/options.php' );
cy.get( '#simple_podcasting_onboarding' ).should(
'have.value',
'completed'
);
});
});
} );
} );
Loading
Loading