Compare commits

...

2 Commits

Author SHA1 Message Date
Cursor Agent bc69fa3b43 fix: add contactAttributeKey mock to workspace tests 2026-05-13 09:53:15 +00:00
Cursor Agent 47b60eccd5 fix: seed default contact attributes when creating workspace (ENG-929)
Co-authored-by: Johannes <jobenjada@users.noreply.github.com>
2026-05-13 09:47:26 +00:00
2 changed files with 20 additions and 0 deletions
@@ -38,6 +38,9 @@ vi.mock("@formbricks/database", () => ({
workspaceTeam: {
createMany: vi.fn(),
},
contactAttributeKey: {
createMany: vi.fn(),
},
feedbackDirectory: {
upsert: vi.fn(),
findFirst: vi.fn(),
@@ -54,6 +54,13 @@ export const updateWorkspace = async (
return updatedWorkspace as TWorkspace;
};
const DEFAULT_CONTACT_ATTRIBUTES = [
{ key: "email", name: "Email", dataType: "string" },
{ key: "userId", name: "User ID", dataType: "string" },
{ key: "firstName", name: "First Name", dataType: "string" },
{ key: "lastName", name: "Last Name", dataType: "string" },
] as const;
export const createWorkspace = async (
organizationId: string,
workspaceInput: TWorkspaceUpdateInput
@@ -89,6 +96,16 @@ export const createWorkspace = async (
});
}
await prisma.contactAttributeKey.createMany({
data: DEFAULT_CONTACT_ATTRIBUTES.map((attr) => ({
key: attr.key,
name: attr.name,
type: "default",
dataType: attr.dataType as any,
workspaceId: workspace.id,
})),
});
return workspace;
} catch (error) {
if (error instanceof Prisma.PrismaClientKnownRequestError) {