Skip to content

feat(testUtils): add navigation option to grantAccessIfNeeded and imp…#29

Merged
sebastianchristopher merged 3 commits into
masterfrom
patch_add_navigation_support
Jun 25, 2026
Merged

feat(testUtils): add navigation option to grantAccessIfNeeded and imp…#29
sebastianchristopher merged 3 commits into
masterfrom
patch_add_navigation_support

Conversation

@sebastianchristopher

Copy link
Copy Markdown
Contributor

…lement cookie dialog dismissal

The original code was written for the pre-test auth stage, so assumed that the grantAccessIfNeeded should also navigate to the page. This doesn't work with this tool, which has some steps before Grant Access which get wiped if you re-navigate to the page. This PR adds support for cases where the flow is already on the correct page, but maintains backwards compatibility (don't need to touch existing tests).

Also adds another method to dismiss the new(?) cookie dialog.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Playwright helper utilities to support “grant access” flows without forcing a re-navigation (preserving in-test state), and introduces a new helper for dismissing a OneTrust cookie dialog.

Changes:

  • Add an optional { shouldNavigate } option to grantAccessIfNeeded (defaulting to true) so callers can skip page.goto(...).
  • Add dismissCookieDialog(page, timeoutMs) helper to accept cookies if the OneTrust banner/dialog appears.
  • Document the new grantAccessIfNeeded(..., { shouldNavigate: false }) usage in the README.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/testUtils.js Adds optional navigation behavior to grantAccessIfNeeded and introduces dismissCookieDialog.
README.md Documents skipping navigation when calling grantAccessIfNeeded.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/testUtils.js Outdated
Comment thread src/testUtils.js Outdated
Comment on lines +26 to +29
const { shouldNavigate = true } = options
if (shouldNavigate) {
await page.goto(toolUrl)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I probably would have made toolUrl optional, if it's not supplied then it doesn't navigate, if it's supplied then do. Generally I think it would be clearer if almost all uses of this method just did the navigate themselves as there's not much benefit of having it in this method.

Comment thread src/testUtils.js
Comment on lines +136 to +141
/**
* Dismiss the OneTrust cookie dialog by accepting cookies if the banner appears.
* @param {import('@playwright/test').Page} page - Playwright page
* @param {number} [timeoutMs=3000] - Max wait for the dialog accept button
* @returns {Promise<void>}
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if this would be better handled by https://playwright.dev/docs/api/class-page#page-add-locator-handler which allows us to just accept the dialog if it ever appears and not explicitly wait for it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this the case for the beta banner as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, I think so, not essential, I was just commenting because it was new code.

@buckett buckett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@sebastianchristopher sebastianchristopher merged commit a8108d4 into master Jun 25, 2026
2 checks passed
@sebastianchristopher sebastianchristopher deleted the patch_add_navigation_support branch June 25, 2026 12:01
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.

3 participants