@wordpress/e2e-tests 6.0.0 → 6.1.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.
@@ -1,142 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- createNewPost,
6
- pressKeyWithModifier,
7
- insertBlock,
8
- } from '@wordpress/e2e-test-utils';
9
-
10
- async function focusBlockToolbar() {
11
- await pressKeyWithModifier( 'alt', 'F10' );
12
- }
13
-
14
- async function expectLabelToHaveFocus( label ) {
15
- let ariaLabel = await page.evaluate( () =>
16
- document.activeElement.getAttribute( 'aria-label' )
17
- );
18
- // If the labels don't match, try pressing Up Arrow to focus the block wrapper in non-content editable block.
19
- if ( ariaLabel !== label ) {
20
- await page.keyboard.press( 'ArrowUp' );
21
- ariaLabel = await page.evaluate( () =>
22
- document.activeElement.getAttribute( 'aria-label' )
23
- );
24
- }
25
- await expect( ariaLabel ).toBe( label );
26
- }
27
-
28
- async function testBlockToolbarKeyboardNavigation(
29
- currentBlockLabel,
30
- currentBlockTitle
31
- ) {
32
- await focusBlockToolbar();
33
- await expectLabelToHaveFocus( currentBlockTitle );
34
- await page.keyboard.press( 'ArrowRight' );
35
- await expectLabelToHaveFocus( 'Move up' );
36
- await page.keyboard.press( 'Tab' );
37
- await expectLabelToHaveFocus( currentBlockLabel );
38
- await pressKeyWithModifier( 'shift', 'Tab' );
39
- await expectLabelToHaveFocus( 'Move up' );
40
- }
41
-
42
- async function wrapCurrentBlockWithGroup( currentBlockTitle ) {
43
- await page.click( `[aria-label="${ currentBlockTitle }"]` );
44
- await page.click( '.editor-block-list-item-group' );
45
- }
46
-
47
- async function testGroupKeyboardNavigation(
48
- currentBlockLabel,
49
- currentBlockTitle
50
- ) {
51
- await expectLabelToHaveFocus( 'Block: Group' );
52
- await page.keyboard.press( 'ArrowRight' );
53
- await expectLabelToHaveFocus( currentBlockLabel );
54
- await pressKeyWithModifier( 'shift', 'Tab' );
55
- await expectLabelToHaveFocus( 'Select Group' );
56
- await page.keyboard.press( 'ArrowRight' );
57
- await expectLabelToHaveFocus( currentBlockTitle );
58
- }
59
-
60
- describe( 'Toolbar roving tabindex', () => {
61
- beforeEach( async () => {
62
- await createNewPost();
63
- await insertBlock( 'Paragraph' );
64
- await page.keyboard.type( 'First block' );
65
- } );
66
-
67
- it( 'ensures paragraph block toolbar uses roving tabindex', async () => {
68
- await insertBlock( 'Paragraph' );
69
- await page.keyboard.type( 'Paragraph' );
70
- await testBlockToolbarKeyboardNavigation(
71
- 'Paragraph block',
72
- 'Paragraph'
73
- );
74
- await wrapCurrentBlockWithGroup( 'Paragraph' );
75
- await testGroupKeyboardNavigation( 'Paragraph block', 'Paragraph' );
76
- } );
77
-
78
- it( 'ensures heading block toolbar uses roving tabindex', async () => {
79
- await insertBlock( 'Heading' );
80
- await page.keyboard.type( 'Heading' );
81
- await testBlockToolbarKeyboardNavigation( 'Block: Heading', 'Heading' );
82
- await wrapCurrentBlockWithGroup( 'Heading' );
83
- await testGroupKeyboardNavigation( 'Block: Heading', 'Heading' );
84
- } );
85
-
86
- it( 'ensures list block toolbar uses roving tabindex', async () => {
87
- await insertBlock( 'List' );
88
- await page.keyboard.type( 'List' );
89
- await testBlockToolbarKeyboardNavigation( 'List text', 'Select List' );
90
- await page.click( `[aria-label="Select List"]` );
91
- await wrapCurrentBlockWithGroup( 'List' );
92
- await testGroupKeyboardNavigation( 'Block: List', 'List' );
93
- } );
94
-
95
- it( 'ensures image block toolbar uses roving tabindex', async () => {
96
- await insertBlock( 'Image' );
97
- await testBlockToolbarKeyboardNavigation( 'Block: Image', 'Image' );
98
- await wrapCurrentBlockWithGroup( 'Image' );
99
- await testGroupKeyboardNavigation( 'Block: Image', 'Image' );
100
- } );
101
-
102
- it( 'ensures table block toolbar uses roving tabindex', async () => {
103
- await insertBlock( 'Table' );
104
- await testBlockToolbarKeyboardNavigation( 'Block: Table', 'Table' );
105
- // Move focus to the first toolbar item.
106
- await page.keyboard.press( 'Home' );
107
- await expectLabelToHaveFocus( 'Table' );
108
- await page.click( '.blocks-table__placeholder-button' );
109
- await page.keyboard.press( 'Tab' );
110
- await testBlockToolbarKeyboardNavigation( 'Body cell text', 'Table' );
111
- await wrapCurrentBlockWithGroup( 'Table' );
112
- await testGroupKeyboardNavigation( 'Block: Table', 'Table' );
113
- } );
114
-
115
- it( 'ensures custom html block toolbar uses roving tabindex', async () => {
116
- await insertBlock( 'Custom HTML' );
117
- await testBlockToolbarKeyboardNavigation( 'HTML', 'Custom HTML' );
118
- await wrapCurrentBlockWithGroup( 'Custom HTML' );
119
- await testGroupKeyboardNavigation(
120
- 'Block: Custom HTML',
121
- 'Custom HTML'
122
- );
123
- } );
124
-
125
- it( 'ensures block toolbar remembers the last focused item', async () => {
126
- await insertBlock( 'Paragraph' );
127
- await page.keyboard.type( 'Paragraph' );
128
- await focusBlockToolbar();
129
- await page.keyboard.press( 'ArrowRight' );
130
- await expectLabelToHaveFocus( 'Move up' );
131
- await page.keyboard.press( 'Tab' );
132
- await pressKeyWithModifier( 'shift', 'Tab' );
133
- await expectLabelToHaveFocus( 'Move up' );
134
- } );
135
-
136
- it( 'can reach toolbar items with arrow keys after pressing alt+F10', async () => {
137
- await pressKeyWithModifier( 'alt', 'F10' );
138
- await page.keyboard.press( 'ArrowRight' );
139
- await page.keyboard.press( 'ArrowRight' );
140
- await expectLabelToHaveFocus( 'Bold' );
141
- } );
142
- } );