fix: show empty work preview without invoking the Agent
This commit is contained in:
1 parent
077184aaba
commit
0167d361ed
11 files changed
+391
-15
No files matched your search
@@ -7,6 +7,26 @@ beforeEach(() => { vi.useFakeTimers(); ensure.mockReset(); });
|
||||
afterEach(() => vi.useRealTimers());
|
||||
|
||||
describe('work preview request lifecycle', () => {
|
||||
it('stops polling an empty project and checks again when the work tab is reopened', async () => {
|
||||
ensure.mockResolvedValue({ status: 'empty' });
|
||||
const onResult = vi.fn();
|
||||
const { result, rerender } = renderHook(({ enabled }) => useWorkPreview({ projectId: 'p1', enabled, onResult }), {
|
||||
initialProps: { enabled: true },
|
||||
});
|
||||
await act(async () => {});
|
||||
await act(async () => vi.advanceTimersByTimeAsync(60_000));
|
||||
expect(result.current.result).toEqual({ status: 'empty' });
|
||||
expect(onResult).toHaveBeenCalledWith({ status: 'empty' });
|
||||
expect(ensure).toHaveBeenCalledTimes(1);
|
||||
|
||||
await act(async () => rerender({ enabled: false }));
|
||||
ensure.mockResolvedValue({ status: 'ready' });
|
||||
await act(async () => rerender({ enabled: true }));
|
||||
expect(result.current.result).toEqual({ status: 'ready' });
|
||||
await act(async () => vi.advanceTimersByTimeAsync(60_000));
|
||||
expect(ensure).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('resumes a manually opened work page and ignores the older startup response', async () => {
|
||||
let finish!: (value: unknown) => void;
|
||||
ensure.mockImplementationOnce(() => new Promise((resolve) => { finish = resolve; })).mockResolvedValue({ status: 'ready' });
|
||||
|
||||
Reference in new issue
Block a user