Scheduling infrastructure for absolutely everyone.
fix: seed script command (#24668)
Eunjae Lee3418a25a8511
diff --git a/apps/api/v1/test/lib/bookings/_get.integration-test.ts b/apps/api/v1/test/lib/bookings/_get.integration-test.tsindex c1ec9e7b292..2f2ba4f98e0 100644--- a/apps/api/v1/test/lib/bookings/_get.integration-test.ts+++ b/apps/api/v1/test/lib/bookings/_get.integration-test.ts@@ -4,7 +4,7 @@ import { createMocks } from "node-mocks-http";import { describe, expect, it, beforeAll } from "vitest";import { ZodError } from "zod";-import prisma from "@calcom/prisma";+import { prisma } from "@calcom/prisma";import { handler } from "../../../pages/api/bookings/_get";@@ -217,6 +217,22 @@ describe("GET /api/bookings", async () => {describe("Expand feature to add relational data in return payload", () => {it("Returns only team data when expand=team is set", async () => {const adminUser = await prisma.user.findFirstOrThrow({ where: { email: "[email protected]" } });++ // Find a team booking and a non-team booking from seed data+ const team1 = await prisma.team.findFirst({ where: { slug: "team1" } });+ const teamEventType = await prisma.eventType.findFirst({+ where: { teamId: team1?.id },+ include: { bookings: true },+ });+ const teamBooking = teamEventType?.bookings[0];++ const nonTeamBooking = await prisma.booking.findFirst({+ where: {+ eventType: { teamId: null },+ userId: proUser.id,+ },+ });+const { req } = createMocks<CustomNextApiRequest, CustomNextApiResponse>({method: "GET",query: {@@ -229,14 +245,23 @@ describe("GET /api/bookings", async () => {req.isOrganizationOwnerOrAdmin = true;const responseData = await handler(req);- console.log("bookings=>", responseData.bookings);- responseData.bookings.forEach((booking) => {- if (booking.id === 31) expect(booking.eventType?.team?.slug).toBe("team1");- if (booking.id === 19) {- // The team field can be either null or undefined due to nullish() in the schema- expect(booking.eventType?.team === null || booking.eventType?.team === undefined).toBe(true);++ // Verify team booking has team data+ if (teamBooking) {+ const returnedTeamBooking = responseData.bookings.find((b) => b.id === teamBooking.id);+ expect(returnedTeamBooking?.eventType?.team?.slug).toBe("team1");+ }++ // Verify non-team booking has null/undefined team+ if (nonTeamBooking) {+ const returnedNonTeamBooking = responseData.bookings.find((b) => b.id === nonTeamBooking.id);+ if (returnedNonTeamBooking) {+ expect(+ returnedNonTeamBooking.eventType?.team === null ||+ returnedNonTeamBooking.eventType?.team === undefined+ ).toBe(true);}- });+ }});});diff --git a/packages/features/insights/services/InsightsBookingService.integration-test.ts b/packages/features/insights/services/InsightsBookingService.integration-test.tsindex c0d04566016..55bb3bf6ea0 100644--- a/packages/features/insights/services/InsightsBookingService.integration-test.ts+++ b/packages/features/insights/services/InsightsBookingService.integration-test.ts@@ -724,10 +724,11 @@ describe("InsightsBookingService Integration Tests", () => {});const baseConditions = await service.getBaseConditions();- const results = await prisma.$queryRaw<{ id: number }[]>`+ const query = Prisma.sql`SELECT id FROM "BookingTimeStatusDenormalized"WHERE ${baseConditions}`;+ const results = await prisma.$queryRaw<{ id: number }[]>(query);// Should return the user booking since it matches both conditionsexpect(results).toEqual([diff --git a/packages/prisma/package.json b/packages/prisma/package.jsonindex c8254f5c4df..2ac07638538 100644--- a/packages/prisma/package.json+++ b/packages/prisma/package.json@@ -18,6 +18,7 @@"post-install": "yarn generate-schemas","seed-app-store": "ts-node --transpile-only ../../scripts/seed-app-store.ts","delete-app": "ts-node --transpile-only ./delete-app.ts",+ "seed-basic": "ts-node --transpile-only ../../scripts/seed.ts","seed-insights": "ts-node --transpile-only ../../scripts/seed-insights.ts","seed-pbac": "ts-node --transpile-only ../../scripts/seed-pbac-organization.ts"},@@ -45,6 +46,6 @@"zod-utils.ts"],"prisma": {- "seed": "ts-node --transpile-only ../../scripts/seed.ts"+ "seed": "yarn seed-basic"}}