fix(ui): update HookStatusDisplay tests for extension visibility and refactor to stable pattern

This commit is contained in:
Keith Guerin
2026-03-20 15:07:34 -07:00
parent 0f50e07840
commit 3bdda2d9eb

View File

@@ -18,12 +18,10 @@ describe('<HookStatusDisplay />', () => {
const props = {
activeHooks: [{ name: 'test-hook', eventName: 'BeforeAgent' }],
};
const { lastFrame, waitUntilReady, unmount } = render(
<HookStatusDisplay {...props} />,
);
await waitUntilReady();
expect(lastFrame()).toMatchSnapshot();
unmount();
const result = render(<HookStatusDisplay {...props} />);
await result.waitUntilReady();
expect(result.lastFrame()).toMatchSnapshot();
result.unmount();
});
it('should render multiple executing hooks', async () => {
@@ -33,12 +31,10 @@ describe('<HookStatusDisplay />', () => {
{ name: 'h2', eventName: 'BeforeAgent' },
],
};
const { lastFrame, waitUntilReady, unmount } = render(
<HookStatusDisplay {...props} />,
);
await waitUntilReady();
expect(lastFrame()).toMatchSnapshot();
unmount();
const result = render(<HookStatusDisplay {...props} />);
await result.waitUntilReady();
expect(result.lastFrame()).toMatchSnapshot();
result.unmount();
});
it('should render sequential hook progress', async () => {
@@ -47,36 +43,30 @@ describe('<HookStatusDisplay />', () => {
{ name: 'step', eventName: 'BeforeAgent', index: 1, total: 3 },
],
};
const { lastFrame, waitUntilReady, unmount } = render(
<HookStatusDisplay {...props} />,
);
await waitUntilReady();
expect(lastFrame()).toMatchSnapshot();
unmount();
const result = render(<HookStatusDisplay {...props} />);
await result.waitUntilReady();
expect(result.lastFrame()).toMatchSnapshot();
result.unmount();
});
it('should return empty string if no active hooks', async () => {
const props = { activeHooks: [] };
const { lastFrame, waitUntilReady, unmount } = render(
<HookStatusDisplay {...props} />,
);
await waitUntilReady();
expect(lastFrame({ allowEmpty: true })).toBe('');
unmount();
const result = render(<HookStatusDisplay {...props} />);
await result.waitUntilReady();
expect(result.lastFrame({ allowEmpty: true })).toBe('');
result.unmount();
});
it('should show generic message when only system/extension hooks are active', async () => {
it('should show generic message when only system hooks are active', async () => {
const props = {
activeHooks: [
{ name: 'ext-hook', eventName: 'BeforeAgent', source: 'extensions' },
{ name: 'sys-hook', eventName: 'BeforeAgent', source: 'system' },
],
};
const { lastFrame, waitUntilReady, unmount } = render(
<HookStatusDisplay {...props} />,
);
await waitUntilReady();
expect(lastFrame()).toContain('Working...');
unmount();
const result = render(<HookStatusDisplay {...props} />);
await result.waitUntilReady();
expect(result.lastFrame()).toContain('Working...');
result.unmount();
});
it('matches SVG snapshot for single hook', async () => {
@@ -85,9 +75,9 @@ describe('<HookStatusDisplay />', () => {
{ name: 'test-hook', eventName: 'BeforeAgent', source: 'user' },
],
};
const renderResult = render(<HookStatusDisplay {...props} />);
await renderResult.waitUntilReady();
await expect(renderResult).toMatchSvgSnapshot();
renderResult.unmount();
const result = render(<HookStatusDisplay {...props} />);
await result.waitUntilReady();
await expect(result).toMatchSvgSnapshot();
result.unmount();
});
});