Skip to content

Commit

Permalink
Add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jan 21, 2020
1 parent bb0917c commit 23702a1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ exports[`Multi-block selection should allow selecting outer edge if there is no

exports[`Multi-block selection should always expand single line selection 1`] = `""`;

exports[`Multi-block selection should clear selection when clicking next to blocks 1`] = `
"<!-- wp:paragraph -->
<p>1</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>2</p>
<!-- /wp:paragraph -->"
`;

exports[`Multi-block selection should copy and paste 1`] = `
"<!-- wp:paragraph -->
<p>1</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,4 +408,31 @@ describe( 'Multi-block selection', () => {

expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should clear selection when clicking next to blocks', async () => {
await clickBlockAppender();
await page.keyboard.type( '1' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( '2' );
await pressKeyWithModifier( 'shift', 'ArrowUp' );

await testNativeSelection();
expect( await getSelectedFlatIndices() ).toEqual( [ 1, 2 ] );

const coord = await page.evaluate( () => {
const element = document.querySelector( '.wp-block-paragraph' );
const rect = element.getBoundingClientRect();
return {
x: rect.x - 1,
y: rect.y + ( rect.height / 2 ),
};
} );

await page.mouse.click( coord.x, coord.y );

await testNativeSelection();
expect( await getSelectedFlatIndices() ).toEqual( [] );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );

0 comments on commit 23702a1

Please sign in to comment.