Skip to content

Commit 03b3034

Browse files
committed
test(console): keep the probe's unregister out of render
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgWPe8iKWPE5j7CLjdF
1 parent a257694 commit 03b3034

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎ui/apps/console/src/__tests__/nativePushRegistration-29042.test.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import { afterEach, beforeEach, describe, expect, it, vi, type Mock } from 'vitest';
2020
import { act, cleanup, render } from '@testing-library/react';
21-
import type { ReactNode } from 'react';
21+
import { useEffect, type ReactNode } from 'react';
2222
import { AuthCtx, type AuthContextValue } from '../../../../packages/auth/src/AuthContext';
2323
import { useAuth } from '../../../../packages/auth/src/useAuth';
2424
import { resetBeforeSignOutForTests, runBeforeSignOut } from '../../../../packages/auth/src/beforeSignOut';
@@ -97,8 +97,13 @@ function deviceRequests(): Array<{ method: string; url: string; body: unknown }>
9797
.filter((request) => request.url.includes(DEVICES));
9898
}
9999

100+
function keepUnregister(fn: () => Promise<void>) {
101+
unregister = fn;
102+
}
103+
100104
function Probe({ pathname }: { pathname: string }) {
101-
unregister = useNativePushRegistration(pathname);
105+
const fn = useNativePushRegistration(pathname);
106+
useEffect(() => keepUnregister(fn), [fn]);
102107
return null;
103108
}
104109

0 commit comments

Comments
 (0)