From bd4609c0befca50b1e38842da4cb003c8e5b7403 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Thu, 6 Aug 2026 11:42:16 -0700 Subject: [PATCH] feat(admin): add send-password-reset-email toggle to create user modal --- .../components/admin/add-user-modal.test.tsx | 147 ++++++++++++++++-- .../components/admin/add-user-modal.tsx | 41 ++++- 2 files changed, 174 insertions(+), 14 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/settings/components/admin/add-user-modal.test.tsx b/apps/sim/app/workspace/[workspaceId]/settings/components/admin/add-user-modal.test.tsx index 71883816a30..24e1153969f 100644 --- a/apps/sim/app/workspace/[workspaceId]/settings/components/admin/add-user-modal.test.tsx +++ b/apps/sim/app/workspace/[workspaceId]/settings/components/admin/add-user-modal.test.tsx @@ -7,7 +7,14 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true -const { addUserMutation, mockMutate, mockReset } = vi.hoisted(() => ({ +const { + addUserMutation, + mockMutate, + mockReset, + mockResetPassword, + mockToast, + resetPasswordMutation, +} = vi.hoisted(() => ({ addUserMutation: { current: { isPending: false, @@ -16,6 +23,9 @@ const { addUserMutation, mockMutate, mockReset } = vi.hoisted(() => ({ }, mockMutate: vi.fn(), mockReset: vi.fn(), + mockResetPassword: vi.fn(), + mockToast: { success: vi.fn(), error: vi.fn() }, + resetPasswordMutation: { current: { isPending: false } }, })) vi.mock('@sim/emcn', () => ({ @@ -58,6 +68,29 @@ vi.mock('@sim/emcn', () => ({ ), + Label: ({ htmlFor, children }: { htmlFor?: string; children: ReactNode }) => ( + + ), + Switch: ({ + id, + checked, + onCheckedChange, + disabled, + }: { + id?: string + checked: boolean + onCheckedChange: (checked: boolean) => void + disabled?: boolean + }) => ( + onCheckedChange(event.target.checked)} + /> + ), + toast: mockToast, ChipModalField: ({ type, inputType, @@ -114,6 +147,18 @@ vi.mock('@/hooks/queries/admin-users', () => ({ }), })) +vi.mock('@/hooks/queries/user-profile', () => ({ + useResetPassword: () => ({ + mutateAsync: mockResetPassword, + isPending: resetPasswordMutation.current.isPending, + reset: vi.fn(), + }), +})) + +vi.mock('@/lib/core/utils/urls', () => ({ + getBaseUrl: () => 'https://sim.test', +})) + import { AddUserModal } from '@/app/workspace/[workspaceId]/settings/components/admin/add-user-modal' import type { AddUserInput, AdminUser } from '@/hooks/queries/admin-users' @@ -157,6 +202,38 @@ async function changeField(label: string, value: string) { }) } +/** Resolves a switch through its `