Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions e2e/dashboard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from "@playwright/test";
import { encode } from "next-auth/jwt";
import { scrollToWidget } from "./helpers/dashboard-mocks";
import { scrollToWidget } from "./helpers/dashboard-mocks.js";

/**
* dashboard.spec.ts
Expand Down Expand Up @@ -113,7 +113,7 @@ async function injectMockSession(page: import("@playwright/test").Page) {
})
);

await page.route("**/api/goals**", (route) => {
await page.route(/\/api\/goals(\?|$)/, (route) => {
if (route.request().method() === "POST") {
return route.fulfill({
contentType: "application/json",
Expand Down Expand Up @@ -556,12 +556,14 @@ test("[Dashboard E2E] analytics widgets render once without duplicate metric req
const { min, max } = METRICS_REQUEST_BOUNDS[endpoint];
await expect
.poll(
() => {
const count = countMetricRequests(requestUrls, endpoint);
return count >= min && count <= max;
},
{ timeout: 15_000 },
() => countMetricRequests(requestUrls, endpoint),
{ timeout: 15_000 }
)
.toBe(true);
.toBeGreaterThanOrEqual(min);

expect(
countMetricRequests(requestUrls, endpoint),
`Endpoint ${endpoint} should not exceed ${max} duplicate requests`
).toBeLessThanOrEqual(max);
}
});
});
Loading