fix: e2e tests#348
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThis PR centralizes Playwright cookie-consent into a helper and fixtures module, loads ChangesPlaywright Test Infrastructure Consolidation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/voting.spec.ts (1)
98-109:⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
should display progress bar for success rateis now a duplicate ofshould display success rate percentage and voter count.After this change, both tests make exactly the same two assertions (
/\d+%/visible and/verified by \d+ users/ivisible) but with different names. The "progress bar" test no longer verifies the progress bar element itself.Either restore the structural assertion (e.g. a
role="progressbar"or width-bearing element), or remove the redundant test to avoid false confidence in coverage.♻️ Suggested fix — restore the progress bar element assertion
test('should display progress bar for success rate', async ({ page }) => { const listingsPage = new ListingsPage(page) await listingsPage.goto() await expect(listingsPage.listingItems.first()).toBeVisible() await listingsPage.clickFirstListing() await page.waitForLoadState('domcontentloaded') - await expect(page.getByText(/\d+%/)).toBeVisible() - await expect(page.getByText(/verified by \d+ users/i)).toBeVisible() + const progressBar = page.locator('[role="progressbar"]') + await expect(progressBar).toBeVisible() })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/voting.spec.ts` around lines 98 - 109, The test "should display progress bar for success rate" duplicates "should display success rate percentage and voter count" by only asserting the percentage and voter count; update the test in tests/voting.spec.ts to either remove it or, preferably, restore a structural assertion for the progress bar: after navigating with ListingsPage and clickFirstListing (and the existing expect on percentage and voter count), add an assertion targeting the progress bar element (e.g., getByRole('progressbar') or a selector for the progress-bar element / width-bearing element) to verify it exists and/or has a non-zero width/style reflecting the percentage; keep the existing ListingsPage/listingItems usage and page.waitForLoadState calls intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@tests/voting.spec.ts`:
- Around line 98-109: The test "should display progress bar for success rate"
duplicates "should display success rate percentage and voter count" by only
asserting the percentage and voter count; update the test in
tests/voting.spec.ts to either remove it or, preferably, restore a structural
assertion for the progress bar: after navigating with ListingsPage and
clickFirstListing (and the existing expect on percentage and voter count), add
an assertion targeting the progress bar element (e.g., getByRole('progressbar')
or a selector for the progress-bar element / width-bearing element) to verify it
exists and/or has a non-zero width/style reflecting the percentage; keep the
existing ListingsPage/listingItems usage and page.waitForLoadState calls intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 855596ed-ef94-47c0-b3ce-c88ecb9f3ade
📒 Files selected for processing (40)
playwright.config.tssrc/components/ui/form/MultiSelect.tsxtests/accessibility.spec.tstests/admin-dashboard.spec.tstests/admin-permissions.spec.tstests/admin-reports.spec.tstests/admin-users.spec.tstests/android-downloads.spec.tstests/auth.setup.tstests/auth.spec.tstests/badge-system.spec.tstests/browsing.spec.tstests/commenting.spec.tstests/custom-fields.spec.tstests/error-handling.spec.tstests/filtering.spec.tstests/fixtures.tstests/forms.spec.tstests/full-listing-flow.spec.tstests/game-management.spec.tstests/helpers/cookie-consent.tstests/helpers/data-factory.tstests/helpers/test-config.tstests/igdb-search.spec.tstests/listing-approval.spec.tstests/listings-success-rate-sorting.spec.tstests/navigation.spec.tstests/notification-system.spec.tstests/pages/BasePage.tstests/pagination.spec.tstests/pc-listings.spec.tstests/pc-voting.spec.tstests/performance.spec.tstests/router-coverage.spec.tstests/search.spec.tstests/trust-integration.spec.tstests/trust-system.spec.tstests/user-flows.spec.tstests/user-moderation.spec.tstests/voting.spec.ts
💤 Files with no reviewable changes (2)
- tests/helpers/test-config.ts
- tests/pages/BasePage.ts
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
prisma/seeders/usersSeeder.ts (1)
159-167:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFail the seeder if any user cannot be synchronized.
This catch only logs and continues, so the script can finish with missing seed users and still print
Users seeding completed. In e2e setup that turns a deterministic seeding failure into a much harder-to-diagnose test failure later.Suggested fix
+ const failedUsers: string[] = [] + for (const userData of users) { try { // ... } catch (error) { + failedUsers.push(userData.email) console.error(`❌ Failed to seed user ${userData.email}:`, error) } } + + if (failedUsers.length > 0) { + throw new Error(`Failed to seed users: ${failedUsers.join(', ')}`) + } console.info('✅ Users seeding completed')🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@prisma/seeders/usersSeeder.ts` around lines 159 - 167, The seeder currently swallows errors in the catch block that prints "❌ Failed to seed user ..." so the script can falsely report completion; modify the catch inside the user seeding loop (the try/catch that logs `console.error(\`❌ Failed to seed user ${userData.email}:\`, error)`) to re-throw the error or call process.exit(1) after logging so the seeding process fails fast when any user synchronization fails, ensuring the script does not proceed to the "Users seeding completed" messages on error.
🧹 Nitpick comments (1)
src/components/ui/form/MultiSelect.tsx (1)
165-167: ⚡ Quick winToggle-button close path skips
closeDropdown, leaving a stale search query.
onClick={() => setIsOpen(!isOpen)}does not clearsearchQuerywhen closing, so if the user types a search and then clicks the trigger to dismiss, the filter persists. The next open will render the pre-filtered list.handleClickOutsideand the newcloseDropdown(Escape) both clear the query — this is the only path that doesn't.♻️ Proposed fix
- onClick={() => setIsOpen(!isOpen)} + onClick={() => (isOpen ? closeDropdown() : setIsOpen(true))}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/ui/form/MultiSelect.tsx` around lines 165 - 167, The toggle button's onClick only flips isOpen and misses clearing searchQuery; update the handler so that when the dropdown is open it calls closeDropdown() (which clears the query and handles Escape/outside-close behavior) and when closed it opens via setIsOpen(true); replace the existing onClick={() => setIsOpen(!isOpen)} with logic that invokes closeDropdown() on the close path and setIsOpen(true) on the open path so searchQuery is not left stale.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@prisma/seeders/usersSeeder.ts`:
- Line 104: Remove the sensitive console.info that prints DEFAULT_SEED_PASSWORD;
instead log a non-sensitive message (or nothing) indicating that seed users were
created. Locate the console.info call referencing DEFAULT_SEED_PASSWORD in
usersSeeder (the line that prints "🔑 Default password for all seed users:
${DEFAULT_SEED_PASSWORD}") and replace it with a generic informational message
(e.g., "Default seed users created") or remove the log entirely so the actual
password is not written to logs.
- Around line 129-137: When reconciling existing users, update all mutable Clerk
fields in the single clerk.users.updateUser call (include username, firstName,
lastName, password, skipPasswordChecks and publicMetadata.role) instead of only
password, and ensure username uniqueness is respected; remove or consolidate the
separate clerk.users.updateUserMetadata call. Also make the Prisma update
operation for the existing user include profileImage (matching the create
branch) so Prisma stays consistent with Clerk. Target symbols:
clerk.users.updateUser, clerk.users.updateUserMetadata (remove/merge),
DEFAULT_SEED_PASSWORD, and the Prisma update block that currently omits
profileImage.
---
Outside diff comments:
In `@prisma/seeders/usersSeeder.ts`:
- Around line 159-167: The seeder currently swallows errors in the catch block
that prints "❌ Failed to seed user ..." so the script can falsely report
completion; modify the catch inside the user seeding loop (the try/catch that
logs `console.error(\`❌ Failed to seed user ${userData.email}:\`, error)`) to
re-throw the error or call process.exit(1) after logging so the seeding process
fails fast when any user synchronization fails, ensuring the script does not
proceed to the "Users seeding completed" messages on error.
---
Nitpick comments:
In `@src/components/ui/form/MultiSelect.tsx`:
- Around line 165-167: The toggle button's onClick only flips isOpen and misses
clearing searchQuery; update the handler so that when the dropdown is open it
calls closeDropdown() (which clears the query and handles Escape/outside-close
behavior) and when closed it opens via setIsOpen(true); replace the existing
onClick={() => setIsOpen(!isOpen)} with logic that invokes closeDropdown() on
the close path and setIsOpen(true) on the open path so searchQuery is not left
stale.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9bda30de-b0be-494a-a64c-2077ae30dada
📒 Files selected for processing (5)
prisma/seeders/usersSeeder.tssrc/components/ui/form/MultiSelect.test.tsxsrc/components/ui/form/MultiSelect.tsxsrc/server/api/routers/pcListings.test.tstests/filtering.spec.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/filtering.spec.ts (1)
10-11: ⚡ Quick winConsider testing keyboard-based dropdown dismissal.
The function now explicitly closes the dropdown by re-clicking the filter button and verifies it closes. While this tests the click-to-close path effectively, the PR summary mentions "MultiSelect Escape handling" but this helper doesn't verify keyboard-based dismissal (e.g., pressing Escape).
Consider adding a complementary test helper or test case that verifies dropdown closing via the Escape key to ensure both interaction patterns work correctly.
Optional: Example keyboard-based dismissal test
async function selectFirstFilterOptionWithKeyboard(page: Page, filterButton: Locator) { await filterButton.click() const firstOption = page.locator('label:has(input[type="checkbox"])').first() await expect(firstOption).toBeVisible() await firstOption.click() await page.keyboard.press('Escape') await expect(firstOption).toBeHidden() }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/filtering.spec.ts` around lines 10 - 11, Add a complementary keyboard-dismissal test helper that mirrors the click-to-close flow but presses Escape to close: in the tests use the same filterButton and firstOption locators (e.g., create a helper named selectFirstFilterOptionWithKeyboard or a test case) to click filterButton, assert firstOption is visible, select the option, call page.keyboard.press('Escape'), then assert firstOption is hidden; this verifies MultiSelect Escape handling in addition to the existing click-to-close check.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/helpers/data-factory.ts`:
- Around line 208-210: ensureApprovedPcListing currently uses
approveFirstPendingListing which can approve an unrelated row; replace that flow
with a targeted approver that finds the row by the created listing's path (e.g.,
implement approvePendingPcListingByPath) and use it from
ensureApprovedPcListing: navigate to the approvals page, wait for loading to
finish, locate the specific tbody tr that contains the listing's path/slug (use
the last path segment from detailUrl), assert the row is visible, click its
approve button, confirm the dialog and wait for it to close so the exact listing
is approved before returning detailUrl.
---
Nitpick comments:
In `@tests/filtering.spec.ts`:
- Around line 10-11: Add a complementary keyboard-dismissal test helper that
mirrors the click-to-close flow but presses Escape to close: in the tests use
the same filterButton and firstOption locators (e.g., create a helper named
selectFirstFilterOptionWithKeyboard or a test case) to click filterButton,
assert firstOption is visible, select the option, call
page.keyboard.press('Escape'), then assert firstOption is hidden; this verifies
MultiSelect Escape handling in addition to the existing click-to-close check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f7ed8a3e-b2df-400e-b437-b121517b2a81
📒 Files selected for processing (12)
src/components/ui/SuccessRateBar.tsxsrc/components/ui/VoteButtons.tsxtests/data-setup.spec.tstests/filtering.spec.tstests/fixtures.tstests/helpers/data-factory.tstests/notification-system.spec.tstests/pages/AuthPage.tstests/pagination.spec.tstests/pc-voting.spec.tstests/trust-integration.spec.tstests/voting.spec.ts
✅ Files skipped from review due to trivial changes (4)
- src/components/ui/SuccessRateBar.tsx
- tests/pages/AuthPage.ts
- src/components/ui/VoteButtons.tsx
- tests/notification-system.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/fixtures.ts
- tests/pagination.spec.ts
…ng user metadata handling
…nd improving test logic
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/trust-integration.spec.ts (1)
108-125:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUse a fresh approved PC listing for the upvote-path test.
ensureApprovedPcListing(browser)can return an older approved listing thatuser.jsonhas already voted on. In that case, the click here removes the vote instead of creating an upvote, so this test no longer guarantees theUPVOTEaction it asserts.Suggested fix
test('voting on a PC listing records UPVOTE trust action', async ({ browser }) => { - const pcListingUrl = await ensureApprovedPcListing(browser) + let pcListingUrl = '' + + await withContext(browser, 'tests/.auth/user.json', async (page) => { + pcListingUrl = await createPcListing(page) + }) + + await withContext(browser, 'tests/.auth/super_admin.json', async (page) => { + await approvePendingPcListingByUrl(page, pcListingUrl) + }) await withContext(browser, 'tests/.auth/user.json', async (page) => { await page.goto(pcListingUrl) await page.waitForLoadState('domcontentloaded') const confirmButton = page.getByRole('button', { name: /confirm/i }) await expect(confirmButton).toBeVisible() - const wasPressed = await confirmButton.getAttribute('aria-pressed') - await confirmButton.click() - - await expect(confirmButton).toHaveAttribute( - 'aria-pressed', - wasPressed === 'true' ? 'false' : 'true', - ) + await confirmButton.click() + await expect(confirmButton).toHaveAttribute('aria-pressed', 'true') })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/trust-integration.spec.ts` around lines 108 - 125, The test "voting on a PC listing records UPVOTE trust action" uses ensureApprovedPcListing(browser) which can return a listing the test user has already voted on, so the click may remove a vote instead of creating an UPVOTE; change the test to use a fresh, unvoted approved listing (either by adding a new helper like ensureUnvotedApprovedPcListing or adding a "fresh" flag to ensureApprovedPcListing) that creates a new listing, approves it, and returns its URL, or alternatively assert and reset the initial state by ensuring confirmButton has aria-pressed === 'false' before clicking; update the call in this test to use the new helper or state-reset logic so the click always creates an UPVOTE.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/listings-success-rate-sorting.spec.ts`:
- Around line 13-15: The current dismissal logic masks real locator/strictness
errors by using .catch(() => false) on the isVisible check; update the
dismissBanner locator (the variable dismissBanner defined earlier) to use
.first() so it targets a single element, then remove the .catch(() => false) and
keep the conditional as if (await dismissBanner.isVisible({ timeout: 1000 })) {
await dismissBanner.click() } so strict-mode locator issues will surface while
still safely handling an optional banner.
---
Outside diff comments:
In `@tests/trust-integration.spec.ts`:
- Around line 108-125: The test "voting on a PC listing records UPVOTE trust
action" uses ensureApprovedPcListing(browser) which can return a listing the
test user has already voted on, so the click may remove a vote instead of
creating an UPVOTE; change the test to use a fresh, unvoted approved listing
(either by adding a new helper like ensureUnvotedApprovedPcListing or adding a
"fresh" flag to ensureApprovedPcListing) that creates a new listing, approves
it, and returns its URL, or alternatively assert and reset the initial state by
ensuring confirmButton has aria-pressed === 'false' before clicking; update the
call in this test to use the new helper or state-reset logic so the click always
creates an UPVOTE.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d5cb86cd-ed05-406c-b913-b0d9d9ce2d08
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (23)
.github/workflows/e2e-tests.ymlpackage.jsonprisma/seeders/usersSeeder.tssrc/components/ui/form/MultiSelect.test.tsxtests/admin-reports.spec.tstests/admin-users.spec.tstests/auth.setup.tstests/browsing.spec.tstests/commenting.spec.tstests/data-setup.spec.tstests/error-handling.spec.tstests/filtering.spec.tstests/fixtures.tstests/global.setup.tstests/helpers/data-factory.tstests/listings-success-rate-sorting.spec.tstests/notification-system.spec.tstests/pages/AuthPage.tstests/pages/GamesPage.tstests/pages/ListingsPage.tstests/pagination.spec.tstests/router-coverage.spec.tstests/trust-integration.spec.ts
💤 Files with no reviewable changes (4)
- tests/global.setup.ts
- tests/pages/ListingsPage.ts
- .github/workflows/e2e-tests.yml
- tests/pages/GamesPage.ts
✅ Files skipped from review due to trivial changes (3)
- tests/error-handling.spec.ts
- tests/router-coverage.spec.ts
- tests/pages/AuthPage.ts
🚧 Files skipped from review as they are similar to previous changes (10)
- tests/browsing.spec.ts
- tests/commenting.spec.ts
- tests/auth.setup.ts
- tests/fixtures.ts
- tests/notification-system.spec.ts
- tests/pagination.spec.ts
- tests/admin-users.spec.ts
- tests/admin-reports.spec.ts
- src/components/ui/form/MultiSelect.test.tsx
- prisma/seeders/usersSeeder.ts
Description
Fixes # (issue)
Type of change
How Has This Been Tested?
Screenshots (if applicable)
Checklist
Notes for reviewers
Summary by CodeRabbit
New Features
Tests
Chores