Skip to content

Commit 18fd64f

Browse files
committed
Fix wrong test
1 parent c72aecd commit 18fd64f

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

packages/trpc/server/routers/viewer/eventTypes/heavy/duplicate.handler.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,22 @@ vi.mock("@calcom/features/eventtypes/repositories/eventTypeRepository");
1515
describe("duplicateHandler", () => {
1616
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1717
const ctx = { user: { id: 1, profile: { id: 1 } } } as any;
18-
const input = { id: 123, slug: "test-event", title: "Test", description: "Test", length: 30, teamId: null };
18+
const input = {
19+
id: 123,
20+
slug: "test-event",
21+
title: "Test",
22+
description: "Test",
23+
length: 30,
24+
teamId: null,
25+
};
1926
const eventType = { id: 123, userId: 1, teamId: null, users: [{ id: 1 }] };
2027

2128
beforeEach(() => {
2229
vi.resetAllMocks();
2330
prismaMock.eventType.findUnique.mockResolvedValue(eventType);
2431
});
2532

26-
it("should throw BAD_REQUEST in case of unique constraint violation", async () => {
33+
it("should throw INTERNAL_SERVER_ERROR in case of unique constraint violation", async () => {
2734
const { EventTypeRepository } = await import(
2835
"@calcom/features/eventtypes/repositories/eventTypeRepository"
2936
);
@@ -41,8 +48,9 @@ describe("duplicateHandler", () => {
4148

4249
await expect(duplicateHandler({ ctx, input })).rejects.toThrow(
4350
new TRPCError({
44-
code: "BAD_REQUEST",
45-
message: "Error duplicating event type PrismaClientKnownRequestError: Unique constraint failed",
51+
code: "INTERNAL_SERVER_ERROR",
52+
message:
53+
"Error duplicating event type PrismaClientKnownRequestError: Unique constraint failed",
4654
})
4755
);
4856
});

vitest.config.mts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export default defineConfig({
1515
},
1616
{
1717
find: /^\.\/tailwind\.generated\.css\?inline$/,
18-
replacement: path.resolve(__dirname, "vitest-mocks/tailwind.generated.css"),
18+
replacement: path.resolve(
19+
__dirname,
20+
"vitest-mocks/tailwind.generated.css"
21+
),
1922
},
2023
// Alias Node.js built-ins for jsdom environment
2124
{ find: "crypto", replacement: "node:crypto" },
@@ -28,20 +31,30 @@ export default defineConfig({
2831
// Platform packages that need to be resolved from source in CI
2932
{
3033
find: "@calcom/platform-constants",
31-
replacement: path.resolve(__dirname, "packages/platform/constants/index.ts"),
34+
replacement: path.resolve(
35+
__dirname,
36+
"packages/platform/constants/index.ts"
37+
),
3238
},
3339
{
3440
find: "@calcom/embed-react",
35-
replacement: path.resolve(__dirname, "packages/embeds/embed-react/src/index.ts"),
41+
replacement: path.resolve(
42+
__dirname,
43+
"packages/embeds/embed-react/src/index.ts"
44+
),
3645
},
3746
{
3847
find: "@calcom/embed-snippet",
39-
replacement: path.resolve(__dirname, "packages/embeds/embed-snippet/src/index.ts"),
48+
replacement: path.resolve(
49+
__dirname,
50+
"packages/embeds/embed-snippet/src/index.ts"
51+
),
4052
},
4153
],
4254
},
4355
test: {
4456
globals: true,
57+
silent: true,
4558
environment: "jsdom",
4659
setupFiles: ["./setupVitest.ts"],
4760
server: {
@@ -72,6 +85,8 @@ function setEnvVariablesThatAreUsedBeforeSetup() {
7285
process.env.DAILY_API_KEY = "MOCK_DAILY_API_KEY";
7386
// With same env variable, we can test both non org and org booking scenarios
7487
process.env.NEXT_PUBLIC_WEBAPP_URL = "http://app.cal.local:3000";
75-
process.env.CALCOM_SERVICE_ACCOUNT_ENCRYPTION_KEY = "UNIT_TEST_ENCRYPTION_KEY";
76-
process.env.STRIPE_PRIVATE_KEY = process.env.STRIPE_PRIVATE_KEY || "sk_test_dummy_unit_test_key";
88+
process.env.CALCOM_SERVICE_ACCOUNT_ENCRYPTION_KEY =
89+
"UNIT_TEST_ENCRYPTION_KEY";
90+
process.env.STRIPE_PRIVATE_KEY =
91+
process.env.STRIPE_PRIVATE_KEY || "sk_test_dummy_unit_test_key";
7792
}

0 commit comments

Comments
 (0)