Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(desktop-app): cover native login during link refresh (R17-L6)
Josuéc5519ba9b5de
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useAuthController.desktopEnvironment.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useAuthController.desktopEnvironment.test.tsxindex 563ca6b77..776a7f23f 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/useAuthController.desktopEnvironment.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/useAuthController.desktopEnvironment.test.tsx@@ -228,7 +228,7 @@ afterEach(async () => {})describe('Desktop environment handoff', () => {- it('preserves a session that starts while setup confirmation rereads configuration', async () => {+ it('preserves a native login that starts while setup confirmation rereads configuration', async () => {const linkedEnvironment = {appName: 'New tenant',externalRestApiBaseUrl: 'https://new-api.example.test/api/v1',@@ -263,10 +263,71 @@ describe('Desktop environment handoff', () => {await Promise.resolve()})await waitFor(() => expect(finishRefresh).toBeTypeOf('function'))- await act(async () => setAuthenticatedForTest?.(true))++ let finishLogin!: (result: {+ token: string+ me: {+ id: string+ email: string+ name: string+ picture: null+ teamId: string+ teamName: string+ role: string+ }+ }) => void+ let reportLoginStarted!: () => void+ const loginStarted = new Promise<void>(resolve => {+ reportLoginStarted = resolve+ })+ const loginResult = new Promise<{+ token: string+ me: {+ id: string+ email: string+ name: string+ picture: null+ teamId: string+ teamName: string+ role: string+ }+ }>(resolve => {+ finishLogin = resolve+ })+ const native = nativeAppService as unknown as {+ authClient: { googleLogin: ReturnType<typeof vi.fn> }+ tokenStore: { setSessionToken: ReturnType<typeof vi.fn> }+ }+ native.authClient = {+ googleLogin: vi.fn(() => {+ reportLoginStarted()+ return loginResult+ }),+ }+ native.tokenStore.setSessionToken = vi.fn().mockResolvedValue(undefined)+ let login!: Promise<unknown>+ await act(async () => {+ login = nativeAppService!.googleLogin('synthetic-google-login-during-refresh')+ await loginStarted+ })finishRefresh?.(await runtimeConfigModule!.getDesktopRuntimeConfigState())await act(async () => confirmation)+ finishLogin({+ token: 'synthetic-session-during-refresh',+ me: {+ id: 'refresh-race-user',+ email: '[email protected]',+ name: 'Refresh Race User',+ picture: null,+ teamId: 'team-b',+ teamName: 'Team B',+ role: 'member',+ },+ })+ await act(async () => login)+ await act(async () => setAuthenticatedForTest?.(true))+const saveRuntimeConfigCallCount = mocks.saveRuntimeConfig.mock.calls.lengthmocks.saveRuntimeConfig.mockReset()const finalState = await runtimeConfigModule!.getDesktopRuntimeConfigState()