Skip to content

Commit 7b20f2d

Browse files
committed
test(app-shell): read the launcher entries through an effect callback, not a reassigned outer variable
Lint UI refused the hook test's `seen = useLauncherApps(...)` under react-hooks/globals; the probe now hands its entries to a vi.fn from an effect. Claude-Session: https://claude.ai/code/session_01JQwxbYwBbR8jCpWPE5Kosz Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8cc708a commit 7b20f2d

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎ui/packages/app-shell/src/hooks/__tests__/useLauncherApps-26838.test.tsx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,19 @@ afterEach(() => {
8686
describe('useLauncherApps narrows by /me/apps (objectstack#26838)', () => {
8787
it('drops an app the /me/apps answer does not list, keeping the /meta/app entries', async () => {
8888
const fetcher = meApps(['setup', 'account', 'crm']);
89-
let seen: unknown[] = [];
89+
const seen = vi.fn<(apps: unknown[]) => void>();
9090
function Entries() {
91-
seen = useLauncherApps(state.apps).apps;
91+
const { apps } = useLauncherApps(state.apps);
92+
React.useEffect(() => seen(apps), [apps]);
9293
return null;
9394
}
9495
renderWith(fetcher as unknown as typeof fetch, <><Probe /><Entries /></>);
9596
await waitFor(() => expect(screen.getByTestId('probe')).toHaveTextContent(/^setup,crm$/));
9697
expect(screen.getByTestId('probe')).toHaveAttribute('data-pending', 'false');
9798
// The entries are `/meta/app`'s own objects, not the answer's.
98-
expect(seen).toEqual([SETUP, CRM]);
99-
expect(seen[0]).toBe(SETUP);
99+
const entries = seen.mock.lastCall?.[0];
100+
expect(entries).toEqual([SETUP, CRM]);
101+
expect(entries?.[0]).toBe(SETUP);
100102
expect(fetcher).toHaveBeenCalledTimes(1);
101103
expect(fetcher.mock.calls[0][0]).toBe(ENDPOINT);
102104
});

0 commit comments

Comments
 (0)