Skip to content

Commit 6306300

Browse files
committed
fix(tests): poll for ClickHouse ingestion in metrics test
Replace fixed wait(3000) with the existing waitForMetricsToIncludeUsersByCountry helper. The last sign-in (mailbox-3 → CH) sometimes wasn't ingested by ClickHouse before the metrics call fired, causing the CH bucket to be missing from the response and the snapshot to fail intermittently in CI.
1 parent 82dd811 commit 6306300

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

apps/e2e/tests/backend/endpoints/api/v1/internal-metrics.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@ it("should return metrics data with users", async ({ expect }) => {
173173
backendContext.set({ mailbox: mailboxes[2], ipData: { country: "CH", ipAddress: "127.0.0.1", city: "Zurich", region: "ZH", latitude: 47.3769, longitude: 8.5417, tzIdentifier: "Europe/Zurich" } });
174174
await Auth.Otp.signIn();
175175

176-
await wait(3000); // the event log is async, so let's give it some time to be written to the DB
177-
178-
const response = await niceBackendFetch("/api/v1/internal/metrics", { accessType: 'admin' });
176+
// the event log is async; poll until ClickHouse has ingested all sign-ins (last one is mailbox-3 → CH)
177+
const response = await waitForMetricsToIncludeUsersByCountry({ countryCode: "CH", expectedCount: 1 });
179178
expect(response).toMatchSnapshot(`metrics_result_with_users`);
180179

181180
await ensureAnonymousUsersAreStillExcluded(response);

0 commit comments

Comments
 (0)