Skip to content

Commit

Permalink
Rename POM to CoverBlockUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
worldomonation committed May 12, 2023
1 parent 7897f28 commit 405c709
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/e2e/specs/editor/blocks/cover.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const { v4: uuid } = require( 'uuid' );
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.use( {
imageBlockUtils: async ( { page }, use ) => {
await use( new ImageBlockUtils( { page } ) );
coverBlockUtils: async ( { page }, use ) => {
await use( new CoverBlockUtils( { page } ) );
},
} );

Expand All @@ -27,7 +27,7 @@ test.describe( 'Cover', () => {
test( 'can set overlay color using color picker on block placeholder', async ( {
page,
editor,
imageBlockUtils,
coverBlockUtils,
} ) => {
await editor.insertBlock( { name: 'core/cover' } );
const coverBlock = page.getByRole( 'document', {
Expand All @@ -41,7 +41,7 @@ test.describe( 'Cover', () => {
await expect( blackColorSwatch ).toBeVisible();

// Get the RGB value of Black.
const [ blackRGB ] = await imageBlockUtils.getBackgroundColorAndOpacity(
const [ blackRGB ] = await coverBlockUtils.getBackgroundColorAndOpacity(
coverBlock
);

Expand All @@ -50,22 +50,22 @@ test.describe( 'Cover', () => {

// Get the RGB value of the background dim.
const [ actualRGB ] =
await imageBlockUtils.getBackgroundColorAndOpacity( coverBlock );
await coverBlockUtils.getBackgroundColorAndOpacity( coverBlock );

expect( blackRGB ).toEqual( actualRGB );
} );

test( 'can set background image using image upload on block placeholder', async ( {
page,
editor,
imageBlockUtils,
coverBlockUtils,
} ) => {
await editor.insertBlock( { name: 'core/cover' } );
const coverBlock = page.getByRole( 'document', {
name: 'Block: Cover',
} );

const filename = await imageBlockUtils.upload(
const filename = await coverBlockUtils.upload(
coverBlock.getByTestId( 'form-file-upload-input' )
);
const fileBasename = path.basename( filename );
Expand All @@ -82,22 +82,22 @@ test.describe( 'Cover', () => {
test( 'dims background image down by 50% by default', async ( {
page,
editor,
imageBlockUtils,
coverBlockUtils,
} ) => {
await editor.insertBlock( { name: 'core/cover' } );
const coverBlock = page.getByRole( 'document', {
name: 'Block: Cover',
} );

await imageBlockUtils.upload(
await coverBlockUtils.upload(
coverBlock.getByTestId( 'form-file-upload-input' )
);

// The hidden span must be used as the target for opacity and color value.
// Using the Cover block to calculate the opacity results in an incorrect value of 1.
// The hidden span value returns the correct opacity at 0.5.
const [ backgroundDimColor, backgroundDimOpacity ] =
await imageBlockUtils.getBackgroundColorAndOpacity(
await coverBlockUtils.getBackgroundColorAndOpacity(
coverBlock.locator( 'span[aria-hidden="true"]' )
);
expect( backgroundDimColor ).toBe( 'rgb(0, 0, 0)' );
Expand Down Expand Up @@ -207,15 +207,15 @@ test.describe( 'Cover', () => {
test( 'dims the background image down by 50% when transformed from the Image block', async ( {
page,
editor,
imageBlockUtils,
coverBlockUtils,
} ) => {
await editor.insertBlock( { name: 'core/image' } );

const imageBlock = page.getByRole( 'document', {
name: 'Block: Image',
} );

await imageBlockUtils.upload(
await coverBlockUtils.upload(
imageBlock.getByTestId( 'form-file-upload-input' )
);

Expand All @@ -235,7 +235,7 @@ test.describe( 'Cover', () => {
// Using the Cover block to calculate the opacity results in an incorrect value of 1.
// The hidden span value returns the correct opacity at 0.5.
const [ backgroundDimColor, backgroundDimOpacity ] =
await imageBlockUtils.getBackgroundColorAndOpacity(
await coverBlockUtils.getBackgroundColorAndOpacity(
coverBlock.locator( 'span[aria-hidden="true"]' )
);

Expand All @@ -247,7 +247,7 @@ test.describe( 'Cover', () => {
} );
} );

class ImageBlockUtils {
class CoverBlockUtils {
constructor( { page } ) {
/** @type {Page} */
this.page = page;
Expand Down

0 comments on commit 405c709

Please sign in to comment.