Skip to content

[BUG] Fix ESM import resolution, route shadowing, and polling timeout anti-pattern #3311

Description

@rudrakshtank

Bug Description

There are three interconnected issues in this test file that cause test flakiness, poor debugging experiences, and execution failures:

ESM Import Error: The import for scrollToWidget from ./helpers/dashboard-mocks lacks the .js extension. In strictly-typed Next.js/ESM environments, this triggers an ERR_MODULE_NOT_FOUND error.

Route Shadowing: The wildcard route **/api/goals** is registered after **/api/goals/sync**. Because Playwright evaluates routes in reverse order of registration, the broader wildcard intercepts sync requests. It returns a 201 Created with { ok: true } instead of the expected payload containing last_synced_at, potentially crashing the dashboard's goal synchronization logic.

Polling Timeout Anti-Pattern: In the duplicate metrics test, the expect.poll assertion evaluates a boolean condition (count >= min && count <= max). If the application accidentally dispatches duplicate requests causing count to exceed max, the assertion returns false. Instead of failing immediately to indicate the upper bound was breached, Playwright polls aimlessly for 15 seconds before timing out with an unhelpful Expected: true, Received: false message.

Steps to Reproduce

Run the Playwright test suite in an ES Modules environment; the test runner crashes on the missing .js extension.

Load the dashboard so the app automatically triggers a POST /api/goals/sync. The /api/goals wildcard catches it, stripping the last_synced_at field and causing frontend hydration or logic errors.

If an analytics widget mounts twice, triggering (for example) 3 requests to /api/metrics/prs (where the max bound is 2), the final test loop hangs for 15 seconds instead of correctly and immediately reporting that 3 requests exceeded the maximum of 2.

Affected Area

Other

Screenshots

No response

Browser & OS

No response

Environment

None

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggssoc:assignedGSSoC: Issue assigned to a contributorneeds-triageNeeds maintainer triage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions