fix: seed script command (#24668)
* feat: add seed-all command to run all seed scripts - Add seed-all command to packages/prisma/package.json - Create scripts/seed-all.ts to run seed.ts, seed-insights.ts, and seed-pbac-organization.ts in sequence - Update Prisma configuration to use seed-all as the default seed command - Add GitHub workflow to test seed-all command with a real PostgreSQL database Co-Authored-By: [email protected] <[email protected]> * fix: use correct path resolution in seed-all script Co-Authored-By: [email protected] <[email protected]> * fix: simplify database verification step in test workflow Co-Authored-By: [email protected] <[email protected]> * refactor: use seed-all in cache-db action instead of separate workflow - Update cache-db action to use seed-all command - Remove test-seed-all.yml workflow as requested Co-Authored-By: [email protected] <[email protected]> * fix error * change command name * fix integration tests * run basic seed by default --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
3 files changed
+37
-10
No files matched your search
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user