fix(auth): initialize Google Identity once
This commit is contained in:
@@ -155,8 +155,9 @@ describe('LoginPage', () => {
|
||||
it('completes a Google credential return without account-linking copy', async () => {
|
||||
process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID = 'google-client';
|
||||
let callback: ((response: { credential: string }) => void) | undefined;
|
||||
const initialize = jest.fn((options: any) => { callback = options.callback; });
|
||||
(window as any).google = { accounts: { id: {
|
||||
initialize: jest.fn((options: any) => { callback = options.callback; }),
|
||||
initialize,
|
||||
renderButton: jest.fn((host: HTMLElement) => {
|
||||
const button = document.createElement('button');
|
||||
button.textContent = 'Continue with Google';
|
||||
@@ -172,6 +173,7 @@ describe('LoginPage', () => {
|
||||
|
||||
await waitFor(() => expect(mockedApi.post).toHaveBeenCalledWith('/auth/google/exchange', { token: 'synthetic-google-token', rememberMe: true }));
|
||||
await waitFor(() => expect(mockNavigate).toHaveBeenCalledWith('/dashboard', { replace: true }));
|
||||
expect(initialize).toHaveBeenCalledTimes(1);
|
||||
expect(screen.queryByText(/create your account automatically/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user