@wordpress/e2e-tests 5.2.1-next.4d3b314fd5.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.4.0 (2022-10-19)
6
+
7
+ ## 5.3.0 (2022-10-05)
8
+
9
+ ### New features
10
+
11
+ - Added Autocomplete Component e2e test suite. [#42905](https://github.com/WordPress/gutenberg/pull/42905).
12
+
5
13
  ## 5.2.0 (2022-09-21)
6
14
 
7
15
  ## 5.0.0 (2022-08-24)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "5.2.1-next.4d3b314fd5.0",
3
+ "version": "5.4.0",
4
4
  "description": "End-To-End (E2E) tests for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -23,11 +23,11 @@
23
23
  "node": ">=14"
24
24
  },
25
25
  "dependencies": {
26
- "@wordpress/e2e-test-utils": "^8.2.1-next.4d3b314fd5.0",
27
- "@wordpress/jest-console": "^6.1.1-next.4d3b314fd5.0",
28
- "@wordpress/jest-puppeteer-axe": "^5.1.1-next.4d3b314fd5.0",
29
- "@wordpress/scripts": "^24.2.1-next.4d3b314fd5.0",
30
- "@wordpress/url": "^3.19.1-next.4d3b314fd5.0",
26
+ "@wordpress/e2e-test-utils": "^8.4.0",
27
+ "@wordpress/jest-console": "^6.3.0",
28
+ "@wordpress/jest-puppeteer-axe": "^5.3.0",
29
+ "@wordpress/scripts": "^24.4.0",
30
+ "@wordpress/url": "^3.21.0",
31
31
  "chalk": "^4.0.0",
32
32
  "expect-puppeteer": "^4.4.0",
33
33
  "filenamify": "^4.2.0",
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "25054766423cb49d959eb656c2533530073ff5c2"
49
+ "gitHead": "a2ff0e6471c88436dad0287beb88d1729aa6f5dd"
50
50
  }
