@wordpress/e2e-tests 2.2.15 → 2.2.18

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.
@@ -4,7 +4,6 @@
4
4
  "name": "core/post-excerpt",
5
5
  "isValid": true,
6
6
  "attributes": {
7
- "wordCount": 55,
8
7
  "showMoreOnNewLine": true
9
8
  },
10
9
  "innerBlocks": [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "2.2.15",
3
+ "version": "2.2.18",
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": ">=12"
24
24
  },
25
25
  "dependencies": {
26
- "@wordpress/e2e-test-utils": "^5.3.0",
26
+ "@wordpress/e2e-test-utils": "^5.3.2",
27
27
  "@wordpress/jest-console": "^4.0.5",
28
28
  "@wordpress/jest-puppeteer-axe": "^3.0.5",
29
- "@wordpress/scripts": "^16.1.4",
30
- "@wordpress/url": "^3.1.1",
29
+ "@wordpress/scripts": "^16.1.5",
30
+ "@wordpress/url": "^3.1.3",
31
31
  "chalk": "^4.0.0",
32
32
  "expect-puppeteer": "^4.4.0",
33
33
  "lodash": "^4.17.21",
@@ -41,5 +41,5 @@
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "42a6dbdbf9c981e71ea4752c94e5642d6f6cac1d"
44
+ "gitHead": "6464883c6c546233543a1ee01428059dee3560fc"
45
45
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "apiVersion": 2,
3
+ "name": "test/iframed-inline-styles",
4
+ "title": "Iframed Inline Styles",
5
+ "category": "text",
6
+ "icon": "smiley",
7
+ "description": "",
8
+ "supports": {
9
+ "html": false
10
+ },
11
+ "textdomain": "iframed-inline-styles",
12
+ "editorScript": "iframed-inline-styles-editor-script",
13
+ "editorStyle": "file:./editor.css",
14
+ "style": "iframed-inline-styles-style"
15
+ }
@@ -0,0 +1,4 @@
1
+ /* Random rule with `wp-block` in the selector. */
2
+ .wp-block-test-iframed-inline-styles {
3
+ display: block;
4
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The following styles get applied inside the editor only.
3
+ */
4
+ .wp-block-test-iframed-inline-styles {
5
+ border: 1px dotted #f00;
6
+ }
@@ -0,0 +1,15 @@
1
+ ( ( { wp: { element, blocks, blockEditor } } ) => {
2
+ const { createElement: el } = element;
3
+ const { registerBlockType } = blocks;
4
+ const { useBlockProps } = blockEditor;
5
+
6
+ registerBlockType( 'test/iframed-inline-styles', {
7
+ apiVersion: 2,
8
+ edit: function Edit() {
9
+ return el( 'div', useBlockProps(), 'Edit' );
10
+ },
11
+ save: function Save() {
12
+ return el( 'div', useBlockProps.save(), 'Save' );
13
+ },
14
+ } );
15
+ } )( window );
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The following styles get applied both on the front of your site and in the
3
+ * editor.
4
+ */
5
+ .wp-block-test-iframed-inline-styles {
6
+ background-color: #21759b;
7
+ color: #fff;
8
+ padding: 2px;
9
+ }
@@ -0,0 +1,52 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test Iframed Inline Styles
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * @package gutenberg-test-iframed-inline-styles
8
+ */
9
+
10
+ add_action(
11
+ 'setup_theme',
12
+ function() {
13
+ add_theme_support( 'block-templates' );
14
+ }
15
+ );
16
+
17
+ add_action(
18
+ 'init',
19
+ function() {
20
+ wp_register_script(
21
+ 'iframed-inline-styles-editor-script',
22
+ plugin_dir_url( __FILE__ ) . 'iframed-inline-styles/editor.js',
23
+ array(
24
+ 'wp-blocks',
25
+ 'wp-block-editor',
26
+ 'wp-element',
27
+ ),
28
+ filemtime( plugin_dir_path( __FILE__ ) . 'iframed-inline-styles/editor.js' )
29
+ );
30
+ wp_register_style(
31
+ 'iframed-inline-styles-style',
32
+ plugin_dir_url( __FILE__ ) . 'iframed-inline-styles/style.css',
33
+ array(),
34
+ filemtime( plugin_dir_path( __FILE__ ) . 'iframed-inline-styles/style.css' )
35
+ );
36
+ wp_add_inline_style( 'iframed-inline-styles-style', '.wp-block-test-iframed-inline-styles{padding:20px}' );
37
+ register_block_type_from_metadata( __DIR__ . '/iframed-inline-styles' );
38
+ }
39
+ );
40
+
41
+ add_action(
42
+ 'enqueue_block_editor_assets',
43
+ function() {
44
+ wp_enqueue_style(
45
+ 'iframed-inline-styles-compat-style',
46
+ plugin_dir_url( __FILE__ ) . 'iframed-inline-styles/compat-style.css',
47
+ array(),
48
+ filemtime( plugin_dir_path( __FILE__ ) . 'iframed-inline-styles/compat-style.css' )
49
+ );
50
+ wp_add_inline_style( 'iframed-inline-styles-compat-style', '.wp-block-test-iframed-inline-styles{border-width:2px}' );
51
+ }
52
+ );
@@ -28,7 +28,7 @@
28
28
  el( 'div', { className: 'grid-item' } ),
29
29
  el( 'div', { className: 'grid-item' } ),
30
30
  el( 'div', { className: 'grid-item grid-item--height2' } ),
31
- ]
31
+ ];
32
32
 
