Skip to content

Commit 6ccb976

Browse files
authored
Merge pull request #760 from 10up/update/cypress-wp-utils
Update the `@10up/cypress-wp-utils` package to 0.3.0
2 parents 04deade + 2bb3366 commit 6ccb976

15 files changed

+33
-123
lines changed

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"role": "developer"
3737
},
3838
"devDependencies": {
39-
"@10up/cypress-wp-utils": "^0.2.0",
39+
"@10up/cypress-wp-utils": "^0.3.0",
4040
"@wordpress/env": "^9.4.0",
4141
"@wordpress/scripts": "^27.3.0",
4242
"cypress": "^13.6.4",

tests/cypress/integration/image-processing/image-generation-openai-dalle.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe( 'Image Generation (OpenAI DALL·E) Tests', () => {
5757
} );
5858

5959
// Open post settings sidebar.
60-
cy.openDocumentSettingsSidebarCustom();
60+
cy.openDocumentSettingsSidebar();
6161

6262
// Find and open the Featured image panel.
6363
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("Featured image")`;

tests/cypress/integration/language-processing/classify-content-ibm-watson.test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', ()
125125
} );
126126

127127
// Open post settings sidebar
128-
cy.openDocumentSettingsSidebarCustom();
128+
cy.openDocumentSettingsSidebar();
129129

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

216216
// Open post settings sidebar
217-
cy.openDocumentSettingsSidebarCustom();
217+
cy.openDocumentSettingsSidebar();
218218

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

255255
// Open post settings sidebar
256-
cy.openDocumentSettingsSidebarCustom();
256+
cy.openDocumentSettingsSidebar();
257257

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

294294
// Open post settings sidebar
295-
cy.openDocumentSettingsSidebarCustom();
295+
cy.openDocumentSettingsSidebar();
296296

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

342342
// Open post settings sidebar
343-
cy.openDocumentSettingsSidebarCustom();
343+
cy.openDocumentSettingsSidebar();
344344

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

383383
// Open post settings sidebar
384-
cy.openDocumentSettingsSidebarCustom();
384+
cy.openDocumentSettingsSidebar();
385385

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

437437
// Open post settings sidebar
438-
cy.openDocumentSettingsSidebarCustom();
438+
cy.openDocumentSettingsSidebar();
439439

440440
// Verify Each Created taxonomies.
441441
cy.verifyPostTaxonomyTerms( 'tags', threshold / 100 );

tests/cypress/integration/language-processing/classify-content-openapi-embeddings.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => {
5151
} );
5252

5353
// Open post settings sidebar.
54-
cy.openDocumentSettingsSidebarCustom();
54+
cy.openDocumentSettingsSidebar();
5555

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

121121
// Open post settings sidebar.
122-
cy.openDocumentSettingsSidebarCustom();
122+
cy.openDocumentSettingsSidebar();
123123

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

165-
cy.createClassicPost( {
165+
cy.classicCreatePost( {
166166
title: 'Embeddings test classic',
167167
content: "This feature uses OpenAI's Embeddings capabilities.",
168168
postType: 'post',

tests/cypress/integration/language-processing/excerpt-generation-azure-openai.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {
7070
} );
7171

7272
// Open post settings sidebar.
73-
cy.openDocumentSettingsSidebarCustom();
73+
cy.openDocumentSettingsSidebar();
7474

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

107107
const data = getChatGPTData();
108108

109-
cy.createClassicPost( {
109+
cy.classicCreatePost( {
110110
title: 'Excerpt test classic',
111111
content: 'Test GPT content.',
112112
postType: 'post',

tests/cypress/integration/language-processing/excerpt-generation-googleai-gemini-api.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {
5959
} );
6060

6161
// Open post settings sidebar.
62-
cy.openDocumentSettingsSidebarCustom();
62+
cy.openDocumentSettingsSidebar();
6363

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

9696
const data = getGeminiAPIData();
9797

98-
cy.createClassicPost( {
98+
cy.classicCreatePost( {
9999
title: 'Excerpt test classic',
100100
content: 'Test GPT content.',
101101
postType: 'post',

tests/cypress/integration/language-processing/excerpt-generation-openapi-chatgpt.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {
5656
} );
5757

5858
// Open post settings sidebar.
59-
cy.openDocumentSettingsSidebarCustom();
59+
cy.openDocumentSettingsSidebar();
6060

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

9393
const data = getChatGPTData();
9494

95-
cy.createClassicPost( {
95+
cy.classicCreatePost( {
9696
title: 'Excerpt test classic',
9797
content: 'Test GPT content.',
9898
postType: 'post',
@@ -212,7 +212,7 @@ describe( '[Language processing] Excerpt Generation Tests', () => {
212212
} );
213213

214214
// Open post settings sidebar.
215-
cy.openDocumentSettingsSidebarCustom();
215+
cy.openDocumentSettingsSidebar();
216216

217217
// Find and open the excerpt panel.
218218
const panelButtonSelector = `.components-panel__body .components-panel__body-title button:contains("Excerpt")`;

tests/cypress/integration/language-processing/text-to-speech-amazon-polly.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe( '[Language Processing] Text to Speech (Amazon Polly) Tests', () => {
3535
} );
3636

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

100-
cy.createClassicPost( {
100+
cy.classicCreatePost( {
101101
title: 'Text to Speech test classic',
102102
content:
103103
"This feature uses Amazon Polly's Text to Speech capabilities.",

tests/cypress/integration/language-processing/text-to-speech-microsoft-azure.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe( '[Language Processing] Text to Speech (Microsoft Azure) Tests', () =>
3535
} );
3636

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

100-
cy.createClassicPost( {
100+
cy.classicCreatePost( {
101101
title: 'Text to Speech test classic',
102102
content:
103103
"This feature uses Microsoft's Text to Speech capabilities.",

tests/cypress/integration/language-processing/text-to-speech-openai-text-to-speech.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe( '[Language Processing] Text to Speech (OpenAI) Tests', () => {
3030
} );
3131

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

95-
cy.createClassicPost( {
95+
cy.classicCreatePost( {
9696
title: 'Text to Speech test classic',
9797
content: "This feature uses OpenAI's Text to Speech capabilities.",
9898
postType: 'post',

tests/cypress/integration/language-processing/title-generation-azure-openai.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe( '[Language processing] Title Generation Tests', () => {
6363
} );
6464

6565
// Open post settings sidebar.
66-
cy.openDocumentSettingsSidebarCustom();
66+
cy.openDocumentSettingsSidebar();
6767

6868
// Find and open the summary panel.
6969
const panelButtonSelector = `.components-panel__body.edit-post-post-status .components-panel__body-title button`;

tests/cypress/integration/language-processing/title-generation-googleai-gemini-api.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe( '[Language processing] Title Generation Tests', () => {
4747
} );
4848

4949
// Open post settings sidebar.
50-
cy.openDocumentSettingsSidebarCustom();
50+
cy.openDocumentSettingsSidebar();
5151

5252
// Find and open the summary panel.
5353
const panelButtonSelector = `.components-panel__body.edit-post-post-status .components-panel__body-title button`;

tests/cypress/integration/language-processing/title-generation-openapi-chatgpt.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe( '[Language processing] Title Generation Tests', () => {
4444
} );
4545

4646
// Open post settings sidebar.
47-
cy.openDocumentSettingsSidebarCustom();
47+
cy.openDocumentSettingsSidebar();
4848

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

217217
// Open post settings sidebar.
218-
cy.openDocumentSettingsSidebarCustom();
218+
cy.openDocumentSettingsSidebar();
219219

220220
// Find and open the summary panel.
221221
const panelButtonSelector = `.components-panel__body.edit-post-post-status .components-panel__body-title button`;

tests/cypress/support/commands.js

-90
Original file line numberDiff line numberDiff line change
@@ -523,93 +523,3 @@ Cypress.Commands.add( 'enableClassicEditor', () => {
523523
}
524524
} );
525525
} );
526-
527-
Cypress.Commands.add(
528-
'createClassicPost',
529-
( {
530-
postType = 'post',
531-
title = 'Test Post',
532-
content = 'Test content',
533-
status = 'publish',
534-
beforeSave,
535-
} ) => {
536-
cy.visit( `/wp-admin/post-new.php?post_type=${ postType }` );
537-
538-
cy.get( '#title' ).click().clear().type( title );
539-
540-
cy.get( '#content_ifr' ).then( ( $iframe ) => {
541-
const doc = $iframe.contents().find( 'body#tinymce' );
542-
cy.wrap( doc ).find( 'p:last-child' ).type( content );
543-
} );
544-
545-
if ( 'undefined' !== typeof beforeSave ) {
546-
beforeSave();
547-
}
548-
549-
cy.intercept( 'POST', '/wp-admin/post.php', ( req ) => {
550-
req.alias = 'savePost';
551-
} );
552-
553-
if ( 'draft' === status ) {
554-
cy.get( '#save-post' )
555-
.should( 'not.have.class', 'disabled' )
556-
.click();
557-
} else {
558-
cy.get( '#publish' ).should( 'not.have.class', 'disabled' ).click();
559-
}
560-
561-
cy.wait( '@savePost' ).then( ( response ) => {
562-
const body = new URLSearchParams( response.request?.body );
563-
const id = body.get( 'post_ID' );
564-
cy.wrap( id );
565-
} );
566-
}
567-
);
568-
569-
/**
570-
* Open the document settings sidebar.
571-
*
572-
* This has been modified to work with the new WordPress editor.
573-
* Once the next version of Cypress WP Utils is released, we can
574-
* remove this.
575-
*
576-
* @param tab - Name of the tab
577-
*
578-
* @example
579-
* Open 'Post' tab
580-
* ```
581-
* cy.openDocumentSettingsSidebarCustom()
582-
* ```
583-
*
584-
* @example
585-
* Open 'Block' tab
586-
* ```
587-
* cy.openDocumentSettingsSidebarCustom('Block')
588-
* ```
589-
*/
590-
Cypress.Commands.add( 'openDocumentSettingsSidebarCustom', ( tab = 'Post' ) => {
591-
cy.get( 'body' ).then( ( $body ) => {
592-
const $settingButtonIds = [
593-
'button[aria-expanded="false"][aria-label="Settings"]',
594-
];
595-
596-
$settingButtonIds.forEach( ( $settingButtonId ) => {
597-
if ( $body.find( $settingButtonId ).length ) {
598-
cy.get( $settingButtonId ).click();
599-
cy.wrap( $body.find( $settingButtonId ) ).as( 'sidebarButton' );
600-
}
601-
} );
602-
603-
const $tabSelectors = [
604-
`div[role="tablist"] button:contains("${ tab }")`,
605-
`.edit-post-sidebar__panel-tabs button:contains("${ tab }")`,
606-
];
607-
608-
$tabSelectors.forEach( ( $tabSelector ) => {
609-
if ( $body.find( $tabSelector ).length ) {
610-
cy.get( $tabSelector ).click();
611-
cy.wrap( $body.find( $tabSelector ) ).as( 'selectedTab' );
612-
}
613-
} );
614-
} );
615-
} );

0 commit comments

Comments
 (0)