Skip to content

Commit

Permalink
Fix e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Oct 19, 2024
1 parent 2cb9ef2 commit a2dc1c5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 42 deletions.
4 changes: 2 additions & 2 deletions src/settings/global-settings/setting-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ export default function SettingModal( { options, isAdministrator, setIsSettingMo
value={ currentOptions.block_style?.cell_text_align }
isDeselectable
onChange={ ( value ) => {
if ( typeof value !== 'string' || value !== undefined ) {
if ( typeof value !== 'string' && value !== undefined ) {
return;
}
const newValue =
Expand Down Expand Up @@ -556,7 +556,7 @@ export default function SettingModal( { options, isAdministrator, setIsSettingMo
value={ currentOptions.block_style?.cell_vertical_align }
isDeselectable
onChange={ ( value ) => {
if ( typeof value !== 'string' || value !== undefined ) {
if ( typeof value !== 'string' && value !== undefined ) {
return;
}
const newValue =
Expand Down
8 changes: 3 additions & 5 deletions test/e2e/specs/table-style.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ async function applyCellStyles( page, pageUtils ) {
await page.getByRole( 'button', { name: 'Align center' } ).click();
await page.getByRole( 'button', { name: 'Align middle' } ).click();
// Cell Tag element.
await page.getByRole( 'button', { name: 'TH', exact: true } ).click();
await page.getByRole( 'radio', { name: 'TD' } ).click();
await page.getByRole( 'radio', { name: 'TH' } ).click();
// Cell CSS class.
await page.getByRole( 'textbox', { name: 'Cell CSS class(es)' } ).fill( 'custom' );
// id, headers, scope getBlockAttributes.
Expand Down Expand Up @@ -252,10 +253,7 @@ test.describe( 'Styles', () => {
await page.getByRole( 'spinbutton', { name: 'Right' } ).fill( '2' );
await page.getByRole( 'spinbutton', { name: 'Bottom' } ).fill( '3' );
await page.getByRole( 'spinbutton', { name: 'Left' } ).fill( '4' );
await page
.locator( '[aria-labelledby="flexible-table-block-caption-side-heading"]' )
.getByRole( 'button', { name: 'Top' } )
.click();
await page.getByRole( 'radio', { name: 'Top' } ).click();
await page.getByRole( 'button', { name: 'Align center' } ).click();
expect( await editor.getEditedPostContent() ).toMatchSnapshot();
} );
Expand Down
70 changes: 35 additions & 35 deletions test/e2e/specs/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test.describe( 'Transform from core table block', () => {
.nth( 0 )
.fill( 'Core Table Block' );

// Starting with WP6.6, "Fixed width table cells" is enabled by default, so this option must be explicitly disabled.
// Starting with WP 6.6, "Fixed width table cells" is enabled by default, so this option must be explicitly disabled.
await page.getByRole( 'checkbox', { name: 'Fixed width table cells' } ).uncheck();

await editor.transformBlockTo( 'flexible-table-block/table' );
Expand All @@ -48,7 +48,7 @@ test.describe( 'Transform from core table block', () => {
await page.getByRole( 'checkbox', { name: 'Header section' } ).check();
await page.getByRole( 'checkbox', { name: 'Footer section' } ).check();

// Starting with WP6.6, Fixed width table cells is enabled by default, so this option must be explicitly disabled.
// Starting with WP 6.6, Fixed width table cells is enabled by default, so this option must be explicitly disabled.
await page.getByRole( 'checkbox', { name: 'Fixed width table cells' } ).uncheck();

await editor.transformBlockTo( 'flexible-table-block/table' );
Expand Down Expand Up @@ -87,13 +87,13 @@ test.describe( 'Transform from flexible table block', () => {
.fill( 'Flexible Table Block' );
await editor.transformBlockTo( 'core/table' );

// Starting with WP6.6, "Fixed width table cells" is enabled by default.
// Starting with WP 6.6, "Fixed width table cells" is enabled by default.
const expected = [ '6-5' ].includes( wpVersion )
? // WP6.5
? // WP 6.5
`<!-- wp:table {"hasFixedLayout":true} -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td></td><td></td><td></td></tr><tr><td>Flexible Table Block</td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`
: // WP6.6
: // WP 6.6, WP 6.7
`<!-- wp:table -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td></td><td></td><td></td></tr><tr><td>Flexible Table Block</td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`;
Expand Down Expand Up @@ -121,13 +121,13 @@ test.describe( 'Transform from flexible table block', () => {
await page.getByRole( 'checkbox', { name: 'Fixed width table cells' } ).uncheck();
await editor.transformBlockTo( 'core/table' );

// Starting with WP6.6, "Fixed width table cells" is enabled by default.
// Starting with WP 6.6, "Fixed width table cells" is enabled by default.
const expected = [ '6-5' ].includes( wpVersion )
? // WP6.5
? // WP 6.5
`<!-- wp:table -->
<figure class="wp-block-table"><table><tbody><tr><td>Flexible Table Block</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`
: // WP6.6
: // WP 6.6, WP 6.7
`<!-- wp:table {"hasFixedLayout":false} -->
<figure class="wp-block-table"><table><tbody><tr><td>Flexible Table Block</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`;
Expand Down Expand Up @@ -155,13 +155,13 @@ test.describe( 'Transform from flexible table block', () => {
await page.getByRole( 'button', { name: 'Separate' } ).click();
await editor.transformBlockTo( 'core/table' );

// Starting with WP6.6, "Fixed width table cells" is enabled by default.
// Starting with WP 6.6, "Fixed width table cells" is enabled by default.
const expected = [ '6-5' ].includes( wpVersion )
? // WP6.5
? // WP 6.5
`<!-- wp:table {"hasFixedLayout":true} -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`
: // WP6.6
: // WP 6.6, WP 6.7
`<!-- wp:table -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`;
Expand Down Expand Up @@ -192,13 +192,13 @@ test.describe( 'Transform from flexible table block', () => {
await page.getByRole( 'menuitem', { name: 'Merge cells' } ).click();
await editor.transformBlockTo( 'core/table' );

// Starting with WP6.6, "Fixed width table cells" is enabled by default.
// Starting with WP 6.6, "Fixed width table cells" is enabled by default.
const expected = [ '6-5' ].includes( wpVersion )
? // WP6.5
? // WP 6.5
`<!-- wp:table {"hasFixedLayout":true} -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td colspan="2">Cell 1</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`
: // WP6.6
: // WP 6.6, WP 6.7
`<!-- wp:table -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td colspan="2">Cell 1</td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`;
Expand Down Expand Up @@ -226,16 +226,16 @@ test.describe( 'Transform from flexible table block', () => {
await page.getByRole( 'spinbutton', { name: 'Cell font size' } ).fill( '20' );
await page.fill( '.ftb-padding-control__header-control input', '1' );
await page.getByRole( 'button', { name: 'Solid' } ).click();
await page.getByRole( 'button', { name: 'TH', exact: true } ).click();
await page.getByRole( 'radio', { name: 'TH' } ).click();
await editor.transformBlockTo( 'core/table' );

// Starting with WP6.6, "Fixed width table cells" is enabled by default.
// Starting with WP 6.6, "Fixed width table cells" is enabled by default.
const expected = [ '6-5' ].includes( wpVersion )
? // WP6.5
? // WP 6.5
`<!-- wp:table {"hasFixedLayout":true} -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td>Flexible Table Block</td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`
: // WP6.6
: // WP 6.6, WP 6.7
`<!-- wp:table -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td>Flexible Table Block</td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`;
Expand All @@ -257,19 +257,19 @@ test.describe( 'Transform from flexible table block', () => {
.getByRole( 'tab', { name: 'Settings' } )
.click();
await page.getByRole( 'button', { name: 'Cell settings' } ).click();
await page.getByRole( 'button', { name: 'TH', exact: true } ).click();
await page.getByRole( 'radio', { name: 'TH' } ).click();
await page.getByRole( 'textbox', { name: 'id attribute' } ).fill( 'id' );
await page.getByRole( 'textbox', { name: 'headers attribute' } ).fill( 'headers' );
await page.getByRole( 'button', { name: 'row', exact: true } ).click();
await editor.transformBlockTo( 'core/table' );

// Starting with WP6.6, "Fixed width table cells" is enabled by default.
// Starting with WP 6.6, "Fixed width table cells" is enabled by default.
const expected = [ '6-5' ].includes( wpVersion )
? // WP6.5
? // WP 6.5
`<!-- wp:table {"hasFixedLayout":true} -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`
: // WP6.6
: // WP 6.6, WP 6.7
`<!-- wp:table -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table></figure>
<!-- /wp:table -->`;
Expand All @@ -291,20 +291,20 @@ test.describe( 'Transform from flexible table block', () => {
.getByRole( 'tab', { name: 'Settings' } )
.click();
await page.getByRole( 'button', { name: 'Cell settings' } ).click();
await page.getByRole( 'button', { name: 'TD', exact: true } ).click();
await page.getByRole( 'radio', { name: 'TD' } ).click();
await editor.canvas.getByRole( 'textbox', { name: 'Body cell text' } ).nth( 0 ).click();
await page.getByRole( 'button', { name: 'TH', exact: true } ).click();
await page.getByRole( 'radio', { name: 'TH' } ).click();
await editor.canvas.getByRole( 'textbox', { name: 'Footer cell text' } ).nth( 0 ).click();
await page.getByRole( 'button', { name: 'TH', exact: true } ).click();
await page.getByRole( 'radio', { name: 'TH' } ).click();
await editor.transformBlockTo( 'core/table' );

// Starting with WP6.6, "Fixed width table cells" is enabled by default.
// Starting with WP 6.6, "Fixed width table cells" is enabled by default.
const expected = [ '6-5' ].includes( wpVersion )
? // WP6.5
? // WP 6.5
`<!-- wp:table {"hasFixedLayout":true} -->
<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody><tfoot><tr><td></td><td></td><td></td></tr></tfoot></table></figure>
<!-- /wp:table -->`
: // WP6.6
: // WP 6.6, WP 6.7
`<!-- wp:table -->
<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody><tfoot><tr><td></td><td></td><td></td></tr></tfoot></table></figure>
<!-- /wp:table -->`;
Expand All @@ -328,13 +328,13 @@ test.describe( 'Transform from flexible table block', () => {
await page.keyboard.type( 'Block' );
await editor.transformBlockTo( 'core/table' );

// Starting with WP6.6, "Fixed width table cells" is enabled by default.
// Starting with WP 6.6, "Fixed width table cells" is enabled by default.
const expected = [ '6-5' ].includes( wpVersion )
? // WP6.5
? // WP 6.5
`<!-- wp:table {"hasFixedLayout":true} -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table><figcaption class="wp-element-caption">Flexible<br>Table<br>Block</figcaption></figure>
<!-- /wp:table -->`
: // WP6.6
: // WP 6.6, WP 6.7
`<!-- wp:table -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table><figcaption class="wp-element-caption">Flexible<br>Table<br>Block</figcaption></figure>
<!-- /wp:table -->`;
Expand All @@ -360,16 +360,16 @@ test.describe( 'Transform from flexible table block', () => {
await page.getByRole( 'button', { name: 'Caption settings', exact: true } ).click();
await page.getByRole( 'spinbutton', { name: 'Caption font size' } ).fill( '20' );
await page.fill( '.ftb-padding-control__header-control input', '20' );
await page.getByRole( 'button', { name: 'Top' } ).click();
await page.getByRole( 'radio', { name: 'Top' } ).click();
await editor.transformBlockTo( 'core/table' );

// Starting with WP6.6, "Fixed width table cells" is enabled by default.
// Starting with WP 6.6, "Fixed width table cells" is enabled by default.
const expected = [ '6-5' ].includes( wpVersion )
? // WP6.5
? // WP 6.5
`<!-- wp:table {"hasFixedLayout":true} -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table><figcaption class="wp-element-caption">Flexible Table Block</figcaption></figure>
<!-- /wp:table -->`
: // WP6.6
: // WP 6.6, WP 6.7
`<!-- wp:table -->
<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table><figcaption class="wp-element-caption">Flexible Table Block</figcaption></figure>
<!-- /wp:table -->`;
Expand Down
File renamed without changes.

0 comments on commit a2dc1c5

Please sign in to comment.