Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the @10up/cypress-wp-utils package to 0.3.0 #760

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"role": "developer"
},
"devDependencies": {
"@10up/cypress-wp-utils": "^0.2.0",
"@10up/cypress-wp-utils": "^0.3.0",
"@wordpress/env": "^9.4.0",
"@wordpress/scripts": "^27.3.0",
"cypress": "^13.6.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe( 'Image Generation (OpenAI DALL·E) Tests', () => {
} );

// Open post settings sidebar.
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Find and open the Featured image panel.
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("Featured image")`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', ()
} );

// Open post settings sidebar
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Open Panel
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("ClassifAI")`;
Expand Down Expand Up @@ -214,7 +214,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', ()
} );

// Open post settings sidebar
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Open Panel
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("ClassifAI")`;
Expand Down Expand Up @@ -253,7 +253,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', ()
} );

// Open post settings sidebar
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Verify Each Created taxonomies.
[ 'categories', 'keywords', 'concepts', 'entities' ].forEach(
Expand Down Expand Up @@ -292,7 +292,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', ()
} );

// Open post settings sidebar
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Verify Each Created taxonomies.
[ 'categories', 'keywords', 'concepts', 'entities' ].forEach(
Expand Down Expand Up @@ -340,7 +340,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', ()
} );

// Open post settings sidebar
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Verify Each Created taxonomies with threshold 75.
[ 'categories', 'keywords', 'concepts', 'entities' ].forEach(
Expand Down Expand Up @@ -381,7 +381,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', ()
} );

// Open post settings sidebar
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Verify Each Created taxonomies with threshold 75 as we have already created terms with threshold 75. So, those are existing terms.
[ 'categories', 'keywords', 'concepts', 'entities' ].forEach(
Expand Down Expand Up @@ -435,7 +435,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', ()
} );

// Open post settings sidebar
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Verify Each Created taxonomies.
cy.verifyPostTaxonomyTerms( 'tags', threshold / 100 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => {
} );

// Open post settings sidebar.
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Find and open the category panel.
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("Categories")`;
Expand Down Expand Up @@ -119,7 +119,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => {
} );

