test: stabilize UI and gateway auth timing (#109257)

This commit is contained in:
Dallin Romney
2026-07-16 11:13:42 -07:00
committed by GitHub
parent b85531c62f
commit 9f0e35c233
2 changed files with 16 additions and 19 deletions
+12 -18
View File
@@ -116,25 +116,19 @@ describe("probeGateway auth integration", () => {
expect(fs.existsSync(statePath("identity", "device-auth.json"))).toBe(false);
});
describe("with cached device auth", () => {
let cachedProbeResult: Awaited<ReturnType<typeof probeGateway>>;
beforeAll(async () => {
const token = requireGatewayToken();
await seedCachedOperatorToken(["operator.read"]);
cachedProbeResult = await probeGateway({
url: `ws://127.0.0.1:${gatewayHarness.port}`,
auth: { token },
timeoutMs: 5_000,
});
it("keeps detail RPCs available for local authenticated probes with cached device auth", async () => {
const token = requireGatewayToken();
await seedCachedOperatorToken(["operator.read"]);
const result = await probeGateway({
url: `ws://127.0.0.1:${gatewayHarness.port}`,
auth: { token },
timeoutMs: 10_000,
});
it("keeps detail RPCs available for local authenticated probes with cached device auth", async () => {
expect(cachedProbeResult.ok).toBe(true);
expect(cachedProbeResult.error).toBeNull();
expectRecord(cachedProbeResult.health, "probe health");
expectRecord(cachedProbeResult.status, "probe status");
expectRecord(cachedProbeResult.configSnapshot, "probe config snapshot");
});
expect(result.ok).toBe(true);
expect(result.error).toBeNull();
expectRecord(result.health, "probe health");
expectRecord(result.status, "probe status");
expectRecord(result.configSnapshot, "probe config snapshot");
});
});
+4 -1
View File
@@ -236,9 +236,12 @@ it("gates profile usage refreshes by payload age and page visibility", async ()
pendingFiles: 1,
staleFiles: 0,
});
page.lastProfileLoadedAtMs = Date.now();
const nowMs = Date.now();
const nowSpy = vi.spyOn(Date, "now").mockReturnValue(nowMs);
page.lastProfileLoadedAtMs = nowMs;
page.scheduleCacheSettleRefresh();
expect(settleDelayMs).toBe(USAGE_PAYLOAD_TTL_MS);
nowSpy.mockRestore();
page.lastProfileLoadedAtMs = Date.now() - USAGE_PAYLOAD_TTL_MS;
visibility.mockReturnValue("hidden");