Skip to content

Commit 382ce25

Browse files
committed
test(app-shell): hand the refresh handle out through an effect
The Home roster refresh case reassigned an outer variable during render, which the React compiler lint rule refuses (Lint UI). The handle is now filled from an effect on a holder object passed as a prop. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvowqEy7Lkj2dKGw2i
1 parent c2ce30e commit 382ce25

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎ui/packages/app-shell/src/console/home/__tests__/homeObjectReads-29121.test.tsx‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,24 @@ describe('Home asks for the objects it names, never the whole registry (objectst
173173
});
174174

175175
it('outside an app, a refresh asks the roster’s names again in one ?names= request', async () => {
176-
let refresh: ((type?: string) => Promise<void>) | undefined;
177-
function RefreshHandle() {
178-
refresh = useMetadata().refresh;
176+
const handle: { refresh?: (type?: string) => Promise<void> } = {};
177+
function RefreshHandle({ into }: { into: typeof handle }) {
178+
const { refresh } = useMetadata();
179+
React.useEffect(() => {
180+
into.refresh = refresh;
181+
}, [into, refresh]);
179182
return null;
180183
}
181184
const calls = mount(
182185
<>
183-
<RefreshHandle />
186+
<RefreshHandle into={handle} />
184187
<GateProbe />
185188
</>,
186189
);
187190
await waitFor(() => expect(screen.getByTestId('gate')).toHaveAttribute('data-cloud', 'false'));
188191
await settle();
189192
await act(async () => {
190-
await refresh!('object');
193+
await handle.refresh!('object');
191194
});
192195
await settle();
193196
expect(screen.getByTestId('gate')).toHaveAttribute('data-cloud', 'false');

0 commit comments

Comments
 (0)