// Open post settings sidebar.
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Find and open the category panel.
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("Categories")`;
Expand Down Expand Up @@ -162,7 +162,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => {
cy.get( '#category' ).check();
cy.get( '#submit' ).click();

cy.createClassicPost( {
cy.classicCreatePost( {
title: 'Embeddings test classic',
content: "This feature uses OpenAI's Embeddings capabilities.",
postType: 'post',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {
} );

// Open post settings sidebar.
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Find and open the excerpt panel.
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("Excerpt")`;
Expand Down Expand Up @@ -106,7 +106,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {

const data = getChatGPTData();

cy.createClassicPost( {
cy.classicCreatePost( {
title: 'Excerpt test classic',
content: 'Test GPT content.',
postType: 'post',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {
} );

// Open post settings sidebar.
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Find and open the excerpt panel.
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("Excerpt")`;
Expand Down Expand Up @@ -95,7 +95,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {

const data = getGeminiAPIData();

cy.createClassicPost( {
cy.classicCreatePost( {
title: 'Excerpt test classic',
content: 'Test GPT content.',
postType: 'post',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {
} );

// Open post settings sidebar.
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Find and open the excerpt panel.
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("Excerpt")`;
Expand Down Expand Up @@ -92,7 +92,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {

const data = getChatGPTData();

cy.createClassicPost( {
cy.classicCreatePost( {
title: 'Excerpt test classic',
content: 'Test GPT content.',
postType: 'post',
Expand Down Expand Up @@ -212,7 +212,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {
} );

// Open post settings sidebar.
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Find and open the excerpt panel.
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("Excerpt")`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe( '[Language Processing] Text to Speech (Amazon Polly) Tests', () => {
} );

cy.get( 'button[aria-label="Close panel"]' ).click();
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();
cy.get( '.classifai-panel' ).click();
cy.get( '#classifai-audio-controls__preview-btn' ).should( 'exist' );
} );
Expand Down Expand Up @@ -97,7 +97,7 @@ describe( '[Language Processing] Text to Speech (Amazon Polly) Tests', () => {
it( 'Can see the enable button in a post (Classic Editor)', () => {
cy.enableClassicEditor();

cy.createClassicPost( {
cy.classicCreatePost( {
title: 'Text to Speech test classic',
content:
"This feature uses Amazon Polly's Text to Speech capabilities.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe( '[Language Processing] Text to Speech (Microsoft Azure) Tests', () =>
} );

cy.get( 'button[aria-label="Close panel"]' ).click();
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();
cy.get( '.classifai-panel' ).click();
cy.get( '#classifai-audio-controls__preview-btn' ).should( 'exist' );
} );
Expand Down Expand Up @@ -97,7 +97,7 @@ describe( '[Language Processing] Text to Speech (Microsoft Azure) Tests', () =>
it( 'Can see the enable button in a post (Classic Editor)', () => {
cy.enableClassicEditor();

cy.createClassicPost( {
cy.classicCreatePost( {
title: 'Text to Speech test classic',
content:
"This feature uses Microsoft's Text to Speech capabilities.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe( '[Language Processing] Text to Speech (OpenAI) Tests', () => {
} );

cy.get( 'button[aria-label="Close panel"]' ).click();
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();
cy.get( '.classifai-panel' ).click();
cy.get( '#classifai-audio-controls__preview-btn' ).should( 'exist' );
} );
Expand Down Expand Up @@ -92,7 +92,7 @@ describe( '[Language Processing] Text to Speech (OpenAI) Tests', () => {
it( 'Can see the enable button in a post (Classic Editor)', () => {
cy.enableClassicEditor();

cy.createClassicPost( {
cy.classicCreatePost( {
title: 'Text to Speech test classic',
content: "This feature uses OpenAI's Text to Speech capabilities.",
postType: 'post',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe( '[Language processing] Title Generation Tests', () => {
} );

// Open post settings sidebar.
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Find and open the summary panel.
const panelButtonSelector = `.components-panel__body.edit-post-post-status .components-panel__body-title button`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe( '[Language processing] Title Generation Tests', () => {
} );

// Open post settings sidebar.
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Find and open the summary panel.
const panelButtonSelector = `.components-panel__body.edit-post-post-status .components-panel__body-title button`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe( '[Language processing] Title Generation Tests', () => {
} );

// Open post settings sidebar.
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Find and open the summary panel.
const panelButtonSelector = `.components-panel__body.edit-post-post-status .components-panel__body-title button`;
Expand Down Expand Up @@ -215,7 +215,7 @@ describe( '[Language processing] Title Generation Tests', () => {
} );

// Open post settings sidebar.
cy.openDocumentSettingsSidebarCustom();
cy.openDocumentSettingsSidebar();

// Find and open the summary panel.
const panelButtonSelector = `.components-panel__body.edit-post-post-status .components-panel__body-title button`;
Expand Down
90 changes: 0 additions & 90 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,93 +523,3 @@ Cypress.Commands.add( 'enableClassicEditor', () => {
}
} );
} );

Cypress.Commands.add(
'createClassicPost',
( {
postType = 'post',
title = 'Test Post',
content = 'Test content',
status = 'publish',
beforeSave,
} ) => {
cy.visit( `/wp-admin/post-new.php?post_type=${ postType }` );

cy.get( '#title' ).click().clear().type( title );

cy.get( '#content_ifr' ).then( ( $iframe ) => {
const doc = $iframe.contents().find( 'body#tinymce' );
cy.wrap( doc ).find( 'p:last-child' ).type( content );
} );

if ( 'undefined' !== typeof beforeSave ) {
beforeSave();
}

cy.intercept( 'POST', '/wp-admin/post.php', ( req ) => {
req.alias = 'savePost';
} );

if ( 'draft' === status ) {
cy.get( '#save-post' )
.should( 'not.have.class', 'disabled' )
.click();
} else {
cy.get( '#publish' ).should( 'not.have.class', 'disabled' ).click();
}

cy.wait( '@savePost' ).then( ( response ) => {
const body = new URLSearchParams( response.request?.body );
const id = body.get( 'post_ID' );
cy.wrap( id );
} );
}
);

/**
* Open the document settings sidebar.
*
* This has been modified to work with the new WordPress editor.
* Once the next version of Cypress WP Utils is released, we can
* remove this.
*
* @param tab - Name of the tab
*
* @example
* Open 'Post' tab
* ```
* cy.openDocumentSettingsSidebarCustom()
* ```
*
* @example
* Open 'Block' tab
* ```
* cy.openDocumentSettingsSidebarCustom('Block')
* ```
*/
Cypress.Commands.add( 'openDocumentSettingsSidebarCustom', ( tab = 'Post' ) => {
cy.get( 'body' ).then( ( $body ) => {
const $settingButtonIds = [
'button[aria-expanded="false"][aria-label="Settings"]',
];

$settingButtonIds.forEach( ( $settingButtonId ) => {
if ( $body.find( $settingButtonId ).length ) {
cy.get( $settingButtonId ).click();
cy.wrap( $body.find( $settingButtonId ) ).as( 'sidebarButton' );
}
} );

const $tabSelectors = [
`div[role="tablist"] button:contains("${ tab }")`,
`.edit-post-sidebar__panel-tabs button:contains("${ tab }")`,
];

$tabSelectors.forEach( ( $tabSelector ) => {
if ( $body.find( $tabSelector ).length ) {
cy.get( $tabSelector ).click();
cy.wrap( $body.find( $tabSelector ) ).as( 'selectedTab' );
}
} );
} );
} );
Loading