test: fix broken suites
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import { unlink, writeFileSync } from "fs";
|
||||
import { mkdtempSync, unlink, writeFileSync } from "fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
|
||||
// The route consults admin-dashboard overrides (ADMIN_CONFIG_DIR, default
|
||||
// data/admin) before env vars. Point it at an empty temp dir so local admin
|
||||
// state on the developer's machine can't leak into these env-driven
|
||||
// assertions. Must happen before the first GET, because the config manager
|
||||
// singleton loads the directory once and caches it.
|
||||
process.env.ADMIN_CONFIG_DIR = mkdtempSync(path.join(tmpdir(), 'bw-config-route-'));
|
||||
|
||||
// Mock NextResponse before importing the route
|
||||
vi.mock('next/server', () => ({
|
||||
NextResponse: {
|
||||
|
||||
@@ -302,6 +302,11 @@ describe('JMAPClient resilience', () => {
|
||||
});
|
||||
|
||||
it('does not mark the connection lost or reconnect repeatedly while rate limited', async () => {
|
||||
// The file-level shouldAdvanceTime lets fake time creep forward with
|
||||
// the wall clock, which can fire the 30s keep-alive an extra time on a
|
||||
// slow or loaded machine. This test counts pings, so pin the clock and
|
||||
// advance it explicitly.
|
||||
vi.useFakeTimers({ shouldAdvanceTime: false });
|
||||
const client = await createConnectedClient();
|
||||
const callback = vi.fn();
|
||||
client.onConnectionChange(callback);
|
||||
|
||||
Reference in New Issue
Block a user