Skip to content

Commit

Permalink
Adapt old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 21, 2024
1 parent 6f3545b commit b3f4488
Showing 1 changed file with 18 additions and 40 deletions.
58 changes: 18 additions & 40 deletions test/e2e/specs/editor/various/block-bindings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1193,11 +1193,6 @@ test.describe( 'Block bindings', () => {
await expect( paragraphBlock ).toHaveText(
'Value of the text_custom_field'
);
// Paragraph is not editable.
await expect( paragraphBlock ).toHaveAttribute(
'contenteditable',
'false'
);

// Check the frontend shows the value of the custom field.
const postId = await editor.publishPost();
Expand Down Expand Up @@ -1331,6 +1326,12 @@ test.describe( 'Block bindings', () => {
},
},
} );
// Select the paragraph and press Enter at the end of it.
const paragraph = editor.canvas.getByRole( 'document', {
name: 'Block: Paragraph',
} );
await editor.selectBlocks( paragraph );
await page.keyboard.press( 'End' );
await page.keyboard.press( 'Enter' );
const [ initialParagraph, newEmptyParagraph ] =
await editor.canvas
Expand Down Expand Up @@ -1473,11 +1474,6 @@ test.describe( 'Block bindings', () => {
await expect( headingBlock ).toHaveText(
'Value of the text_custom_field'
);
// Heading is not editable.
await expect( headingBlock ).toHaveAttribute(
'contenteditable',
'false'
);

// Check the frontend shows the value of the custom field.
const postId = await editor.publishPost();
Expand Down Expand Up @@ -1509,6 +1505,13 @@ test.describe( 'Block bindings', () => {
},
},
} );

// Select the heading and press Enter at the end of it.
const heading = editor.canvas.getByRole( 'document', {
name: 'Block: Heading',
} );
await editor.selectBlocks( heading );
await page.keyboard.press( 'End' );
await page.keyboard.press( 'Enter' );
// Can't use `editor.getBlocks` because it doesn't return the meta value shown in the editor.
const [ initialHeading, newEmptyParagraph ] =
Expand Down Expand Up @@ -1568,12 +1571,6 @@ test.describe( 'Block bindings', () => {
'Value of the text_custom_field'
);

// Button is not editable.
await expect( buttonBlock ).toHaveAttribute(
'contenteditable',
'false'
);

// Check the frontend shows the value of the custom field.
const postId = await editor.publishPost();
await page.goto( `/?p=${ postId }` );
Expand Down Expand Up @@ -1702,6 +1699,7 @@ test.describe( 'Block bindings', () => {
} )
.getByRole( 'textbox' )
.click();
await page.keyboard.press( 'End' );
await page.keyboard.press( 'Enter' );
const [ initialButton, newEmptyButton ] = await editor.canvas
.locator( '[data-type="core/button"]' )
Expand Down Expand Up @@ -1826,12 +1824,7 @@ test.describe( 'Block bindings', () => {
imagePlaceholderSrc
);

// Alt textarea is disabled and with the custom field value.
await expect(
page
.getByRole( 'tabpanel', { name: 'Settings' } )
.getByLabel( 'Alternative text' )
).toHaveAttribute( 'readonly' );
// Alt textarea should have the custom field value.
const altValue = await page
.getByRole( 'tabpanel', { name: 'Settings' } )
.getByLabel( 'Alternative text' )
Expand Down Expand Up @@ -1892,7 +1885,7 @@ test.describe( 'Block bindings', () => {
imagePlaceholderSrc
);

// Title input is disabled and with the custom field value.
// Title input should have the custom field value.
const advancedButton = page
.getByRole( 'tabpanel', { name: 'Settings' } )
.getByRole( 'button', {
Expand All @@ -1903,11 +1896,6 @@ test.describe( 'Block bindings', () => {
if ( isAdvancedPanelOpen === 'false' ) {
await advancedButton.click();
}
await expect(
page
.getByRole( 'tabpanel', { name: 'Settings' } )
.getByLabel( 'Title attribute' )
).toHaveAttribute( 'readonly' );
const titleValue = await page
.getByRole( 'tabpanel', { name: 'Settings' } )
.getByLabel( 'Title attribute' )
Expand Down Expand Up @@ -1972,19 +1960,14 @@ test.describe( 'Block bindings', () => {
imageCustomFieldSrc
);

// Alt textarea is disabled and with the custom field value.
await expect(
page
.getByRole( 'tabpanel', { name: 'Settings' } )
.getByLabel( 'Alternative text' )
).toHaveAttribute( 'readonly' );
// Alt textarea should have the custom field value.
const altValue = await page
.getByRole( 'tabpanel', { name: 'Settings' } )
.getByLabel( 'Alternative text' )
.inputValue();
expect( altValue ).toBe( 'Value of the text_custom_field' );

// Title input is enabled and with the original value.
// Title input should have the original value.
const advancedButton = page
.getByRole( 'tabpanel', { name: 'Settings' } )
.getByRole( 'button', {
Expand All @@ -1995,11 +1978,6 @@ test.describe( 'Block bindings', () => {
if ( isAdvancedPanelOpen === 'false' ) {
await advancedButton.click();
}
await expect(
page
.getByRole( 'tabpanel', { name: 'Settings' } )
.getByLabel( 'Title attribute' )
).toBeEnabled();
const titleValue = await page
.getByRole( 'tabpanel', { name: 'Settings' } )
.getByLabel( 'Title attribute' )
Expand Down

0 comments on commit b3f4488

Please sign in to comment.