33
33
  registerBlockType( 'test/iframed-masonry-block', {
34
34
  edit: function Edit() {
@@ -38,6 +38,36 @@ describe( 'Buttons', () => {
38
38
  expect( await getEditedPostContent() ).toMatchSnapshot();
39
39
  } );
40
40
 
41
+ it( 'moves focus from the link editor back to the button when escape is pressed after the URL has been submitted', async () => {
42
+ // Regression: https://github.com/WordPress/gutenberg/issues/34307
43
+ await insertBlock( 'Buttons' );
44
+ await pressKeyWithModifier( 'primary', 'k' );
45
+ await page.waitForFunction(
46
+ () => !! document.activeElement.closest( '.block-editor-url-input' )
47
+ );
48
+ await page.keyboard.type( 'https://example.com' );
49
+ await page.keyboard.press( 'Enter' );
50
+ await page.waitForFunction(
51
+ () =>
52
+ document.activeElement ===
53
+ document.querySelector(
54
+ '.block-editor-link-control a[href="https://example.com"]'
55
+ )
56
+ );
57
+ await page.keyboard.press( 'Escape' );
58
+
59
+ // Focus should move from the link control to the button block's text.
60
+ await page.waitForFunction(
61
+ () =>
62
+ document.activeElement ===
63
+ document.querySelector( '[aria-label="Button text"]' )
64
+ );
65
+
66
+ // The link control should still be visible when a URL is set.
67
+ const linkControl = await page.$( '.block-editor-link-control' );
68
+ expect( linkControl ).toBeTruthy();
69
+ } );
70
+
41
71
  it( 'can jump to the link editor using the keyboard shortcut', async () => {
42
72
  await insertBlock( 'Buttons' );
43
73
  await page.keyboard.type( 'WordPress' );
@@ -0,0 +1,7 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`iframed inline styles should load inline styles in iframe 1`] = `
4
+ "<!-- wp:test/iframed-inline-styles -->
5
+ <div class=\\"wp-block-test-iframed-inline-styles\\">Save</div>
6
+ <!-- /wp:test/iframed-inline-styles -->"
7
+ `;
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`changing image size should load script and dependencies in iframe 1`] = `
3
+ exports[`iframed masonry block should load script and dependencies in iframe 1`] = `
4
4
  "<!-- wp:test/iframed-masonry-block -->
5
5
  <div class=\\"wp-block-test-iframed-masonry-block\\"><div class=\\"grid-item\\"></div><div class=\\"grid-item grid-item--width2 grid-item--height2\\"></div><div class=\\"grid-item grid-item--height3\\"></div><div class=\\"grid-item grid-item--height2\\"></div><div class=\\"grid-item grid-item--width3\\"></div><div class=\\"grid-item\\"></div><div class=\\"grid-item\\"></div><div class=\\"grid-item grid-item--height2\\"></div><div class=\\"grid-item grid-item--width2 grid-item--height3\\"></div><div class=\\"grid-item\\"></div><div class=\\"grid-item grid-item--height2\\"></div><div class=\\"grid-item\\"></div><div class=\\"grid-item grid-item--width2 grid-item--height2\\"></div><div class=\\"grid-item grid-item--width2\\"></div><div class=\\"grid-item\\"></div><div class=\\"grid-item grid-item--height2\\"></div><div class=\\"grid-item\\"></div><div class=\\"grid-item\\"></div><div class=\\"grid-item grid-item--height3\\"></div><div class=\\"grid-item grid-item--height2\\"></div><div class=\\"grid-item\\"></div><div class=\\"grid-item\\"></div><div class=\\"grid-item grid-item--height2\\"></div></div>
6
6
  <!-- /wp:test/iframed-masonry-block -->"
@@ -0,0 +1,67 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ activatePlugin,
6
+ createNewPost,
7
+ deactivatePlugin,
8
+ insertBlock,
9
+ getEditedPostContent,
10
+ openDocumentSettingsSidebar,
11
+ clickButton,
12
+ canvas,
13
+ } from '@wordpress/e2e-test-utils';
14
+
15
+ async function getComputedStyle( context, property ) {
16
+ await context.waitForSelector( '.wp-block-test-iframed-inline-styles' );
17
+ return await context.evaluate( ( prop ) => {
18
+ const container = document.querySelector(
19
+ '.wp-block-test-iframed-inline-styles'
20
+ );
21
+ return window.getComputedStyle( container )[ prop ];
22
+ }, property );
23
+ }
24
+
25
+ describe( 'iframed inline styles', () => {
26
+ beforeEach( async () => {
27
+ await activatePlugin( 'gutenberg-test-iframed-inline-styles' );
28
+ await createNewPost( { postType: 'page' } );
29
+ } );
30
+
31
+ afterEach( async () => {
32
+ await deactivatePlugin( 'gutenberg-test-iframed-inline-styles' );
33
+ } );
34
+
35
+ it( 'should load inline styles in iframe', async () => {
36
+ await insertBlock( 'Iframed Inline Styles' );
37
+
38
+ expect( await getEditedPostContent() ).toMatchSnapshot();
39
+ expect( await getComputedStyle( page, 'padding' ) ).toBe( '20px' );
40
+ expect( await getComputedStyle( page, 'border-width' ) ).toBe( '2px' );
41
+
42
+ await openDocumentSettingsSidebar();
43
+ await clickButton( 'Page' );
44
+ await clickButton( 'Template' );
45
+ await clickButton( 'New' );
46
+ await page.keyboard.press( 'Tab' );
47
+ await page.keyboard.press( 'Tab' );
48
+ await page.keyboard.type( 'Iframed Test' );
49
+ await clickButton( 'Create' );
50
+ await page.waitForSelector( 'iframe[name="editor-canvas"]' );
51
+
52
+ // Inline styles of properly enqueued stylesheet should load.
53
+ expect( await getComputedStyle( canvas(), 'padding' ) ).toBe( '20px' );
54
+
55
+ // Inline styles of stylesheet loaded with the compatibility layer
56
+ // should load.
57
+ expect( await getComputedStyle( canvas(), 'border-width' ) ).toBe(
58
+ '2px'
59
+ );
60
+
61
+ expect( console ).toHaveErrored(
62
+ `Stylesheet iframed-inline-styles-compat-style-css was not properly added.
63
+ For blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).
64
+ For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles). <link rel="stylesheet" id="iframed-inline-styles-compat-style-css" href="http://localhost:8889/wp-content/plugins/gutenberg-test-plugins/iframed-inline-styles/compat-style.css?ver=1626189899" media="all">`
65
+ );
66
+ } );
67
+ } );
@@ -26,7 +26,7 @@ async function didMasonryLoadCorrectly( context ) {
26
26
  } );
27
27
  }
