Bug Description
In the deletion test ([Goals E2E] deleting a goal removes it from the list), the "/api/goals" and "/api/goals/" wildcard route patterns inadvertently intercept requests meant for /api/goals/sync. Because Playwright evaluates routes in reverse order of registration (last registered takes precedence), these wildcards run before the specific /api/goals/sync mock set up in setupGoalsMocks.
When the frontend fires a POST request to /api/goals/sync, the "/api/goals/" wildcard catches it. Because the method is POST—bypassing the DELETE and PATCH conditional blocks—the handler defaults to returning route.fulfill({ status: 204, body: "" }). The frontend application then attempts to parse this empty 204 response as JSON (expecting { ok: true, last_synced_at: ... }), which throws a JSON parsing exception, crashing the widget and failing the test.
Steps to Reproduce
Run the Playwright test "deleting a goal removes it from the list".
The application mounts and automatically dispatches a POST request to /api/goals/sync to synchronize user goals.
The newly registered Playwright wildcard route "/api/goals/" aggressively intercepts this request because it matches the wildcard pattern and has higher precedence than the original setupGoalsMocks mock.
The handler evaluates the HTTP method. Since it's POST (not DELETE or PATCH), it executes the fallback catch-all: return route.fulfill({ status: 204, body: "" }).
The frontend fetch client attempts to parse the empty response body as JSON, resulting in an unhandled exception that interrupts the DOM rendering and causes the visibility assertions to time out.
Affected Area
Other
Screenshots
No response
Browser & OS
No response
Environment
None
Additional Context
No response
Bug Description
In the deletion test ([Goals E2E] deleting a goal removes it from the list), the "/api/goals" and "/api/goals/" wildcard route patterns inadvertently intercept requests meant for /api/goals/sync. Because Playwright evaluates routes in reverse order of registration (last registered takes precedence), these wildcards run before the specific /api/goals/sync mock set up in setupGoalsMocks.
When the frontend fires a POST request to /api/goals/sync, the "/api/goals/" wildcard catches it. Because the method is POST—bypassing the DELETE and PATCH conditional blocks—the handler defaults to returning route.fulfill({ status: 204, body: "" }). The frontend application then attempts to parse this empty 204 response as JSON (expecting { ok: true, last_synced_at: ... }), which throws a JSON parsing exception, crashing the widget and failing the test.
Steps to Reproduce
Run the Playwright test "deleting a goal removes it from the list".
The application mounts and automatically dispatches a POST request to /api/goals/sync to synchronize user goals.
The newly registered Playwright wildcard route "/api/goals/" aggressively intercepts this request because it matches the wildcard pattern and has higher precedence than the original setupGoalsMocks mock.
The handler evaluates the HTTP method. Since it's POST (not DELETE or PATCH), it executes the fallback catch-all: return route.fulfill({ status: 204, body: "" }).
The frontend fetch client attempts to parse the empty response body as JSON, resulting in an unhandled exception that interrupts the DOM rendering and causes the visibility assertions to time out.
Affected Area
Other
Screenshots
No response
Browser & OS
No response
Environment
None
Additional Context
No response