@wordpress/e2e-tests 6.0.0 → 6.2.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.
@@ -15,6 +15,7 @@ import {
15
15
  visitSiteEditor,
16
16
  enterEditMode,
17
17
  deleteAllTemplates,
18
+ canvas,
18
19
  } from '@wordpress/e2e-test-utils';
19
20
 
20
21
  describe( 'Multi-entity save flow', () => {
@@ -94,8 +95,8 @@ describe( 'Multi-entity save flow', () => {
94
95
  it( 'Save flow should work as expected.', async () => {
95
96
  await createNewPost();
96
97
  // Edit the page some.
97
- await page.waitForSelector( '.editor-post-title' );
98
- await page.click( '.editor-post-title' );
98
+ await canvas().waitForSelector( '.editor-post-title' );
99
+ await canvas().click( '.editor-post-title' );
99
100
  await page.keyboard.type( 'Test Post...' );
100
101
  await page.keyboard.press( 'Enter' );
101
102
 
@@ -110,8 +111,8 @@ describe( 'Multi-entity save flow', () => {
110
111
 
111
112
  // Add a reusable block and edit it.
112
113
  await createReusableBlock( 'Hi!', 'Test' );
113
- await page.waitForSelector( 'p[data-type="core/paragraph"]' );
114
- await page.click( 'p[data-type="core/paragraph"]' );
114
+ await canvas().waitForSelector( 'p[data-type="core/paragraph"]' );
115
+ await canvas().click( 'p[data-type="core/paragraph"]' );
115
116
  await page.keyboard.type( 'Oh!' );
116
117
 
117
118
  // Should trigger multi-entity save button once template part edited.
@@ -169,7 +170,7 @@ describe( 'Multi-entity save flow', () => {
169
170
  } );
170
171
 
171
172
  // Update the post.
172
- await page.click( '.editor-post-title' );
173
+ await canvas().click( '.editor-post-title' );
173
174
  await page.keyboard.type( '...more title!' );
174
175
 
175
176
  // Verify update button is enabled.
@@ -182,9 +183,9 @@ describe( 'Multi-entity save flow', () => {
182
183
  await assertExistence( saveA11ySelector, false );
183
184
 
184
185
  // Update reusable block again.
185
- await page.click( 'p[data-type="core/paragraph"]' );
186
+ await canvas().click( 'p[data-type="core/paragraph"]' );
186
187
  // We need to click again due to the clickthrough overlays in reusable blocks.
187
- await page.click( 'p[data-type="core/paragraph"]' );
188
+ await canvas().click( 'p[data-type="core/paragraph"]' );
188
189
  await page.keyboard.type( 'R!' );
189
190
 
190
191
  // Multi-entity saving should be enabled.
@@ -203,19 +204,19 @@ describe( 'Multi-entity save flow', () => {
203
204
  );
204
205
  const editableSiteTitleSelector =
205
206
  '.wp-block-site-title a[contenteditable="true"]';
206
- await page.waitForSelector( editableSiteTitleSelector );
207
- await page.focus( editableSiteTitleSelector );
207
+ await canvas().waitForSelector( editableSiteTitleSelector );
208
+ await canvas().focus( editableSiteTitleSelector );
208
209
  await page.keyboard.type( '...' );
209
210
 
210
211
  await insertBlock( 'Site Tagline' );
211
212
  // Wait for the placeholder.
212
- await page.waitForXPath(
213
+ await canvas().waitForXPath(
213
214
  '//span[@data-rich-text-placeholder="Write site tagline…"]'
214
215
  );
215
216
  const editableSiteTagLineSelector =
216
217
  '.wp-block-site-tagline[contenteditable="true"]';
217
- await page.waitForSelector( editableSiteTagLineSelector );
218
- await page.focus( editableSiteTagLineSelector );
218
+ await canvas().waitForSelector( editableSiteTagLineSelector );
219
+ await canvas().focus( editableSiteTagLineSelector );
219
220
  await page.keyboard.type( 'Just another WordPress site' );
220
221
 
221
222
  await clickButton( 'Publish' );
@@ -1,5 +0,0 @@
1
- {
2
- "__file": "wp_block",
3
- "title": "Greeting",
4
- "content": "<!-- wp:paragraph -->\n<p>Hello there</p>\n<!-- /wp:paragraph -->"
5
- }
@@ -1,123 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Quote can be converted to a pullquote 1`] = `
4
- "<!-- wp:pullquote -->
5
- <figure class=\\"wp-block-pullquote\\"><blockquote><p>one<br>two</p><cite>cite</cite></blockquote></figure>
6
- <!-- /wp:pullquote -->"
7
- `;
8
-
9
- exports[`Quote can be converted to paragraphs and renders a paragraph for the cite, if it exists 1`] = `
10
- "<!-- wp:paragraph -->
11
- <p>one</p>
12
- <!-- /wp:paragraph -->
13
-
14
- <!-- wp:paragraph -->
15
- <p>two</p>
16
- <!-- /wp:paragraph -->
17
-
18
- <!-- wp:paragraph -->
19
- <p>cite</p>
20
- <!-- /wp:paragraph -->"
21
- `;
22
-
23
- exports[`Quote can be converted to paragraphs and renders a void paragraph if both the cite and quote are void 1`] = `""`;
24
-
25
- exports[`Quote can be converted to paragraphs and renders one paragraph block per <p> within quote 1`] = `
26
- "<!-- wp:paragraph -->
27
- <p>one</p>
28
- <!-- /wp:paragraph -->
29
-
30
- <!-- wp:paragraph -->
31
- <p>two</p>
32
- <!-- /wp:paragraph -->"
33
- `;
34
-
35
- exports[`Quote can be converted to paragraphs and renders only one paragraph for the cite, if the quote is void 1`] = `
36
- "<!-- wp:paragraph -->
37
- <p></p>
38
- <!-- /wp:paragraph -->
39
-
40
- <!-- wp:paragraph -->
41
- <p>cite</p>
42
- <!-- /wp:paragraph -->"
43
- `;
44
-
45
- exports[`Quote can be created by converting a heading 1`] = `
46
- "<!-- wp:quote -->
47
- <blockquote class=\\"wp-block-quote\\"><!-- wp:heading -->
48
- <h2 class=\\"wp-block-heading\\">test</h2>
49
- <!-- /wp:heading --></blockquote>
50
- <!-- /wp:quote -->"
51
- `;
52
-
53
- exports[`Quote can be created by converting a paragraph 1`] = `
54
- "<!-- wp:quote -->
55
- <blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
56
- <p>test</p>
57
- <!-- /wp:paragraph --></blockquote>
58
- <!-- /wp:quote -->"
59
- `;
60
-
61
- exports[`Quote can be created by converting multiple paragraphs 1`] = `
62
- "<!-- wp:quote -->
63
- <blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
64
- <p>one</p>
65
- <!-- /wp:paragraph -->
66
-
67
- <!-- wp:paragraph -->
68
- <p>two</p>
69
- <!-- /wp:paragraph --></blockquote>
70
- <!-- /wp:quote -->"
71
- `;
72
-
73
- exports[`Quote can be created by typing "/quote" 1`] = `
74
- "<!-- wp:quote -->
75
- <blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
76
- <p>I’m a quote</p>
77
- <!-- /wp:paragraph --></blockquote>
78
- <!-- /wp:quote -->"
79
- `;
80
-
81
- exports[`Quote can be created by typing > in front of text of a paragraph block 1`] = `
82
- "<!-- wp:quote -->
83
- <blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
84
- <p>test</p>
85
- <!-- /wp:paragraph --></blockquote>
86
- <!-- /wp:quote -->"
87
- `;
88
-
89
- exports[`Quote can be created by using > at the start of a paragraph block 1`] = `
90
- "<!-- wp:quote -->
91
- <blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
92
- <p>A quote</p>
93
- <!-- /wp:paragraph -->
94
-
95
- <!-- wp:paragraph -->
96
- <p>Another paragraph</p>
97
- <!-- /wp:paragraph --></blockquote>
98
- <!-- /wp:quote -->"
99
- `;
100
-
101
- exports[`Quote can be split at the end 1`] = `
102
- "<!-- wp:quote -->
103
- <blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
104
- <p>1</p>
105
- <!-- /wp:paragraph --></blockquote>
106
- <!-- /wp:quote -->
107
-
108
- <!-- wp:paragraph -->
109
- <p></p>
110
- <!-- /wp:paragraph -->"
111
- `;
112
-
113
- exports[`Quote can be split at the end 2`] = `
114
- "<!-- wp:quote -->
115
- <blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
116
- <p>1</p>
117
- <!-- /wp:paragraph -->
118
-
119
- <!-- wp:paragraph -->
120
- <p>2</p>
121
- <!-- /wp:paragraph --></blockquote>
122
- <!-- /wp:quote -->"
123
- `;
@@ -1,199 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- clickBlockAppender,
6
- getEditedPostContent,
7
- createNewPost,
8
- pressKeyTimes,
9
- transformBlockTo,
10
- insertBlock,
11
- } from '@wordpress/e2e-test-utils';
12
-
13
- describe( 'Quote', () => {
14
- beforeEach( async () => {
15
- await createNewPost();
16
- } );
17
-
18
- it( 'can be created by using > at the start of a paragraph block', async () => {
19
- // Create a block with some text that will trigger a list creation.
20
- await clickBlockAppender();
21
- await page.keyboard.type( '> A quote' );
22
-
23
- // Create a second list item.
24
- await page.keyboard.press( 'Enter' );
25
- await page.keyboard.type( 'Another paragraph' );
26
-
27
- expect( await getEditedPostContent() ).toMatchSnapshot();
28
- } );
29
-
30
- it( 'can be created by typing > in front of text of a paragraph block', async () => {
31
- // Create a list with the slash block shortcut.
32
- await clickBlockAppender();
33
- await page.keyboard.type( 'test' );
34
- await pressKeyTimes( 'ArrowLeft', 4 );
35
- await page.keyboard.type( '> ' );
36
-
37
- expect( await getEditedPostContent() ).toMatchSnapshot();
38
- } );
39
-
40
- it( 'can be created by typing "/quote"', async () => {
41
- // Create a list with the slash block shortcut.
42
- await clickBlockAppender();
43
- await page.keyboard.type( '/quote' );
44
- await page.waitForXPath(
45
- `//*[contains(@class, "components-autocomplete__result") and contains(@class, "is-selected") and contains(text(), 'Quote')]`
46
- );
47
- await page.keyboard.press( 'Enter' );
48
- await page.keyboard.type( 'I’m a quote' );
49
-
50
- expect( await getEditedPostContent() ).toMatchSnapshot();
51
- } );
52
-
53
- it( 'can be created by converting a paragraph', async () => {
54
- await clickBlockAppender();
55
- await page.keyboard.type( 'test' );
56
- await transformBlockTo( 'Quote' );
57
-
58
- expect( await getEditedPostContent() ).toMatchSnapshot();
59
- } );
60
-
61
- it( 'can be created by converting multiple paragraphs', async () => {
62
- await clickBlockAppender();
63
- await page.keyboard.type( 'one' );
64
- await page.keyboard.press( 'Enter' );
65
- await page.keyboard.type( 'two' );
66
- await page.keyboard.down( 'Shift' );
67
- await page.click( '[data-type="core/paragraph"]' );
68
- await page.keyboard.up( 'Shift' );
69
- await transformBlockTo( 'Quote' );
70
-
71
- expect( await getEditedPostContent() ).toMatchSnapshot();
72
- } );
73
-
74
- describe( 'can be converted to paragraphs', () => {
75
- it( 'and renders one paragraph block per <p> within quote', async () => {
76
- await insertBlock( 'Quote' );
77
- await page.keyboard.type( 'one' );
78
- await page.keyboard.press( 'Enter' );
79
- await page.keyboard.type( 'two' );
80
- // Navigate to the citation to select the block.
81
- await page.keyboard.press( 'ArrowRight' );
82
- await transformBlockTo( 'Unwrap' );
83
-
84
- expect( await getEditedPostContent() ).toMatchSnapshot();
85
- } );
86
-
87
- it( 'and renders a paragraph for the cite, if it exists', async () => {
88
- await insertBlock( 'Quote' );
89
- await page.keyboard.type( 'one' );
90
- await page.keyboard.press( 'Enter' );
91
- await page.keyboard.type( 'two' );
92
- await page.keyboard.press( 'ArrowRight' );
93
- await page.keyboard.type( 'cite' );
94
- await transformBlockTo( 'Unwrap' );
95
-
96
- expect( await getEditedPostContent() ).toMatchSnapshot();
97
- } );
98
-
99
- it( 'and renders only one paragraph for the cite, if the quote is void', async () => {
100
- await insertBlock( 'Quote' );
101
- await page.keyboard.press( 'ArrowRight' );
102
- await page.keyboard.type( 'cite' );
103
- await transformBlockTo( 'Unwrap' );
104
-
105
- expect( await getEditedPostContent() ).toMatchSnapshot();
106
- } );
107
-
108
- it( 'and renders a void paragraph if both the cite and quote are void', async () => {
109
- await insertBlock( 'Quote' );
110
- await page.keyboard.press( 'ArrowRight' ); // Select the quote
111
- await transformBlockTo( 'Unwrap' );
112
-
113
- expect( await getEditedPostContent() ).toMatchSnapshot();
114
- } );
115
- } );
116
-
117
- it( 'can be created by converting a heading', async () => {
118
- await insertBlock( 'Heading' );
119
- await page.keyboard.type( 'test' );
120
- await transformBlockTo( 'Quote' );
121
-
122
- expect( await getEditedPostContent() ).toMatchSnapshot();
123
- } );
124
-
125
- it( 'can be converted to a pullquote', async () => {
126
- await insertBlock( 'Quote' );
127
- await page.keyboard.type( 'one' );
128
- await page.keyboard.press( 'Enter' );
129
- await page.keyboard.type( 'two' );
130
- await page.keyboard.press( 'ArrowRight' );
131
- await page.keyboard.type( 'cite' );
132
- await transformBlockTo( 'Pullquote' );
133
- expect( await getEditedPostContent() ).toMatchSnapshot();
134
- } );
135
-
136
- it( 'can be split at the end', async () => {
137
- await insertBlock( 'Quote' );
138
- await page.keyboard.type( '1' );
139
- await page.keyboard.press( 'Enter' );
140
- await page.keyboard.press( 'Enter' );
141
-
142
- // Expect empty paragraph outside quote block.
143
- expect( await getEditedPostContent() ).toMatchSnapshot();
144
-
145
- await page.keyboard.press( 'Backspace' );
146
- // Allow time for selection to update.
147
- await page.evaluate( () => new Promise( window.requestIdleCallback ) );
148
- await page.keyboard.type( '2' );
149
-
150
- // Expect the paragraph to be merged into the quote block.
151
- expect( await getEditedPostContent() ).toMatchSnapshot();
152
- } );
153
-
154
- it( 'can be unwrapped on Backspace', async () => {
155
- await insertBlock( 'Quote' );
156
-
157
- expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
158
- "<!-- wp:quote -->
159
- <blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
160
- <p></p>
161
- <!-- /wp:paragraph --></blockquote>
162
- <!-- /wp:quote -->"
163
- ` );
164
-
165
- await page.keyboard.press( 'Backspace' );
166
-
167
- expect( await getEditedPostContent() ).toMatchInlineSnapshot( `""` );
168
- } );
169
-
170
- it( 'can be unwrapped with content on Backspace', async () => {
171
- await insertBlock( 'Quote' );
172
- await page.keyboard.type( '1' );
173
- await page.keyboard.press( 'ArrowRight' );
174
- await page.keyboard.type( '2' );
175
-
176
- expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
177
- "<!-- wp:quote -->
178
- <blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
179
- <p>1</p>
180
- <!-- /wp:paragraph --><cite>2</cite></blockquote>
181
- <!-- /wp:quote -->"
182
- ` );
183
-
184
- await page.keyboard.press( 'ArrowLeft' );
185
- await page.keyboard.press( 'ArrowUp' );
186
- await page.keyboard.press( 'ArrowUp' );
187
- await page.keyboard.press( 'Backspace' );
188
-
189
- expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
190
- "<!-- wp:paragraph -->
191
- <p>1</p>
192
- <!-- /wp:paragraph -->
193
-
194
- <!-- wp:quote -->
195
- <blockquote class=\\"wp-block-quote\\"><cite>2</cite></blockquote>
196
- <!-- /wp:quote -->"
197
- ` );
198
- } );
199
- } );