mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-21 04:10:47 +02:00
add gstack 2 parity and lifecycle gates
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
|
||||
import { describe, test, expect, beforeAll, afterAll } from 'bun:test';
|
||||
import { BrowserManager } from '../../browse/src/browser-manager';
|
||||
import { handleReadCommand } from '../../browse/src/read-commands';
|
||||
import { handleWriteCommand } from '../../browse/src/write-commands';
|
||||
import { handleReadCommand as dispatchReadCommand } from '../../browse/src/read-commands';
|
||||
import { handleWriteCommand as dispatchWriteCommand } from '../../browse/src/write-commands';
|
||||
import { generateCompareHtml } from '../src/compare';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
@@ -28,6 +28,14 @@ let tmpDir: string;
|
||||
let boardHtmlPath: string;
|
||||
let serverState: string;
|
||||
|
||||
function handleReadCommand(command: string, args: string[]) {
|
||||
return dispatchReadCommand(command, args, bm.getActiveSession(), bm);
|
||||
}
|
||||
|
||||
function handleWriteCommand(command: string, args: string[]) {
|
||||
return dispatchWriteCommand(command, args, bm.getActiveSession(), bm);
|
||||
}
|
||||
|
||||
function createTestPng(filePath: string): void {
|
||||
const png = Buffer.from(
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/58BAwAI/AL+hc2rNAAAAABJRU5ErkJggg==',
|
||||
@@ -121,10 +129,10 @@ beforeAll(async () => {
|
||||
await bm.launch();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
afterAll(async () => {
|
||||
try { server.stop(); } catch {}
|
||||
try { await bm.close(1000); } catch {}
|
||||
fs.rmSync(tmpDir, { recursive: true, force: true });
|
||||
setTimeout(() => process.exit(0), 500);
|
||||
});
|
||||
|
||||
// ─── The critical test: browser click → file on disk ─────────────
|
||||
|
||||
@@ -82,8 +82,12 @@ describe("generateVariant Retry-After handling", () => {
|
||||
expect(result.success).toBe(true);
|
||||
expect(calls.length).toBe(2);
|
||||
const gap = calls[1].ts - calls[0].ts;
|
||||
expect(gap).toBeGreaterThanOrEqual(2500);
|
||||
expect(gap).toBeLessThan(4500);
|
||||
// HTTP-date has whole-second precision, so a value created "3 seconds
|
||||
// from now" encodes an actual delay between 2s and 3s. Compare against
|
||||
// the encoded deadline instead of a phase-dependent fixed 2.5s floor.
|
||||
const encodedWait = Date.parse(future) - calls[0].ts;
|
||||
expect(gap).toBeGreaterThanOrEqual(encodedWait - 150);
|
||||
expect(gap).toBeLessThan(encodedWait + 1000);
|
||||
});
|
||||
|
||||
test("invalid Retry-After (alphanumeric): falls through to exponential", async () => {
|
||||
|
||||
Reference in New Issue
Block a user