@wordpress/e2e-tests 7.16.0 → 7.17.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 +2 -0
- package/package.json +7 -7
- package/plugins/interactive-blocks.php +2 -2
- package/specs/editor/plugins/__snapshots__/container-blocks.test.js.snap +0 -58
- package/specs/editor/plugins/__snapshots__/cpt-locking.test.js.snap +0 -147
- package/specs/editor/plugins/__snapshots__/inner-blocks-render-appender.test.js.snap +0 -25
- package/specs/editor/plugins/__snapshots__/meta-attribute-block.test.js.snap +0 -9
- package/specs/editor/plugins/__snapshots__/plugins-api.test.js.snap +0 -7
- package/specs/editor/plugins/annotations.test.js +0 -189
- package/specs/editor/plugins/child-blocks.test.js +0 -66
- package/specs/editor/plugins/container-blocks.test.js +0 -130
- package/specs/editor/plugins/cpt-locking.test.js +0 -251
- package/specs/editor/plugins/inner-blocks-prioritized-inserter-blocks.test.js +0 -132
- package/specs/editor/plugins/inner-blocks-render-appender.test.js +0 -126
- package/specs/editor/plugins/meta-attribute-block.test.js +0 -100
- package/specs/editor/plugins/meta-boxes.test.js +0 -137
- package/specs/editor/plugins/plugins-api.test.js +0 -189
- package/specs/editor/various/publish-button.test.js +0 -46
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.17.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": "^10.
|
27
|
-
"@wordpress/jest-console": "^7.
|
28
|
-
"@wordpress/jest-puppeteer-axe": "^6.
|
29
|
-
"@wordpress/scripts": "^26.
|
30
|
-
"@wordpress/url": "^3.
|
26
|
+
"@wordpress/e2e-test-utils": "^10.17.0",
|
27
|
+
"@wordpress/jest-console": "^7.17.0",
|
28
|
+
"@wordpress/jest-puppeteer-axe": "^6.17.0",
|
29
|
+
"@wordpress/scripts": "^26.17.0",
|
30
|
+
"@wordpress/url": "^3.47.0",
|
31
31
|
"chalk": "^4.0.0",
|
32
32
|
"expect-puppeteer": "^4.4.0",
|
33
33
|
"filenamify": "^4.2.0",
|
@@ -45,5 +45,5 @@
|
|
45
45
|
"publishConfig": {
|
46
46
|
"access": "public"
|
47
47
|
},
|
48
|
-
"gitHead": "
|
48
|
+
"gitHead": "839018ff6029ba749780e288e08ff9cd898e50e8"
|
49
49
|
}
|
@@ -39,8 +39,8 @@ add_action(
|
|
39
39
|
// HTML is not correct or malformed.
|
40
40
|
if ( 'true' === $_GET['disable_directives_ssr'] ) {
|
41
41
|
remove_filter(
|
42
|
-
'
|
43
|
-
'
|
42
|
+
'render_block_data',
|
43
|
+
'gutenberg_interactivity_mark_root_blocks'
|
44
44
|
);
|
45
45
|
}
|
46
46
|
}
|
@@ -1,58 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Container block without paragraph support ensures we can use the alternative block appender properly 1`] = `
|
4
|
-
"<!-- wp:test/container-without-paragraph -->
|
5
|
-
<!-- wp:image -->
|
6
|
-
<figure class="wp-block-image"><img alt=""/></figure>
|
7
|
-
<!-- /wp:image -->
|
8
|
-
<!-- /wp:test/container-without-paragraph -->"
|
9
|
-
`;
|
10
|
-
|
11
|
-
exports[`InnerBlocks Template Sync Ensure inner block writing flow works as expected without additional paragraphs added 1`] = `
|
12
|
-
"<!-- wp:test/test-inner-blocks-paragraph-placeholder -->
|
13
|
-
<!-- wp:paragraph {"placeholder":"Content…","fontSize":"large"} -->
|
14
|
-
<p class="has-large-font-size">Test Paragraph</p>
|
15
|
-
<!-- /wp:paragraph -->
|
16
|
-
<!-- /wp:test/test-inner-blocks-paragraph-placeholder -->"
|
17
|
-
`;
|
18
|
-
|
19
|
-
exports[`InnerBlocks Template Sync Ensures blocks without locking are kept intact even if they do not match the template 1`] = `
|
20
|
-
"<!-- wp:test/test-inner-blocks-no-locking -->
|
21
|
-
<!-- wp:paragraph {"fontSize":"large"} -->
|
22
|
-
<p class="has-large-font-size">Content…</p>
|
23
|
-
<!-- /wp:paragraph -->
|
24
|
-
|
25
|
-
<!-- wp:paragraph -->
|
26
|
-
<p>added paragraph</p>
|
27
|
-
<!-- /wp:paragraph -->
|
28
|
-
<!-- /wp:test/test-inner-blocks-no-locking -->
|
29
|
-
"
|
30
|
-
`;
|
31
|
-
|
32
|
-
exports[`InnerBlocks Template Sync Removes blocks that are not expected by the template if a lock all exists 1`] = `
|
33
|
-
"<!-- wp:test/test-inner-blocks-locking-all -->
|
34
|
-
<!-- wp:paragraph {"fontSize":"large"} -->
|
35
|
-
<p class="has-large-font-size">Content…</p>
|
36
|
-
<!-- /wp:paragraph -->
|
37
|
-
<!-- /wp:test/test-inner-blocks-locking-all -->"
|
38
|
-
`;
|
39
|
-
|
40
|
-
exports[`InnerBlocks Template Sync Synchronizes blocks if lock 'all' is set and the template prop is changed 1`] = `
|
41
|
-
"<!-- wp:test/test-inner-blocks-update-locked-template -->
|
42
|
-
<!-- wp:paragraph {"fontSize":"large"} -->
|
43
|
-
<p class="has-large-font-size">Content…</p>
|
44
|
-
<!-- /wp:paragraph -->
|
45
|
-
<!-- /wp:test/test-inner-blocks-update-locked-template -->"
|
46
|
-
`;
|
47
|
-
|
48
|
-
exports[`InnerBlocks Template Sync Synchronizes blocks if lock 'all' is set and the template prop is changed 2`] = `
|
49
|
-
"<!-- wp:test/test-inner-blocks-update-locked-template {"hasUpdatedTemplate":true} -->
|
50
|
-
<!-- wp:paragraph {"fontSize":"large"} -->
|
51
|
-
<p class="has-large-font-size">Content…</p>
|
52
|
-
<!-- /wp:paragraph -->
|
53
|
-
|
54
|
-
<!-- wp:paragraph {"fontSize":"large"} -->
|
55
|
-
<p class="has-large-font-size">Two</p>
|
56
|
-
<!-- /wp:paragraph -->
|
57
|
-
<!-- /wp:test/test-inner-blocks-update-locked-template -->"
|
58
|
-
`;
|
@@ -1,147 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`cpt locking template_lock all should insert line breaks when using enter and shift-enter 1`] = `
|
4
|
-
"<!-- wp:image -->
|
5
|
-
<figure class="wp-block-image"><img alt=""/></figure>
|
6
|
-
<!-- /wp:image -->
|
7
|
-
|
8
|
-
<!-- wp:paragraph {"placeholder":"Add a description"} -->
|
9
|
-
<p>First line<br>Second line<br>Third line</p>
|
10
|
-
<!-- /wp:paragraph -->
|
11
|
-
|
12
|
-
<!-- wp:quote -->
|
13
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
14
|
-
<p></p>
|
15
|
-
<!-- /wp:paragraph --></blockquote>
|
16
|
-
<!-- /wp:quote -->
|
17
|
-
|
18
|
-
<!-- wp:columns -->
|
19
|
-
<div class="wp-block-columns"></div>
|
20
|
-
<!-- /wp:columns -->"
|
21
|
-
`;
|
22
|
-
|
23
|
-
exports[`cpt locking template_lock all should not error when deleting the cotents of a paragraph 1`] = `
|
24
|
-
"<!-- wp:image -->
|
25
|
-
<figure class="wp-block-image"><img alt=""/></figure>
|
26
|
-
<!-- /wp:image -->
|
27
|
-
|
28
|
-
<!-- wp:paragraph {"placeholder":"Add a description"} -->
|
29
|
-
<p></p>
|
30
|
-
<!-- /wp:paragraph -->
|
31
|
-
|
32
|
-
<!-- wp:quote -->
|
33
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
34
|
-
<p></p>
|
35
|
-
<!-- /wp:paragraph --></blockquote>
|
36
|
-
<!-- /wp:quote -->
|
37
|
-
|
38
|
-
<!-- wp:columns -->
|
39
|
-
<div class="wp-block-columns"></div>
|
40
|
-
<!-- /wp:columns -->"
|
41
|
-
`;
|
42
|
-
|
43
|
-
exports[`cpt locking template_lock all unlocked group should allow blocks to be moved 1`] = `
|
44
|
-
"<!-- wp:group {"templateLock":false} -->
|
45
|
-
<div class="wp-block-group"><!-- wp:paragraph {"placeholder":"Add a description"} -->
|
46
|
-
<p>p1</p>
|
47
|
-
<!-- /wp:paragraph -->
|
48
|
-
|
49
|
-
<!-- wp:quote -->
|
50
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
51
|
-
<p></p>
|
52
|
-
<!-- /wp:paragraph --></blockquote>
|
53
|
-
<!-- /wp:quote --></div>
|
54
|
-
<!-- /wp:group -->"
|
55
|
-
`;
|
56
|
-
|
57
|
-
exports[`cpt locking template_lock all unlocked group should allow blocks to be removed 1`] = `
|
58
|
-
"<!-- wp:group {"templateLock":false} -->
|
59
|
-
<div class="wp-block-group"><!-- wp:quote -->
|
60
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
61
|
-
<p></p>
|
62
|
-
<!-- /wp:paragraph --></blockquote>
|
63
|
-
<!-- /wp:quote --></div>
|
64
|
-
<!-- /wp:group -->"
|
65
|
-
`;
|
66
|
-
|
67
|
-
exports[`cpt locking template_lock false should allow blocks to be inserted 1`] = `
|
68
|
-
"<!-- wp:image -->
|
69
|
-
<figure class="wp-block-image"><img alt=""/></figure>
|
70
|
-
<!-- /wp:image -->
|
71
|
-
|
72
|
-
<!-- wp:paragraph {"placeholder":"Add a description"} -->
|
73
|
-
<p></p>
|
74
|
-
<!-- /wp:paragraph -->
|
75
|
-
|
76
|
-
<!-- wp:quote -->
|
77
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
78
|
-
<p></p>
|
79
|
-
<!-- /wp:paragraph --></blockquote>
|
80
|
-
<!-- /wp:quote -->
|
81
|
-
|
82
|
-
<!-- wp:columns -->
|
83
|
-
<div class="wp-block-columns"></div>
|
84
|
-
<!-- /wp:columns -->
|
85
|
-
|
86
|
-
<!-- wp:list -->
|
87
|
-
<ul><!-- wp:list-item -->
|
88
|
-
<li>List content</li>
|
89
|
-
<!-- /wp:list-item --></ul>
|
90
|
-
<!-- /wp:list -->"
|
91
|
-
`;
|
92
|
-
|
93
|
-
exports[`cpt locking template_lock false should allow blocks to be moved 1`] = `
|
94
|
-
"<!-- wp:paragraph {"placeholder":"Add a description"} -->
|
95
|
-
<p>p1</p>
|
96
|
-
<!-- /wp:paragraph -->
|
97
|
-
|
98
|
-
<!-- wp:image -->
|
99
|
-
<figure class="wp-block-image"><img alt=""/></figure>
|
100
|
-
<!-- /wp:image -->
|
101
|
-
|
102
|
-
<!-- wp:quote -->
|
103
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
104
|
-
<p></p>
|
105
|
-
<!-- /wp:paragraph --></blockquote>
|
106
|
-
<!-- /wp:quote -->
|
107
|
-
|
108
|
-
<!-- wp:columns -->
|
109
|
-
<div class="wp-block-columns"></div>
|
110
|
-
<!-- /wp:columns -->"
|
111
|
-
`;
|
112
|
-
|
113
|
-
exports[`cpt locking template_lock false should allow blocks to be removed 1`] = `
|
114
|
-
"<!-- wp:image -->
|
115
|
-
<figure class="wp-block-image"><img alt=""/></figure>
|
116
|
-
<!-- /wp:image -->
|
117
|
-
|
118
|
-
<!-- wp:quote -->
|
119
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
120
|
-
<p></p>
|
121
|
-
<!-- /wp:paragraph --></blockquote>
|
122
|
-
<!-- /wp:quote -->
|
123
|
-
|
124
|
-
<!-- wp:columns -->
|
125
|
-
<div class="wp-block-columns"></div>
|
126
|
-
<!-- /wp:columns -->"
|
127
|
-
`;
|
128
|
-
|
129
|
-
exports[`cpt locking template_lock insert should allow blocks to be moved 1`] = `
|
130
|
-
"<!-- wp:paragraph {"placeholder":"Add a description"} -->
|
131
|
-
<p>p1</p>
|
132
|
-
<!-- /wp:paragraph -->
|
133
|
-
|
134
|
-
<!-- wp:image -->
|
135
|
-
<figure class="wp-block-image"><img alt=""/></figure>
|
136
|
-
<!-- /wp:image -->
|
137
|
-
|
138
|
-
<!-- wp:quote -->
|
139
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
140
|
-
<p></p>
|
141
|
-
<!-- /wp:paragraph --></blockquote>
|
142
|
-
<!-- /wp:quote -->
|
143
|
-
|
144
|
-
<!-- wp:columns -->
|
145
|
-
<div class="wp-block-columns"></div>
|
146
|
-
<!-- /wp:columns -->"
|
147
|
-
`;
|
@@ -1,25 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`RenderAppender prop of InnerBlocks Users can customize the appender and can still insert blocks using exposed components 1`] = `
|
4
|
-
"<!-- wp:test/inner-blocks-render-appender -->
|
5
|
-
<div style="outline:1px solid gray;padding:5px" class="wp-block-test-inner-blocks-render-appender"><!-- wp:quote -->
|
6
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
7
|
-
<p></p>
|
8
|
-
<!-- /wp:paragraph --></blockquote>
|
9
|
-
<!-- /wp:quote --></div>
|
10
|
-
<!-- /wp:test/inner-blocks-render-appender -->"
|
11
|
-
`;
|
12
|
-
|
13
|
-
exports[`RenderAppender prop of InnerBlocks Users can dynamically customize the appender 1`] = `
|
14
|
-
"<!-- wp:test/inner-blocks-render-appender-dynamic -->
|
15
|
-
<div style="outline:1px solid gray;padding:5px" class="wp-block-test-inner-blocks-render-appender-dynamic"><!-- wp:quote -->
|
16
|
-
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
17
|
-
<p></p>
|
18
|
-
<!-- /wp:paragraph --></blockquote>
|
19
|
-
<!-- /wp:quote -->
|
20
|
-
|
21
|
-
<!-- wp:video -->
|
22
|
-
<figure class="wp-block-video"></figure>
|
23
|
-
<!-- /wp:video --></div>
|
24
|
-
<!-- /wp:test/inner-blocks-render-appender-dynamic -->"
|
25
|
-
`;
|
@@ -1,9 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Block with a meta attribute Early Registration Should persist the meta attribute properly 1`] = `"<!-- wp:test/test-meta-attribute-block-early /-->"`;
|
4
|
-
|
5
|
-
exports[`Block with a meta attribute Early Registration Should persist the meta attribute properly in a different post type 1`] = `"<!-- wp:test/test-meta-attribute-block-early /-->"`;
|
6
|
-
|
7
|
-
exports[`Block with a meta attribute Late Registration Should persist the meta attribute properly 1`] = `"<!-- wp:test/test-meta-attribute-block-late /-->"`;
|
8
|
-
|
9
|
-
exports[`Block with a meta attribute Late Registration Should persist the meta attribute properly in a different post type 1`] = `"<!-- wp:test/test-meta-attribute-block-late /-->"`;
|
@@ -1,7 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Using Plugins API Document Setting Custom Panel Should render a custom panel inside Document Setting sidebar 1`] = `"My Custom Panel"`;
|
4
|
-
|
5
|
-
exports[`Using Plugins API Sidebar Medium screen Should open plugins sidebar using More Menu item and render content 1`] = `"<div class="components-panel__header interface-complementary-area-header__small"><span class="interface-complementary-area-header__small-title">(no title)</span><button type="button" aria-controls="my-sidebar-plugin:title-sidebar" class="components-button has-icon" aria-label="Close plugin"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg></button></div><div class="components-panel__header interface-complementary-area-header" tabindex="-1"><strong>Plugin title</strong><button type="button" aria-pressed="true" aria-expanded="true" class="components-button interface-complementary-area__pin-unpin-item is-pressed has-icon" aria-label="Unpin from toolbar"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"></path></svg></button><button type="button" aria-controls="my-sidebar-plugin:title-sidebar" class="components-button has-icon" aria-label="Close plugin"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg></button></div><div class="components-panel"><div class="components-panel__body sidebar-title-plugin-panel is-opened"><div class="components-panel__row"><label for="title-plain-text">Title:</label><textarea class="block-editor-plain-text" id="title-plain-text" placeholder="(no title)" rows="1" style="overflow: hidden; overflow-wrap: break-word; resize: none; height: 18px;"></textarea></div><div class="components-panel__row"><button type="button" class="components-button is-primary">Reset</button></div></div></div>"`;
|
6
|
-
|
7
|
-
exports[`Using Plugins API Sidebar Should open plugins sidebar using More Menu item and render content 1`] = `"<div class="components-panel__header interface-complementary-area-header__small"><span class="interface-complementary-area-header__small-title">(no title)</span><button type="button" aria-controls="my-sidebar-plugin:title-sidebar" class="components-button has-icon" aria-label="Close plugin"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg></button></div><div class="components-panel__header interface-complementary-area-header" tabindex="-1"><strong>Plugin title</strong><button type="button" aria-pressed="true" aria-expanded="true" class="components-button interface-complementary-area__pin-unpin-item is-pressed has-icon" aria-label="Unpin from toolbar"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"></path></svg></button><button type="button" aria-controls="my-sidebar-plugin:title-sidebar" class="components-button has-icon" aria-label="Close plugin"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg></button></div><div class="components-panel"><div class="components-panel__body sidebar-title-plugin-panel is-opened"><div class="components-panel__row"><label for="title-plain-text">Title:</label><textarea class="block-editor-plain-text" id="title-plain-text" placeholder="(no title)" rows="1" style="overflow: hidden; overflow-wrap: break-word; resize: none; height: 18px;"></textarea></div><div class="components-panel__row"><button type="button" class="components-button is-primary">Reset</button></div></div></div>"`;
|
@@ -1,189 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
clickBlockToolbarButton,
|
7
|
-
clickMenuItem,
|
8
|
-
clickOnMoreMenuItem,
|
9
|
-
createNewPost,
|
10
|
-
deactivatePlugin,
|
11
|
-
canvas,
|
12
|
-
} from '@wordpress/e2e-test-utils';
|
13
|
-
|
14
|
-
const clickOnBlockSettingsMenuItem = async ( buttonLabel ) => {
|
15
|
-
await clickBlockToolbarButton( 'Options' );
|
16
|
-
await clickMenuItem( buttonLabel );
|
17
|
-
};
|
18
|
-
|
19
|
-
const ANNOTATIONS_SELECTOR = '.annotation-text-e2e-tests';
|
20
|
-
|
21
|
-
describe( 'Annotations', () => {
|
22
|
-
beforeAll( async () => {
|
23
|
-
await activatePlugin( 'gutenberg-test-plugin-plugins-api' );
|
24
|
-
} );
|
25
|
-
|
26
|
-
afterAll( async () => {
|
27
|
-
await deactivatePlugin( 'gutenberg-test-plugin-plugins-api' );
|
28
|
-
} );
|
29
|
-
|
30
|
-
beforeEach( async () => {
|
31
|
-
await createNewPost();
|
32
|
-
} );
|
33
|
-
|
34
|
-
/**
|
35
|
-
* Annotates the text in the first block from start to end.
|
36
|
-
*
|
37
|
-
* @param {number} start Position to start the annotation.
|
38
|
-
* @param {number} end Position to end the annotation.
|
39
|
-
*
|
40
|
-
* @return {void}
|
41
|
-
*/
|
42
|
-
async function annotateFirstBlock( start, end ) {
|
43
|
-
await page.focus( '#annotations-tests-range-start' );
|
44
|
-
await page.keyboard.press( 'Backspace' );
|
45
|
-
await page.keyboard.type( start + '' );
|
46
|
-
await page.focus( '#annotations-tests-range-end' );
|
47
|
-
await page.keyboard.press( 'Backspace' );
|
48
|
-
await page.keyboard.type( end + '' );
|
49
|
-
|
50
|
-
// Click add annotation button.
|
51
|
-
const addAnnotationButton = (
|
52
|
-
await page.$x( "//button[contains(text(), 'Add annotation')]" )
|
53
|
-
)[ 0 ];
|
54
|
-
await addAnnotationButton.click();
|
55
|
-
await canvas().evaluate( () =>
|
56
|
-
document.querySelector( '.wp-block-paragraph' ).focus()
|
57
|
-
);
|
58
|
-
}
|
59
|
-
|
60
|
-
/**
|
61
|
-
* Presses the button that removes all annotations.
|
62
|
-
*
|
63
|
-
* @return {void}
|
64
|
-
*/
|
65
|
-
async function removeAnnotations() {
|
66
|
-
// Click remove annotations button.
|
67
|
-
const addAnnotationButton = (
|
68
|
-
await page.$x( "//button[contains(text(), 'Remove annotations')]" )
|
69
|
-
)[ 0 ];
|
70
|
-
await addAnnotationButton.click();
|
71
|
-
await canvas().evaluate( () =>
|
72
|
-
document.querySelector( '[contenteditable]' ).focus()
|
73
|
-
);
|
74
|
-
}
|
75
|
-
|
76
|
-
/**
|
77
|
-
* Returns the inner text of the first text annotation on the page.
|
78
|
-
*
|
79
|
-
* @return {Promise<string>} The annotated text.
|
80
|
-
*/
|
81
|
-
async function getAnnotatedText() {
|
82
|
-
const annotations = await canvas().$$( ANNOTATIONS_SELECTOR );
|
83
|
-
|
84
|
-
const annotation = annotations[ 0 ];
|
85
|
-
|
86
|
-
return await canvas().evaluate( ( el ) => el.innerText, annotation );
|
87
|
-
}
|
88
|
-
|
89
|
-
/**
|
90
|
-
* Returns the inner HTML of the first RichText in the page.
|
91
|
-
*
|
92
|
-
* @return {Promise<string>} Inner HTML.
|
93
|
-
*/
|
94
|
-
async function getRichTextInnerHTML() {
|
95
|
-
const htmlContent = await canvas().$$( '.wp-block-paragraph' );
|
96
|
-
return await canvas().evaluate( ( el ) => {
|
97
|
-
return el.innerHTML;
|
98
|
-
}, htmlContent[ 0 ] );
|
99
|
-
}
|
100
|
-
|
101
|
-
it( 'allows a block to be annotated', async () => {
|
102
|
-
await page.keyboard.type( 'Title' + '\n' + 'Paragraph to annotate' );
|
103
|
-
|
104
|
-
await clickOnMoreMenuItem( 'Annotations' );
|
105
|
-
|
106
|
-
let annotations = await canvas().$$( ANNOTATIONS_SELECTOR );
|
107
|
-
expect( annotations ).toHaveLength( 0 );
|
108
|
-
|
109
|
-
await annotateFirstBlock( 9, 13 );
|
110
|
-
|
111
|
-
annotations = await canvas().$$( ANNOTATIONS_SELECTOR );
|
112
|
-
expect( annotations ).toHaveLength( 1 );
|
113
|
-
|
114
|
-
const text = await getAnnotatedText();
|
115
|
-
expect( text ).toBe( ' to ' );
|
116
|
-
|
117
|
-
await clickOnBlockSettingsMenuItem( 'Edit as HTML' );
|
118
|
-
|
119
|
-
const htmlContent = await canvas().$$(
|
120
|
-
'.block-editor-block-list__block-html-textarea'
|
121
|
-
);
|
122
|
-
const html = await canvas().evaluate( ( el ) => {
|
123
|
-
return el.innerHTML;
|
124
|
-
}, htmlContent[ 0 ] );
|
125
|
-
|
126
|
-
// There should be no <mark> tags in the raw content.
|
127
|
-
expect( html ).toBe( '<p>Paragraph to annotate</p>' );
|
128
|
-
} );
|
129
|
-
|
130
|
-
it( 'keeps the cursor in the same location when applying annotation', async () => {
|
131
|
-
await page.keyboard.type( 'Title' + '\n' + 'ABC' );
|
132
|
-
await clickOnMoreMenuItem( 'Annotations' );
|
133
|
-
|
134
|
-
await annotateFirstBlock( 1, 2 );
|
135
|
-
|
136
|
-
// The selection should still be at the end, so test that by typing:
|
137
|
-
await page.keyboard.type( 'D' );
|
138
|
-
|
139
|
-
await removeAnnotations();
|
140
|
-
const htmlContent = await canvas().$$( '.wp-block-paragraph' );
|
141
|
-
const html = await canvas().evaluate( ( el ) => {
|
142
|
-
return el.innerHTML;
|
143
|
-
}, htmlContent[ 0 ] );
|
144
|
-
|
145
|
-
expect( html ).toBe( 'ABCD' );
|
146
|
-
} );
|
147
|
-
|
148
|
-
it( 'moves when typing before it', async () => {
|
149
|
-
await page.keyboard.type( 'Title' + '\n' + 'ABC' );
|
150
|
-
await clickOnMoreMenuItem( 'Annotations' );
|
151
|
-
|
152
|
-
await annotateFirstBlock( 1, 2 );
|
153
|
-
|
154
|
-
await page.keyboard.press( 'ArrowLeft' );
|
155
|
-
await page.keyboard.press( 'ArrowLeft' );
|
156
|
-
await page.keyboard.press( 'ArrowLeft' );
|
157
|
-
await page.keyboard.press( 'ArrowLeft' );
|
158
|
-
|
159
|
-
// Put an 1 after the A, it should not be annotated.
|
160
|
-
await page.keyboard.type( '1' );
|
161
|
-
|
162
|
-
const annotatedText = await getAnnotatedText();
|
163
|
-
expect( annotatedText ).toBe( 'B' );
|
164
|
-
|
165
|
-
await removeAnnotations();
|
166
|
-
const blockText = await getRichTextInnerHTML();
|
167
|
-
expect( blockText ).toBe( 'A1BC' );
|
168
|
-
} );
|
169
|
-
|
170
|
-
it( 'grows when typing inside it', async () => {
|
171
|
-
await page.keyboard.type( 'Title' + '\n' + 'ABC' );
|
172
|
-
await clickOnMoreMenuItem( 'Annotations' );
|
173
|
-
|
174
|
-
await annotateFirstBlock( 1, 2 );
|
175
|
-
|
176
|
-
await page.keyboard.press( 'ArrowLeft' );
|
177
|
-
await page.keyboard.press( 'ArrowLeft' );
|
178
|
-
|
179
|
-
// Put an 1 after the A, it should not be annotated.
|
180
|
-
await page.keyboard.type( '2' );
|
181
|
-
|
182
|
-
const annotatedText = await getAnnotatedText();
|
183
|
-
expect( annotatedText ).toBe( 'B2' );
|
184
|
-
|
185
|
-
await removeAnnotations();
|
186
|
-
const blockText = await getRichTextInnerHTML();
|
187
|
-
expect( blockText ).toBe( 'AB2C' );
|
188
|
-
} );
|
189
|
-
} );
|
@@ -1,66 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
closeGlobalBlockInserter,
|
7
|
-
createNewPost,
|
8
|
-
deactivatePlugin,
|
9
|
-
getAllBlockInserterItemTitles,
|
10
|
-
insertBlock,
|
11
|
-
openGlobalBlockInserter,
|
12
|
-
} from '@wordpress/e2e-test-utils';
|
13
|
-
|
14
|
-
describe( 'Child Blocks', () => {
|
15
|
-
beforeAll( async () => {
|
16
|
-
await activatePlugin( 'gutenberg-test-child-blocks' );
|
17
|
-
} );
|
18
|
-
|
19
|
-
beforeEach( async () => {
|
20
|
-
await createNewPost();
|
21
|
-
} );
|
22
|
-
|
23
|
-
afterAll( async () => {
|
24
|
-
await deactivatePlugin( 'gutenberg-test-child-blocks' );
|
25
|
-
} );
|
26
|
-
|
27
|
-
it( 'are hidden from the global block inserter', async () => {
|
28
|
-
await openGlobalBlockInserter();
|
29
|
-
await expect( await getAllBlockInserterItemTitles() ).not.toContain(
|
30
|
-
'Child Blocks Child'
|
31
|
-
);
|
32
|
-
} );
|
33
|
-
|
34
|
-
it( 'shows up in a parent block', async () => {
|
35
|
-
await insertBlock( 'Child Blocks Unrestricted Parent' );
|
36
|
-
await closeGlobalBlockInserter();
|
37
|
-
await page.waitForSelector(
|
38
|
-
'[data-type="test/child-blocks-unrestricted-parent"] .block-editor-default-block-appender'
|
39
|
-
);
|
40
|
-
await page.click(
|
41
|
-
'[data-type="test/child-blocks-unrestricted-parent"] .block-editor-default-block-appender'
|
42
|
-
);
|
43
|
-
await openGlobalBlockInserter();
|
44
|
-
const inserterItemTitles = await getAllBlockInserterItemTitles();
|
45
|
-
expect( inserterItemTitles ).toContain( 'Child Blocks Child' );
|
46
|
-
expect( inserterItemTitles.length ).toBeGreaterThan( 20 );
|
47
|
-
} );
|
48
|
-
|
49
|
-
it( 'display in a parent block with allowedItems', async () => {
|
50
|
-
await insertBlock( 'Child Blocks Restricted Parent' );
|
51
|
-
await closeGlobalBlockInserter();
|
52
|
-
await page.waitForSelector(
|
53
|
-
'[data-type="test/child-blocks-restricted-parent"] .block-editor-default-block-appender'
|
54
|
-
);
|
55
|
-
await page.click(
|
56
|
-
'[data-type="test/child-blocks-restricted-parent"] .block-editor-default-block-appender'
|
57
|
-
);
|
58
|
-
await openGlobalBlockInserter();
|
59
|
-
const allowedBlocks = await getAllBlockInserterItemTitles();
|
60
|
-
expect( allowedBlocks.sort() ).toEqual( [
|
61
|
-
'Child Blocks Child',
|
62
|
-
'Image',
|
63
|
-
'Paragraph',
|
64
|
-
] );
|
65
|
-
} );
|
66
|
-
} );
|