Skip to content

Commit

Permalink
Update table caption e2e test to include testing caption position
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Jun 11, 2019
1 parent 111c61e commit e27beab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
@@ -1,11 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Table allows a caption to be added 1`] = `
exports[`Table allows a caption to be added and supports positioning the caption below the table 1`] = `
"<!-- wp:table -->
<table class=\\"wp-block-table\\"><caption>Caption!</caption><tbody><tr><td></td><td></td></tr><tr><td></td><td></td></tr></tbody></table>
<!-- /wp:table -->"
`;
exports[`Table allows a caption to be added and supports positioning the caption below the table 2`] = `
"<!-- wp:table {\\"captionPosition\\":\\"bottom\\"} -->
<table class=\\"wp-block-table has-bottom-caption\\"><caption>Caption!</caption><tbody><tr><td></td><td></td></tr><tr><td></td><td></td></tr></tbody></table>
<!-- /wp:table -->"
`;
exports[`Table allows header and footer rows to be switched on and off 1`] = `
"<!-- wp:table -->
<table class=\\"wp-block-table\\"><thead><tr><th>header</th><th></th></tr></thead><tbody><tr><td>body</td><td></td></tr><tr><td></td><td></td></tr></tbody><tfoot><tr><td>footer</td><td></td></tr></tfoot></table>
Expand Down
19 changes: 16 additions & 3 deletions packages/e2e-tests/specs/blocks/table.test.js
@@ -1,7 +1,12 @@
/**
* WordPress dependencies
*/
import { createNewPost, insertBlock, getEditedPostContent } from '@wordpress/e2e-test-utils';
import {
clickBlockToolbarButton,
createNewPost,
getEditedPostContent,
insertBlock,
} from '@wordpress/e2e-test-utils';

const createButtonSelector = "//div[@data-type='core/table']//button[text()='Create Table']";

Expand Down Expand Up @@ -116,7 +121,7 @@ describe( 'Table', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'allows a caption to be added', async () => {
it( 'allows a caption to be added and supports positioning the caption below the table', async () => {
await insertBlock( 'Table' );

// Create the table.
Expand All @@ -127,7 +132,15 @@ describe( 'Table', () => {
await page.click( '.wp-block-table__caption-content' );
await page.keyboard.type( 'Caption!' );

// Expect the post to have the correct written content inside the table.
// Expect the post to have the correct table caption.
expect( await getEditedPostContent() ).toMatchSnapshot();

// Toggle the position of the caption.
await clickBlockToolbarButton( 'Edit table' );
const captionPositioningButton = await page.$x( "//button[text()='Show Caption Below Table']" );
await captionPositioningButton[ 0 ].click();

// Expect the caption to be below the table (an additional classname should be added to the table).
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );

0 comments on commit e27beab

Please sign in to comment.