mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
test: stabilize UI and gateway auth timing (#109257)
This commit is contained in:
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user