Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(profile-ui): cover reset identity mismatch
Josué2a978f53c06d
diff --git a/profile-ui/app/components/__tests__/InvitationClient.r6IdentityFence.test.tsx b/profile-ui/app/components/__tests__/InvitationClient.r6IdentityFence.test.tsxnew file mode 100644index 000000000..b6d52e414--- /dev/null+++ b/profile-ui/app/components/__tests__/InvitationClient.r6IdentityFence.test.tsx@@ -0,0 +1,80 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { cleanup, fireEvent, render, screen } from '@testing-library/react'+import type { InvitationPreview } from '@/app/types/api'+import { InvitationClient } from '../../invitations/[token]/InvitationClient'++const mocks = vi.hoisted(() => ({+ checkAuth: vi.fn(),+ routerReplace: vi.fn(),+ setupInvitationPasswordWithToken: vi.fn(),+}))++vi.mock('next/navigation', () => ({+ useRouter: () => ({ replace: mocks.routerReplace }),+}))++vi.mock('@components/AuthContext', () => ({+ useAuth: () => ({ checkAuth: mocks.checkAuth }),+}))++vi.mock('@lib/api', () => ({+ acceptInvitation: vi.fn(),+ getEvenfireDownloadUrl: () => 'https://downloads.example.invalid/evenfire',+ setupInvitationPasswordWithToken: mocks.setupInvitationPasswordWithToken,+}))++const invitation: InvitationPreview = {+ id: 'r6-identity-reset',+ teamId: null,+ teamName: null,+ email: '[email protected]',+ role: 'member',+ purpose: 'password_reset',+ status: 'pending',+ expiresAt: new Date(Date.now() + 60_000).toISOString(),+ acceptedAt: null,+ userId: 'r6-expected-user',+ passwordPending: true,+}++beforeEach(() => {+ mocks.checkAuth.mockReset()+ mocks.routerReplace.mockReset()+ mocks.setupInvitationPasswordWithToken.mockReset().mockResolvedValue({+ ...invitation,+ status: 'accepted',+ passwordUpdated: true,+ userId: 'r6-other-user',+ })+})++afterEach(cleanup)++describe('R6 reset response identity fence', () => {+ it('does not hydrate or navigate when the committed reset response names another user', async () => {+ render(+ <InvitationClient+ invitationToken="r6-one-use-reset-proof"+ initialInvitation={invitation}+ initialError=""+ />+ )+ fireEvent.change(screen.getByLabelText('Password'), {+ target: { value: 'R6-synthetic-new-password' },+ })+ fireEvent.change(screen.getByLabelText('Confirm password'), {+ target: { value: 'R6-synthetic-new-password' },+ })+ fireEvent.click(screen.getByRole('button', { name: 'Reset password' }))++ expect(+ await screen.findByText(+ 'Your password was updated, but the signed-in account does not match this recovery link.'+ )+ ).toBeTruthy()+ expect(mocks.setupInvitationPasswordWithToken).toHaveBeenCalledOnce()+ expect(mocks.checkAuth).not.toHaveBeenCalled()+ expect(mocks.routerReplace).not.toHaveBeenCalled()+ expect(screen.queryByLabelText('Password')).toBeNull()+ })+})diff --git a/profile-ui/package-lock.json b/profile-ui/package-lock.jsonindex 656c5bcb0..eff271b1c 100644--- a/profile-ui/package-lock.json+++ b/profile-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-profile-ui",- "version": "0.1.173",+ "version": "0.1.174","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-profile-ui",- "version": "0.1.173",+ "version": "0.1.174","dependencies": {"@clerum/desktop-app-links": "file:../packages/desktop-app-links","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/profile-ui/package.json b/profile-ui/package.jsonindex 0e64b9fbd..58e95add1 100644--- a/profile-ui/package.json+++ b/profile-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-profile-ui",- "version": "0.1.173",+ "version": "0.1.174","private": true,"scripts": {"dev": "next dev",