Skip to content

Commit 117b224

Browse files
committed
Add connection health test coverage
- add react test renderer types for the web test suite - align connection health tests with numeric timestamps and stable listener iteration
1 parent 5ff23dc commit 117b224

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@types/babel__core": "^7.20.5",
6060
"@types/react": "^19.0.0",
6161
"@types/react-dom": "^19.0.0",
62+
"@types/react-test-renderer": "^19.0.0",
6263
"@vitejs/plugin-react": "^6.0.0",
6364
"@vitest/browser-playwright": "^4.0.18",
6465
"babel-plugin-react-compiler": "^19.0.0-beta-e552027-20250112",

apps/web/src/hooks/useConnectionHealth.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function HookHarness() {
4242

4343
function emitTransportState(nextState: TransportState) {
4444
currentState = nextState;
45-
for (const listener of [...transportStateListeners]) {
45+
for (const listener of new Set(transportStateListeners)) {
4646
listener(nextState);
4747
}
4848
}
@@ -129,8 +129,8 @@ describe("useConnectionHealth", () => {
129129

130130
const refreshedMetrics: ConnectionMetrics = {
131131
reconnectCount: 1,
132-
lastConnectedAt: "2026-04-09T20:00:00.000Z",
133-
lastDisconnectedAt: "2026-04-09T19:59:00.000Z",
132+
lastConnectedAt: Date.parse("2026-04-09T20:00:00.000Z"),
133+
lastDisconnectedAt: Date.parse("2026-04-09T19:59:00.000Z"),
134134
latencyMs: 9,
135135
uptimeMs: 8_000,
136136
};
@@ -149,8 +149,8 @@ describe("useConnectionHealth", () => {
149149

150150
const polledMetrics: ConnectionMetrics = {
151151
reconnectCount: 2,
152-
lastConnectedAt: "2026-04-09T20:05:00.000Z",
153-
lastDisconnectedAt: "2026-04-09T20:04:30.000Z",
152+
lastConnectedAt: Date.parse("2026-04-09T20:05:00.000Z"),
153+
lastDisconnectedAt: Date.parse("2026-04-09T20:04:30.000Z"),
154154
latencyMs: 4,
155155
uptimeMs: 13_000,
156156
};
@@ -177,8 +177,8 @@ describe("useConnectionHealth", () => {
177177

178178
const reconnectingMetrics: ConnectionMetrics = {
179179
reconnectCount: 3,
180-
lastConnectedAt: "2026-04-09T20:10:00.000Z",
181-
lastDisconnectedAt: "2026-04-09T20:10:05.000Z",
180+
lastConnectedAt: Date.parse("2026-04-09T20:10:00.000Z"),
181+
lastDisconnectedAt: Date.parse("2026-04-09T20:10:05.000Z"),
182182
latencyMs: null,
183183
uptimeMs: 0,
184184
};

bun.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)