@wordpress/e2e-tests 4.7.0 → 4.9.1
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/README.md +8 -8
- package/package.json +6 -6
- package/plugins/cpt-locking.php +28 -4
- package/specs/editor/blocks/__snapshots__/quote.test.js.snap +37 -131
- package/specs/editor/blocks/navigation.test.js +2 -1
- package/specs/editor/blocks/quote.test.js +42 -91
- package/specs/editor/plugins/__snapshots__/cpt-locking.test.js.snap +24 -8
- package/specs/editor/plugins/__snapshots__/inner-blocks-render-appender.test.js.snap +6 -2
- package/specs/editor/plugins/__snapshots__/templates.test.js.snap +6 -2
- package/specs/editor/plugins/block-variations.test.js +2 -0
- package/specs/editor/plugins/cpt-locking.test.js +3 -3
- package/specs/editor/plugins/inner-blocks-render-appender.test.js +3 -0
- package/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap +0 -16
- package/specs/editor/various/__snapshots__/rich-text.test.js.snap +12 -0
- package/specs/editor/various/__snapshots__/writing-flow.test.js.snap +3 -3
- package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +1 -1
- package/specs/editor/various/block-switcher.test.js +1 -3
- package/specs/editor/various/multi-block-selection.test.js +2 -27
- package/specs/editor/various/reusable-blocks.test.js +4 -2
- package/specs/editor/various/rich-text.test.js +17 -0
- package/specs/editor/various/writing-flow.test.js +74 -1
- package/specs/site-editor/multi-entity-saving.test.js +3 -3
- package/specs/editor/blocks/__snapshots__/group.test.js.snap +0 -21
- package/specs/editor/blocks/group.test.js +0 -43
- package/specs/editor/blocks/missing.test.js +0 -44
- package/specs/editor/plugins/__snapshots__/deprecated-node-matcher.test.js.snap +0 -13
- package/specs/editor/plugins/__snapshots__/hooks-api.test.js.snap +0 -3
- package/specs/editor/plugins/deprecated-node-matcher.test.js +0 -44
- package/specs/editor/plugins/hooks-api.test.js +0 -44
- package/specs/editor/various/__snapshots__/convert-block-type.test.js.snap +0 -13
- package/specs/editor/various/convert-block-type.test.js +0 -32
@@ -10,7 +10,9 @@ exports[`templates Using a CPT with a predefined template Should add a custom po
|
|
10
10
|
<!-- /wp:paragraph -->
|
11
11
|
|
12
12
|
<!-- wp:quote -->
|
13
|
-
<blockquote class=\\"wp-block-quote\\"
|
13
|
+
<blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
|
14
|
+
<p></p>
|
15
|
+
<!-- /wp:paragraph --></blockquote>
|
14
16
|
<!-- /wp:quote -->
|
15
17
|
|
16
18
|
<!-- wp:columns -->
|
@@ -36,7 +38,9 @@ exports[`templates Using a CPT with a predefined template Should respect user ed
|
|
36
38
|
<!-- /wp:paragraph -->
|
37
39
|
|
38
40
|
<!-- wp:quote -->
|
39
|
-
<blockquote class=\\"wp-block-quote\\"
|
41
|
+
<blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
|
42
|
+
<p></p>
|
43
|
+
<!-- /wp:paragraph --></blockquote>
|
40
44
|
<!-- /wp:quote -->
|
41
45
|
|
42
46
|
<!-- wp:columns -->
|
@@ -148,6 +148,8 @@ describe( 'Block variations', () => {
|
|
148
148
|
|
149
149
|
it( 'should show block information when no matching variation is found', async () => {
|
150
150
|
await insertBlock( 'Large Quote' );
|
151
|
+
// Select the quote block.
|
152
|
+
await page.keyboard.press( 'ArrowDown' );
|
151
153
|
const breadcrumb = await getActiveBreadcrumb();
|
152
154
|
expect( breadcrumb ).toEqual( 'Quote' );
|
153
155
|
const navigationItem = await getFirstNavigationItem();
|
@@ -49,12 +49,12 @@ describe( 'cpt locking', () => {
|
|
49
49
|
|
50
50
|
const shouldAllowBlocksToBeMoved = async () => {
|
51
51
|
await page.click(
|
52
|
-
'.block-editor-rich-text__editable[data-type="core/paragraph"]'
|
52
|
+
'div > .block-editor-rich-text__editable[data-type="core/paragraph"]'
|
53
53
|
);
|
54
54
|
expect( await page.$( 'button[aria-label="Move up"]' ) ).not.toBeNull();
|
55
55
|
await page.click( 'button[aria-label="Move up"]' );
|
56
56
|
await page.type(
|
57
|
-
'.block-editor-rich-text__editable[data-type="core/paragraph"]',
|
57
|
+
'div > .block-editor-rich-text__editable[data-type="core/paragraph"]',
|
58
58
|
'p1'
|
59
59
|
);
|
60
60
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
@@ -193,7 +193,7 @@ describe( 'cpt locking', () => {
|
|
193
193
|
|
194
194
|
it( 'should allow blocks to be removed', async () => {
|
195
195
|
await page.type(
|
196
|
-
'.block-editor-rich-text__editable[data-type="core/paragraph"]',
|
196
|
+
'div > .block-editor-rich-text__editable[data-type="core/paragraph"]',
|
197
197
|
'p1'
|
198
198
|
);
|
199
199
|
await clickBlockToolbarButton( 'Options' );
|
@@ -98,6 +98,9 @@ describe( 'RenderAppender prop of InnerBlocks', () => {
|
|
98
98
|
// Insert a quote block.
|
99
99
|
await quoteButton.click();
|
100
100
|
|
101
|
+
// Select the quote block.
|
102
|
+
await page.keyboard.press( 'ArrowDown' );
|
103
|
+
|
101
104
|
// Verify if the custom block appender text changed as expected.
|
102
105
|
await page.waitForXPath(
|
103
106
|
`//*[contains(@class, "${ DYNAMIC_APPENDER_SELECTOR }")]/span[contains(@class, "single-blocks-appender")][contains(text(), "Single Blocks Appender")]`
|
@@ -146,22 +146,6 @@ exports[`Multi-block selection should handle Enter across blocks 2`] = `
|
|
146
146
|
<!-- /wp:heading -->"
|
147
147
|
`;
|
148
148
|
|
149
|
-
exports[`Multi-block selection should merge into quote with correct selection 1`] = `
|
150
|
-
"<!-- wp:quote -->
|
151
|
-
<blockquote class=\\"wp-block-quote\\"><p>1[</p></blockquote>
|
152
|
-
<!-- /wp:quote -->
|
153
|
-
|
154
|
-
<!-- wp:paragraph -->
|
155
|
-
<p>]2</p>
|
156
|
-
<!-- /wp:paragraph -->"
|
157
|
-
`;
|
158
|
-
|
159
|
-
exports[`Multi-block selection should merge into quote with correct selection 2`] = `
|
160
|
-
"<!-- wp:quote -->
|
161
|
-
<blockquote class=\\"wp-block-quote\\"><p>1</p><p>&2</p></blockquote>
|
162
|
-
<!-- /wp:quote -->"
|
163
|
-
`;
|
164
|
-
|
165
149
|
exports[`Multi-block selection should multi-select from within the list block 1`] = `
|
166
150
|
"<!-- wp:paragraph -->
|
167
151
|
<p>1</p>
|
@@ -178,6 +178,18 @@ exports[`RichText should transform backtick to code 2`] = `
|
|
178
178
|
<!-- /wp:paragraph -->"
|
179
179
|
`;
|
180
180
|
|
181
|
+
exports[`RichText should transform when typing backtick over selection 1`] = `
|
182
|
+
"<!-- wp:paragraph -->
|
183
|
+
<p>A <code>selection</code> test.</p>
|
184
|
+
<!-- /wp:paragraph -->"
|
185
|
+
`;
|
186
|
+
|
187
|
+
exports[`RichText should transform when typing backtick over selection 2`] = `
|
188
|
+
"<!-- wp:paragraph -->
|
189
|
+
<p>A \`selection\` test.</p>
|
190
|
+
<!-- /wp:paragraph -->"
|
191
|
+
`;
|
192
|
+
|
181
193
|
exports[`RichText should undo backtick transform with backspace 1`] = `
|
182
194
|
"<!-- wp:paragraph -->
|
183
195
|
<p>\`a\`</p>
|
@@ -207,9 +207,9 @@ exports[`Writing Flow should navigate empty paragraphs 1`] = `
|
|
207
207
|
`;
|
208
208
|
|
209
209
|
exports[`Writing Flow should not create extra line breaks in multiline value 1`] = `
|
210
|
-
"<!-- wp:
|
211
|
-
<
|
212
|
-
<!-- /wp:
|
210
|
+
"<!-- wp:list -->
|
211
|
+
<ul><li></li></ul>
|
212
|
+
<!-- /wp:list -->"
|
213
213
|
`;
|
214
214
|
|
215
215
|
exports[`Writing Flow should not delete surrounding space when deleting a selected word 1`] = `
|
@@ -87,7 +87,7 @@ describe( 'block editor keyboard shortcuts', () => {
|
|
87
87
|
} );
|
88
88
|
it( 'should prevent deleting multiple selected blocks from inputs', async () => {
|
89
89
|
await clickBlockToolbarButton( 'Options' );
|
90
|
-
await clickMenuItem( '
|
90
|
+
await clickMenuItem( 'Create Reusable block' );
|
91
91
|
const reusableBlockNameInputSelector =
|
92
92
|
'.reusable-blocks-menu-items__convert-modal .components-text-control__input';
|
93
93
|
const nameInput = await page.waitForSelector(
|
@@ -28,9 +28,8 @@ describe( 'Block Switcher', () => {
|
|
28
28
|
expect.arrayContaining( [
|
29
29
|
'Group',
|
30
30
|
'Paragraph',
|
31
|
-
'Quote',
|
32
31
|
'Heading',
|
33
|
-
'
|
32
|
+
'Quote',
|
34
33
|
'Columns',
|
35
34
|
'Table of Contents',
|
36
35
|
] )
|
@@ -56,7 +55,6 @@ describe( 'Block Switcher', () => {
|
|
56
55
|
expect.arrayContaining( [
|
57
56
|
'Group',
|
58
57
|
'Paragraph',
|
59
|
-
'Pullquote',
|
60
58
|
'Heading',
|
61
59
|
'Table of Contents',
|
62
60
|
] )
|
@@ -718,9 +718,8 @@ describe( 'Multi-block selection', () => {
|
|
718
718
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
719
719
|
|
720
720
|
// Clear the selected block.
|
721
|
-
|
722
|
-
|
723
|
-
await page.mouse.click( box.x - 1, box.y );
|
721
|
+
await page.keyboard.press( 'Escape' );
|
722
|
+
await page.keyboard.press( 'Escape' );
|
724
723
|
|
725
724
|
await pressKeyWithModifier( 'primary', 'a' );
|
726
725
|
|
@@ -906,30 +905,6 @@ describe( 'Multi-block selection', () => {
|
|
906
905
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
907
906
|
} );
|
908
907
|
|
909
|
-
it( 'should merge into quote with correct selection', async () => {
|
910
|
-
await clickBlockAppender();
|
911
|
-
await page.keyboard.type( '> 1[' );
|
912
|
-
await page.keyboard.press( 'Enter' );
|
913
|
-
await page.keyboard.press( 'Enter' );
|
914
|
-
await page.keyboard.type( ']2' );
|
915
|
-
await page.keyboard.press( 'ArrowLeft' );
|
916
|
-
// Select everything between [].
|
917
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
918
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
919
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
920
|
-
|
921
|
-
// Test setup.
|
922
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
923
|
-
|
924
|
-
await page.keyboard.press( 'Backspace' );
|
925
|
-
|
926
|
-
// Ensure selection is in the correct place.
|
927
|
-
await page.keyboard.type( '&' );
|
928
|
-
|
929
|
-
// Expect two blocks with "&" in between.
|
930
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
931
|
-
} );
|
932
|
-
|
933
908
|
it( 'should select separator (single element block)', async () => {
|
934
909
|
await clickBlockAppender();
|
935
910
|
await page.keyboard.type( '/hr' );
|
@@ -192,7 +192,7 @@ describe( 'Reusable blocks', () => {
|
|
192
192
|
|
193
193
|
// Convert block to a reusable block.
|
194
194
|
await clickBlockToolbarButton( 'Options' );
|
195
|
-
await clickMenuItem( '
|
195
|
+
await clickMenuItem( 'Create Reusable block' );
|
196
196
|
|
197
197
|
// Set title.
|
198
198
|
const nameInput = await page.waitForSelector(
|
@@ -364,6 +364,8 @@ describe( 'Reusable blocks', () => {
|
|
364
364
|
'.block-editor-block-list__block[aria-label="Block: Quote"]'
|
365
365
|
);
|
366
366
|
await quoteBlock.click();
|
367
|
+
// Select the quote block.
|
368
|
+
await page.keyboard.press( 'ArrowDown' );
|
367
369
|
await openDocumentSettingsSidebar();
|
368
370
|
await page.waitForXPath(
|
369
371
|
'//*[@role="region"][@aria-label="Editor settings"]//button[.="Styles"]'
|
@@ -371,7 +373,7 @@ describe( 'Reusable blocks', () => {
|
|
371
373
|
|
372
374
|
// Convert to reusable.
|
373
375
|
await clickBlockToolbarButton( 'Options' );
|
374
|
-
await clickMenuItem( '
|
376
|
+
await clickMenuItem( 'Create Reusable block' );
|
375
377
|
const nameInput = await page.waitForSelector(
|
376
378
|
reusableBlockNameInputSelector
|
377
379
|
);
|
@@ -148,6 +148,23 @@ describe( 'RichText', () => {
|
|
148
148
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
149
149
|
} );
|
150
150
|
|
151
|
+
it( 'should transform when typing backtick over selection', async () => {
|
152
|
+
await clickBlockAppender();
|
153
|
+
await page.keyboard.type( 'A selection test.' );
|
154
|
+
await page.keyboard.press( 'Home' );
|
155
|
+
await page.keyboard.press( 'ArrowRight' );
|
156
|
+
await page.keyboard.press( 'ArrowRight' );
|
157
|
+
await pressKeyWithModifier( 'shiftAlt', 'ArrowRight' );
|
158
|
+
await page.keyboard.type( '`' );
|
159
|
+
|
160
|
+
expect( await getEditedPostContent() ).toMatchSnapshot();
|
161
|
+
|
162
|
+
// Should undo the transform.
|
163
|
+
await pressKeyWithModifier( 'primary', 'z' );
|
164
|
+
|
165
|
+
expect( await getEditedPostContent() ).toMatchSnapshot();
|
166
|
+
} );
|
167
|
+
|
151
168
|
it( 'should only mutate text data on input', async () => {
|
152
169
|
await clickBlockAppender();
|
153
170
|
await page.keyboard.type( '1' );
|
@@ -282,7 +282,7 @@ describe( 'Writing Flow', () => {
|
|
282
282
|
} );
|
283
283
|
|
284
284
|
it( 'should not create extra line breaks in multiline value', async () => {
|
285
|
-
await insertBlock( '
|
285
|
+
await insertBlock( 'List' );
|
286
286
|
await page.keyboard.type( 'a' );
|
287
287
|
await page.keyboard.press( 'Backspace' );
|
288
288
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
@@ -753,4 +753,77 @@ describe( 'Writing Flow', () => {
|
|
753
753
|
);
|
754
754
|
expect( paragraphs ).toEqual( [ 'first', 'second' ] );
|
755
755
|
} );
|
756
|
+
|
757
|
+
it( 'should move to the start of the first line on ArrowUp', async () => {
|
758
|
+
await page.keyboard.press( 'Enter' );
|
759
|
+
await page.keyboard.type( 'a' );
|
760
|
+
|
761
|
+
async function getHeight() {
|
762
|
+
return await page.evaluate(
|
763
|
+
() => document.activeElement.offsetHeight
|
764
|
+
);
|
765
|
+
}
|
766
|
+
|
767
|
+
const height = await getHeight();
|
768
|
+
|
769
|
+
// Keep typing until the height of the element increases. We need two
|
770
|
+
// lines.
|
771
|
+
while ( height === ( await getHeight() ) ) {
|
772
|
+
await page.keyboard.type( 'a' );
|
773
|
+
}
|
774
|
+
|
775
|
+
// Move to the start of the second line.
|
776
|
+
await page.keyboard.press( 'ArrowLeft' );
|
777
|
+
// Move to the start of the first line.
|
778
|
+
await page.keyboard.press( 'ArrowUp' );
|
779
|
+
// Insert a "." for testing.
|
780
|
+
await page.keyboard.type( '.' );
|
781
|
+
|
782
|
+
// Expect the "." to be added at the start of the paragraph.
|
783
|
+
expect(
|
784
|
+
await page.evaluate( () =>
|
785
|
+
document.activeElement.getAttribute( 'data-type' )
|
786
|
+
)
|
787
|
+
).toBe( 'core/paragraph' );
|
788
|
+
expect(
|
789
|
+
await page.evaluate( () => document.activeElement.textContent )
|
790
|
+
).toMatch( /^\.a+$/ );
|
791
|
+
} );
|
792
|
+
|
793
|
+
it( 'should vertically move the caret from corner to corner', async () => {
|
794
|
+
await page.keyboard.press( 'Enter' );
|
795
|
+
await page.keyboard.type( 'a' );
|
796
|
+
|
797
|
+
async function getHeight() {
|
798
|
+
return await page.evaluate(
|
799
|
+
() => document.activeElement.offsetHeight
|
800
|
+
);
|
801
|
+
}
|
802
|
+
|
803
|
+
const height = await getHeight();
|
804
|
+
|
805
|
+
// Keep typing until the height of the element increases. We need two
|
806
|
+
// lines.
|
807
|
+
while ( height === ( await getHeight() ) ) {
|
808
|
+
await page.keyboard.type( 'a' );
|
809
|
+
}
|
810
|
+
|
811
|
+
// Create a new paragraph.
|
812
|
+
await page.keyboard.press( 'Enter' );
|
813
|
+
// Move to the start of the first line.
|
814
|
+
await page.keyboard.press( 'ArrowUp' );
|
815
|
+
// Insert a "." for testing.
|
816
|
+
await page.keyboard.type( '.' );
|
817
|
+
|
818
|
+
// Expect the "." to be added at the start of the second line.
|
819
|
+
// It should not be added to the first line!
|
820
|
+
expect(
|
821
|
+
await page.evaluate( () =>
|
822
|
+
document.activeElement.getAttribute( 'data-type' )
|
823
|
+
)
|
824
|
+
).toBe( 'core/paragraph' );
|
825
|
+
expect(
|
826
|
+
await page.evaluate( () => document.activeElement.textContent )
|
827
|
+
).toMatch( /^a+\.a$/ );
|
828
|
+
} );
|
756
829
|
} );
|
@@ -207,15 +207,15 @@ describe( 'Multi-entity save flow', () => {
|
|
207
207
|
await page.keyboard.type( '...' );
|
208
208
|
|
209
209
|
await insertBlock( 'Site Tagline' );
|
210
|
-
//
|
210
|
+
// Wait for the placeholder.
|
211
211
|
await page.waitForXPath(
|
212
|
-
'//
|
212
|
+
'//span[@data-rich-text-placeholder="Write site tagline…"]'
|
213
213
|
);
|
214
214
|
const editableSiteTagLineSelector =
|
215
215
|
'.wp-block-site-tagline[contenteditable="true"]';
|
216
216
|
await page.waitForSelector( editableSiteTagLineSelector );
|
217
217
|
await page.focus( editableSiteTagLineSelector );
|
218
|
-
await page.keyboard.type( '
|
218
|
+
await page.keyboard.type( 'Just another WordPress site' );
|
219
219
|
|
220
220
|
await clickButton( 'Publish' );
|
221
221
|
await page.waitForSelector( savePanelSelector );
|
@@ -1,21 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Group can be created using the block inserter 1`] = `
|
4
|
-
"<!-- wp:group -->
|
5
|
-
<div class=\\"wp-block-group\\"></div>
|
6
|
-
<!-- /wp:group -->"
|
7
|
-
`;
|
8
|
-
|
9
|
-
exports[`Group can be created using the slash inserter 1`] = `
|
10
|
-
"<!-- wp:group -->
|
11
|
-
<div class=\\"wp-block-group\\"></div>
|
12
|
-
<!-- /wp:group -->"
|
13
|
-
`;
|
14
|
-
|
15
|
-
exports[`Group can have other blocks appended to it using the button appender 1`] = `
|
16
|
-
"<!-- wp:group -->
|
17
|
-
<div class=\\"wp-block-group\\"><!-- wp:paragraph -->
|
18
|
-
<p>Group Block with a Paragraph</p>
|
19
|
-
<!-- /wp:paragraph --></div>
|
20
|
-
<!-- /wp:group -->"
|
21
|
-
`;
|
@@ -1,43 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockAppender,
|
6
|
-
searchForBlock,
|
7
|
-
getEditedPostContent,
|
8
|
-
createNewPost,
|
9
|
-
} from '@wordpress/e2e-test-utils';
|
10
|
-
|
11
|
-
describe( 'Group', () => {
|
12
|
-
beforeEach( async () => {
|
13
|
-
await createNewPost();
|
14
|
-
} );
|
15
|
-
|
16
|
-
it( 'can be created using the block inserter', async () => {
|
17
|
-
await searchForBlock( 'Group' );
|
18
|
-
await page.click( '.editor-block-list-item-group' );
|
19
|
-
|
20
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
21
|
-
} );
|
22
|
-
|
23
|
-
it( 'can be created using the slash inserter', async () => {
|
24
|
-
await clickBlockAppender();
|
25
|
-
await page.keyboard.type( '/group' );
|
26
|
-
await page.waitForXPath(
|
27
|
-
`//*[contains(@class, "components-autocomplete__result") and contains(@class, "is-selected") and contains(text(), 'Group')]`
|
28
|
-
);
|
29
|
-
await page.keyboard.press( 'Enter' );
|
30
|
-
|
31
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
32
|
-
} );
|
33
|
-
|
34
|
-
it( 'can have other blocks appended to it using the button appender', async () => {
|
35
|
-
await searchForBlock( 'Group' );
|
36
|
-
await page.click( '.editor-block-list-item-group' );
|
37
|
-
await page.click( '.block-editor-button-block-appender' );
|
38
|
-
await page.click( '.editor-block-list-item-paragraph' );
|
39
|
-
await page.keyboard.type( 'Group Block with a Paragraph' );
|
40
|
-
|
41
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
42
|
-
} );
|
43
|
-
} );
|
@@ -1,44 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import { createNewPost, setPostContent } from '@wordpress/e2e-test-utils';
|
5
|
-
|
6
|
-
describe( 'missing block', () => {
|
7
|
-
beforeEach( async () => {
|
8
|
-
await createNewPost();
|
9
|
-
} );
|
10
|
-
|
11
|
-
it( 'should strip potentially malicious on* attributes', async () => {
|
12
|
-
let hasAlert = false;
|
13
|
-
|
14
|
-
page.on( 'dialog', () => {
|
15
|
-
hasAlert = true;
|
16
|
-
} );
|
17
|
-
|
18
|
-
await setPostContent(
|
19
|
-
`<!-- wp:non-existing-block-here --><img src onerror=alert(1)>`
|
20
|
-
);
|
21
|
-
|
22
|
-
// Give the browser time to show the alert.
|
23
|
-
await page.evaluate( () => new Promise( window.requestIdleCallback ) );
|
24
|
-
|
25
|
-
expect( hasAlert ).toBe( false );
|
26
|
-
} );
|
27
|
-
|
28
|
-
it( 'hould strip potentially malicious script tags', async () => {
|
29
|
-
let hasAlert = false;
|
30
|
-
|
31
|
-
page.on( 'dialog', () => {
|
32
|
-
hasAlert = true;
|
33
|
-
} );
|
34
|
-
|
35
|
-
await setPostContent(
|
36
|
-
`<!-- wp:non-existing-block-here --><script>alert("EVIL");</script>`
|
37
|
-
);
|
38
|
-
|
39
|
-
// Give the browser time to show the alert.
|
40
|
-
await page.evaluate( () => new Promise( window.requestIdleCallback ) );
|
41
|
-
|
42
|
-
expect( hasAlert ).toBe( false );
|
43
|
-
} );
|
44
|
-
} );
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Deprecated Node Matcher should insert block with children source 1`] = `
|
4
|
-
"<!-- wp:deprecated-children-matcher -->
|
5
|
-
<p class=\\"wp-block-deprecated-children-matcher\\">test<br/><strong>a</strong></p>
|
6
|
-
<!-- /wp:deprecated-children-matcher -->"
|
7
|
-
`;
|
8
|
-
|
9
|
-
exports[`Deprecated Node Matcher should insert block with node source 1`] = `
|
10
|
-
"<!-- wp:deprecated-node-matcher -->
|
11
|
-
<blockquote class=\\"wp-block-deprecated-node-matcher\\"><p>test</p><p></p></blockquote>
|
12
|
-
<!-- /wp:deprecated-node-matcher -->"
|
13
|
-
`;
|
@@ -1,44 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
createNewPost,
|
7
|
-
deactivatePlugin,
|
8
|
-
getEditedPostContent,
|
9
|
-
insertBlock,
|
10
|
-
pressKeyWithModifier,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
describe( 'Deprecated Node Matcher', () => {
|
14
|
-
beforeAll( async () => {
|
15
|
-
await activatePlugin( 'gutenberg-test-deprecated-node-matcher' );
|
16
|
-
} );
|
17
|
-
|
18
|
-
beforeEach( async () => {
|
19
|
-
await createNewPost();
|
20
|
-
} );
|
21
|
-
|
22
|
-
afterAll( async () => {
|
23
|
-
await deactivatePlugin( 'gutenberg-test-deprecated-node-matcher' );
|
24
|
-
} );
|
25
|
-
|
26
|
-
it( 'should insert block with node source', async () => {
|
27
|
-
await insertBlock( 'Deprecated Node Matcher' );
|
28
|
-
await page.keyboard.type( 'test' );
|
29
|
-
await page.keyboard.press( 'Enter' );
|
30
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
31
|
-
} );
|
32
|
-
|
33
|
-
it( 'should insert block with children source', async () => {
|
34
|
-
await insertBlock( 'Deprecated Children Matcher' );
|
35
|
-
await page.keyboard.type( 'test' );
|
36
|
-
await page.keyboard.press( 'Enter' );
|
37
|
-
await page.keyboard.type( 'a' );
|
38
|
-
await page.keyboard.down( 'Shift' );
|
39
|
-
await page.keyboard.press( 'ArrowLeft' );
|
40
|
-
await page.keyboard.up( 'Shift' );
|
41
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
42
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
43
|
-
} );
|
44
|
-
} );
|
@@ -1,44 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
clickBlockAppender,
|
7
|
-
createNewPost,
|
8
|
-
deactivatePlugin,
|
9
|
-
getEditedPostContent,
|
10
|
-
} from '@wordpress/e2e-test-utils';
|
11
|
-
|
12
|
-
describe( 'Using Hooks API', () => {
|
13
|
-
beforeAll( async () => {
|
14
|
-
await activatePlugin( 'gutenberg-test-hooks-api' );
|
15
|
-
} );
|
16
|
-
|
17
|
-
afterAll( async () => {
|
18
|
-
await deactivatePlugin( 'gutenberg-test-hooks-api' );
|
19
|
-
} );
|
20
|
-
|
21
|
-
beforeEach( async () => {
|
22
|
-
await createNewPost();
|
23
|
-
} );
|
24
|
-
|
25
|
-
it( 'Should contain a reset block button on the sidebar', async () => {
|
26
|
-
await clickBlockAppender();
|
27
|
-
await page.keyboard.type( 'First paragraph' );
|
28
|
-
expect(
|
29
|
-
await page.$( '.edit-post-sidebar .e2e-reset-block-button' )
|
30
|
-
).not.toBeNull();
|
31
|
-
} );
|
32
|
-
|
33
|
-
it( 'Pressing reset block button resets the block', async () => {
|
34
|
-
await clickBlockAppender();
|
35
|
-
await page.keyboard.type( 'First paragraph' );
|
36
|
-
const paragraphContent = await page.$eval(
|
37
|
-
'p[data-type="core/paragraph"]',
|
38
|
-
( element ) => element.textContent
|
39
|
-
);
|
40
|
-
expect( paragraphContent ).toEqual( 'First paragraph' );
|
41
|
-
await page.click( '.edit-post-sidebar .e2e-reset-block-button' );
|
42
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
43
|
-
} );
|
44
|
-
} );
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`Code block should convert to a preformatted block 1`] = `
|
4
|
-
"<!-- wp:code -->
|
5
|
-
<pre class=\\"wp-block-code\\"><code>print \\"Hello Dolly!\\"</code></pre>
|
6
|
-
<!-- /wp:code -->"
|
7
|
-
`;
|
8
|
-
|
9
|
-
exports[`Code block should convert to a preformatted block 2`] = `
|
10
|
-
"<!-- wp:preformatted -->
|
11
|
-
<pre class=\\"wp-block-preformatted\\">print \\"Hello Dolly!\\"</pre>
|
12
|
-
<!-- /wp:preformatted -->"
|
13
|
-
`;
|
@@ -1,32 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
getEditedPostContent,
|
6
|
-
createNewPost,
|
7
|
-
insertBlock,
|
8
|
-
transformBlockTo,
|
9
|
-
} from '@wordpress/e2e-test-utils';
|
10
|
-
|
11
|
-
describe( 'Code block', () => {
|
12
|
-
beforeEach( async () => {
|
13
|
-
await createNewPost();
|
14
|
-
} );
|
15
|
-
|
16
|
-
it( 'should convert to a preformatted block', async () => {
|
17
|
-
const code = 'print "Hello Dolly!"';
|
18
|
-
|
19
|
-
await insertBlock( 'Code' );
|
20
|
-
await page.keyboard.type( code );
|
21
|
-
|
22
|
-
// Verify the content starts out as a Code block.
|
23
|
-
const originalPostContent = await getEditedPostContent();
|
24
|
-
expect( originalPostContent ).toMatchSnapshot();
|
25
|
-
|
26
|
-
await transformBlockTo( 'Preformatted' );
|
27
|
-
|
28
|
-
// The content should now be a Preformatted block with no data loss.
|
29
|
-
const convertedPostContent = await getEditedPostContent();
|
30
|
-
expect( convertedPostContent ).toMatchSnapshot();
|
31
|
-
} );
|
32
|
-
} );
|