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

✅ Add global setup for cookie acceptance in E2E tests #703

Merged
merged 1 commit into from
Feb 10, 2025

Conversation

sasamuku
Copy link
Member

@sasamuku sasamuku commented Feb 10, 2025

Add global setup for cookie acceptance in E2E tests.

Related Issue

Testing

Other Information

Copy link

changeset-bot bot commented Feb 10, 2025

⚠️ No Changeset found

Latest commit: 55a5dee

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Error Handling

The cookie button click silently catches and ignores errors. Should validate if this is the desired behavior or if errors should be handled differently.

await cookieButton.click({ timeout: 3000, force: true }).catch(() => {})
Timeout Value

The hardcoded 3000ms timeout for cookie button click may need to be configurable or aligned with other timeout values in the config.

await cookieButton.click({ timeout: 3000, force: true }).catch(() => {})

Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Validate element before force clicking

Verify the cookie button exists before attempting to click it to prevent
potential force-click issues on non-existent elements.

frontend/packages/e2e/global-setup.ts [9-12]

 const cookieButton = page.getByRole('button', {
   name: 'Accept All Cookies',
 })
-await cookieButton.click({ timeout: 3000, force: true }).catch(() => {})
+if (await cookieButton.isVisible())
+  await cookieButton.click({ timeout: 3000 }).catch(() => {})
  • Apply this suggestion
Suggestion importance[1-10]: 8

__

Why: Checking element visibility before clicking and removing force:true is a more robust approach that prevents potential flaky tests and better handles cases when the cookie button is not present.

Medium
General
Add error handling for setup failures

Add error handling and logging for the cookie button click failure. The current
.catch(() => {}) silently ignores failures which could mask setup issues.

frontend/packages/e2e/global-setup.ts [12]

-await cookieButton.click({ timeout: 3000, force: true }).catch(() => {})
+await cookieButton.click({ timeout: 3000, force: true }).catch((error) => {
+  console.warn('Cookie acceptance button not found or not clickable:', error.message);
+})
  • Apply this suggestion
Suggestion importance[1-10]: 7

__

Why: Adding proper error logging for cookie button click failures would help debug test setup issues instead of silently ignoring them. This is important for test maintainability and troubleshooting.

Medium

Copy link
Member

@MH4GF MH4GF left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏻

@MH4GF MH4GF added this pull request to the merge queue Feb 10, 2025
Merged via the queue into main with commit 43cd9fa Feb 10, 2025
15 checks passed
@MH4GF MH4GF deleted the global_setup_for_e2e branch February 10, 2025 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants