Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E (cover.test.js): Wait for the height input element #47294

Merged
merged 3 commits into from
Jan 20, 2023
Merged
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
16 changes: 7 additions & 9 deletions packages/e2e-tests/specs/editor/blocks/cover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,22 @@ describe( 'Cover', () => {
'.components-circular-option-picker__option-wrapper:first-child button'
);

// Select the cover block.By default the child paragraph gets selected.
// Select the cover block. By default the child paragraph gets selected.
await page.click(
'.edit-post-header-toolbar__document-overview-toggle'
);
await page.click(
'.block-editor-list-view-block__contents-container a'
);

const heightInput = (
await page.$x(
'//div[./label[contains(text(),"Minimum height of cover")]]/following-sibling::div//input'
)
)[ 0 ];
const heightInputHandle = await page.waitForSelector(
'input[id*="block-cover-height-input"]'
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an idiomatic way in Puppeter/Playwright to find an input labelled as "Minimum height of cover"? React Testing Library can do it with the .getByLabelText query. If there is a <label for="x"> with that text and the for attribute points to an <input id="x">, it will return the input.

Copy link
Member Author

@WunderBart WunderBart Jan 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an idiomatic way in Puppeter/Playwright to find an input labelled as "Minimum height of cover"?

Not in Puppeteer, but fortunately, there is one in Playwright:

await page.getByLabel("Minimum height of cover");

We should definitely use it when this spec is migrated.


// Verify the height of the cover is not defined.
expect(
await page.evaluate( ( { value } ) => value, heightInput )
).toBeFalsy();
await page.evaluate( ( { value } ) => value, heightInputHandle )
).toBe( '' );

const resizeButton = await page.$(
'.components-resizable-box__handle-bottom'
Expand Down Expand Up @@ -188,7 +186,7 @@ describe( 'Cover', () => {
expect(
await page.evaluate(
( { value } ) => Number.parseInt( value ),
heightInput
heightInputHandle
)
).toBeGreaterThan( 100 );
} );
Expand Down