Add phenotype cloning, failure atlas, AI court session, and clearance L0-L4
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
This commit is contained in:
38
server/web/e2e/live-stub.ts
Normal file
38
server/web/e2e/live-stub.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { APIRequestContext } from '@playwright/test';
|
||||
import { fetchFleetSecret, waitForServerHealth } from './fixtures';
|
||||
import { connectStubAgent } from './stub-agent';
|
||||
|
||||
const baseURL = process.env.AETHERFORGE_URL || 'http://127.0.0.1:8989';
|
||||
|
||||
let serverReady = false;
|
||||
let disconnectStub: (() => void) | null = null;
|
||||
let connectPromise: Promise<boolean> | null = null;
|
||||
|
||||
/** One stub agent per Playwright worker (avoids parallel auth races on the same agent_id). */
|
||||
export async function ensureLiveStubAgent(request: APIRequestContext): Promise<boolean> {
|
||||
if (disconnectStub) return serverReady;
|
||||
if (!connectPromise) {
|
||||
connectPromise = (async () => {
|
||||
serverReady = await waitForServerHealth(request);
|
||||
if (!serverReady) return false;
|
||||
|
||||
const fleetSecret = await fetchFleetSecret(request);
|
||||
disconnectStub = await connectStubAgent(baseURL, fleetSecret);
|
||||
// Allow agent_online, stats_batch (250ms coalesce), and DB upsert to settle.
|
||||
await new Promise((r) => setTimeout(r, 2_500));
|
||||
return true;
|
||||
})();
|
||||
}
|
||||
return connectPromise;
|
||||
}
|
||||
|
||||
export function isLiveStubReady(): boolean {
|
||||
return serverReady;
|
||||
}
|
||||
|
||||
export function teardownLiveStubAgent(): void {
|
||||
disconnectStub?.();
|
||||
disconnectStub = null;
|
||||
connectPromise = null;
|
||||
serverReady = false;
|
||||
}
|
||||
Reference in New Issue
Block a user