Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add e2e test
  • Loading branch information
ellatrix committed Sep 29, 2021
commit e3f26a949d88d7d49a826a665e3be3b7ac2f3532
33 changes: 33 additions & 0 deletions packages/e2e-tests/specs/editor/blocks/image.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,37 @@ describe( 'Image', () => {
// broken temporary URL.
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should align right and have visible toolbar', async () => {
await insertBlock( 'Image' );
const filename1 = await upload( '.wp-block-image input[type="file"]' );
await waitForImage( filename1 );

const regex1 = new RegExp(
`<!-- wp:image {"id":\\d+,"sizeSlug":"full","linkDestination":"none"} -->\\s*<figure class="wp-block-image size-full"><img src="[^"]+\\/${ filename1 }\\.png" alt="" class="wp-image-\\d+"/></figure>\\s*<!-- \\/wp:image -->`
);
expect( await getEditedPostContent() ).toMatch( regex1 );

await clickBlockToolbarButton( 'Align' );
await clickButton( 'Align right' );

const regex2 = new RegExp(
`<!-- wp:image {"align":"right","id":\\d+,"sizeSlug":"full","linkDestination":"none"} -->\\s*<div class="wp-block-image"><figure class="alignright size-full"><img src="[^"]+\\/${ filename1 }\\.png" alt="" class="wp-image-\\d+"/></figure></div>\\s*<!-- \\/wp:image -->`
);

expect( await getEditedPostContent() ).toMatch( regex2 );

// Ensure that the end of the toolbar is not hidden.
// The page should not have to scroll horizontall to access the toolbar.
// See: https://github.com/WordPress/gutenberg/pull/35082.
await clickBlockToolbarButton( 'Options' );

const scrollLeft = await page.evaluate( () => {
return wp.dom.getScrollContainer(
document.querySelector( '.wp-block' )
).scrollLeft;
} );

expect( scrollLeft ).toBe( 0 );
} );
} );