Skip to content

Commit

Permalink
Add e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed Jan 18, 2024
1 parent 21388ac commit b4143f1
Showing 1 changed file with 95 additions and 1 deletion.
96 changes: 95 additions & 1 deletion test/e2e/specs/editor/various/list-view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ test.describe( 'List View', () => {
).toBeFocused();
} );

test( 'should select, duplicate, delete, and deselect blocks using keyboard', async ( {
test( 'should cut, copy, paste, select, duplicate, delete, and deselect blocks using keyboard', async ( {
editor,
page,
pageUtils,
Expand Down Expand Up @@ -779,6 +779,100 @@ test.describe( 'List View', () => {
{ name: 'core/heading', selected: false, focused: false },
{ name: 'core/file', selected: false, focused: true },
] );

// Copy and paste blocks. To begin, add another Group block.
await editor.insertBlock( {
name: 'core/group',
innerBlocks: [
{ name: 'core/paragraph' },
{ name: 'core/pullquote' },
],
} );

// Click the newly inserted Group block List View item to ensure it is focused.
await listView
.getByRole( 'link', {
name: 'Group',
expanded: false,
} )
.click();

// Move down to group block, expand, and then move to the paragraph block.
await page.keyboard.press( 'ArrowDown' );
await page.keyboard.press( 'ArrowRight' );
await page.keyboard.press( 'ArrowDown' );
await page.keyboard.press( 'ArrowDown' );
await pageUtils.pressKeys( 'primary+c' );
await page.keyboard.press( 'ArrowUp' );
await pageUtils.pressKeys( 'primary+v' );

await expect
.poll(
listViewUtils.getBlocksWithA11yAttributes,
'Should be able to copy focused block and paste in the list view via keyboard shortcuts'
)
.toMatchObject( [
{ name: 'core/heading', selected: false, focused: false },
{ name: 'core/file', selected: false, focused: false },
{
name: 'core/group',
selected: true,
innerBlocks: [
{
name: 'core/pullquote',
selected: false,
focused: true,
},
{
name: 'core/pullquote',
selected: false,
focused: false,
},
],
},
] );

// Cut and paste blocks.
await page.keyboard.press( 'ArrowUp' );
await pageUtils.pressKeys( 'primary+x' );

await expect
.poll(
listViewUtils.getBlocksWithA11yAttributes,
'Should be able to cut a block in the list view, with the preceding block being selected'
)
.toMatchObject( [
{ name: 'core/heading', selected: false, focused: false },
{ name: 'core/file', selected: true, focused: true },
] );

await pageUtils.pressKeys( 'primary+v' );

await expect
.poll(
listViewUtils.getBlocksWithA11yAttributes,
'Should be able to paste previously cut block in the list view via keyboard shortcuts'
)
.toMatchObject( [
{ name: 'core/heading', selected: false, focused: false },
{
name: 'core/group',
selected: true,
focused: true,
innerBlocks: [
{
name: 'core/pullquote',
selected: false,
focused: false,
},
{
name: 'core/pullquote',
selected: false,
focused: false,
},
],
},
] );
} );

test( 'block settings dropdown menu', async ( {
Expand Down

0 comments on commit b4143f1

Please sign in to comment.