Skip to content

Commit

Permalink
Add a custom version of the openDocumentSettingsSidebar function to f…
Browse files Browse the repository at this point in the history
…ix issues with WP 6.5. Turn on trunk E2E tests again
  • Loading branch information
dkotter committed Apr 4, 2024
1 parent ac1ab65 commit 04deade
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
core:
- {name: 'WP latest', version: 'latest'}
- {name: 'WP minimum', version: 'WordPress/WordPress#6.1'}
# - {name: 'WP trunk', version: 'WordPress/WordPress#master'}
- {name: 'WP trunk', version: 'WordPress/WordPress#master'}
steps:
- name: Checkout
uses: actions/checkout@v4
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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// Find and open the category panel.
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("Categories")`;
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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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 @@ -59,7 +59,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {
} );

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

// 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 @@ -56,7 +56,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {
} );

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

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

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

// 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.get( 'button[data-label="Post"]' ).click();
cy.openDocumentSettingsSidebarCustom();
cy.get( '.classifai-panel' ).click();
cy.get( '#classifai-audio-controls__preview-btn' ).should( 'exist' );
} );
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.get( 'button[data-label="Post"]' ).click();
cy.openDocumentSettingsSidebarCustom();
cy.get( '.classifai-panel' ).click();
cy.get( '#classifai-audio-controls__preview-btn' ).should( 'exist' );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ describe( '[Language Processing] Text to Speech (OpenAI) Tests', () => {
it( 'Generates audio from text', () => {
cy.createPost( {
title: 'Text to Speech test',
content:
"This feature uses OpenAI's Text to Speech capabilities.",
content: "This feature uses OpenAI's Text to Speech capabilities.",
} );

cy.get( 'button[aria-label="Close panel"]' ).click();
cy.get( 'button[data-label="Post"]' ).click();
cy.openDocumentSettingsSidebarCustom();
cy.get( '.classifai-panel' ).click();
cy.get( '#classifai-audio-controls__preview-btn' ).should( 'exist' );
} );
Expand Down Expand Up @@ -95,8 +94,7 @@ describe( '[Language Processing] Text to Speech (OpenAI) Tests', () => {

cy.createClassicPost( {
title: 'Text to Speech test classic',
content:
"This feature uses OpenAI's Text to Speech capabilities.",
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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

// 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.openDocumentSettingsSidebar();
cy.openDocumentSettingsSidebarCustom();

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

/**
* 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' );
}
} );
} );
} );

0 comments on commit 04deade

Please sign in to comment.