28
28
 
29
- describe( 'changing image size', () => {
29
+ describe( 'iframed masonry block', () => {
30
30
  beforeEach( async () => {
31
31
  await activatePlugin( 'gutenberg-test-iframed-masonry-block' );
32
32
  await createNewPost( { postType: 'page' } );
@@ -162,6 +162,18 @@ exports[`Multi-block selection should return original focus after failed multi s
162
162
  <!-- /wp:paragraph -->"
163
163
  `;
164
164
 
165
+ exports[`Multi-block selection should select all from empty selection 1`] = `
166
+ "<!-- wp:paragraph -->
167
+ <p>1</p>
168
+ <!-- /wp:paragraph -->
169
+
170
+ <!-- wp:paragraph -->
171
+ <p>2</p>
172
+ <!-- /wp:paragraph -->"
173
+ `;
174
+
175
+ exports[`Multi-block selection should select all from empty selection 2`] = `""`;
176
+
165
177
  exports[`Multi-block selection should set attributes for multiple paragraphs 1`] = `
166
178
  "<!-- wp:paragraph {\\"align\\":\\"center\\"} -->
167
179
  <p class=\\"has-text-align-center\\">1</p>
@@ -110,6 +110,12 @@ exports[`RichText should return focus when pressing formatting button 1`] = `
110
110
  <!-- /wp:paragraph -->"
111
111
  `;
112
112
 
113
+ exports[`RichText should run input rules after composition end 1`] = `
114
+ "<!-- wp:paragraph -->
115
+ <p><code>a</code></p>
116
+ <!-- /wp:paragraph -->"
117
+ `;
118
+
113
119
  exports[`RichText should split rich text on paste 1`] = `
114
120
  "<!-- wp:paragraph -->
115
121
  <p>a</p>
@@ -636,4 +636,43 @@ describe( 'Multi-block selection', () => {
636
636
  '[data-type="core/paragraph"].is-multi-selected'
637
637
  );
638
638
  } );
639
+
640
+ it( 'should select all from empty selection', async () => {
641
+ await clickBlockAppender();
642
+
643
+ await page.keyboard.type( '1' );
644
+ await page.keyboard.press( 'Enter' );
645
+ await page.keyboard.type( '2' );
646
+
647
+ // Confirm setup.
648
+ expect( await getEditedPostContent() ).toMatchSnapshot();
649
+
650
+ // Clear the selected block.
651
+ const paragraph = await page.$( '[data-type="core/paragraph"]' );
652
+ const box = await paragraph.boundingBox();
653
+ await page.mouse.click( box.x - 1, box.y );
654
+
655
+ await pressKeyWithModifier( 'primary', 'a' );
656
+
657
+ await page.keyboard.press( 'Backspace' );
658
+
659
+ // Expect both paragraphs to be deleted.
660
+ expect( await getEditedPostContent() ).toMatchSnapshot();
661
+ } );
662
+
663
+ it( 'should select title if the cursor is on title', async () => {
664
+ await clickBlockAppender();
665
+
666
+ await page.keyboard.type( '1' );
667
+ await page.keyboard.press( 'Enter' );
668
+ await page.keyboard.type( '2' );
669
+
670
+ await page.type( '.editor-post-title__input', 'Post title' );
671
+
672
+ await pressKeyWithModifier( 'primary', 'a' );
673
+ const selectedText = await page.evaluate( () => {
674
+ return window.getSelection().toString();
675
+ } );
676
+ expect( selectedText ).toEqual( 'Post title' );
677
+ } );
639
678
  } );
@@ -451,4 +451,23 @@ describe( 'RichText', () => {
451
451
  await page.keyboard.press( 'ArrowLeft' );
452
452
  expect( await page.$( blockToolbarSelector ) ).toBe( null );
453
453
  } );
454
+
455
+ it( 'should run input rules after composition end', async () => {
456
+ await clickBlockAppender();
457
+ // Puppeteer doesn't support composition, so emulate it by inserting
458
+ // text in the DOM directly, setting selection in the right place, and
459
+ // firing `compositionend`.
460
+ // See https://github.com/puppeteer/puppeteer/issues/4981.
461
+ await page.evaluate( () => {
462
+ document.activeElement.textContent = '`a`';
463
+ const selection = window.getSelection();
464
+ selection.selectAllChildren( document.activeElement );
465
+ selection.collapseToEnd();
466
+ document.activeElement.dispatchEvent(
467
+ new CompositionEvent( 'compositionend' )
468
+ );
469
+ } );
470
+
471
+ expect( await getEditedPostContent() ).toMatchSnapshot();
472
+ } );
454
473
  } );