diff --git a/apps/api/v2/jest-e2e.json b/apps/api/v2/jest-e2e.json index f34af4a666..cbf895ce74 100644 --- a/apps/api/v2/jest-e2e.json +++ b/apps/api/v2/jest-e2e.json @@ -13,5 +13,5 @@ "setupFiles": ["/test/setEnvVars.ts", "jest-date-mock"], "reporters": ["default", "jest-summarizing-reporter"], "workerIdleMemoryLimit": "512MB", - "maxWorkers": 2 + "maxWorkers": 8 } diff --git a/apps/api/v2/package.json b/apps/api/v2/package.json index 99448e1f5e..255d629267 100644 --- a/apps/api/v2/package.json +++ b/apps/api/v2/package.json @@ -20,6 +20,7 @@ "test:cov": "yarn dev:build && jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "yarn dev:build && NODE_OPTIONS='--max_old_space_size=8192 --experimental-vm-modules' jest --ci --forceExit --config ./jest-e2e.json", + "test:e2e:local": "yarn test:e2e --maxWorkers=4", "test:e2e:watch": "yarn dev:build && jest --runInBand --detectOpenHandles --forceExit --config ./jest-e2e.json --watch", "prisma": "yarn workspace @calcom/prisma prisma", "generate-schemas": "yarn prisma generate && yarn prisma format", diff --git a/apps/api/v2/src/app.e2e-spec.ts b/apps/api/v2/src/app.e2e-spec.ts index 5e8a0c8b22..18a23020db 100644 --- a/apps/api/v2/src/app.e2e-spec.ts +++ b/apps/api/v2/src/app.e2e-spec.ts @@ -14,6 +14,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { RateLimitRepositoryFixture } from "test/fixtures/repository/rate-limit.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { X_CAL_CLIENT_ID, X_CAL_SECRET_KEY } from "@calcom/platform-constants"; import { User, PlatformOAuthClient, Team, RateLimit } from "@calcom/prisma/client"; @@ -24,7 +25,7 @@ describe("AppController", () => { let userRepositoryFixture: UserRepositoryFixture; let apiKeysRepositoryFixture: ApiKeysRepositoryFixture; let rateLimitRepositoryFixture: RateLimitRepositoryFixture; - const userEmail = "app-rate-limits-e2e@api.com"; + const userEmail = `app-rate-limits-user-${randomString()}@api.com`; let user: User; let organization: Team; @@ -94,7 +95,9 @@ describe("AppController", () => { ); organizationsRepositoryFixture = new OrganizationRepositoryFixture(moduleRef); - organization = await organizationsRepositoryFixture.create({ name: "ecorp" }); + organization = await organizationsRepositoryFixture.create({ + name: `app-rate-limits-organization-${randomString()}`, + }); oauthClientRepositoryFixture = new OAuthClientRepositoryFixture(moduleRef); oAuthClient = await createOAuthClient(organization.id); profilesRepositoryFixture = new ProfileRepositoryFixture(moduleRef); diff --git a/apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.e2e-spec.ts index 0e249c11fd..cc31378ffd 100644 --- a/apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.e2e-spec.ts @@ -8,6 +8,7 @@ import { SchedulesModule_2024_04_15 } from "@/ee/schedules/schedules_2024_04_15/ import { SchedulesService_2024_04_15 } from "@/ee/schedules/schedules_2024_04_15/services/schedules.service"; import { PermissionsGuard } from "@/modules/auth/guards/permissions/permissions.guard"; import { PrismaModule } from "@/modules/prisma/prisma.module"; +import { TokensModule } from "@/modules/tokens/tokens.module"; import { UsersModule } from "@/modules/users/users.module"; import { INestApplication } from "@nestjs/common"; import { NestExpressApplication } from "@nestjs/platform-express"; @@ -18,6 +19,7 @@ import { ApiKeysRepositoryFixture } from "test/fixtures/repository/api-keys.repo import { BookingsRepositoryFixture } from "test/fixtures/repository/bookings.repository.fixture"; import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-types.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS, ERROR_STATUS } from "@calcom/platform-constants"; @@ -35,7 +37,7 @@ describe("Bookings Endpoints 2024-04-15", () => { let apiKeysRepositoryFixture: ApiKeysRepositoryFixture; let apiKeyString: string; - const userEmail = "bookings-controller-e2e@api.com"; + const userEmail = `bookings-2024-04-15-user-${randomString()}@api.com`; let user: User; let eventTypeId: number; @@ -67,13 +69,17 @@ describe("Bookings Endpoints 2024-04-15", () => { const { keyString } = await apiKeysRepositoryFixture.createApiKey(user.id, null); apiKeyString = keyString; const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `bookings-2024-04-15-schedule-${randomString()}-${describe.name}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); const event = await eventTypesRepositoryFixture.create( - { title: "peer coding", slug: "peer-coding", length: 60 }, + { + title: `bookings-2024-04-15-event-type-${randomString()}-${describe.name}`, + slug: `bookings-2024-04-15-event-type-${randomString()}-${describe.name}`, + length: 60, + }, user.id ); eventTypeId = event.id; @@ -343,94 +349,6 @@ describe("Bookings Endpoints 2024-04-15", () => { }); }); - // note(Lauris) : found this test broken here - first thing to fix is that recurring endpoint accepts an array not 1 object. - // it("should create a recurring booking", async () => { - // const bookingStart = "2040-05-25T09:30:00.000Z"; - // const bookingEnd = "2040-05-25T10:30:00.000Z"; - // const bookingEventTypeId = 7; - // const bookingTimeZone = "Europe/London"; - // const bookingLanguage = "en"; - // const bookingHashedLink = ""; - // const bookingRecurringCount = 5; - // const currentBookingRecurringIndex = 0; - - // const body = { - // start: bookingStart, - // end: bookingEnd, - // eventTypeId: bookingEventTypeId, - // timeZone: bookingTimeZone, - // language: bookingLanguage, - // metadata: {}, - // hashedLink: bookingHashedLink, - // recurringCount: bookingRecurringCount, - // currentRecurringIndex: currentBookingRecurringIndex, - // }; - - // return request(app.getHttpServer()) - // .post("/v2/bookings/recurring") - // .send(body) - // .expect(201) - // .then((response) => { - // const responseBody: ApiResponse>> = - // response.body; - - // expect(responseBody.status).toEqual("recurring"); - // }); - // }); - - // note(Lauris) : found this test broken here - first thing to fix is that the eventTypeId must be team event type, because - // instant bookings only work for teams. - // it("should create an instant booking", async () => { - // const bookingStart = "2040-05-25T09:30:00.000Z"; - // const bookingEnd = "2040-25T10:30:00.000Z"; - // const bookingEventTypeId = 7; - // const bookingTimeZone = "Europe/London"; - // const bookingLanguage = "en"; - // const bookingHashedLink = ""; - - // const body = { - // start: bookingStart, - // end: bookingEnd, - // eventTypeId: bookingEventTypeId, - // timeZone: bookingTimeZone, - // language: bookingLanguage, - // metadata: {}, - // hashedLink: bookingHashedLink, - // }; - - // return request(app.getHttpServer()) - // .post("/v2/bookings/instant") - // .send(body) - // .expect(201) - // .then((response) => { - // const responseBody: ApiResponse>> = response.body; - - // expect(responseBody.status).toEqual("instant"); - // }); - // }); - - // cancelling a booking hangs the test for some reason - it.skip("should cancel a booking", async () => { - const bookingId = createdBooking.id; - - const body = { - allRemainingBookings: false, - cancellationReason: "Was fighting some unforseen rescheduling demons", - }; - - return request(app.getHttpServer()) - .post(`/v2/bookings/${bookingId}/cancel`) - .send(body) - .expect(201) - .then((response) => { - const responseBody: ApiResponse<{ status: typeof SUCCESS_STATUS | typeof ERROR_STATUS }> = - response.body; - - expect(bookingId).toBeDefined(); - expect(responseBody.status).toEqual(SUCCESS_STATUS); - }); - }); - afterAll(async () => { await userRepositoryFixture.deleteByEmail(user.email); await bookingsRepositoryFixture.deleteAllBookings(user.id, user.email); diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/api-key-bookings.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/api-key-bookings.e2e-spec.ts index 6ebfea76d7..61fb209749 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/api-key-bookings.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/api-key-bookings.e2e-spec.ts @@ -19,6 +19,7 @@ import { BookingsRepositoryFixture } from "test/fixtures/repository/bookings.rep import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-types.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants"; @@ -72,10 +73,11 @@ describe("Bookings Endpoints 2024-08-13", () => { let apiKeysRepositoryFixture: ApiKeysRepositoryFixture; let apiKeyString: string; - const userEmail = "bookings-controller-e2e@api.com"; + const userEmail = `api-key-bookings-2024-08-13-user-${randomString()}@api.com`; let user: User; let eventTypeId: number; + const eventTypeSlug = `api-key-bookings-2024-08-13-event-type-${randomString()}`; let createdBooking: BookingOutput_2024_08_13; let rescheduledBooking: BookingOutput_2024_08_13; @@ -100,7 +102,9 @@ describe("Bookings Endpoints 2024-08-13", () => { schedulesService = moduleRef.get(SchedulesService_2024_04_15); apiKeysRepositoryFixture = new ApiKeysRepositoryFixture(moduleRef); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ + name: `api-key-bookings-organization-${randomString()}`, + }); user = await userRepositoryFixture.create({ email: userEmail, @@ -110,13 +114,17 @@ describe("Bookings Endpoints 2024-08-13", () => { apiKeyString = keyString; const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `api-key-bookings-e2e-api-key-bookings-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); const event = await eventTypesRepositoryFixture.create( - { title: "peer coding", slug: "peer-coding", length: 60 }, + { + title: `api-key-bookings-e2e-api-key-bookings-2024-08-13-event-type-${randomString()}`, + slug: eventTypeSlug, + length: 60, + }, user.id ); eventTypeId = event.id; diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/booking-fields.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/booking-fields.e2e-spec.ts index f9f697909e..8b6af23ac2 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/booking-fields.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/booking-fields.e2e-spec.ts @@ -16,7 +16,7 @@ import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-type import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-client.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; -import { randomNumber } from "test/utils/randomNumber"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants"; @@ -26,9 +26,7 @@ import { GetSeatedBookingOutput_2024_08_13, } from "@calcom/platform-types"; import { BookingOutput_2024_08_13 } from "@calcom/platform-types"; -import { Booking, PlatformOAuthClient, Team, User } from "@calcom/prisma/client"; - -const suffix = randomNumber(); +import { Booking, PlatformOAuthClient, Team, User, EventType } from "@calcom/prisma/client"; describe("Bookings Endpoints 2024-08-13", () => { describe("Booking fields", () => { @@ -43,7 +41,7 @@ describe("Bookings Endpoints 2024-08-13", () => { let oAuthClient: PlatformOAuthClient; let teamRepositoryFixture: TeamRepositoryFixture; - const userEmail = `alice-${suffix}@api.com`; + const userEmail = `booking-fields-2024-08-13-user-${randomString()}@api.com`; let user: User; let bookingWithSplitName: Booking; @@ -54,7 +52,12 @@ describe("Bookings Endpoints 2024-08-13", () => { let seatedBookingWithSplitName: Booking; - let eventTypeWithBookingFieldsId: number; + let eventTypeId: number; + let seatedEvent: EventType; + let eventTypeWithBookingFields: EventType; + const eventTypeSlug = `booking-fields-2024-08-13-event-type-${randomString()}`; + const eventTypeWithBookingFieldsSlug = `booking-fields-2024-08-13-event-type-${randomString()}`; + const seatedEventTypeSlug = `booking-fields-2024-08-13-event-type-${randomString()}`; beforeAll(async () => { const moduleRef = await withApiAuth( @@ -76,7 +79,9 @@ describe("Bookings Endpoints 2024-08-13", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: `booking fields ${suffix}` }); + organization = await teamRepositoryFixture.create({ + name: `booking-fields-2024-08-13-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ @@ -89,109 +94,36 @@ describe("Bookings Endpoints 2024-08-13", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `booking-fields-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); const event = await eventTypesRepositoryFixture.create( - { title: "peer coding", slug: `normal-booking-${randomNumber()}`, length: 60 }, - user.id - ); - - bookingWithSplitName = await bookingsRepositoryFixture.create({ - user: { - connect: { - id: user.id, - }, - }, - startTime: new Date(Date.UTC(2020, 0, 8, 12, 0, 0)), - endTime: new Date(Date.UTC(2020, 0, 8, 13, 0, 0)), - title: "peer coding lets goo", - uid: "booking", - eventType: { - connect: { - id: event.id, - }, - }, - location: "integrations:daily", - customInputs: {}, - metadata: {}, - responses: { - name: splitName, - email: "oldie@gmail.com", - }, - attendees: { - create: { - email: "oldie@gmail.com", - name: "Oldie Goldie", - locale: "lv", - timeZone: "Europe/Rome", - }, - }, - }); - - const seatedEvent = await eventTypesRepositoryFixture.create( - { title: "peer coding", slug: `seated-${randomNumber()}`, length: 60, seatsPerTimeSlot: 3 }, - user.id - ); - - seatedBookingWithSplitName = await bookingsRepositoryFixture.create({ - user: { - connect: { - id: user.id, - }, - }, - startTime: new Date(Date.UTC(2020, 0, 8, 14, 0, 0)), - endTime: new Date(Date.UTC(2020, 0, 8, 15, 0, 0)), - title: "peer coding lets goo", - uid: "seated-booking", - eventType: { - connect: { - id: seatedEvent.id, - }, - }, - location: "integrations:daily", - customInputs: {}, - metadata: {}, - responses: { - name: splitName, - email: "oldie@gmail.com", - }, - attendees: { - create: { - email: "oldie@gmail.com", - name: "Oldie Goldie", - locale: "lv", - timeZone: "Europe/Rome", - bookingSeat: { - create: { - referenceUid: "unique-seat-uid", - data: { - responses: { - email: "oldie@gmail.com", - name: { - firstName: "Oldie", - lastName: "Goldie", - }, - }, - }, - metadata: {}, - booking: { - connect: { - uid: "seated-booking", - }, - }, - }, - }, - }, - }, - }); - - const eventTypeWithBookingFields = await eventTypesRepositoryFixture.create( { - title: "peer coding with booking fields", - slug: `with-custom-booking-fields-${randomNumber()}`, + title: `booking-fields-2024-08-13-event-type-${randomString()}`, + slug: eventTypeSlug, + length: 60, + }, + user.id + ); + + eventTypeId = event.id; + + seatedEvent = await eventTypesRepositoryFixture.create( + { + title: `booking-fields-2024-08-13-event-type-${randomString()}`, + slug: seatedEventTypeSlug, + length: 60, + seatsPerTimeSlot: 3, + }, + user.id + ); + + eventTypeWithBookingFields = await eventTypesRepositoryFixture.create( + { + title: `booking-fields-2024-08-13-event-type-${randomString()}`, + slug: eventTypeWithBookingFieldsSlug, length: 60, bookingFields: [ { @@ -381,11 +313,93 @@ describe("Bookings Endpoints 2024-08-13", () => { }, user.id ); - eventTypeWithBookingFieldsId = eventTypeWithBookingFields.id; + + bookingWithSplitName = await bookingsRepositoryFixture.create({ + user: { + connect: { + id: user.id, + }, + }, + startTime: new Date(Date.UTC(2020, 0, 8, 12, 0, 0)), + endTime: new Date(Date.UTC(2020, 0, 8, 13, 0, 0)), + title: "peer coding lets goo", + uid: "booking", + eventType: { + connect: { + id: eventTypeId, + }, + }, + location: "integrations:daily", + customInputs: {}, + metadata: {}, + responses: { + name: splitName, + email: "oldie@gmail.com", + }, + attendees: { + create: { + email: "oldie@gmail.com", + name: "Oldie Goldie", + locale: "lv", + timeZone: "Europe/Rome", + }, + }, + }); + + seatedBookingWithSplitName = await bookingsRepositoryFixture.create({ + user: { + connect: { + id: user.id, + }, + }, + startTime: new Date(Date.UTC(2020, 0, 8, 14, 0, 0)), + endTime: new Date(Date.UTC(2020, 0, 8, 15, 0, 0)), + title: "peer coding lets goo", + uid: "seated-booking", + eventType: { + connect: { + id: seatedEvent.id, + }, + }, + location: "integrations:daily", + customInputs: {}, + metadata: {}, + responses: { + name: splitName, + email: "oldie@gmail.com", + }, + attendees: { + create: { + email: "oldie@gmail.com", + name: "Oldie Goldie", + locale: "lv", + timeZone: "Europe/Rome", + bookingSeat: { + create: { + referenceUid: "unique-seat-uid", + data: { + responses: { + email: "oldie@gmail.com", + name: { + firstName: "Oldie", + lastName: "Goldie", + }, + }, + }, + metadata: {}, + booking: { + connect: { + uid: "seated-booking", + }, + }, + }, + }, + }, + }, + }); app = moduleRef.createNestApplication(); bootstrap(app as NestExpressApplication); - await app.init(); }); @@ -457,7 +471,7 @@ describe("Bookings Endpoints 2024-08-13", () => { it("should not be able to book an event type with custom required booking fields if they are missing in bookingFieldsResponses", async () => { const body: CreateBookingInput_2024_08_13 = { start: new Date(Date.UTC(2030, 0, 8, 13, 0, 0)).toISOString(), - eventTypeId: eventTypeWithBookingFieldsId, + eventTypeId: eventTypeWithBookingFields.id, attendee: { name: "Mr Proper", email: "mr_proper@gmail.com", @@ -476,7 +490,7 @@ describe("Bookings Endpoints 2024-08-13", () => { it("should be able to book an event type with custom required booking fields", async () => { const body: CreateBookingInput_2024_08_13 = { start: new Date(Date.UTC(2030, 0, 8, 13, 0, 0)).toISOString(), - eventTypeId: eventTypeWithBookingFieldsId, + eventTypeId: eventTypeWithBookingFields.id, attendee: { name: "Mr Proper", email: "mr_proper@gmail.com", diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/confirm-bookings.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/confirm-bookings.e2e-spec.ts index 84c2ae15cb..541f4a47c0 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/confirm-bookings.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/confirm-bookings.e2e-spec.ts @@ -16,6 +16,7 @@ import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-type import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-client.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants"; @@ -35,11 +36,11 @@ describe("Bookings Endpoints 2024-08-13", () => { let oAuthClient: PlatformOAuthClient; let teamRepositoryFixture: TeamRepositoryFixture; - const userEmail = "bookings-controller-e2e@api.com"; + const userEmail = `confirm-bookings-2024-08-13-user-${randomString()}@api.com`; let user: User; let eventTypeId: number; - const eventTypeSlug = "peer-coding"; + const eventTypeSlug = `confirm-bookings-2024-08-13-event-type-${randomString()}`; let createdBooking1: Booking; let createdBooking2: Booking; @@ -64,7 +65,9 @@ describe("Bookings Endpoints 2024-08-13", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ + name: `confirm-bookings-2024-08-13-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ @@ -77,13 +80,17 @@ describe("Bookings Endpoints 2024-08-13", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `confirm-bookings-2024-08-13-${randomString()}-schedule`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); const event = await eventTypesRepositoryFixture.create( - { title: "peer coding", slug: eventTypeSlug, length: 60 }, + { + title: `confirm-bookings-2024-08-13-${randomString()}-event-type`, + slug: `confirm-bookings-2024-08-13-${randomString()}-event-type-slug`, + length: 60, + }, user.id ); eventTypeId = event.id; diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/confirm-emails.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/confirm-emails.e2e-spec.ts index 9ef524f1a5..2d9e7b3f7b 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/confirm-emails.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/confirm-emails.e2e-spec.ts @@ -20,6 +20,7 @@ import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-type import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-client.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants"; @@ -92,7 +93,7 @@ describe("Bookings Endpoints 2024-08-13 confirm emails", () => { let emailsEnabledSetup: EmailSetup; let emailsDisabledSetup: EmailSetup; - const authEmail = `admin-${Math.floor(Math.random() * 1000)}@example.com`; + const authEmail = `confirm-emails-2024-08-13-admin-${randomString()}@api.com`; beforeAll(async () => { const moduleRef = await withApiAuth( @@ -114,7 +115,9 @@ describe("Bookings Endpoints 2024-08-13 confirm emails", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ + name: `confirm-emails-2024-08-13-organization-${randomString()}`, + }); await setupEnabledEmails(); await setupDisabledEmails(); @@ -139,7 +142,7 @@ describe("Bookings Endpoints 2024-08-13 confirm emails", () => { const oAuthClientEmailsEnabled = await createOAuthClient(organization.id, true); const user = await userRepositoryFixture.create({ - email: `alice-${Math.floor(Math.random() * 1000)}@gmail.com`, + email: `confirm-emails-2024-08-13-user-${randomString()}@api.com`, platformOAuthClients: { connect: { id: oAuthClientEmailsEnabled.id, @@ -148,14 +151,19 @@ describe("Bookings Endpoints 2024-08-13 confirm emails", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `confirm-emails-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); const event = await eventTypesRepositoryFixture.create( - { title: "peer coding", slug: "peer-coding", length: 60, requiresConfirmation: true }, + { + title: "peer coding", + slug: `confirm-emails-2024-08-13-event-type-${randomString()}`, + length: 60, + requiresConfirmation: true, + }, user.id ); @@ -171,7 +179,7 @@ describe("Bookings Endpoints 2024-08-13 confirm emails", () => { const oAuthClientEmailsDisabled = await createOAuthClient(organization.id, false); const user = await userRepositoryFixture.create({ - email: `bob-${Math.floor(Math.random() * 1000)}@gmail.com`, + email: `confirm-emails-2024-08-13-user-${randomString()}@api.com`, platformOAuthClients: { connect: { id: oAuthClientEmailsDisabled.id, @@ -179,13 +187,18 @@ describe("Bookings Endpoints 2024-08-13 confirm emails", () => { }, }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `confirm-emails-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); const event = await eventTypesRepositoryFixture.create( - { title: "peer coding", slug: "peer-coding", length: 60, requiresConfirmation: true }, + { + title: "peer coding", + slug: `confirm-emails-2024-08-13-event-type-${randomString()}`, + length: 60, + requiresConfirmation: true, + }, user.id ); diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/team-emails.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/team-emails.e2e-spec.ts index 74190df366..d386680d3a 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/team-emails.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/team-emails.e2e-spec.ts @@ -23,6 +23,7 @@ import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-cli import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants"; @@ -103,7 +104,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { let emailsEnabledSetup: EmailSetup; let emailsDisabledSetup: EmailSetup; - const authEmail = "admin@example.com"; + const authEmail = "team-emails-2024-08-13-user-admin@example.com"; beforeAll(async () => { const moduleRef = await withApiAuth( @@ -128,7 +129,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { hostsRepositoryFixture = new HostsRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ name: `team-emails-organization-${randomString()}` }); await setupEnabledEmails(); await setupDisabledEmails(); @@ -152,7 +153,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { const oAuthClientEmailsEnabled = await createOAuthClient(organization.id, true); const team = await teamRepositoryFixture.create({ - name: "team 1", + name: `team-emails-team-${randomString()}`, isOrganization: false, parent: { connect: { id: organization.id } }, createdByOAuthClient: { @@ -163,7 +164,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { }); const member1 = await userRepositoryFixture.create({ - email: "alice@gmail.com", + email: `team-emails-2024-08-13-member1-${randomString()}@api.com`, platformOAuthClients: { connect: { id: oAuthClientEmailsEnabled.id, @@ -172,7 +173,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { }); const member2 = await userRepositoryFixture.create({ - email: "bob@gmail.com", + email: `team-emails-2024-08-13-member2-${randomString()}@api.com`, platformOAuthClients: { connect: { id: oAuthClientEmailsEnabled.id, @@ -181,7 +182,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `team-emails-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; @@ -237,8 +238,8 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { team: { connect: { id: team.id }, }, - title: "Collective Event Type", - slug: "collective-event-type", + title: `team-emails-2024-08-13-event-type-${randomString()}`, + slug: `team-emails-2024-08-13-event-type-${randomString()}`, length: 60, assignAllTeamMembers: true, bookingFields: [], @@ -278,8 +279,8 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { team: { connect: { id: team.id }, }, - title: "Round Robin Event Type", - slug: "round-robin-event-type", + title: `team-emails-2024-08-13-event-type-${randomString()}`, + slug: `team-emails-2024-08-13-event-type-${randomString()}`, length: 60, assignAllTeamMembers: false, bookingFields: [], @@ -336,7 +337,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { const oAuthClientEmailsDisabled = await createOAuthClient(organization.id, false); const team = await teamRepositoryFixture.create({ - name: "team 2", + name: `team-emails-2024-08-13-team-${randomString()}`, isOrganization: false, parent: { connect: { id: organization.id } }, createdByOAuthClient: { @@ -347,7 +348,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { }); const member1 = await userRepositoryFixture.create({ - email: "charlie@gmail.com", + email: `team-emails-2024-08-13-member1-${randomString()}@api.com`, platformOAuthClients: { connect: { id: oAuthClientEmailsDisabled.id, @@ -356,7 +357,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { }); const member2 = await userRepositoryFixture.create({ - email: "dean@gmail.com", + email: `team-emails-2024-08-13-member2-${randomString()}@api.com`, platformOAuthClients: { connect: { id: oAuthClientEmailsDisabled.id, @@ -365,7 +366,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `team-emails-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; @@ -421,8 +422,8 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { team: { connect: { id: team.id }, }, - title: "Collective Event Type", - slug: "collective-event-type", + title: `team-emails-2024-08-13-event-type-${randomString()}`, + slug: `team-emails-2024-08-13-event-type-${randomString()}`, length: 60, assignAllTeamMembers: true, bookingFields: [], @@ -462,8 +463,8 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { team: { connect: { id: team.id }, }, - title: "Round Robin Event Type", - slug: "round-robin-event-type", + title: `team-emails-2024-08-13-event-type-${randomString()}`, + slug: `team-emails-2024-08-13-event-type-${randomString()}`, length: 60, assignAllTeamMembers: false, bookingFields: [], @@ -965,17 +966,19 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => { }); }); }); + afterAll(async () => { await teamRepositoryFixture.delete(organization.id); + await userRepositoryFixture.deleteByEmail(authEmail); await userRepositoryFixture.deleteByEmail(emailsEnabledSetup.member1.email); - await userRepositoryFixture.deleteByEmail(emailsDisabledSetup.member1.email); + await userRepositoryFixture.deleteByEmail(emailsDisabledSetup.member2.email); await bookingsRepositoryFixture.deleteAllBookings( emailsEnabledSetup.member1.id, emailsEnabledSetup.member1.email ); await bookingsRepositoryFixture.deleteAllBookings( emailsDisabledSetup.member1.id, - emailsDisabledSetup.member1.email + emailsDisabledSetup.member2.email ); await app.close(); }); diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/user-emails.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/user-emails.e2e-spec.ts index 7d115bdf31..b45fe865d2 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/user-emails.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/emails/user-emails.e2e-spec.ts @@ -20,6 +20,7 @@ import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-type import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-client.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants"; import { @@ -101,7 +102,9 @@ describe("Bookings Endpoints 2024-08-13 user emails", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ + name: `user-emails-2024-08-13-organization-${randomString()}`, + }); await setupEnabledEmails(); await setupDisabledEmails(); @@ -116,7 +119,7 @@ describe("Bookings Endpoints 2024-08-13 user emails", () => { const oAuthClientEmailsEnabled = await createOAuthClient(organization.id, true); const user = await userRepositoryFixture.create({ - email: `alice-${Math.floor(Math.random() * 1000)}@gmail.com`, + email: `user-emails-2024-08-13-user-${randomString()}@api.com`, platformOAuthClients: { connect: { id: oAuthClientEmailsEnabled.id, @@ -125,22 +128,26 @@ describe("Bookings Endpoints 2024-08-13 user emails", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `user-emails-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); const event = await eventTypesRepositoryFixture.create( - { title: "peer coding", slug: "peer-coding", length: 60 }, + { + title: `user-emails-2024-08-13-event-type-${randomString()}`, + slug: `user-emails-2024-08-13-event-type-${randomString()}`, + length: 60, + }, user.id ); const recurringEvent = await eventTypesRepositoryFixture.create( // note(Lauris): freq 2 means weekly, interval 1 means every week and count 3 means 3 weeks in a row { - title: "peer coding recurring", - slug: "peer-coding-recurring", + title: `user-emails-2024-08-13-recurring-event-type-${randomString()}`, + slug: `user-emails-2024-08-13-recurring-event-type-${randomString()}`, length: 60, recurringEvent: { freq: 2, count: 3, interval: 1 }, }, @@ -160,7 +167,7 @@ describe("Bookings Endpoints 2024-08-13 user emails", () => { const oAuthClientEmailsDisabled = await createOAuthClient(organization.id, false); const user = await userRepositoryFixture.create({ - email: `bob-${Math.floor(Math.random() * 1000)}@gmail.com`, + email: `user-emails-2024-08-13-user-${randomString()}@api.com`, platformOAuthClients: { connect: { id: oAuthClientEmailsDisabled.id, @@ -168,21 +175,25 @@ describe("Bookings Endpoints 2024-08-13 user emails", () => { }, }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `user-emails-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); const event = await eventTypesRepositoryFixture.create( - { title: "peer coding", slug: "peer-coding", length: 60 }, + { + title: `user-emails-2024-08-13-event-type-${randomString()}`, + slug: `user-emails-2024-08-13-event-type-${randomString()}`, + length: 60, + }, user.id ); const recurringEvent = await eventTypesRepositoryFixture.create( // note(Lauris): freq 2 means weekly, interval 1 means every week and count 3 means 3 weeks in a row { - title: "peer coding recurring", - slug: "peer-coding-recurring", + title: `user-emails-2024-08-13-recurring-event-type-${randomString()}`, + slug: `user-emails-2024-08-13-recurring-event-type-${randomString()}`, length: 60, recurringEvent: { freq: 2, count: 3, interval: 1 }, }, diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/reassign-bookings.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/reassign-bookings.e2e-spec.ts index 63219cd7e8..e710a5bd9c 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/reassign-bookings.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/reassign-bookings.e2e-spec.ts @@ -21,6 +21,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants"; @@ -45,8 +46,8 @@ describe("Bookings Endpoints 2024-08-13", () => { let organizationsRepositoryFixture: OrganizationRepositoryFixture; let profileRepositoryFixture: ProfileRepositoryFixture; - const teamUserEmail = "orgUser1team1@api.com"; - const teamUserEmail2 = "orgUser2team1@api.com"; + const teamUserEmail = `reassign-bookings-2024-08-13-user1-${randomString()}@api.com`; + const teamUserEmail2 = `reassign-bookings-2024-08-13-user2-${randomString()}@api.com`; let teamUser1: User; let teamUser2: User; @@ -78,11 +79,13 @@ describe("Bookings Endpoints 2024-08-13", () => { hostsRepositoryFixture = new HostsRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await organizationsRepositoryFixture.create({ name: "organization team bookings" }); + organization = await organizationsRepositoryFixture.create({ + name: `reassign-bookings-2024-08-13-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); team = await teamRepositoryFixture.create({ - name: "team 1", + name: `reassign-bookings-2024-08-13-team-${randomString()}`, isOrganization: false, parent: { connect: { id: organization.id } }, createdByOAuthClient: { @@ -95,17 +98,17 @@ describe("Bookings Endpoints 2024-08-13", () => { teamUser1 = await userRepositoryFixture.create({ email: teamUserEmail, locale: "it", - name: "orgUser1team1", + name: `reassign-bookings-2024-08-13-user1-${randomString()}`, }); teamUser2 = await userRepositoryFixture.create({ email: teamUserEmail2, locale: "it", - name: "orgUser2team1", + name: `reassign-bookings-2024-08-13-user2-${randomString()}`, }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `reassign-bookings-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; @@ -164,8 +167,8 @@ describe("Bookings Endpoints 2024-08-13", () => { users: { connect: [{ id: teamUser1.id }, { id: teamUser2.id }], }, - title: "Round Robin Event Type", - slug: "round-robin-event-type", + title: `reassign-bookings-2024-08-13-event-type-${randomString()}`, + slug: `reassign-bookings-2024-08-13-event-type-${randomString()}`, length: 60, assignAllTeamMembers: false, bookingFields: [], diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/recurring-bookings.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/recurring-bookings.e2e-spec.ts index 13113e179f..cd17ec46be 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/recurring-bookings.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/recurring-bookings.e2e-spec.ts @@ -17,6 +17,7 @@ import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-type import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-client.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants"; @@ -41,11 +42,13 @@ describe("Bookings Endpoints 2024-08-13", () => { let oAuthClient: PlatformOAuthClient; let teamRepositoryFixture: TeamRepositoryFixture; - const userEmail = "bookings-controller-e2e@api.com"; + const userEmail = `recurring-bookings-2024-08-13-user-${randomString()}@api.com`; let user: User; const maxRecurrenceCount = 3; let recurringEventTypeId: number; + const recurringEventSlug = `recurring-bookings-2024-08-13-event-type-${randomString()}`; + let createdRecurringBooking: RecurringBookingOutput_2024_08_13[]; beforeAll(async () => { const moduleRef = await withApiAuth( @@ -67,7 +70,9 @@ describe("Bookings Endpoints 2024-08-13", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ + name: `recurring-bookings-2024-08-13-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ @@ -80,7 +85,7 @@ describe("Bookings Endpoints 2024-08-13", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `recurring-bookings-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; @@ -89,8 +94,8 @@ describe("Bookings Endpoints 2024-08-13", () => { const recurringEvent = await eventTypesRepositoryFixture.create( // note(Lauris): freq 2 means weekly, interval 1 means every week and count 3 means 3 weeks in a row { - title: "peer coding recurring", - slug: "peer-coding-recurring", + title: `recurring-bookings-2024-08-13-event-type-${randomString()}`, + slug: recurringEventSlug, length: 60, recurringEvent: { freq: 2, count: maxRecurrenceCount, interval: 1 }, }, @@ -344,7 +349,7 @@ describe("Bookings Endpoints 2024-08-13", () => { let oAuthClient: PlatformOAuthClient; let teamRepositoryFixture: TeamRepositoryFixture; - const userEmail = "bookings-controller-e2e@api.com"; + const userEmail = `recurring-bookings-2024-08-13-user-${randomString()}@api.com`; let user: User; const maxRecurrenceCount = 4; @@ -380,7 +385,9 @@ describe("Bookings Endpoints 2024-08-13", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ + name: `recurring-bookings-2024-08-13-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ @@ -393,17 +400,18 @@ describe("Bookings Endpoints 2024-08-13", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `recurring-bookings-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); + const recurringEventSlug = `recurring-bookings-2024-08-13-event-type-${randomString()}`; const recurringEvent = await eventTypesRepositoryFixture.create( // note(Lauris): freq 2 means weekly, interval 1 means every week and count 3 means 3 weeks in a row { - title: "peer coding recurring", - slug: "peer-coding-recurring", + title: `recurring-bookings-2024-08-13-event-type-${randomString()}`, + slug: recurringEventSlug, length: 60, recurringEvent: { freq: 2, count: maxRecurrenceCount, interval: 1 }, }, @@ -551,7 +559,7 @@ describe("Bookings Endpoints 2024-08-13", () => { let oAuthClient: PlatformOAuthClient; let teamRepositoryFixture: TeamRepositoryFixture; - const userEmail = "bookings-controller-e2e@api.com"; + const userEmail = `recurring-bookings-2024-08-13-user-${randomString()}@api.com`; let user: User; const maxRecurrenceCount = 4; @@ -587,7 +595,9 @@ describe("Bookings Endpoints 2024-08-13", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ + name: `recurring-bookings-2024-08-13-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ @@ -600,17 +610,18 @@ describe("Bookings Endpoints 2024-08-13", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `recurring-bookings-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); + const recurringEventSlug = `recurring-bookings-2024-08-13-event-type-${randomString()}`; const recurringEvent = await eventTypesRepositoryFixture.create( // note(Lauris): freq 2 means weekly, interval 1 means every week and count 3 means 3 weeks in a row { - title: "peer coding recurring", - slug: "peer-coding-recurring", + title: `recurring-bookings-2024-08-13-event-type-${randomString()}`, + slug: recurringEventSlug, length: 60, recurringEvent: { freq: 2, count: maxRecurrenceCount, interval: 1 }, }, diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/seated-bookings.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/seated-bookings.e2e-spec.ts index a7f9fb6319..bb5ab98d82 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/seated-bookings.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/seated-bookings.e2e-spec.ts @@ -19,6 +19,7 @@ import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-type import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-client.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants"; @@ -51,22 +52,23 @@ describe("Bookings Endpoints 2024-08-13", () => { let oAuthClient: PlatformOAuthClient; let teamRepositoryFixture: TeamRepositoryFixture; - const userEmail = "seated-bookings-controller-e2e@api.com"; + const userEmail = `seated-bookings-user-${randomString()}@api.com`; let user: User; - const seatedTventTypeSlug = "peer-coding-seated"; - const recurringSeatedTventTypeSlug = "peer-coding-recurring-seated"; let seatedEventTypeId: number; let recurringSeatedEventTypeId: number; const maxRecurrenceCount = 3; + const seatedEventSlug = `seated-bookings-event-type-${randomString()}`; + const recurringSeatedEventSlug = `seated-bookings-event-type-${randomString()}`; + let createdSeatedBooking: CreateSeatedBookingOutput_2024_08_13; let createdRecurringSeatedBooking: CreateRecurringSeatedBookingOutput_2024_08_13[]; - const emailAttendeeOne = "mr_proper_seated@gmail.com"; - const nameAttendeeOne = "Mr Proper Seated"; - const emailAttendeeTwo = "mr_proper_friend_seated@gmail.com"; - const nameAttendeeTwo = "Mr Proper Friend Seated"; + const emailAttendeeOne = `seated-bookings-attendee1-${randomString()}@api.com`; + const nameAttendeeOne = `Attendee One ${randomString()}`; + const emailAttendeeTwo = `seated-bookings-attendee2-${randomString()}@api.com`; + const nameAttendeeTwo = `Attendee Two ${randomString()}`; beforeAll(async () => { const moduleRef = await withApiAuth( @@ -88,7 +90,9 @@ describe("Bookings Endpoints 2024-08-13", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ + name: `seated-bookings-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ @@ -101,15 +105,15 @@ describe("Bookings Endpoints 2024-08-13", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `seated-bookings-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); const seatedEvent = await eventTypesRepositoryFixture.create( { - title: "peer coding", - slug: seatedTventTypeSlug, + title: `seated-bookings-2024-08-13-event-type-${randomString()}`, + slug: seatedEventSlug, length: 60, seatsPerTimeSlot: 5, seatsShowAttendees: true, @@ -123,8 +127,8 @@ describe("Bookings Endpoints 2024-08-13", () => { const recurringSeatedEvent = await eventTypesRepositoryFixture.create( // note(Lauris): freq 2 means weekly, interval 1 means every week and count 3 means 3 weeks in a row { - title: "peer coding recurring", - slug: recurringSeatedTventTypeSlug, + title: `seated-bookings-2024-08-13-recurring-event-type-${randomString()}`, + slug: recurringSeatedEventSlug, length: 60, recurringEvent: { freq: 2, count: maxRecurrenceCount, interval: 1 }, seatsPerTimeSlot: 5, @@ -200,7 +204,7 @@ describe("Bookings Endpoints 2024-08-13", () => { expect(data.eventTypeId).toEqual(seatedEventTypeId); expect(data.eventType).toEqual({ id: seatedEventTypeId, - slug: seatedTventTypeSlug, + slug: seatedEventSlug, }); expect(data.attendees.length).toEqual(1); expect(data.attendees[0]).toEqual({ @@ -272,7 +276,7 @@ describe("Bookings Endpoints 2024-08-13", () => { expect(data.eventTypeId).toEqual(seatedEventTypeId); expect(data.eventType).toEqual({ id: seatedEventTypeId, - slug: seatedTventTypeSlug, + slug: seatedEventSlug, }); expect(data.attendees.length).toEqual(2); // note(Lauris): first attendee is from previous test request @@ -366,7 +370,7 @@ describe("Bookings Endpoints 2024-08-13", () => { expect(firstBooking.eventTypeId).toEqual(recurringSeatedEventTypeId); expect(firstBooking.eventType).toEqual({ id: recurringSeatedEventTypeId, - slug: recurringSeatedTventTypeSlug, + slug: recurringSeatedEventSlug, }); expect(firstBooking.attendees.length).toEqual(1); expect(firstBooking.attendees[0]).toEqual({ @@ -401,7 +405,7 @@ describe("Bookings Endpoints 2024-08-13", () => { expect(secondBooking.eventTypeId).toEqual(recurringSeatedEventTypeId); expect(secondBooking.eventType).toEqual({ id: recurringSeatedEventTypeId, - slug: recurringSeatedTventTypeSlug, + slug: recurringSeatedEventSlug, }); expect(secondBooking.attendees.length).toEqual(1); expect(secondBooking.attendees[0]).toEqual({ @@ -575,7 +579,7 @@ describe("Bookings Endpoints 2024-08-13", () => { expect(data.eventTypeId).toEqual(seatedEventTypeId); expect(data.eventType).toEqual({ id: seatedEventTypeId, - slug: seatedTventTypeSlug, + slug: seatedEventSlug, }); expect(data.attendees.length).toEqual(1); const attendee = createdSeatedBooking.attendees.find((a) => a.seatUid === body.seatUid); @@ -629,7 +633,7 @@ describe("Bookings Endpoints 2024-08-13", () => { expect(data.eventTypeId).toEqual(seatedEventTypeId); expect(data.eventType).toEqual({ id: seatedEventTypeId, - slug: seatedTventTypeSlug, + slug: seatedEventSlug, }); expect(data.attendees.length).toEqual(0); expect(data.location).toBeDefined(); @@ -681,22 +685,23 @@ describe("Bookings Endpoints 2024-08-13", () => { let oAuthClient: PlatformOAuthClient; let teamRepositoryFixture: TeamRepositoryFixture; - const userEmail = "seated-bookings-controller-e2e@api.com"; + const userEmail = `seated-bookings-user-${randomString()}@api.com`; let user: User; - const seatedTventTypeSlug = "peer-coding-seated"; - const recurringSeatedTventTypeSlug = "peer-coding-recurring-seated"; let seatedEventTypeId: number; let recurringSeatedEventTypeId: number; const maxRecurrenceCount = 3; + const seatedEventSlug = `seated-bookings-event-type-${randomString()}`; + const recurringSeatedEventSlug = `seated-bookings-event-type-${randomString()}`; + let createdSeatedBooking: CreateSeatedBookingOutput_2024_08_13; let createdRecurringSeatedBooking: CreateRecurringSeatedBookingOutput_2024_08_13[]; - const emailAttendeeOne = "mr_proper_first@gmail.com"; - const nameAttendeeOne = "Mr Proper First"; - const emailAttendeeTwo = "mr_proper_second@gmail.com"; - const nameAttendeeTwo = "Mr Proper Second"; + const emailAttendeeOne = `seated-bookings-attendee1-${randomString()}@api.com`; + const nameAttendeeOne = `Attendee One ${randomString()}`; + const emailAttendeeTwo = `seated-bookings-attendee2-${randomString()}@api.com`; + const nameAttendeeTwo = `Attendee Two ${randomString()}`; beforeAll(async () => { const moduleRef = await withApiAuth( @@ -718,7 +723,9 @@ describe("Bookings Endpoints 2024-08-13", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ + name: `seated-bookings-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ @@ -731,20 +738,17 @@ describe("Bookings Endpoints 2024-08-13", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `seated-bookings-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); const seatedEvent = await eventTypesRepositoryFixture.create( { - title: "peer coding", - slug: seatedTventTypeSlug, + title: `seated-bookings-2024-08-13-event-type-${randomString()}`, + slug: seatedEventSlug, length: 60, - seatsPerTimeSlot: 5, - seatsShowAttendees: true, - seatsShowAvailabilityCount: true, - locations: [{ type: "inPerson", address: "via 10, rome, italy" }], + seatsPerTimeSlot: 3, }, user.id ); @@ -753,14 +757,11 @@ describe("Bookings Endpoints 2024-08-13", () => { const recurringSeatedEvent = await eventTypesRepositoryFixture.create( // note(Lauris): freq 2 means weekly, interval 1 means every week and count 3 means 3 weeks in a row { - title: "peer coding recurring", - slug: recurringSeatedTventTypeSlug, + title: `seated-bookings-2024-08-13-recurring-event-type-${randomString()}`, + slug: recurringSeatedEventSlug, length: 60, + seatsPerTimeSlot: 3, recurringEvent: { freq: 2, count: maxRecurrenceCount, interval: 1 }, - seatsPerTimeSlot: 5, - seatsShowAttendees: true, - seatsShowAvailabilityCount: true, - locations: [{ type: "inPerson", address: "via 10, rome, italy" }], }, user.id ); @@ -836,7 +837,7 @@ describe("Bookings Endpoints 2024-08-13", () => { expect(firstBooking.eventTypeId).toEqual(recurringSeatedEventTypeId); expect(firstBooking.eventType).toEqual({ id: recurringSeatedEventTypeId, - slug: recurringSeatedTventTypeSlug, + slug: recurringSeatedEventSlug, }); expect(firstBooking.attendees.length).toEqual(1); expect(firstBooking.attendees[0]).toEqual({ @@ -871,7 +872,7 @@ describe("Bookings Endpoints 2024-08-13", () => { expect(secondBooking.eventTypeId).toEqual(recurringSeatedEventTypeId); expect(secondBooking.eventType).toEqual({ id: recurringSeatedEventTypeId, - slug: recurringSeatedTventTypeSlug, + slug: recurringSeatedEventSlug, }); expect(secondBooking.attendees.length).toEqual(1); expect(secondBooking.attendees[0]).toEqual({ @@ -949,7 +950,7 @@ describe("Bookings Endpoints 2024-08-13", () => { expect(firstBooking.eventTypeId).toEqual(recurringSeatedEventTypeId); expect(firstBooking.eventType).toEqual({ id: recurringSeatedEventTypeId, - slug: recurringSeatedTventTypeSlug, + slug: recurringSeatedEventSlug, }); expect(firstBooking.attendees.length).toEqual(2); const firstAttendee = firstBooking.attendees.find( @@ -1003,7 +1004,7 @@ describe("Bookings Endpoints 2024-08-13", () => { expect(secondBooking.eventTypeId).toEqual(recurringSeatedEventTypeId); expect(secondBooking.eventType).toEqual({ id: recurringSeatedEventTypeId, - slug: recurringSeatedTventTypeSlug, + slug: recurringSeatedEventSlug, }); expect(secondBooking.attendees.length).toEqual(2); expect(secondBooking.attendees[0]).toEqual({ diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/team-bookings.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/team-bookings.e2e-spec.ts index 1fb926ded4..37e8adf5d3 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/team-bookings.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/team-bookings.e2e-spec.ts @@ -21,6 +21,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants"; @@ -52,8 +53,8 @@ describe("Bookings Endpoints 2024-08-13", () => { let organizationsRepositoryFixture: OrganizationRepositoryFixture; let profileRepositoryFixture: ProfileRepositoryFixture; - const teamUserEmail = "orgUser1team1@api.com"; - const teamUserEmail2 = "orgUser2team1@api.com"; + const teamUserEmail = `team-bookings-user1-${randomString()}@api.com`; + const teamUserEmail2 = `team-bookings-user2-${randomString()}@api.com`; let teamUser: User; let teamUser2: User; @@ -61,6 +62,10 @@ describe("Bookings Endpoints 2024-08-13", () => { let team2EventTypeId: number; let phoneOnlyEventTypeId: number; + const team1EventTypeSlug = `team-bookings-event-type-${randomString()}`; + const team2EventTypeSlug = `team-bookings-event-type-${randomString()}`; + const phoneOnlyEventTypeSlug = `team-bookings-event-type-${randomString()}`; + beforeAll(async () => { const moduleRef = await withApiAuth( teamUserEmail, @@ -85,11 +90,13 @@ describe("Bookings Endpoints 2024-08-13", () => { hostsRepositoryFixture = new HostsRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await organizationsRepositoryFixture.create({ name: "organization team bookings" }); + organization = await organizationsRepositoryFixture.create({ + name: `team-bookings-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); team1 = await teamRepositoryFixture.create({ - name: "team 1", + name: `team-bookings-team1-${randomString()}`, isOrganization: false, parent: { connect: { id: organization.id } }, createdByOAuthClient: { @@ -100,7 +107,7 @@ describe("Bookings Endpoints 2024-08-13", () => { }); team2 = await teamRepositoryFixture.create({ - name: "team 2", + name: `team-bookings-team2-${randomString()}`, isOrganization: false, parent: { connect: { id: organization.id } }, createdByOAuthClient: { @@ -133,7 +140,7 @@ describe("Bookings Endpoints 2024-08-13", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `team-bookings-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; @@ -196,8 +203,8 @@ describe("Bookings Endpoints 2024-08-13", () => { team: { connect: { id: team1.id }, }, - title: "Collective Event Type", - slug: "collective-event-type", + title: `team-bookings-2024-08-13-event-type-${randomString()}`, + slug: team1EventTypeSlug, length: 60, assignAllTeamMembers: true, bookingFields: [], @@ -211,8 +218,8 @@ describe("Bookings Endpoints 2024-08-13", () => { team: { connect: { id: team1.id }, }, - title: "Phone Only Event Type", - slug: "phone-only-event-type", + title: `team-bookings-2024-08-13-event-type-${randomString()}`, + slug: phoneOnlyEventTypeSlug, length: 15, assignAllTeamMembers: false, hosts: { @@ -288,8 +295,8 @@ describe("Bookings Endpoints 2024-08-13", () => { team: { connect: { id: team2.id }, }, - title: "Collective Event Type 2", - slug: "collective-event-type-2", + title: `team-bookings-2024-08-13-event-type-${randomString()}`, + slug: team2EventTypeSlug, length: 60, assignAllTeamMembers: true, bookingFields: [], diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts index 6f001fda88..0eaa6eb14b 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts @@ -21,6 +21,7 @@ import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-type import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-client.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { @@ -58,12 +59,13 @@ describe("Bookings Endpoints 2024-08-13", () => { let oAuthClient: PlatformOAuthClient; let teamRepositoryFixture: TeamRepositoryFixture; - const userEmail = "bookings-controller-e2e@api.com"; + const userEmail = `user-bookings-user-${randomString()}@api.com`; let user: User; let eventTypeId: number; - const eventTypeSlug = "peer-coding"; + const eventTypeSlug = `user-bookings-event-type-${randomString()}`; let recurringEventTypeId: number; + const recurringEventTypeSlug = `user-bookings-event-type-${randomString()}`; let createdBooking: BookingOutput_2024_08_13; let rescheduledBooking: BookingOutput_2024_08_13; @@ -91,12 +93,14 @@ describe("Bookings Endpoints 2024-08-13", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ + name: `user-bookings-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ email: userEmail, - username: `bob-${Math.floor(Math.random() * 1000)}@gmail.com`, + username: userEmail, platformOAuthClients: { connect: { id: oAuthClient.id, @@ -105,13 +109,18 @@ describe("Bookings Endpoints 2024-08-13", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `user-bookings-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; await schedulesService.createUserSchedule(user.id, userSchedule); + const event = await eventTypesRepositoryFixture.create( - { title: "peer coding", slug: eventTypeSlug, length: 60 }, + { + title: `user-bookings-2024-08-13-event-type-${randomString()}`, + slug: eventTypeSlug, + length: 60, + }, user.id ); eventTypeId = event.id; @@ -120,7 +129,7 @@ describe("Bookings Endpoints 2024-08-13", () => { // note(Lauris): freq 2 means weekly, interval 1 means every week and count 3 means 3 weeks in a row { title: "peer coding recurring", - slug: "peer-coding-recurring", + slug: recurringEventTypeSlug, length: 60, recurringEvent: { freq: 2, count: 3, interval: 1 }, }, diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/variable-length-bookings.e2e-spec.ts b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/variable-length-bookings.e2e-spec.ts index bb406fd1ae..3c316aed5c 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/variable-length-bookings.e2e-spec.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/variable-length-bookings.e2e-spec.ts @@ -17,6 +17,7 @@ import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-type import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-client.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants"; @@ -36,12 +37,13 @@ describe("Bookings Endpoints 2024-08-13", () => { let oAuthClient: PlatformOAuthClient; let teamRepositoryFixture: TeamRepositoryFixture; - const userEmail = "bookings-controller-e2e@api.com"; + const userEmail = `variable-length-bookings-2024-08-13-user-${randomString()}@api.com`; let user: User; let variableLengthEventType: EventType; - const variableLengthEventTypeSlug = "variable-length-event"; + const VARIABLE_LENGTH_EVENT_TYPE_SLUG = `variable-length-bookings-2024-08-13-event-type-${randomString()}`; let normalEventType: EventType; + const NORMAL_EVENT_TYPE_SLUG = `variable-length-bookings-2024-08-13-event-type-${randomString()}`; beforeAll(async () => { const moduleRef = await withApiAuth( @@ -63,7 +65,9 @@ describe("Bookings Endpoints 2024-08-13", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); schedulesService = moduleRef.get(SchedulesService_2024_04_15); - organization = await teamRepositoryFixture.create({ name: "organization bookings" }); + organization = await teamRepositoryFixture.create({ + name: `variable-length-bookings-2024-08-13-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ @@ -76,7 +80,7 @@ describe("Bookings Endpoints 2024-08-13", () => { }); const userSchedule: CreateScheduleInput_2024_04_15 = { - name: "working time", + name: `variable-length-bookings-2024-08-13-schedule-${randomString()}`, timeZone: "Europe/Rome", isDefault: true, }; @@ -84,8 +88,8 @@ describe("Bookings Endpoints 2024-08-13", () => { variableLengthEventType = await eventTypesRepositoryFixture.create( { - title: "variable length event", - slug: variableLengthEventTypeSlug, + title: `variable-length-bookings-2024-08-13-event-type-${randomString()}`, + slug: VARIABLE_LENGTH_EVENT_TYPE_SLUG, length: 15, metadata: { multipleDuration: [15, 30, 60] }, }, @@ -93,7 +97,11 @@ describe("Bookings Endpoints 2024-08-13", () => { ); normalEventType = await eventTypesRepositoryFixture.create( - { title: "normal event", slug: "normal-event", length: 15 }, + { + title: `variable-length-bookings-2024-08-13-event-type-${randomString()}`, + slug: NORMAL_EVENT_TYPE_SLUG, + length: 15, + }, user.id ); diff --git a/apps/api/v2/src/ee/calendars/controllers/calendars.controller.e2e-spec.ts b/apps/api/v2/src/ee/calendars/controllers/calendars.controller.e2e-spec.ts index c0e2d0575b..84db5e556d 100644 --- a/apps/api/v2/src/ee/calendars/controllers/calendars.controller.e2e-spec.ts +++ b/apps/api/v2/src/ee/calendars/controllers/calendars.controller.e2e-spec.ts @@ -20,6 +20,7 @@ import { TokensRepositoryFixture } from "test/fixtures/repository/tokens.reposit import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; import { CalendarsServiceMock } from "test/mocks/calendars-service-mock"; import { IcsCalendarServiceMock } from "test/mocks/ics-calendar-service-mock"; +import { randomString } from "test/utils/randomString"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; import { @@ -71,9 +72,12 @@ describe("Platform Calendars Endpoints", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); tokensRepositoryFixture = new TokensRepositoryFixture(moduleRef); credentialsRepositoryFixture = new CredentialsRepositoryFixture(moduleRef); - organization = await teamRepositoryFixture.create({ name: "organization" }); + organization = await teamRepositoryFixture.create({ name: `calendars-organization-${randomString()}` }); oAuthClient = await createOAuthClient(organization.id); - user = await userRepositoryFixture.createOAuthManagedUser("office365-connect@gmail.com", oAuthClient.id); + user = await userRepositoryFixture.createOAuthManagedUser( + `calendars-user-${randomString()}@api.com`, + oAuthClient.id + ); const tokens = await tokensRepositoryFixture.createTokens(user.id, oAuthClient.id); accessTokenSecret = tokens.accessToken; refreshTokenSecret = tokens.refreshToken; diff --git a/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts b/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts index d332e4a88b..cd3deb317e 100644 --- a/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts +++ b/apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.e2e-spec.ts @@ -22,6 +22,7 @@ import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-type import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-client.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { @@ -77,8 +78,8 @@ describe("Event types Endpoints", () => { let teamRepositoryFixture: TeamRepositoryFixture; let eventTypesRepositoryFixture: EventTypesRepositoryFixture; - const userEmail = "event-types-test-e2e@api.com"; - const name = "bob-the-builder"; + const userEmail = `event-types-2024-04-15-user-${randomString()}@api.com`; + const name = `event-types-2024-04-15-user-${randomString()}`; const username = name; let eventType: EventType; let user: User; @@ -105,7 +106,9 @@ describe("Event types Endpoints", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); eventTypesRepositoryFixture = new EventTypesRepositoryFixture(moduleRef); - organization = await teamRepositoryFixture.create({ name: "organization" }); + organization = await teamRepositoryFixture.create({ + name: `event-types-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ email: userEmail, @@ -139,7 +142,7 @@ describe("Event types Endpoints", () => { it("should create an event type", async () => { const body: CreateEventTypeInput_2024_04_15 = { title: "Test Event Type", - slug: "test-event-type", + slug: `event-types-event-type-${randomString()}`, description: "A description of the test event type.", length: 60, hidden: false, diff --git a/apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts b/apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts index 55688922fa..b5273e4586 100644 --- a/apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts +++ b/apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts @@ -19,6 +19,7 @@ import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repo import { SchedulesRepositoryFixture } from "test/fixtures/repository/schedules.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_06_14 } from "@calcom/platform-constants"; @@ -86,9 +87,9 @@ describe("Event types Endpoints", () => { let schedulesRepostoryFixture: SchedulesRepositoryFixture; let profileRepositoryFixture: ProfileRepositoryFixture; let membershipsRepositoryFixture: MembershipRepositoryFixture; - const userEmail = "event-types-test-e2e@api.com"; - const falseTestEmail = "false-event-types@api.com"; - const name = "bob-the-builder"; + const userEmail = `event-types-2024-06-14-user-${randomString()}@api.com`; + const falseTestEmail = `event-types-2024-06-14-false-user-${randomString()}@api.com`; + const name = `event-types-2024-06-14-user-${randomString()}`; const username = name; let eventType: EventTypeOutput_2024_06_14; let user: User; @@ -186,8 +187,8 @@ describe("Event types Endpoints", () => { profileRepositoryFixture = new ProfileRepositoryFixture(moduleRef); membershipsRepositoryFixture = new MembershipRepositoryFixture(moduleRef); organization = await teamRepositoryFixture.create({ - name: "organization", - slug: "event-type-2024-06-14-org-slug", + name: `event-types-2024-06-14-organization-${randomString()}`, + slug: `event-type-2024-06-14-org-slug-${randomString()}`, }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ @@ -197,9 +198,9 @@ describe("Event types Endpoints", () => { }); orgUser = await userRepositoryFixture.create({ - email: "event-types-2024-06-14-org-user@example.com", - name: "event-types-2024-06-14-org-user", - username: "event-types-2024-06-14-org-user", + email: `event-types-2024-06-14-org-user-${randomString()}@example.com`, + name: `event-types-2024-06-14-org-user-${randomString()}`, + username: `event-types-2024-06-14-org-user-${randomString()}`, }); profileRepositoryFixture.create({ @@ -218,17 +219,32 @@ describe("Event types Endpoints", () => { }); orgUserEventType1 = await eventTypesRepositoryFixture.create( - { title: "orgUserEventType1", slug: "org-event-type-1", length: 60, locations: [] }, + { + title: `event-types-2024-06-14-event-type-${randomString()}`, + slug: `event-types-2024-06-14-event-type-${randomString()}`, + length: 60, + locations: [], + }, orgUser.id ); orgUserEventType2 = await eventTypesRepositoryFixture.create( - { title: "orgUserEventType2", slug: "org-event-type-2", length: 60, locations: [] }, + { + title: `event-types-2024-06-14-event-type-${randomString()}`, + slug: `event-types-2024-06-14-event-type-${randomString()}`, + length: 60, + locations: [], + }, orgUser.id ); orgUserEventType3 = await eventTypesRepositoryFixture.create( - { title: "orgUserEventType3", slug: "org-event-type-3", length: 60, locations: [] }, + { + title: `event-types-2024-06-14-event-type-${randomString()}`, + slug: `event-types-2024-06-14-event-type-${randomString()}`, + length: 60, + locations: [], + }, orgUser.id ); @@ -241,25 +257,25 @@ describe("Event types Endpoints", () => { falseTestUser = await userRepositoryFixture.create({ email: falseTestEmail, - name: "false-test", + name: `event-types-2024-06-14-false-test-user-${randomString()}`, username: falseTestEmail, }); firstSchedule = await schedulesRepostoryFixture.create({ userId: user.id, - name: "work", + name: `event-types-2024-06-14-schedule-work-${randomString()}`, timeZone: "Europe/Rome", }); secondSchedule = await schedulesRepostoryFixture.create({ userId: user.id, - name: "chill", + name: `event-types-2024-06-14-schedule-chill-${randomString()}`, timeZone: "Europe/Rome", }); falseTestSchedule = await schedulesRepostoryFixture.create({ userId: falseTestUser.id, - name: "work", + name: `event-types-2024-06-14-schedule-work-${randomString()}`, timeZone: "Europe/Rome", }); @@ -1221,7 +1237,9 @@ describe("Event types Endpoints", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); eventTypesRepositoryFixture = new EventTypesRepositoryFixture(moduleRef); - organization = await teamRepositoryFixture.create({ name: "organization" }); + organization = await teamRepositoryFixture.create({ + name: `event-types-2024-06-14-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ email: userEmail, @@ -1708,7 +1726,9 @@ describe("Event types Endpoints", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); eventTypesRepositoryFixture = new EventTypesRepositoryFixture(moduleRef); - organization = await teamRepositoryFixture.create({ name: "organization" }); + organization = await teamRepositoryFixture.create({ + name: `event-types-2024-06-14-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); user = await userRepositoryFixture.create({ email: userEmail, diff --git a/apps/api/v2/src/ee/me/me.controller.e2e-spec.ts b/apps/api/v2/src/ee/me/me.controller.e2e-spec.ts index d69ae85390..fb2df5f26f 100644 --- a/apps/api/v2/src/ee/me/me.controller.e2e-spec.ts +++ b/apps/api/v2/src/ee/me/me.controller.e2e-spec.ts @@ -15,6 +15,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { SchedulesRepositoryFixture } from "test/fixtures/repository/schedules.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -29,7 +30,7 @@ describe("Me Endpoints", () => { let schedulesRepositoryFixture: SchedulesRepositoryFixture; let profilesRepositoryFixture: ProfileRepositoryFixture; let organizationsRepositoryFixture: OrganizationRepositoryFixture; - const userEmail = "me-controller-e2e@api.com"; + const userEmail = `me-controller-user-${randomString()}@api.com`; let user: User; let org: Team; @@ -58,7 +59,7 @@ describe("Me Endpoints", () => { }); org = await organizationsRepositoryFixture.create({ - name: "Test org team", + name: `me-controller-organization-${randomString()}`, isOrganization: true, isPlatform: true, }); diff --git a/apps/api/v2/src/ee/schedules/schedules_2024_04_15/controllers/schedules.controller.e2e-spec.ts b/apps/api/v2/src/ee/schedules/schedules_2024_04_15/controllers/schedules.controller.e2e-spec.ts index 370cd14929..d858a497d2 100644 --- a/apps/api/v2/src/ee/schedules/schedules_2024_04_15/controllers/schedules.controller.e2e-spec.ts +++ b/apps/api/v2/src/ee/schedules/schedules_2024_04_15/controllers/schedules.controller.e2e-spec.ts @@ -16,6 +16,7 @@ import { User } from "@prisma/client"; import * as request from "supertest"; import { SchedulesRepositoryFixture } from "test/fixtures/repository/schedules.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_04_15 } from "@calcom/platform-constants"; @@ -28,10 +29,11 @@ describe("Schedules Endpoints", () => { let userRepositoryFixture: UserRepositoryFixture; let scheduleRepositoryFixture: SchedulesRepositoryFixture; - const userEmail = "schedules-controller-e2e@api.com"; + const userEmail = `schedules-2024-04-15-user-${randomString()}@api.com`; let user: User; let createdSchedule: CreateScheduleOutput_2024_04_15["data"]; + const scheduleName = `schedules-2024-04-15-schedule-${randomString()}`; const defaultAvailabilityDays = [1, 2, 3, 4, 5]; const defaultAvailabilityStartTime = "1970-01-01T09:00:00.000Z"; const defaultAvailabilityEndTime = "1970-01-01T17:00:00.000Z"; @@ -67,7 +69,6 @@ describe("Schedules Endpoints", () => { }); it("should not create an invalid schedule", async () => { - const scheduleName = "schedule-name"; const scheduleTimeZone = "Europe/Rome"; const isDefault = true; @@ -98,13 +99,11 @@ describe("Schedules Endpoints", () => { }); it("should create a default schedule", async () => { - const scheduleName = "schedule-name"; - const scheduleTimeZone = "Europe/Rome"; const isDefault = true; const body: CreateScheduleInput_2024_04_15 = { name: scheduleName, - timeZone: scheduleTimeZone, + timeZone: "Europe/Rome", isDefault, }; @@ -118,7 +117,7 @@ describe("Schedules Endpoints", () => { expect(responseData.status).toEqual(SUCCESS_STATUS); expect(responseData.data).toBeDefined(); expect(responseData.data.isDefault).toEqual(isDefault); - expect(responseData.data.timeZone).toEqual(scheduleTimeZone); + expect(responseData.data.timeZone).toEqual("Europe/Rome"); expect(responseData.data.name).toEqual(scheduleName); const schedule = responseData.data.schedule; @@ -177,7 +176,7 @@ describe("Schedules Endpoints", () => { }); it("should update schedule name", async () => { - const newScheduleName = "new-schedule-name"; + const newScheduleName = `schedules-2024-04-15-schedule-${randomString()}`; const body: UpdateScheduleInput_2024_04_15 = { name: newScheduleName, diff --git a/apps/api/v2/src/ee/schedules/schedules_2024_06_11/controllers/schedules.controller.e2e-spec.ts b/apps/api/v2/src/ee/schedules/schedules_2024_06_11/controllers/schedules.controller.e2e-spec.ts index e12d7598fb..b0bec9d735 100644 --- a/apps/api/v2/src/ee/schedules/schedules_2024_06_11/controllers/schedules.controller.e2e-spec.ts +++ b/apps/api/v2/src/ee/schedules/schedules_2024_06_11/controllers/schedules.controller.e2e-spec.ts @@ -32,11 +32,11 @@ describe("Schedules Endpoints", () => { let userRepositoryFixture: UserRepositoryFixture; let scheduleRepositoryFixture: SchedulesRepositoryFixture; - const userEmail = "schedules-controller-e2e@api.com"; + const userEmail = `schedules-2024-06-11-user@api.com`; let user: User; const createScheduleInput: CreateScheduleInput_2024_06_11 = { - name: "work", + name: `schedules-2024-06-11-work`, timeZone: "Europe/Rome", isDefault: true, }; diff --git a/apps/api/v2/src/modules/auth/strategies/api-auth/api-auth.strategy.e2e-spec.ts b/apps/api/v2/src/modules/auth/strategies/api-auth/api-auth.strategy.e2e-spec.ts index 6351591ff2..b4bdb132ab 100644 --- a/apps/api/v2/src/modules/auth/strategies/api-auth/api-auth.strategy.e2e-spec.ts +++ b/apps/api/v2/src/modules/auth/strategies/api-auth/api-auth.strategy.e2e-spec.ts @@ -23,6 +23,7 @@ import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository. import { TokensRepositoryFixture } from "test/fixtures/repository/tokens.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; import { MockedRedisService } from "test/mocks/mock-redis-service"; +import { randomString } from "test/utils/randomString"; import { X_CAL_CLIENT_ID, X_CAL_SECRET_KEY } from "@calcom/platform-constants"; @@ -39,9 +40,9 @@ describe("ApiAuthStrategy", () => { let oAuthClientRepositoryFixture: OAuthClientRepositoryFixture; let profilesRepositoryFixture: ProfileRepositoryFixture; - const validApiKeyEmail = "api-key-user-email@example.com"; - const validAccessTokenEmail = "access-token-user-email@example.com"; - const validOAuthEmail = "oauth-user@example.com"; + const validApiKeyEmail = `api-auth-api-key-user-${randomString()}@api.com`; + const validAccessTokenEmail = `api-auth-access-token-user-${randomString()}@api.com`; + const validOAuthEmail = `api-auth-oauth-user-${randomString()}@api.com`; let validApiKeyUser: User; let validAccessTokenUser: User; @@ -83,7 +84,7 @@ describe("ApiAuthStrategy", () => { teamRepositoryFixture = new TeamRepositoryFixture(module); oAuthClientRepositoryFixture = new OAuthClientRepositoryFixture(module); profilesRepositoryFixture = new ProfileRepositoryFixture(module); - organization = await teamRepositoryFixture.create({ name: "organization" }); + organization = await teamRepositoryFixture.create({ name: `api-auth-organization-${randomString()}` }); validApiKeyUser = await userRepositoryFixture.create({ email: validApiKeyEmail, }); diff --git a/apps/api/v2/src/modules/billing/controllers/billing.controller.e2e-spec.ts b/apps/api/v2/src/modules/billing/controllers/billing.controller.e2e-spec.ts index db83acd38e..5a9124c4de 100644 --- a/apps/api/v2/src/modules/billing/controllers/billing.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/billing/controllers/billing.controller.e2e-spec.ts @@ -16,13 +16,14 @@ import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-cli import { OrganizationRepositoryFixture } from "test/fixtures/repository/organization.repository.fixture"; import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { Team, PlatformOAuthClient, PlatformBilling } from "@calcom/prisma/client"; describe("Platform Billing Controller (e2e)", () => { let app: INestApplication; - const userEmail = "platform-billing-controller-e2e@api.com"; + const userEmail = `billing-user-${randomString()}@api.com`; let user: UserWithProfile; let billing: PlatformBilling; let userRepositoryFixture: UserRepositoryFixture; @@ -47,7 +48,9 @@ describe("Platform Billing Controller (e2e)", () => { oauthClientRepositoryFixture = new OAuthClientRepositoryFixture(moduleRef); membershipsRepositoryFixture = new MembershipRepositoryFixture(moduleRef); platformBillingRepositoryFixture = new PlatformBillingRepositoryFixture(moduleRef); - organization = await organizationsRepositoryFixture.create({ name: "platform billing" }); + organization = await organizationsRepositoryFixture.create({ + name: `billing-organization-${randomString()}`, + }); user = await userRepositoryFixture.create({ email: userEmail, diff --git a/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.e2e-spec.ts b/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.e2e-spec.ts index fbcd9a3799..7ab7365365 100644 --- a/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.e2e-spec.ts @@ -11,6 +11,7 @@ import { User } from "@prisma/client"; import * as request from "supertest"; import { CredentialsRepositoryFixture } from "test/fixtures/repository/credentials.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { @@ -30,7 +31,7 @@ describe("Conferencing Endpoints", () => { let userRepositoryFixture: UserRepositoryFixture; let credentialsRepositoryFixture: CredentialsRepositoryFixture; - const userEmail = "conferencing-controller-user-e2e@api.com"; + const userEmail = `conferencing-user-${randomString()}@api.com`; let user: User; beforeAll(async () => { diff --git a/apps/api/v2/src/modules/destination-calendars/controllers/destination-calendars.controller.e2e-spec.ts b/apps/api/v2/src/modules/destination-calendars/controllers/destination-calendars.controller.e2e-spec.ts index aea7ef04d6..662afd30ce 100644 --- a/apps/api/v2/src/modules/destination-calendars/controllers/destination-calendars.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/destination-calendars/controllers/destination-calendars.controller.e2e-spec.ts @@ -17,6 +17,7 @@ import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-cli import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { TokensRepositoryFixture } from "test/fixtures/repository/tokens.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { APPLE_CALENDAR_TYPE, APPLE_CALENDAR_ID } from "@calcom/platform-constants"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -55,9 +56,14 @@ describe("Platform Destination Calendar Endpoints", () => { teamRepositoryFixture = new TeamRepositoryFixture(moduleRef); tokensRepositoryFixture = new TokensRepositoryFixture(moduleRef); credentialsRepositoryFixture = new CredentialsRepositoryFixture(moduleRef); - organization = await teamRepositoryFixture.create({ name: "organization" }); + organization = await teamRepositoryFixture.create({ + name: `destination-calendars-organization-${randomString()}`, + }); oAuthClient = await createOAuthClient(organization.id); - user = await userRepositoryFixture.createOAuthManagedUser("office365-connect@gmail.com", oAuthClient.id); + user = await userRepositoryFixture.createOAuthManagedUser( + `destination-calendars-user-${randomString()}@api.com`, + oAuthClient.id + ); const tokens = await tokensRepositoryFixture.createTokens(user.id, oAuthClient.id); accessTokenSecret = tokens.accessToken; refreshTokenSecret = tokens.refreshToken; diff --git a/apps/api/v2/src/modules/event-types/controllers/event-types-webhooks.controller.e2e-spec.ts b/apps/api/v2/src/modules/event-types/controllers/event-types-webhooks.controller.e2e-spec.ts index a2e26feb33..868e76d5cf 100644 --- a/apps/api/v2/src/modules/event-types/controllers/event-types-webhooks.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/event-types/controllers/event-types-webhooks.controller.e2e-spec.ts @@ -17,13 +17,14 @@ import * as request from "supertest"; import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-types.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; import { WebhookRepositoryFixture } from "test/fixtures/repository/webhooks.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { EventType, Webhook } from "@calcom/prisma/client"; describe("EventTypes WebhooksController (e2e)", () => { let app: INestApplication; - const userEmail = "event-types-webhook-controller-e2e@api.com"; + const userEmail = `event-types-webhooks-user-${randomString()}@api.com`; let user: UserWithProfile; let otherUser: UserWithProfile; let eventType: EventType; @@ -55,14 +56,14 @@ describe("EventTypes WebhooksController (e2e)", () => { }); otherUser = await userRepositoryFixture.create({ - email: "other-user-webhook-controller@api.com", - username: "other-user-webhook-controller@api.com", + email: `event-types-webhooks-other-user-${randomString()}@api.com`, + username: `event-types-webhooks-other-user-${randomString()}@api.com`, }); eventType = await eventTypeRepositoryFixture.create( { title: "Event Type 1", - slug: "webhook-event-type-1", + slug: `event-types-webhooks-event-type-${randomString()}`, length: 60, }, user.id @@ -71,7 +72,7 @@ describe("EventTypes WebhooksController (e2e)", () => { eventType2 = await eventTypeRepositoryFixture.create( { title: "Event Type 2", - slug: "webhook-event-type-2", + slug: `event-types-webhooks-event-type-${randomString()}`, length: 60, }, user.id @@ -80,7 +81,7 @@ describe("EventTypes WebhooksController (e2e)", () => { otherEventType = await eventTypeRepositoryFixture.create( { title: "Other Event Type ", - slug: "other-webhook-event-type", + slug: `event-types-webhooks-other-event-type-${randomString()}`, length: 60, }, otherUser.id diff --git a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.e2e-spec.ts b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.e2e-spec.ts index 5f9d1f1ba4..533c7af03d 100644 --- a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.e2e-spec.ts @@ -22,6 +22,7 @@ import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repo import { SchedulesRepositoryFixture } from "test/fixtures/repository/schedules.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; import { ApiSuccessResponse } from "@calcom/platform-types"; @@ -84,10 +85,10 @@ describe("OAuth Client Users Endpoints", () => { let postResponseData: CreateManagedUserOutput["data"]; - const platformAdminEmail = "platform-sensei@mail.com"; + const platformAdminEmail = `oauth-client-users-admin-${randomString()}@api.com`; let platformAdmin: User; - const userEmail = "oauth-client-user@gmail.com"; + const userEmail = `oauth-client-users-user-${randomString()}@api.com`; const userTimeZone = "Europe/Rome"; beforeAll(async () => { @@ -110,7 +111,7 @@ describe("OAuth Client Users Endpoints", () => { platformAdmin = await userRepositoryFixture.create({ email: platformAdminEmail }); organization = await teamRepositoryFixture.create({ - name: "organization", + name: `oauth-client-users-organization-${randomString()}`, isPlatform: true, isOrganization: true, }); @@ -392,7 +393,7 @@ describe("OAuth Client Users Endpoints", () => { let membershipsRepositoryFixture: MembershipRepositoryFixture; let postResponseData: CreateManagedUserOutput["data"]; - const userEmail = "oauth-client-users-user@gmail.com"; + const userEmail = `oauth-client-users-user-${randomString()}@api.com`; const userTimeZone = "Europe/Rome"; beforeAll(async () => { @@ -411,20 +412,20 @@ describe("OAuth Client Users Endpoints", () => { profileRepositoryFixture = new ProfileRepositoryFixture(moduleRef); membershipsRepositoryFixture = new MembershipRepositoryFixture(moduleRef); organization = await teamRepositoryFixture.create({ - name: "Testy Organization", - isOrganization: true, + name: `oauth-client-users-organization-${randomString()}`, isPlatform: true, + isOrganization: true, }); owner = await userRepositoryFixture.create({ - email: userEmail, - username: userEmail, + email: `oauth-client-users-admin-${randomString()}@api.com`, + username: `oauth-client-users-admin-${randomString()}@api.com`, organization: { connect: { id: organization.id } }, }); await profileRepositoryFixture.create({ uid: `usr-${owner.id}`, - username: userEmail, + username: `oauth-client-users-admin-${randomString()}@api.com`, organization: { connect: { id: organization.id, diff --git a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.e2e-spec.ts b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.e2e-spec.ts index 01316d537c..fafc5792df 100644 --- a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-webhooks/oauth-client-webhooks.controller.e2e-spec.ts @@ -20,14 +20,15 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; import { WebhookRepositoryFixture } from "test/fixtures/repository/webhooks.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withNextAuth } from "test/utils/withNextAuth"; import { PlatformOAuthClient, Team, Webhook } from "@calcom/prisma/client"; describe("OAuth client WebhooksController (e2e)", () => { let app: INestApplication; - const userEmail = "oauth-client-webhook-controller-e2e@api.com"; - const otherUserEmail = "other-oauth-client-webhook-controller-e2e@api.com"; + const userEmail = `oauth-client-webhooks-user-${randomString()}@api.com`; + const otherUserEmail = `oauth-client-webhooks-other-user-${randomString()}@api.com`; let user: UserWithProfile; let otherUser: UserWithProfile; let oAuthClient: PlatformOAuthClient; @@ -69,7 +70,7 @@ describe("OAuth client WebhooksController (e2e)", () => { }); org = await orgRepositoryFixture.create({ - name: "apiOrg", + name: `oauth-client-webhooks-organization-${randomString()}`, isOrganization: true, metadata: { isOrganization: true, @@ -80,7 +81,7 @@ describe("OAuth client WebhooksController (e2e)", () => { isPlatform: true, }); otherOrg = await orgRepositoryFixture.create({ - name: "otherOrg", + name: `oauth-client-webhooks-other-organization-${randomString()}`, isOrganization: true, metadata: { isOrganization: true, diff --git a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-clients/oauth-clients.controller.e2e-spec.ts b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-clients/oauth-clients.controller.e2e-spec.ts index 41fe8249e5..8586b5a674 100644 --- a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-clients/oauth-clients.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-clients/oauth-clients.controller.e2e-spec.ts @@ -18,6 +18,7 @@ import { MembershipRepositoryFixture } from "test/fixtures/repository/membership import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; import { NextAuthMockStrategy } from "test/mocks/next-auth-mock.strategy"; +import { randomString } from "test/utils/randomString"; import { withNextAuth } from "test/utils/withNextAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -68,7 +69,7 @@ describe("OAuth Clients Endpoints", () => { let user: User; let org: Team; let app: INestApplication; - const userEmail = "oauth-clients-test-e2e@api.com"; + const userEmail = `oauth-clients-user-${randomString()}@api.com`; beforeAll(async () => { const moduleRef = await withNextAuth( @@ -89,7 +90,7 @@ describe("OAuth Clients Endpoints", () => { email: userEmail, }); org = await teamFixtures.create({ - name: "apiOrg", + name: `oauth-clients-organization-${randomString()}`, isOrganization: true, metadata: { isOrganization: true, @@ -126,7 +127,7 @@ describe("OAuth Clients Endpoints", () => { let user: User; let org: Team; let app: INestApplication; - const userEmail = "test-e2e@api.com"; + const userEmail = `oauth-clients-user-${randomString()}@api.com`; beforeAll(async () => { const moduleRef = await withNextAuth( @@ -147,7 +148,7 @@ describe("OAuth Clients Endpoints", () => { email: userEmail, }); org = await teamFixtures.create({ - name: "apiOrg", + name: `oauth-clients-organization-${randomString()}`, isOrganization: true, metadata: { isOrganization: true, @@ -211,7 +212,7 @@ describe("OAuth Clients Endpoints", () => { describe("User is part of an organization as Admin", () => { let membership: Membership; let client: { clientId: string; clientSecret: string }; - const oAuthClientName = "test-oauth-client-admin"; + const oAuthClientName = `oauth-clients-admin-${randomString()}`; beforeAll(async () => { membership = await membershipFixtures.addUserToOrg(user, org, "ADMIN", true); @@ -264,7 +265,7 @@ describe("OAuth Clients Endpoints", () => { }); }); it(`/PUT/:id`, () => { - const clientUpdatedName = "test-oauth-client-updated"; + const clientUpdatedName = `oauth-clients-admin-updated-${randomString()}`; const body: UpdateOAuthClientInput = { name: clientUpdatedName }; return request(app.getHttpServer()) .patch(`/api/v2/oauth-clients/${client.clientId}`) @@ -289,7 +290,7 @@ describe("OAuth Clients Endpoints", () => { describe("User is part of an organization as Owner", () => { let membership: Membership; let client: { clientId: string; clientSecret: string }; - const oAuthClientName = "test-oauth-client-owner"; + const oAuthClientName = `oauth-clients-owner-${randomString()}`; const oAuthClientPermissions = 32; beforeAll(async () => { @@ -346,7 +347,7 @@ describe("OAuth Clients Endpoints", () => { }); }); it(`/PUT/:id`, () => { - const clientUpdatedName = "test-oauth-client-updated"; + const clientUpdatedName = `oauth-clients-owner-updated-${randomString()}`; const body: UpdateOAuthClientInput = { name: clientUpdatedName }; return request(app.getHttpServer()) .patch(`/api/v2/oauth-clients/${client.clientId}`) diff --git a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-flow/oauth-flow.controller.e2e-spec.ts b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-flow/oauth-flow.controller.e2e-spec.ts index ee3adfa09d..ac263a4f2c 100644 --- a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-flow/oauth-flow.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-flow/oauth-flow.controller.e2e-spec.ts @@ -19,6 +19,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withNextAuth } from "test/utils/withNextAuth"; import { X_CAL_SECRET_KEY } from "@calcom/platform-constants"; @@ -70,7 +71,7 @@ describe("OAuthFlow Endpoints", () => { let refreshToken: string; beforeAll(async () => { - const userEmail = "developer@platform.com"; + const userEmail = `oauth-flow-user-${randomString()}@api.com`; const moduleRef: TestingModule = await withNextAuth( userEmail, @@ -92,7 +93,9 @@ describe("OAuthFlow Endpoints", () => { email: userEmail, }); - organization = await organizationsRepositoryFixture.create({ name: "organization" }); + organization = await organizationsRepositoryFixture.create({ + name: `oauth-flow-organization-${randomString()}`, + }); await profilesRepositoryFixture.create({ uid: "asd-asd", username: userEmail, diff --git a/apps/api/v2/src/modules/organizations/controllers/attributes/organization-attributes-options.e2e-spec.ts b/apps/api/v2/src/modules/organizations/controllers/attributes/organization-attributes-options.e2e-spec.ts index c291190ef9..b16f0504a5 100644 --- a/apps/api/v2/src/modules/organizations/controllers/attributes/organization-attributes-options.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/controllers/attributes/organization-attributes-options.e2e-spec.ts @@ -14,6 +14,7 @@ import { AttributeRepositoryFixture } from "test/fixtures/repository/attributes. import { MembershipRepositoryFixture } from "test/fixtures/repository/membership.repository.fixture"; import { OrganizationRepositoryFixture } from "test/fixtures/repository/organization.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -26,7 +27,7 @@ describe("Organizations Attributes Options Endpoints", () => { let organizationsRepositoryFixture: OrganizationRepositoryFixture; let membershipFixtures: MembershipRepositoryFixture; - const userEmail = "member@attributes-options-api.com"; + const userEmail = `organization-attributes-options-member-${randomString()}@api.com`; let user: User; let org: Team; let membership: Membership; @@ -45,7 +46,7 @@ describe("Organizations Attributes Options Endpoints", () => { membershipFixtures = new MembershipRepositoryFixture(moduleRef); org = await organizationsRepositoryFixture.create({ - name: "AttributesOptionsCorp", + name: `organization-attributes-options-organization-${randomString()}`, isOrganization: true, }); @@ -97,7 +98,7 @@ describe("Organizations Attributes Options Endpoints", () => { let membershipFixtures: MembershipRepositoryFixture; let attributeRepositoryFixture: AttributeRepositoryFixture; - const userEmail = "admin@attributes-options-api.com"; + const userEmail = `organization-attributes-options-admin-${randomString()}@api.com`; let user: User; let org: Team; let membership: Membership; @@ -123,7 +124,7 @@ describe("Organizations Attributes Options Endpoints", () => { attributeRepositoryFixture = new AttributeRepositoryFixture(moduleRef); org = await organizationsRepositoryFixture.create({ - name: "AttributesOptionsCorp", + name: `organization-attributes-options-admin-organization-${randomString()}`, isOrganization: true, }); diff --git a/apps/api/v2/src/modules/organizations/controllers/attributes/organization-attributes.e2e-spec.ts b/apps/api/v2/src/modules/organizations/controllers/attributes/organization-attributes.e2e-spec.ts index 1365670a19..c7d75c8fd4 100644 --- a/apps/api/v2/src/modules/organizations/controllers/attributes/organization-attributes.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/controllers/attributes/organization-attributes.e2e-spec.ts @@ -12,6 +12,7 @@ import * as request from "supertest"; import { MembershipRepositoryFixture } from "test/fixtures/repository/membership.repository.fixture"; import { OrganizationRepositoryFixture } from "test/fixtures/repository/organization.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -24,7 +25,7 @@ describe("Organizations Attributes Endpoints", () => { let organizationsRepositoryFixture: OrganizationRepositoryFixture; let membershipFixtures: MembershipRepositoryFixture; - const userEmail = "member@attributes-api.com"; + const userEmail = `organization-attributes-member-${randomString()}@api.com`; let user: User; let org: Team; let membership: Membership; @@ -42,7 +43,7 @@ describe("Organizations Attributes Endpoints", () => { membershipFixtures = new MembershipRepositoryFixture(moduleRef); org = await organizationsRepositoryFixture.create({ - name: "AttributesCorp", + name: `organization-attributes-organization-${randomString()}`, isOrganization: true, }); @@ -88,7 +89,7 @@ describe("Organizations Attributes Endpoints", () => { let organizationsRepositoryFixture: OrganizationRepositoryFixture; let membershipFixtures: MembershipRepositoryFixture; - const userEmail = "admin@attributes-api.com"; + const userEmail = `organization-attributes-admin-${randomString()}@api.com`; let user: User; let org: Team; let membership: Membership; @@ -116,7 +117,7 @@ describe("Organizations Attributes Endpoints", () => { membershipFixtures = new MembershipRepositoryFixture(moduleRef); org = await organizationsRepositoryFixture.create({ - name: "AttributesCorp", + name: `organization-attributes-admin-organization-${randomString()}`, isOrganization: true, }); diff --git a/apps/api/v2/src/modules/organizations/controllers/event-types/organizations-event-types.e2e-spec.ts b/apps/api/v2/src/modules/organizations/controllers/event-types/organizations-event-types.e2e-spec.ts index 7f3021bc9f..ddb05aca85 100644 --- a/apps/api/v2/src/modules/organizations/controllers/event-types/organizations-event-types.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/controllers/event-types/organizations-event-types.e2e-spec.ts @@ -14,6 +14,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -48,12 +49,12 @@ describe("Organizations Event Types Endpoints", () => { let falseTestOrg: Team; let falseTestTeam: Team; - const userEmail = "org-admin-event-types-controller-e222e@api.com"; + const userEmail = `organizations-event-types-admin-${randomString()}@api.com`; let userAdmin: User; - const teammate1Email = "teammate111@team.com"; - const teammate2Email = "teammate221@team.com"; - const falseTestUserEmail = "false-user@false-team.com"; + const teammate1Email = `organizations-event-types-teammate1-${randomString()}@api.com`; + const teammate2Email = `organizations-event-types-teammate2-${randomString()}@api.com`; + const falseTestUserEmail = `organizations-event-types-false-user-${randomString()}@api.com`; let teammate1: User; let teammate2: User; let falseTestUser: User; @@ -98,23 +99,23 @@ describe("Organizations Event Types Endpoints", () => { }); org = await organizationsRepositoryFixture.create({ - name: "Test Organization", + name: `organizations-event-types-organization-${randomString()}`, isOrganization: true, }); falseTestOrg = await organizationsRepositoryFixture.create({ - name: "False test org", + name: `organizations-event-types-false-org-${randomString()}`, isOrganization: true, }); team = await teamsRepositoryFixture.create({ - name: "Test org team", + name: `organizations-event-types-team-${randomString()}`, isOrganization: false, parent: { connect: { id: org.id } }, }); falseTestTeam = await teamsRepositoryFixture.create({ - name: "Outside org team", + name: `organizations-event-types-false-team-${randomString()}`, isOrganization: false, parent: { connect: { id: falseTestOrg.id } }, }); @@ -237,7 +238,7 @@ describe("Organizations Event Types Endpoints", () => { const body: CreateTeamEventTypeInput_2024_06_14 = { successRedirectUrl: "https://masterchief.com/argentina/flan/video/1234", title: "Coding consultation collective", - slug: "coding-consultation collective", + slug: `organizations-event-types-collective-${randomString()}`, description: "Our team will review your codebase.", lengthInMinutes: 60, locations: [ @@ -343,7 +344,7 @@ describe("Organizations Event Types Endpoints", () => { it("should create a managed team event-type", async () => { const body: CreateTeamEventTypeInput_2024_06_14 = { title: "Coding consultation managed", - slug: "coding-consultation-managed", + slug: `organizations-event-types-managed-${randomString()}`, description: "Our team will review your codebase.", lengthInMinutes: 60, locations: [ @@ -751,10 +752,10 @@ describe("Organizations Event Types Endpoints", () => { it("should return event type with default bookingFields if they are not defined", async () => { const eventTypeInput = { title: "unknown field event type two", + slug: `organizations-event-types-unknown-${randomString()}`, description: "unknown field event type description two", length: 40, hidden: false, - slug: "unknown-field-type-two", locations: [], schedulingType: SchedulingType.ROUND_ROBIN, }; diff --git a/apps/api/v2/src/modules/organizations/controllers/memberships/organizations-membership.controller.e2e-spec.ts b/apps/api/v2/src/modules/organizations/controllers/memberships/organizations-membership.controller.e2e-spec.ts index ff729aef9c..0de6c14d23 100644 --- a/apps/api/v2/src/modules/organizations/controllers/memberships/organizations-membership.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/controllers/memberships/organizations-membership.controller.e2e-spec.ts @@ -14,6 +14,7 @@ import { MembershipRepositoryFixture } from "test/fixtures/repository/membership import { OrganizationRepositoryFixture } from "test/fixtures/repository/organization.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -33,10 +34,9 @@ describe("Organizations Memberships Endpoints", () => { let membership2: Membership; let membershipCreatedViaApi: Membership; - const userEmail = "org-admin-membership-controller-e2e@api.com"; - const userEmail2 = "org-member-membership-controller-e2e@api.com"; - - const invitedUserEmail = "org-member-invited-membership-controller-e2e@api.com"; + const userEmail = `organizations-memberships-admin-${randomString()}@api.com`; + const userEmail2 = `organizations-memberships-member-${randomString()}@api.com`; + const invitedUserEmail = `organizations-memberships-invited-${randomString()}@api.com`; let user: User; let user2: User; @@ -70,7 +70,7 @@ describe("Organizations Memberships Endpoints", () => { }); org = await organizationsRepositoryFixture.create({ - name: "Test Organization", + name: `organizations-memberships-organization-${randomString()}`, isOrganization: true, }); @@ -217,7 +217,7 @@ describe("Organizations Memberships Endpoints", () => { let org: Team; let membership: Membership; - const userEmail = "org-member-memberships-controller-e2e@api.com"; + const userEmail = `organizations-memberships-member-${randomString()}@api.com`; let user: User; beforeAll(async () => { @@ -238,7 +238,7 @@ describe("Organizations Memberships Endpoints", () => { }); org = await organizationsRepositoryFixture.create({ - name: "Test Organization", + name: `organizations-memberships-organization-${randomString()}`, isOrganization: true, }); diff --git a/apps/api/v2/src/modules/organizations/controllers/schedules/organizations-schedules.e2e-spec.ts b/apps/api/v2/src/modules/organizations/controllers/schedules/organizations-schedules.e2e-spec.ts index ccddb22547..0a9b6b0147 100644 --- a/apps/api/v2/src/modules/organizations/controllers/schedules/organizations-schedules.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/controllers/schedules/organizations-schedules.e2e-spec.ts @@ -12,6 +12,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -35,7 +36,7 @@ describe("Organizations Schedules Endpoints", () => { let organizationsRepositoryFixture: OrganizationRepositoryFixture; let membershipFixtures: MembershipRepositoryFixture; - const userEmail = "mr-robot@schedules-api.com"; + const userEmail = `organizations-schedules-member-${randomString()}@api.com`; let user: User; let org: Team; let membership: Membership; @@ -53,7 +54,7 @@ describe("Organizations Schedules Endpoints", () => { membershipFixtures = new MembershipRepositoryFixture(moduleRef); org = await organizationsRepositoryFixture.create({ - name: "Ecorp", + name: `organizations-schedules-organization-${randomString()}`, isOrganization: true, }); @@ -115,12 +116,15 @@ describe("Organizations Schedules Endpoints", () => { let membershipFixtures: MembershipRepositoryFixture; let profileRepositoryFixture: ProfileRepositoryFixture; - const userEmail = "mr-robot@schedules-api.com"; - const username = "mr-robot"; + const userEmail = `organizations-schedules-admin-${randomString()}@api.com`; + const userEmail2 = `organizations-schedules-member-${randomString()}@api.com`; let user: User; + let user2: User; let org: Team; - let profile: Profile; let membership: Membership; + let membership2: Membership; + let profile: Profile; + let profile2: Profile; let createdSchedule: ScheduleOutput_2024_06_11; @@ -152,7 +156,7 @@ describe("Organizations Schedules Endpoints", () => { profileRepositoryFixture = new ProfileRepositoryFixture(moduleRef); org = await organizationsRepositoryFixture.create({ - name: "Ecorp", + name: `organizations-schedules-admin-organization-${randomString()}`, isOrganization: true, }); @@ -164,7 +168,7 @@ describe("Organizations Schedules Endpoints", () => { profile = await profileRepositoryFixture.create({ uid: `usr-${user.id}`, - username: username, + username: userEmail, organization: { connect: { id: org.id, diff --git a/apps/api/v2/src/modules/organizations/controllers/teams/memberships/organizations-teams-memberships.controller.e2e-spec.ts b/apps/api/v2/src/modules/organizations/controllers/teams/memberships/organizations-teams-memberships.controller.e2e-spec.ts index 9c74cde26e..a376801272 100644 --- a/apps/api/v2/src/modules/organizations/controllers/teams/memberships/organizations-teams-memberships.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/controllers/teams/memberships/organizations-teams-memberships.controller.e2e-spec.ts @@ -17,6 +17,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -44,11 +45,10 @@ describe("Organizations Teams Memberships Endpoints", () => { let membership2: Membership; let membershipCreatedViaApi: OrgTeamMembershipOutputDto; - const userEmail = "org-admin-membership-teams-controller-e2e@api.com"; - const userEmail2 = "org-member-membership-teams-controller-e2e@api.com"; - const nonOrgUserEmail = "non-org-member-membership-teams-controller-e2e@api.com"; - - const invitedUserEmail = "org-member-invited-membership-teams-controller-e2e@api.com"; + const userEmail = `organizations-teams-memberships-admin-${randomString()}@api.com`; + const userEmail2 = `organizations-teams-memberships-member-${randomString()}@api.com`; + const nonOrgUserEmail = `organizations-teams-memberships-non-org-${randomString()}@api.com`; + const invitedUserEmail = `organizations-teams-memberships-invited-${randomString()}@api.com`; let user: User; let user2: User; @@ -92,12 +92,12 @@ describe("Organizations Teams Memberships Endpoints", () => { }); org = await organizationsRepositoryFixture.create({ - name: "Test Organization", + name: `organizations-teams-memberships-organization-${randomString()}`, isOrganization: true, }); orgTeam = await teamsRepositoryFixture.create({ - name: "Org Team", + name: `organizations-teams-memberships-team-${randomString()}`, isOrganization: false, parent: { connect: { id: org.id } }, }); @@ -129,7 +129,7 @@ describe("Organizations Teams Memberships Endpoints", () => { }); nonOrgTeam = await teamsRepositoryFixture.create({ - name: "Non Org Team", + name: `organizations-teams-memberships-non-org-team-${randomString()}`, isOrganization: false, }); diff --git a/apps/api/v2/src/modules/organizations/controllers/teams/organizations-teams.controller.e2e-spec.ts b/apps/api/v2/src/modules/organizations/controllers/teams/organizations-teams.controller.e2e-spec.ts index f2409b80a4..74c8f7391b 100644 --- a/apps/api/v2/src/modules/organizations/controllers/teams/organizations-teams.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/controllers/teams/organizations-teams.controller.e2e-spec.ts @@ -15,6 +15,7 @@ import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-cli import { OrganizationRepositoryFixture } from "test/fixtures/repository/organization.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS, X_CAL_CLIENT_ID, X_CAL_SECRET_KEY } from "@calcom/platform-constants"; @@ -36,7 +37,7 @@ describe("Organizations Team Endpoints", () => { let teamCreatedViaApi: Team; let teamCreatedViaApi2: Team; - const userEmail = "org-admin-teams-controller-e2e@api.com"; + const userEmail = `organizations-teams-admin-${randomString()}@api.com`; let user: User; beforeAll(async () => { @@ -58,7 +59,7 @@ describe("Organizations Team Endpoints", () => { }); org = await organizationsRepositoryFixture.create({ - name: "Test Organization", + name: `organizations-teams-organization-${randomString()}`, isOrganization: true, }); @@ -69,13 +70,13 @@ describe("Organizations Team Endpoints", () => { }); team = await teamsRepositoryFixture.create({ - name: "Test org team", + name: `organizations-teams-team1-${randomString()}`, isOrganization: false, parent: { connect: { id: org.id } }, }); team2 = await teamsRepositoryFixture.create({ - name: "Test org team 2", + name: `organizations-teams-team2-${randomString()}`, isOrganization: false, parent: { connect: { id: org.id } }, }); @@ -133,10 +134,11 @@ describe("Organizations Team Endpoints", () => { }); it("should create the team of the org", async () => { + const teamName = `organizations-teams-api-team1-${randomString()}`; return request(app.getHttpServer()) .post(`/v2/organizations/${org.id}/teams`) .send({ - name: "Team created via API", + name: teamName, slug: "team-created-via-api", bio: "This is our test team created via API", } satisfies CreateOrgTeamDto) @@ -145,7 +147,7 @@ describe("Organizations Team Endpoints", () => { const responseBody: ApiSuccessResponse = response.body; expect(responseBody.status).toEqual(SUCCESS_STATUS); teamCreatedViaApi = responseBody.data; - expect(teamCreatedViaApi.name).toEqual("Team created via API"); + expect(teamCreatedViaApi.name).toEqual(teamName); expect(teamCreatedViaApi.slug).toEqual("team-created-via-api"); expect(teamCreatedViaApi.bio).toEqual("This is our test team created via API"); expect(teamCreatedViaApi.parentId).toEqual(org.id); @@ -171,10 +173,11 @@ describe("Organizations Team Endpoints", () => { }); it("should update the team of the org", async () => { + const updatedTeamName = `organizations-teams-api-team1-${randomString()}-updated`; return request(app.getHttpServer()) .patch(`/v2/organizations/${org.id}/teams/${teamCreatedViaApi.id}`) .send({ - name: "Team created via API Updated", + name: updatedTeamName, weekStart: "Monday", logoUrl: "https://i.cal.com/api/avatar/b0b58752-68ad-4c0d-8024-4fa382a77752.png", bannerUrl: "https://i.cal.com/api/avatar/949be534-7a88-4185-967c-c020b0c0bef3.png", @@ -184,7 +187,7 @@ describe("Organizations Team Endpoints", () => { const responseBody: ApiSuccessResponse = response.body; expect(responseBody.status).toEqual(SUCCESS_STATUS); teamCreatedViaApi = responseBody.data; - expect(teamCreatedViaApi.name).toEqual("Team created via API Updated"); + expect(teamCreatedViaApi.name).toEqual(updatedTeamName); expect(teamCreatedViaApi.weekStart).toEqual("Monday"); expect(teamCreatedViaApi.logoUrl).toEqual( "https://i.cal.com/api/avatar/b0b58752-68ad-4c0d-8024-4fa382a77752.png" @@ -219,10 +222,11 @@ describe("Organizations Team Endpoints", () => { }); it("should create the team of the org without auto-accepting creator", async () => { + const teamName = `organizations-teams-api-team2-${randomString()}`; return request(app.getHttpServer()) .post(`/v2/organizations/${org.id}/teams`) .send({ - name: "Team II created via API", + name: teamName, autoAcceptCreator: false, } satisfies CreateOrgTeamDto) .expect(201) @@ -230,7 +234,7 @@ describe("Organizations Team Endpoints", () => { const responseBody: ApiSuccessResponse = response.body; expect(responseBody.status).toEqual(SUCCESS_STATUS); teamCreatedViaApi2 = responseBody.data; - expect(teamCreatedViaApi2.name).toEqual("Team II created via API"); + expect(teamCreatedViaApi2.name).toEqual(teamName); expect(teamCreatedViaApi2.parentId).toEqual(org.id); const membership = await membershipsRepositoryFixture.getUserMembershipByTeamId( user.id, @@ -265,7 +269,7 @@ describe("Organizations Team Endpoints", () => { let team: Team; let team2: Team; - const userEmail = "org-member-teams-controller-e2e@api.com"; + const userEmail = `organizations-teams-member-${randomString()}@api.com`; let user: User; beforeAll(async () => { @@ -287,7 +291,7 @@ describe("Organizations Team Endpoints", () => { }); org = await organizationsRepositoryFixture.create({ - name: "Test Organization", + name: `organizations-teams-organization-${randomString()}`, isOrganization: true, }); @@ -298,13 +302,13 @@ describe("Organizations Team Endpoints", () => { }); team = await teamsRepositoryFixture.create({ - name: "Test org team", + name: `organizations-teams-team1-${randomString()}`, isOrganization: false, parent: { connect: { id: org.id } }, }); team2 = await teamsRepositoryFixture.create({ - name: "Test org team 2", + name: `organizations-teams-team2-${randomString()}`, isOrganization: false, parent: { connect: { id: org.id } }, }); @@ -338,7 +342,7 @@ describe("Organizations Team Endpoints", () => { return request(app.getHttpServer()) .post(`/v2/organizations/${org.id}/teams`) .send({ - name: "Team created via API", + name: `organizations-teams-api-team1-${randomString()}`, } satisfies CreateOrgTeamDto) .expect(403); }); @@ -347,7 +351,7 @@ describe("Organizations Team Endpoints", () => { return request(app.getHttpServer()) .patch(`/v2/organizations/${org.id}/teams/${team.id}`) .send({ - name: "Team created via API Updated", + name: `organizations-teams-api-team1-${randomString()}-updated`, } satisfies CreateOrgTeamDto) .expect(403); }); @@ -379,7 +383,7 @@ describe("Organizations Team Endpoints", () => { let team: Team; let team2: Team; - const userEmail = "org-member-teams-owner-controller-e2e@api.com"; + const userEmail = `organizations-teams-owner-${randomString()}@api.com`; let user: User; beforeAll(async () => { @@ -401,7 +405,7 @@ describe("Organizations Team Endpoints", () => { }); org = await organizationsRepositoryFixture.create({ - name: "Test Organization", + name: `organizations-teams-organization-${randomString()}`, isOrganization: true, }); @@ -412,13 +416,13 @@ describe("Organizations Team Endpoints", () => { }); team = await teamsRepositoryFixture.create({ - name: "Test org team", + name: `organizations-teams-team1-${randomString()}`, isOrganization: false, parent: { connect: { id: org.id } }, }); team2 = await teamsRepositoryFixture.create({ - name: "Test org team 2", + name: `organizations-teams-team2-${randomString()}`, isOrganization: false, parent: { connect: { id: org.id } }, }); @@ -464,7 +468,7 @@ describe("Organizations Team Endpoints", () => { return request(app.getHttpServer()) .post(`/v2/organizations/${org.id}/teams`) .send({ - name: "Team created via API", + name: `organizations-teams-api-team1-${randomString()}`, } satisfies CreateOrgTeamDto) .expect(403); }); @@ -473,7 +477,7 @@ describe("Organizations Team Endpoints", () => { return request(app.getHttpServer()) .patch(`/v2/organizations/${org.id}/teams/${team.id}`) .send({ - name: "Team created via API Updated", + name: `organizations-teams-api-team1-${randomString()}-updated`, } satisfies CreateOrgTeamDto) .expect(403); }); @@ -509,7 +513,7 @@ describe("Organizations Team Endpoints", () => { let team1: Team; let team2: Team; - const userEmail = "platform-org-member-teams-owner-controller-e2e@api.com"; + const userEmail = `organizations-teams-platform-owner-${randomString()}@api.com`; let user: User; beforeAll(async () => { @@ -531,7 +535,7 @@ describe("Organizations Team Endpoints", () => { }); org = await orgRepositoryFixture.create({ - name: "Platform Test Organization", + name: `organizations-teams-platform-organization-${randomString()}`, isOrganization: true, }); @@ -570,7 +574,7 @@ describe("Organizations Team Endpoints", () => { }); it("should create first oAuth client team", async () => { - const teamName = "Platform team created via API"; + const teamName = `organizations-teams-platform-api-team1-${randomString()}`; return request(app.getHttpServer()) .post(`/v2/organizations/${org.id}/teams`) .set(X_CAL_CLIENT_ID, oAuthClient1.id) @@ -593,7 +597,7 @@ describe("Organizations Team Endpoints", () => { }); it("should create second oAuth client team", async () => { - const teamName = "Platform team II created via API"; + const teamName = `organizations-teams-platform-api-team2-${randomString()}`; return request(app.getHttpServer()) .post(`/v2/organizations/${org.id}/teams`) .set(X_CAL_CLIENT_ID, oAuthClient2.id) diff --git a/apps/api/v2/src/modules/organizations/controllers/teams/schedules/organizations-teams-schedules.e2e-spec.ts b/apps/api/v2/src/modules/organizations/controllers/teams/schedules/organizations-teams-schedules.e2e-spec.ts index cf6dbb5972..4a42315247 100644 --- a/apps/api/v2/src/modules/organizations/controllers/teams/schedules/organizations-teams-schedules.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/controllers/teams/schedules/organizations-teams-schedules.e2e-spec.ts @@ -14,6 +14,7 @@ import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repo import { SchedulesRepositoryFixture } from "test/fixtures/repository/schedules.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -37,11 +38,10 @@ describe("Organizations Teams Schedules Endpoints", () => { let nonOrgTeam: Team; let user2Schedule: Schedule; - const userEmail = "org-admin-schedules-teams-controller-e2e@api.com"; - const userEmail2 = "org-member-schedules-teams-controller-e2e@api.com"; - const nonOrgUserEmail = "non-org-member-schedules-teams-controller-e2e@api.com"; - - const invitedUserEmail = "org-member-invited-schedules-teams-controller-e2e@api.com"; + const userEmail = `organizations-teams-schedules-admin-${randomString()}@api.com`; + const userEmail2 = `organizations-teams-schedules-member-${randomString()}@api.com`; + const nonOrgUserEmail = `organizations-teams-schedules-non-org-${randomString()}@api.com`; + const invitedUserEmail = `organizations-teams-schedules-invited-${randomString()}@api.com`; let user: User; let user2: User; @@ -79,7 +79,7 @@ describe("Organizations Teams Schedules Endpoints", () => { id: user2.id, }, }, - name: "User 2 schedule", + name: `organizations-teams-schedules-user2-schedule-${randomString()}`, timeZone: "America/New_York", }); @@ -94,18 +94,18 @@ describe("Organizations Teams Schedules Endpoints", () => { }); org = await organizationsRepositoryFixture.create({ - name: "Test Organization", + name: `organizations-teams-schedules-organization-${randomString()}`, isOrganization: true, }); orgTeam = await teamsRepositoryFixture.create({ - name: "Org Team", + name: `organizations-teams-schedules-team-${randomString()}`, isOrganization: false, parent: { connect: { id: org.id } }, }); nonOrgTeam = await teamsRepositoryFixture.create({ - name: "Non Org Team", + name: `organizations-teams-schedules-non-org-team-${randomString()}`, isOrganization: false, }); diff --git a/apps/api/v2/src/modules/organizations/controllers/users/ooo/organizations-users-ooo.e2e-spec.ts b/apps/api/v2/src/modules/organizations/controllers/users/ooo/organizations-users-ooo.e2e-spec.ts index d215803b9a..11314ef74b 100644 --- a/apps/api/v2/src/modules/organizations/controllers/users/ooo/organizations-users-ooo.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/controllers/users/ooo/organizations-users-ooo.e2e-spec.ts @@ -14,6 +14,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -34,12 +35,12 @@ describe("Organizations User OOO Endpoints", () => { let falseTestOrg: Team; let falseTestTeam: Team; - const userEmail = "org-admin-ooo-controller-e222e@api.com"; + const userEmail = `organizations-users-ooo-admin-${randomString()}@api.com`; let userAdmin: User; - const teammate1Email = "teammate111ooo@team.com"; - const teammate2Email = "teammate221ooo@team.com"; - const falseTestUserEmail = "false-user-ooo@false-team.com"; + const teammate1Email = `organizations-users-ooo-member1-${randomString()}@api.com`; + const teammate2Email = `organizations-users-ooo-member2-${randomString()}@api.com`; + const falseTestUserEmail = `organizations-users-ooo-false-user-${randomString()}@api.com`; let teammate1: User; let teammate2: User; let falseTestUser: User; @@ -80,23 +81,23 @@ describe("Organizations User OOO Endpoints", () => { }); org = await organizationsRepositoryFixture.create({ - name: "Test Organization ooo", + name: `organizations-users-ooo-organization-${randomString()}`, isOrganization: true, }); falseTestOrg = await organizationsRepositoryFixture.create({ - name: "False test org ooo", + name: `organizations-users-ooo-false-org-${randomString()}`, isOrganization: true, }); team = await teamsRepositoryFixture.create({ - name: "Test org team ooo", + name: `organizations-users-ooo-team-${randomString()}`, isOrganization: false, parent: { connect: { id: org.id } }, }); falseTestTeam = await teamsRepositoryFixture.create({ - name: "Outside org team ooo", + name: `organizations-users-ooo-false-team-${randomString()}`, isOrganization: false, parent: { connect: { id: falseTestOrg.id } }, }); diff --git a/apps/api/v2/src/modules/organizations/controllers/users/organizations-users.e2e-spec.ts b/apps/api/v2/src/modules/organizations/controllers/users/organizations-users.e2e-spec.ts index 2257d5813d..3ed330655e 100644 --- a/apps/api/v2/src/modules/organizations/controllers/users/organizations-users.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/controllers/users/organizations-users.e2e-spec.ts @@ -15,6 +15,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -29,7 +30,7 @@ describe("Organizations Users Endpoints", () => { let membershipFixtures: MembershipRepositoryFixture; let profileRepositoryFixture: ProfileRepositoryFixture; - const userEmail = "member1@org.com"; + const userEmail = `organizations-users-member-${randomString()}@api.com`; let user: User; let org: Team; @@ -47,7 +48,7 @@ describe("Organizations Users Endpoints", () => { profileRepositoryFixture = new ProfileRepositoryFixture(moduleRef); org = await organizationsRepositoryFixture.create({ - name: "Test org 3", + name: `organizations-users-organization-${randomString()}`, isOrganization: true, }); @@ -118,24 +119,24 @@ describe("Organizations Users Endpoints", () => { let organizationsRepositoryFixture: OrganizationRepositoryFixture; let membershipFixtures: MembershipRepositoryFixture; - const userEmail = "admin1@org.com"; - const nonMemberEmail = "non-member@test.com"; + const userEmail = `organizations-users-admin-${randomString()}@api.com`; + const nonMemberEmail = `organizations-users-non-member-${randomString()}@api.com`; let user: User; let org: Team; let createdUser: User; const orgMembersData = [ { - email: "member1@org.com", - username: "member1@org.com", + email: `organizations-users-member1-${randomString()}@api.com`, + username: `organizations-users-member1-${randomString()}@api.com`, }, { - email: "member2@org.com", - username: "member2@org.com", + email: `organizations-users-member2-${randomString()}@api.com`, + username: `organizations-users-member2-${randomString()}@api.com`, }, { - email: "member3@org.com", - username: "member3@org.com", + email: `organizations-users-member3-${randomString()}@api.com`, + username: `organizations-users-member3-${randomString()}@api.com`, }, ]; @@ -154,7 +155,7 @@ describe("Organizations Users Endpoints", () => { membershipFixtures = new MembershipRepositoryFixture(moduleRef); org = await organizationsRepositoryFixture.create({ - name: "Test org 2", + name: `organizations-users-admin-organization-${randomString()}`, isOrganization: true, }); @@ -243,9 +244,9 @@ describe("Organizations Users Endpoints", () => { { userData }, userData.map((u) => u.profile) ); - expect(userData.find((u) => u.profile.username === "member1@org.com")).toBeDefined(); - expect(userData.find((u) => u.profile.username === "member2@org.com")).toBeDefined(); - expect(userData.find((u) => u.profile.username === "member3@org.com")).toBeDefined(); + expect(userData.find((u) => u.profile.username === orgMembersData[0].username)).toBeDefined(); + expect(userData.find((u) => u.profile.username === orgMembersData[1].username)).toBeDefined(); + expect(userData.find((u) => u.profile.username === orgMembersData[2].username)).toBeDefined(); expect(userData.filter((user: { email: string }) => user.email === nonMemberEmail).length).toBe(0); }); @@ -304,7 +305,7 @@ describe("Organizations Users Endpoints", () => { it("should create a new org user", async () => { const newOrgUser = { - email: "new-org-member-b@org.com", + email: `organizations-users-new-member-${randomString()}@api.com`, organizationRole: "MEMBER", autoAccept: true, }; @@ -327,7 +328,7 @@ describe("Organizations Users Endpoints", () => { usernameOrEmail: newOrgUser.email, orgName: org.name, orgId: org.id, - inviterName: "admin1@org.com", + inviterName: userEmail, locale: null, }); createdUser = userData; @@ -366,7 +367,7 @@ describe("Organizations Users Endpoints", () => { let membershipFixtures: MembershipRepositoryFixture; let profileRepositoryFixture: ProfileRepositoryFixture; - const authEmail = "auth@org.com"; + const authEmail = `organizations-users-auth-${randomString()}@api.com`; let user: User; let org: Team; let team: Team; @@ -390,12 +391,12 @@ describe("Organizations Users Endpoints", () => { profileRepositoryFixture = new ProfileRepositoryFixture(moduleRef); org = await organizationsRepositoryFixture.create({ - name: "Test org 4", + name: `organizations-users-organization-${randomString()}`, isOrganization: true, }); team = await teamsRepositoryFixture.create({ - name: "Test org 4 team", + name: `organizations-users-team-${randomString()}`, isOrganization: false, parent: { connect: { id: org.id } }, }); @@ -464,7 +465,7 @@ describe("Organizations Users Endpoints", () => { it("should create a new org user with team event-types", async () => { const newOrgUser = { - email: "new-org-member-d@org.com", + email: `organizations-users-new-member-${randomString()}@api.com`, organizationRole: "MEMBER", autoAccept: true, }; diff --git a/apps/api/v2/src/modules/organizations/controllers/webhooks/organizations-webhooks.e2e-spec.ts b/apps/api/v2/src/modules/organizations/controllers/webhooks/organizations-webhooks.e2e-spec.ts index 8b23a250a6..7edf39e965 100644 --- a/apps/api/v2/src/modules/organizations/controllers/webhooks/organizations-webhooks.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/controllers/webhooks/organizations-webhooks.e2e-spec.ts @@ -17,13 +17,14 @@ import { MembershipRepositoryFixture } from "test/fixtures/repository/membership import { OrganizationRepositoryFixture } from "test/fixtures/repository/organization.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; import { WebhookRepositoryFixture } from "test/fixtures/repository/webhooks.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { Team, Webhook } from "@calcom/prisma/client"; describe("WebhooksController (e2e)", () => { let app: INestApplication; - const userEmail = "webhook-controller-e2e@api.com"; + const userEmail = `organizations-webhooks-admin-${randomString()}@api.com`; let org: Team; let organizationsRepositoryFixture: OrganizationRepositoryFixture; @@ -53,7 +54,7 @@ describe("WebhooksController (e2e)", () => { }); org = await organizationsRepositoryFixture.create({ - name: "Test Organization", + name: `organizations-webhooks-organization-${randomString()}`, isOrganization: true, }); diff --git a/apps/api/v2/src/modules/slots/controllers/slots.controller.e2e-spec.ts b/apps/api/v2/src/modules/slots/controllers/slots.controller.e2e-spec.ts index 45e3102af0..4a975d5066 100644 --- a/apps/api/v2/src/modules/slots/controllers/slots.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/slots/controllers/slots.controller.e2e-spec.ts @@ -16,7 +16,7 @@ import { BookingsRepositoryFixture } from "test/fixtures/repository/bookings.rep import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-types.repository.fixture"; import { SelectedSlotsRepositoryFixture } from "test/fixtures/repository/selected-slots.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; -import { randomNumber } from "test/utils/randomNumber"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -251,7 +251,7 @@ describe("Slots Endpoints", () => { let selectedSlotsRepositoryFixture: SelectedSlotsRepositoryFixture; let bookingsRepositoryFixture: BookingsRepositoryFixture; - const userEmail = `slots-${randomNumber()}-controller-e2e@api.com`; + const userEmail = `slots-${randomString()}-controller-e2e@api.com`; const userName = "bob"; let user: User; let eventTypeId: number; @@ -291,14 +291,23 @@ describe("Slots Endpoints", () => { }); // nxte(Lauris): this creates default schedule monday to friday from 9AM to 5PM in Europe/Rome timezone - await schedulesService.createUserDefaultSchedule(user.id, "Europe/Rome"); + const userSchedule = await schedulesService.createUserSchedule(user.id, { + name: `slots-schedule-${randomString()}-slots.controller.e2e-spec`, + timeZone: "Europe/Rome", + isDefault: true, + }); - const event = await eventTypesRepositoryFixture.create( - { title: "frisbee match", slug: "frisbee-match", length: 60 }, + const eventType = await eventTypesRepositoryFixture.create( + { + title: `slots-event-type-${randomString()}-slots.controller.e2e-spec`, + slug: `slots-event-type-${randomString()}-slots.controller.e2e-spec`, + length: 60, + locations: [], + }, user.id ); - eventTypeId = event.id; - eventTypeSlug = event.slug; + eventTypeId = eventType.id; + eventTypeSlug = eventType.slug; app = moduleRef.createNestApplication(); bootstrap(app as NestExpressApplication); diff --git a/apps/api/v2/src/modules/teams/event-types/controllers/teams-event-types.controller.e2e-spec.ts b/apps/api/v2/src/modules/teams/event-types/controllers/teams-event-types.controller.e2e-spec.ts index 5112dba72d..8905d7151d 100644 --- a/apps/api/v2/src/modules/teams/event-types/controllers/teams-event-types.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/teams/event-types/controllers/teams-event-types.controller.e2e-spec.ts @@ -14,7 +14,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; -import { randomNumber } from "test/utils/randomNumber"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; @@ -47,12 +47,12 @@ describe("Organizations Event Types Endpoints", () => { let team: Team; let falseTestTeam: Team; - const userEmail = `auth-${randomNumber()}@api.com`; + const userEmail = `teams-event-types-user-${randomString()}@api.com`; let userAdmin: User; - const teammate1Email = "teammate111@team.com"; - const teammate2Email = "teammate221@team.com"; - const falseTestUserEmail = "false-user@false-team.com"; + const teammate1Email = `teams-event-types-teammate1-${randomString()}@api.com`; + const teammate2Email = `teams-event-types-teammate2-${randomString()}@api.com`; + const falseTestUserEmail = `teams-event-types-false-user-${randomString()}@api.com`; let teamMember1: User; let teamMember2: User; let falseTestUser: User; @@ -97,12 +97,12 @@ describe("Organizations Event Types Endpoints", () => { }); team = await teamsRepositoryFixture.create({ - name: "Test org team", + name: `teams-event-types-team-${randomString()}`, isOrganization: false, }); falseTestTeam = await teamsRepositoryFixture.create({ - name: "Outside org team", + name: `teams-event-types-false-team-${randomString()}`, isOrganization: false, }); @@ -169,8 +169,8 @@ describe("Organizations Event Types Endpoints", () => { it("should create a collective team event-type", async () => { const body: CreateTeamEventTypeInput_2024_06_14 = { - title: "Coding consultation collective", - slug: "coding-consultation collective", + title: `teams-event-types-collective-${randomString()}`, + slug: `teams-event-types-collective-${randomString()}`, description: "Our team will review your codebase.", lengthInMinutes: 60, locations: [ @@ -275,8 +275,8 @@ describe("Organizations Event Types Endpoints", () => { it("should create a managed team event-type", async () => { const body: CreateTeamEventTypeInput_2024_06_14 = { - title: "Coding consultation managed", - slug: "coding-consultation-managed", + title: `teams-event-types-managed-${randomString()}`, + slug: `teams-event-types-managed-${randomString()}`, description: "Our team will review your codebase.", lengthInMinutes: 60, locations: [ @@ -316,6 +316,7 @@ describe("Organizations Event Types Endpoints", () => { const teamEventTypes = await eventTypesRepositoryFixture.getAllTeamEventTypes(team.id); expect(teammate1EventTypes.length).toEqual(1); + expect(teammate1EventTypes[0].title).toEqual(body.title); expect(teammate2EventTypes.length).toEqual(1); expect(teamEventTypes.filter((eventType) => eventType.schedulingType === "MANAGED").length).toEqual( 1 @@ -423,7 +424,7 @@ describe("Organizations Event Types Endpoints", () => { }); it("should update managed event-type", async () => { - const newTitle = "Coding consultation managed updated"; + const newTitle = `teams-event-types-managed-updated-${randomString()}`; const newHosts: UpdateTeamEventTypeInput_2024_06_14["hosts"] = [ { userId: teamMember1.id, diff --git a/apps/api/v2/src/modules/teams/memberships/controllers/teams-memberships.controller.e2e-spec.ts b/apps/api/v2/src/modules/teams/memberships/controllers/teams-memberships.controller.e2e-spec.ts index a61dc12850..4934e643d3 100644 --- a/apps/api/v2/src/modules/teams/memberships/controllers/teams-memberships.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/teams/memberships/controllers/teams-memberships.controller.e2e-spec.ts @@ -24,7 +24,7 @@ import { OrganizationRepositoryFixture } from "test/fixtures/repository/organiza import { ProfileRepositoryFixture } from "test/fixtures/repository/profiles.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; -import { randomNumber } from "test/utils/randomNumber"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { api } from "@calcom/app-store/alby"; @@ -51,11 +51,11 @@ describe("Teams Memberships Endpoints", () => { let teamMemberMembership: Membership; let membershipCreatedViaApi: TeamMembershipOutput; - const teamAdminEmail = `alice-admin-${randomNumber()}@api.com`; - const teamMemberEmail = `bob-member-${randomNumber()}@api.com`; - const nonTeamUserEmail = `charlie-outsider-${randomNumber()}@api`; + const teamAdminEmail = `alice-admin-${randomString()}@api.com`; + const teamMemberEmail = `bob-member-${randomString()}@api.com`; + const nonTeamUserEmail = `charlie-outsider-${randomString()}@api`; - const invitedUserEmail = `david-invited-${randomNumber()}@api.com`; + const invitedUserEmail = `david-invited-${randomString()}@api.com`; let teamAdmin: User; let teamMember: User; @@ -97,7 +97,7 @@ describe("Teams Memberships Endpoints", () => { }); team = await teamsRepositoryFixture.create({ - name: `Team-${randomNumber()}`, + name: `Team-${randomString()}`, isOrganization: false, }); diff --git a/apps/api/v2/src/modules/teams/teams/controllers/teams.controller.e2e-spec.ts b/apps/api/v2/src/modules/teams/teams/controllers/teams.controller.e2e-spec.ts index db953454df..21f88cdf0e 100644 --- a/apps/api/v2/src/modules/teams/teams/controllers/teams.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/teams/teams/controllers/teams.controller.e2e-spec.ts @@ -17,7 +17,7 @@ import { ApiKeysRepositoryFixture } from "test/fixtures/repository/api-keys.repo import { MembershipRepositoryFixture } from "test/fixtures/repository/membership.repository.fixture"; import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; -import { randomNumber } from "test/utils/randomNumber"; +import { randomString } from "test/utils/randomString"; import { SUCCESS_STATUS } from "@calcom/platform-constants"; import { TeamOutputDto } from "@calcom/platform-types"; @@ -29,11 +29,11 @@ describe("Teams endpoint", () => { let apiKeysRepositoryFixture: ApiKeysRepositoryFixture; let membershipRepositoryFixture: MembershipRepositoryFixture; - const aliceEmail = `alice-${randomNumber()}@api.com`; + const aliceEmail = `alice-${randomString()}@api.com`; let alice: User; let aliceApiKey: string; - const bobEmail = `bob-${randomNumber()}@api.com`; + const bobEmail = `bob-${randomString()}@api.com`; let bob: User; let bobApiKey: string; @@ -75,7 +75,7 @@ describe("Teams endpoint", () => { describe("User has membership in created team", () => { it("should create a team", async () => { const body: CreateTeamInput = { - name: "Team dog", + name: `teams-dog-${randomString()}`, }; return request(app.getHttpServer()) @@ -96,7 +96,7 @@ describe("Teams endpoint", () => { it("should create a team", async () => { const body: CreateTeamInput = { - name: "Team cats", + name: `teams-cats-${randomString()}`, }; return request(app.getHttpServer()) @@ -148,7 +148,7 @@ describe("Teams endpoint", () => { it("should update a team", async () => { const body: UpdateTeamDto = { - name: "Team dogs shepherds", + name: `teams-dogs-shepherds-${randomString()}`, }; return request(app.getHttpServer()) @@ -223,6 +223,7 @@ describe("Teams endpoint", () => { afterAll(async () => { await userRepositoryFixture.deleteByEmail(aliceEmail); + await userRepositoryFixture.deleteByEmail(bobEmail); await teamRepositoryFixture.delete(team1.id); await teamRepositoryFixture.delete(team2.id); await app.close(); diff --git a/apps/api/v2/src/modules/webhooks/controllers/webhooks.controller.e2e-spec.ts b/apps/api/v2/src/modules/webhooks/controllers/webhooks.controller.e2e-spec.ts index d79fab8998..bb8e1b9e61 100644 --- a/apps/api/v2/src/modules/webhooks/controllers/webhooks.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/webhooks/controllers/webhooks.controller.e2e-spec.ts @@ -15,13 +15,14 @@ import { Test } from "@nestjs/testing"; import * as request from "supertest"; import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture"; import { WebhookRepositoryFixture } from "test/fixtures/repository/webhooks.repository.fixture"; +import { randomString } from "test/utils/randomString"; import { withApiAuth } from "test/utils/withApiAuth"; import { Webhook } from "@calcom/prisma/client"; describe("WebhooksController (e2e)", () => { let app: INestApplication; - const userEmail = "webhook-controller-e2e@api.com"; + const userEmail = `webhooks-controller-user-${randomString()}@api.com`; let user: UserWithProfile; let otherUser: UserWithProfile; @@ -47,8 +48,8 @@ describe("WebhooksController (e2e)", () => { }); otherUser = await userRepositoryFixture.create({ - email: "other-user-webhook-controller@api.com", - username: "other-user-webhook-controller@api.com", + email: `webhooks-controller-other-user-${randomString()}@api.com`, + username: `webhooks-controller-other-user-${randomString()}@api.com`, }); otherWebhook = await webhookRepositoryFixture.create({ diff --git a/apps/api/v2/test/utils/randomNumber.ts b/apps/api/v2/test/utils/randomNumber.ts deleted file mode 100644 index 6607ace569..0000000000 --- a/apps/api/v2/test/utils/randomNumber.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function randomNumber(): number { - return Math.floor(Math.random() * 100000); -} diff --git a/apps/api/v2/test/utils/randomString.ts b/apps/api/v2/test/utils/randomString.ts new file mode 100644 index 0000000000..4ecd6ec28e --- /dev/null +++ b/apps/api/v2/test/utils/randomString.ts @@ -0,0 +1,5 @@ +import { v4 as uuidv4 } from "uuid"; + +export function randomString() { + return uuidv4().replace(/-/g, ""); +}