Skip to content
Draft
Changes from all commits
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
62 changes: 62 additions & 0 deletions test/e2e/specs/editor/blocks/cover.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,68 @@
const overlay = coverBlock.locator( '.wp-block-cover__background' );
await expect( overlay ).toBeVisible();
} );

test.describe( 'Block Fields', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.setGutenbergExperiments( [
'gutenberg-content-only-inspector-fields',
] );
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.setGutenbergExperiments( [] );
} );

// See https://github.com/WordPress/gutenberg/issues/74639.
test( "computes dimRatio and isDark when uploading an image via the inspector's Content tab", async ( {
editor,
page,
coverBlockUtils,
} ) => {
await editor.insertBlock( { name: 'core/cover' } );
const coverBlock = editor.canvas.getByRole( 'document', {
name: 'Block: Cover',
} );

// Select the Cover block (not the inner Paragraph).
await editor.selectBlocks( coverBlock );

// Open the Content tab in the inspector.
await editor.openDocumentSettingsSidebar();
const editorSettings = page.getByRole( 'region', {
name: 'Editor settings',
} );

// Click "Choose a media item…" in the Content tab.
await editorSettings
.getByRole( 'button', { name: 'Choose a media item' } )
.click();

// Upload an image via the dropdown.
const fileName = await coverBlockUtils.upload(
page.getByTestId( 'form-file-upload-input' )
);
const fileBasename = path.basename( fileName );

// Wait for the img's src attribute to be prefixed with http.
// Otherwise, the URL for the img src attribute starts is a placeholder
// beginning with `blob`.
await expect( async () => {
const src = await coverBlock
.locator( 'img' )
.getAttribute( 'src' );
expect( src.includes( fileBasename ) ).toBe( true );
} ).toPass();

// The overlay should have dimRatio of 50 (opacity 0.5), not 100.
const overlay = coverBlock.locator( '.wp-block-cover__background' );
await expect( overlay ).toHaveCSS(

Check failure on line 613 in test/e2e/specs/editor/blocks/cover.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 1

[chromium] › test/e2e/specs/editor/blocks/cover.spec.js:571:3 › Cover › Block Fields › computes dimRatio and isDark when uploading an image via the inspector's Content tab

1) [chromium] › test/e2e/specs/editor/blocks/cover.spec.js:571:3 › Cover › Block Fields › computes dimRatio and isDark when uploading an image via the inspector's Content tab Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCSS(expected) failed Locator: locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Block: Cover' }).locator('.wp-block-cover__background') Expected: "rgb(179, 179, 179)" Received: "rgb(0, 0, 0)" Timeout: 5000ms Call log: - Expect "toHaveCSS" with timeout 5000ms - waiting for locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Block: Cover' }).locator('.wp-block-cover__background') 9 × locator resolved to <span aria-hidden="true" class="wp-block-cover__background has-background-dim-100 has-background-dim"></span> - unexpected value "rgb(0, 0, 0)" 611 | // The overlay should have dimRatio of 50 (opacity 0.5), not 100. 612 | const overlay = coverBlock.locator( '.wp-block-cover__background' ); > 613 | await expect( overlay ).toHaveCSS( | ^ 614 | 'background-color', 615 | 'rgb(179, 179, 179)' 616 | ); at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/cover.spec.js:613:28

Check failure on line 613 in test/e2e/specs/editor/blocks/cover.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 1

[chromium] › test/e2e/specs/editor/blocks/cover.spec.js:571:3 › Cover › Block Fields › computes dimRatio and isDark when uploading an image via the inspector's Content tab

1) [chromium] › test/e2e/specs/editor/blocks/cover.spec.js:571:3 › Cover › Block Fields › computes dimRatio and isDark when uploading an image via the inspector's Content tab Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCSS(expected) failed Locator: locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Block: Cover' }).locator('.wp-block-cover__background') Expected: "rgb(179, 179, 179)" Received: "rgb(0, 0, 0)" Timeout: 5000ms Call log: - Expect "toHaveCSS" with timeout 5000ms - waiting for locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Block: Cover' }).locator('.wp-block-cover__background') 9 × locator resolved to <span aria-hidden="true" class="wp-block-cover__background has-background-dim-100 has-background-dim"></span> - unexpected value "rgb(0, 0, 0)" 611 | // The overlay should have dimRatio of 50 (opacity 0.5), not 100. 612 | const overlay = coverBlock.locator( '.wp-block-cover__background' ); > 613 | await expect( overlay ).toHaveCSS( | ^ 614 | 'background-color', 615 | 'rgb(179, 179, 179)' 616 | ); at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/cover.spec.js:613:28

Check failure on line 613 in test/e2e/specs/editor/blocks/cover.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 1

[chromium] › test/e2e/specs/editor/blocks/cover.spec.js:571:3 › Cover › Block Fields › computes dimRatio and isDark when uploading an image via the inspector's Content tab

1) [chromium] › test/e2e/specs/editor/blocks/cover.spec.js:571:3 › Cover › Block Fields › computes dimRatio and isDark when uploading an image via the inspector's Content tab Error: expect(locator).toHaveCSS(expected) failed Locator: locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Block: Cover' }).locator('.wp-block-cover__background') Expected: "rgb(179, 179, 179)" Received: "rgb(0, 0, 0)" Timeout: 5000ms Call log: - Expect "toHaveCSS" with timeout 5000ms - waiting for locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Block: Cover' }).locator('.wp-block-cover__background') 9 × locator resolved to <span aria-hidden="true" class="wp-block-cover__background has-background-dim-100 has-background-dim"></span> - unexpected value "rgb(0, 0, 0)" 611 | // The overlay should have dimRatio of 50 (opacity 0.5), not 100. 612 | const overlay = coverBlock.locator( '.wp-block-cover__background' ); > 613 | await expect( overlay ).toHaveCSS( | ^ 614 | 'background-color', 615 | 'rgb(179, 179, 179)' 616 | ); at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/cover.spec.js:613:28
'background-color',
'rgb(179, 179, 179)'
);
await expect( overlay ).toHaveCSS( 'opacity', '0.5' );
} );
} );
} );

class CoverBlockUtils {
Expand Down
Loading