Files
maestro/ui/src/hooks/useJobStream.test.ts
T
oss-sync b1292e34b2
CI / build-and-test (push) Has been cancelled
sync: update from private repo (edc775f2)
2026-07-06 01:04:12 +00:00

68 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, it, expect } from 'vitest';
import { reduceDelegateStreams } from './useJobStream';
describe('reduceDelegateStreams originJobId contract', () => {
it('lifecycle の originJobId を run に紐づける', () => {
let s = reduceDelegateStreams(
{},
{
type: 'delegate_lifecycle',
delegateRunId: 'r1',
originJobId: 'sub1',
status: 'running',
depth: 1,
description: 'x',
},
);
s = reduceDelegateStreams(s, {
type: 'delegate_text_delta',
delegateRunId: 'r1',
text: 'hello',
});
const run = s['r1'];
expect(run).toBeDefined();
expect(run.originJobId).toBe('sub1');
expect(run.text).toContain('hello');
});
it('originJobId が無い lifecycle は originJobId が null のまま', () => {
const s = reduceDelegateStreams(
{},
{
type: 'delegate_lifecycle',
delegateRunId: 'r2',
status: 'running',
depth: 1,
description: 'parent',
},
);
// originJobId は undefined か null — どちらも null-ish として扱われる
expect(s['r2'].originJobId == null).toBe(true);
});
it('originJobId は text_delta / tool イベントを経ても引き継がれる', () => {
let s = reduceDelegateStreams(
{},
{
type: 'delegate_lifecycle',
delegateRunId: 'r3',
originJobId: 'sub2',
status: 'running',
depth: 1,
description: 'y',
},
);
s = reduceDelegateStreams(s, {
type: 'delegate_tool',
delegateRunId: 'r3',
toolName: 'WebFetch',
});
s = reduceDelegateStreams(s, {
type: 'delegate_text_delta',
delegateRunId: 'r3',
text: 'result',
});
expect(s['r3'].originJobId).toBe('sub2');
});
});