Skip to content

Commit 042e59a

Browse files
committed
test: fix flaky maint window test due to unreliable date seconds (de)serialization
1 parent 77d5634 commit 042e59a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

tests/maintenance.test.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { StatusCodes } from "http-status-codes";
22
import { Temporal } from "temporal-polyfill";
33
import { describe, expect } from "vitest";
4-
import type { AboutNode } from "#/system/system.services";
54
import { expectErrorResponse } from "./fixture/assertions";
65
import { createTestFixtureExtension } from "./fixture/it";
76

@@ -68,14 +67,17 @@ describe("node maintenance window management", () => {
6867
const response = await admin.about();
6968
expect(response.status).toBe(StatusCodes.OK);
7069

71-
const result = (await response.json()) as AboutNode;
72-
expect(result).toHaveProperty("maintenance");
73-
expect(result?.maintenance?.start).toEqual(
74-
maintenanceWindow.start.toISOString(),
75-
);
76-
expect(result?.maintenance?.end).toEqual(
77-
maintenanceWindow.end.toISOString(),
78-
);
70+
const result = (await response.json()) as {
71+
maintenance: { start: string; end: string };
72+
};
73+
74+
const { start: expectedStart, end: expectedEnd } = maintenanceWindow;
75+
76+
const actualStart = new Date(result.maintenance.start).getUTCSeconds();
77+
expect(actualStart).toEqual(expectedStart.getUTCSeconds());
78+
79+
const actualEnd = new Date(result.maintenance.end).getUTCSeconds();
80+
expect(actualEnd).toEqual(expectedEnd.getUTCSeconds());
7981
});
8082

8183
it("can delete a maintenance window", async ({ expect, admin }) => {

0 commit comments

Comments
 (0)