Review found the owning documentation still describing the behaviour this branch replaced, in one case stacked directly above the new docstring saying the opposite. Holding a session proves containment, not ownership, so every text that called store membership the authoritative mapping was actively misleading for the module whose wrong answer misroutes every send. Corrected in the module docstring, the resolution module's precedence description, the sync-refs helper it points at, and the sync DOCUMENTATION.md table and rules. The debug report built its authoritative value membership-first, so for exactly the scenario this branch fixes it reported the parent directory and could raise a source-disagreement alert while routing was in fact correct. It now uses the same record-first order as the resolver. The CLI timeout comment claimed the wait and provisioning windows were additive while the code took the larger of the two. The server provisions the worktree inside session creation, before it waits for the session to go idle, so they do run in sequence: the windows are now summed and the tests pin both cases.
38 lines
1.6 KiB
JavaScript
38 lines
1.6 KiB
JavaScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { resolveControlTimeoutMs } from './cli-control.js';
|
|
|
|
describe('resolveControlTimeoutMs', () => {
|
|
it('keeps the short default HTTP timeout for instant control calls', () => {
|
|
expect(resolveControlTimeoutMs({}, {})).toBeUndefined();
|
|
expect(resolveControlTimeoutMs({ wait: false, timeout: 30 }, {})).toBeUndefined();
|
|
});
|
|
|
|
it('outlives the default server wait window when wait is set', () => {
|
|
expect(resolveControlTimeoutMs({ wait: true }, {})).toBe(630_000);
|
|
});
|
|
|
|
it('derives the HTTP timeout from an explicit wait timeout in seconds', () => {
|
|
expect(resolveControlTimeoutMs({ wait: true, timeout: 30 }, {})).toBe(60_000);
|
|
});
|
|
|
|
it('never shrinks an explicitly requested HTTP timeout', () => {
|
|
expect(resolveControlTimeoutMs({ wait: true, timeout: 30 }, { timeoutMs: 5000 })).toBe(5000);
|
|
});
|
|
|
|
it('allows a worktree to be provisioned without waiting for the session', () => {
|
|
expect(resolveControlTimeoutMs({ worktree: 'feature' }, {})).toBe(120_000);
|
|
});
|
|
|
|
it('ignores a blank worktree name', () => {
|
|
expect(resolveControlTimeoutMs({ worktree: ' ' }, {})).toBeUndefined();
|
|
});
|
|
|
|
it('covers provisioning and waiting in sequence when both are requested', () => {
|
|
// The server creates the worktree before it begins waiting for the session,
|
|
// so the client window must span both rather than the longer of the two.
|
|
expect(resolveControlTimeoutMs({ wait: true, timeout: 30, worktree: 'feature' }, {})).toBe(180_000);
|
|
expect(resolveControlTimeoutMs({ wait: true, worktree: 'feature' }, {})).toBe(750_000);
|
|
});
|
|
});
|