@@ -14,7 +14,7 @@ class Test_Widget extends WP_Widget {
14
14
  /**
15
15
  * Sets up a new test widget instance.
16
16
  */
17
- function __construct() {
17
+ public function __construct() {
18
18
  parent::__construct(
19
19
  'test_widget',
20
20
  'Test Widget',
@@ -0,0 +1,55 @@
1
+ (function () {
2
+ const fruits = {
3
+ name: 'fruit',
4
+ // The prefix that triggers this completer
5
+ triggerPrefix: '~',
6
+ // The option data
7
+ options: [
8
+ { visual: '🍎', name: 'Apple', id: 1 },
9
+ { visual: '🍊', name: 'Orange', id: 2 },
10
+ { visual: '🍇', name: 'Grapes', id: 3 },
11
+ { visual: '🥭', name: 'Mango', id: 4 },
12
+ { visual: '🍓', name: 'Strawberry', id: 5 },
13
+ { visual: '🫐', name: 'Blueberry', id: 6 },
14
+ { visual: '🍒', name: 'Cherry', id: 7 },
15
+ ],
16
+ // Returns a label for an option like "🍊 Orange"
17
+ getOptionLabel: ( option ) => `${ option.visual } ${ option.name }`,
18
+ // Declares that options should be matched by their name
19
+ getOptionKeywords: ( option ) => [ option.name ],
20
+ // Declares that the Grapes option is disabled
21
+ isOptionDisabled: ( option ) => option.name === 'Grapes',
22
+ // Declares completions should be inserted as abbreviations
23
+ getOptionCompletion: ( option ) => (
24
+ option.visual
25
+ ),
26
+ };
27
+
28
+ function duplicateUserMentions( completers ) {
29
+ const [ users ] = completers.filter(
30
+ ( completer ) => completer.name === 'users'
31
+ );
32
+ return {
33
+ ...users,
34
+ name: 'users-copy',
35
+ triggerPrefix: '+',
36
+ getOptionCompletion: ( user ) => `+${ user.slug }`,
37
+ };
38
+ }
39
+
40
+ function appendTestCompleters( completers, blockName ) {
41
+ const copiedUsers = duplicateUserMentions( completers );
42
+ return blockName === 'core/paragraph'
43
+ ? [ ...completers, fruits, copiedUsers ]
44
+ : completers;
45
+ }
46
+
47
+ // Adding the filter with a priority of 11
48
+ // to ensure it fires after the default user mentions are added.
49
+ wp.hooks.addFilter(
50
+ 'editor.Autocomplete.completers',
51
+ 'editor/autocompleters/test',
52
+ appendTestCompleters,
53
+ 11
54
+ );
55
+ })()
@@ -0,0 +1,27 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test Autocompleter
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * @package gutenberg-test-autocompleter
8
+ */
9
+
10
+ /**
11
+ * Registers a custom script for the plugin.
12
+ */
13
+ function enqueue_test_autocompleter_plugin_script() {
14
+ wp_enqueue_script(
15
+ 'gutenberg-test-autocompleter',
16
+ plugins_url( 'test-autocompleter/index.js', __FILE__ ),
17
+ array(
18
+ 'wp-hooks',
19
+ 'wp-element',
20
+ 'wp-block-editor',
21
+ ),
22
+ filemtime( plugin_dir_path( __FILE__ ) . 'test-autocompleter/index.js' ),
23
+ false
24
+ );
25
+ }
26
+
27
+ add_action( 'init', 'enqueue_test_autocompleter_plugin_script' );
@@ -16,6 +16,7 @@ import {
16
16
  clickButton,
17
17
  openListView,
18
18
  getListViewBlocks,
19
+ clickBlockToolbarButton,
19
20
  } from '@wordpress/e2e-test-utils';
20
21
 
21
22
  async function upload( selector ) {
@@ -110,7 +111,7 @@ describe( 'Gallery', () => {
110
111
 
111
112
  const imageListLink = ( await getListViewBlocks( 'Image' ) )[ 0 ];
112
113
  await imageListLink.click();
113
-
114
+ await clickBlockToolbarButton( 'Caption' );
114
115
  const captionElement = await figureElement.$(
115
116
  '.block-editor-rich-text__editable'
116
117
  );
@@ -82,9 +82,9 @@ describe( 'Block Switcher', () => {
82
82
  await pressKeyWithModifier( 'alt', 'F10' );
83
83
 
84
84
  // Verify the block switcher exists.
85
- expect( await hasBlockSwitcher() ).toBeFalsy();
85
+ expect( await hasBlockSwitcher() ).toBeTruthy();
86
86
  // Verify the correct block transforms appear.
87
- expect( await getAvailableBlockTransforms() ).toHaveLength( 0 );
87
+ expect( await getAvailableBlockTransforms() ).toHaveLength( 1 );
88
88
  } );
89
89
 
90
90
  describe( 'Conditional tranformation options', () => {
@@ -236,6 +236,20 @@ describe( 'splitting and merging blocks', () => {
236
236
  await page.keyboard.press( 'Enter' );
237
237
  await page.keyboard.type( 'item 2' );
238
238
  await pressKeyTimes( 'ArrowUp', 3 );
239
+ await page.keyboard.press( 'Delete' );
240
+ expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
241
+ "<!-- wp:paragraph -->
242
+ <p>hi</p>
243
+ <!-- /wp:paragraph -->
244
+
245
+ <!-- wp:paragraph -->
246
+ <p>item 1</p>
247
+ <!-- /wp:paragraph -->
248
+
249
+ <!-- wp:paragraph -->
250
+ <p>item 2</p>
251
+ <!-- /wp:paragraph -->"
252
+ ` );
239
253
  await page.keyboard.press( 'Delete' );
240
254
  // Carret should be in the first block and at the proper position.
241
255
  await page.keyboard.type( '-' );
@@ -259,15 +273,25 @@ describe( 'splitting and merging blocks', () => {
259
273
  await page.keyboard.press( 'ArrowUp' );
260
274
  await pressKeyTimes( 'ArrowLeft', 6 );
261
275
  await page.keyboard.press( 'Backspace' );
262
- // Carret should be in the first block and at the proper position.
263
- await page.keyboard.type( '-' );
264
276
  expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
265
277
  "<!-- wp:paragraph -->
266
278
  <p>hi</p>
267
279
  <!-- /wp:paragraph -->
268
280
 
269
281
  <!-- wp:paragraph -->
270
- <p>-item 1</p>
282
+ <p>item 1</p>
283
+ <!-- /wp:paragraph -->
284
+
285
+ <!-- wp:paragraph -->
286
+ <p>item 2</p>
287
+ <!-- /wp:paragraph -->"
288
+ ` );
289
+ await page.keyboard.press( 'Backspace' );
290
+ // Carret should be in the first block and at the proper position.
291
+ await page.keyboard.type( '-' );
292
+ expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
293
+ "<!-- wp:paragraph -->
294
+ <p>hi-item 1</p>
271
295
  <!-- /wp:paragraph -->
272
296
 
273
297
  <!-- wp:paragraph -->
@@ -266,7 +266,7 @@ describe( 'Multi-entity save flow', () => {
266
266
  } );
267
267
 
268
268
  // Select the header template part via list view.
269
- await page.click( '.edit-site-header-toolbar__list-view-toggle' );
269
+ await page.click( '.edit-site-header-edit-mode__list-view-toggle' );
270
270
  const headerTemplatePartListViewButton = await page.waitForXPath(
271
271
  '//a[contains(@class, "block-editor-list-view-block-select-button")][contains(., "header")]'
272
272
  );
@@ -12,13 +12,13 @@ import {
12
12
 
13
13
  async function toggleSidebar() {
14
14
  await page.click(
15
- '.edit-site-header__actions button[aria-label="Settings"]'
15
+ '.edit-site-header-edit-mode__actions button[aria-label="Settings"]'
16
16
  );
17
17
  }
18
18
 
19
19
  async function getActiveTabLabel() {
20
20
  return await page.$eval(
21
- '.edit-site-sidebar__panel-tab.is-active',
21
+ '.edit-site-sidebar-edit-mode__panel-tab.is-active',
22
22
  ( element ) => element.getAttribute( 'aria-label' )
23
23
  );
24
24
  }
@@ -21,11 +21,11 @@ describe( 'Site Editor Inserter', () => {
21
21
  } );
22
22
 
23
23
  it( 'inserter toggle button should toggle global inserter', async () => {
24
- await page.click( '.edit-site-header-toolbar__inserter-toggle' );
24
+ await page.click( '.edit-site-header-edit-mode__inserter-toggle' );
25
25
  await page.waitForSelector( '.edit-site-editor__inserter-panel', {
26
26
  visible: true,
27
27
  } );
28
- await page.click( '.edit-site-header-toolbar__inserter-toggle' );
28
+ await page.click( '.edit-site-header-edit-mode__inserter-toggle' );
29
29
  await page.waitForSelector( '.edit-site-editor__inserter-panel', {
30
30
  hidden: true,
31
31
  } );
package/plugins/nonce.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: Gutenberg Test Plugin, Nonce
4
- * Plugin URI: https://github.com/WordPress/gutenberg
5
- * Author: Gutenberg Team
6
- *
7
- * @package gutenberg-test-plugin-nonce
8
- */
9
-
10
- /**
11
- * Returns the nonce life time.
12
- */
13
- function gutenberg_test_plugin_nonce_life() {
14
- return 5;
15
- }
16
- add_filter( 'nonce_life', 'gutenberg_test_plugin_nonce_life' );
@@ -1,7 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`changing image size should load script and dependencies in iframe 1`] = `
4
- "<!-- wp:test/iframed-block -->
5
- <p class=\\"wp-block-test-iframed-block\\">Iframed Block (saved)</p>
6
- <!-- /wp:test/iframed-block -->"
7
- `;
@@ -1,49 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- activatePlugin,
6
- createNewPost,
7
- deactivatePlugin,
8
- insertBlock,
9
- getEditedPostContent,
10
- canvas,
11
- createNewTemplate,
12
- } from '@wordpress/e2e-test-utils';
13
-
14
- describe( 'changing image size', () => {
15
- beforeEach( async () => {
16
- await activatePlugin( 'gutenberg-test-iframed-block' );
17
- await createNewPost( { postType: 'page' } );
18
- } );
19
-
20
- afterEach( async () => {
21
- await deactivatePlugin( 'gutenberg-test-iframed-block' );
22
- } );
23
-
24
- it( 'should load script and dependencies in iframe', async () => {
25
- await insertBlock( 'Iframed Block' );
26
-
27
- expect( await getEditedPostContent() ).toMatchSnapshot();
28
-
29
- const element = await page.waitForSelector(
30
- '.wp-block-test-iframed-block'
31
- );
32
- const text = await element.evaluate( ( el ) => el.textContent );
33
-
34
- expect( text ).toBe( 'Iframed Block (set with jQuery)' );
35
-
36
- await createNewTemplate( 'Iframed Test' );
37
-
38
- const iframeElement = await canvas().waitForSelector(
39
- '.wp-block-test-iframed-block'
40
- );
41
- const iframedText = await iframeElement.evaluate(
42
- ( el ) => el.textContent
43
- );
44
-
45
- // Expect the script to load in the iframe, which replaces the block
46
- // text.
47
- expect( iframedText ).toBe( 'Iframed Block (set with jQuery)' );
48
- } );
49
- } );
@@ -1,34 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- activatePlugin,
6
- createNewPost,
7
- deactivatePlugin,
8
- saveDraft,
9
- } from '@wordpress/e2e-test-utils';
10
-
11
- describe( 'Nonce', () => {
12
- // While using beforeEach/afterEach is suboptimal for multiple tests, they
13
- // are used here to ensure that the nonce plugin doesn't interfere with API
14
- // calls made in global before/after calls, which may perform API requests.
15
- beforeEach( async () => {
16
- await activatePlugin( 'gutenberg-test-plugin-nonce' );
17
- } );
18
- afterEach( async () => {
19
- await deactivatePlugin( 'gutenberg-test-plugin-nonce' );
20
- } );
21
-
22
- it( 'should refresh when expired', async () => {
23
- await createNewPost();
24
- await page.keyboard.press( 'Enter' );
25
- // eslint-disable-next-line no-restricted-syntax
26
- await page.waitForTimeout( 5000 );
27
- await page.keyboard.type( 'test' );
28
- // `saveDraft` waits for saving to be successful, so this test would
29
- // timeout if it's not.
30
- await saveDraft();
31
- // We expect a 403 status once.
32
- expect( console ).toHaveErrored();
33
- } );
34
- } );
@@ -1,69 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- clickBlockAppender,
6
- createNewPost,
7
- createUser,
8
- deleteUser,
9
- getEditedPostContent,
10
- pressKeyTimes,
11
- } from '@wordpress/e2e-test-utils';
12
-
13
- describe( 'autocomplete mentions', () => {
14
- beforeAll( async () => {
15
- await createUser( 'testuser', { firstName: 'Jane', lastName: 'Doe' } );
16
- } );
17
-
18
- beforeEach( async () => {
19
- await createNewPost();
20
- } );
21
-
22
- afterAll( async () => {
23
- await deleteUser( 'testuser' );
24
- } );
25
-
26
- it( 'should insert mention', async () => {
27
- await clickBlockAppender();
28
- await page.keyboard.type( 'I am @a' );
29
- await page.waitForSelector( '.components-autocomplete__result' );
30
- await page.keyboard.press( 'Enter' );
31
- await page.keyboard.type( '.' );
32
- expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
33
- "<!-- wp:paragraph -->
34
- <p>I am @admin.</p>
35
- <!-- /wp:paragraph -->"
36
- ` );
37
- } );
38
-
39
- it( 'should insert mention between two other words', async () => {
40
- await clickBlockAppender();
41
- await page.keyboard.type( 'Stuck in the middle with you.' );
42
- await pressKeyTimes( 'ArrowLeft', 'you.'.length );
43
- await page.keyboard.type( '@j' );
44
- await page.waitForSelector( '.components-autocomplete__result' );
45
- await page.keyboard.press( 'Enter' );
46
- await page.keyboard.type( ' ' );
47
- expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
48
- "<!-- wp:paragraph -->
49
- <p>Stuck in the middle with @testuser you.</p>
50
- <!-- /wp:paragraph -->"
51
- ` );
52
- } );
53
-
54
- it( 'should insert two subsequent mentions', async () => {
55
- await clickBlockAppender();
56
- await page.keyboard.type( 'I am @j' );
57
- await page.waitForSelector( '.components-autocomplete__result' );
58
- await page.keyboard.press( 'Enter' );
59
- await page.keyboard.type( ' @a' );
60
- await page.waitForSelector( '.components-autocomplete__result' );
61
- await page.keyboard.press( 'Enter' );
62
- await page.keyboard.type( '.' );
63
- expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
64
- "<!-- wp:paragraph -->
65
- <p>I am @testuser @admin.</p>
66
- <!-- /wp:paragraph -->"
67
- ` );
68
- } );
69
- } );