Skip to content

add safeTab(), fail test when page focus is lost - #3983

Merged
nstepien merged 4 commits into
mainfrom
safeTab()
Feb 26, 2026
Merged

nstepien merged 4 commits into
mainfrom
safeTab()

Conversation

@nstepien

@nstepien nstepien commented Feb 25, 2026 •

Copy link
Copy Markdown
Collaborator

Upstream bug: microsoft/playwright#39268
Looks like they're petrified by a thorough bug report.

@nstepien nstepien self-assigned this Feb 25, 2026
@nstepien
nstepien marked this pull request as ready for review February 25, 2026 18:31
Comment thread test/browser/utils.tsx
export async function scrollGrid(options: ScrollToOptions) {
page.getGrid().element().scroll(options);
// let the browser fire the 'scroll' event
await new Promise(requestAnimationFrame);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Some tests were flaky after scrollGrid(), hopefully this will resolve it.
The scrollend isn't fired when the element isn't scrolled though, but in that case the test will timeout and we'll know why, so we won't unintentionally add useless scrollGrid() calls.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

https://playwright.dev/docs/input#scrolling

Do you think we should try

await page.getByTestId('scrolling-container').evaluate(e => e.scrollTop += 100);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Vitest doesn't expose evaluate, probably because tests run in the browser context, rather than in a nodejs context

Comment thread test/browser/utils.tsx
export async function scrollGrid(options: ScrollToOptions) {
page.getGrid().element().scroll(options);
// let the browser fire the 'scroll' event
await new Promise(requestAnimationFrame);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

https://playwright.dev/docs/input#scrolling

Do you think we should try

await page.getByTestId('scrolling-container').evaluate(e => e.scrollTop += 100);

@nstepien
nstepien merged commit a80e036 into main Feb 26, 2026
1 check passed
@nstepien
nstepien deleted the safeTab() branch February 26, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants