fix: v2 allow creating team events without hosts (#20520)
* fix: v2 allow creating team events without hosts * chore: remove log
This commit is contained in:
1 parent
8ae5d32fe5
commit
feff588603
3 files changed
+12
-38
No files matched your search
+12
-2
@@ -264,7 +264,7 @@ describe("Assign all team members", () => {
|
||||
});
|
||||
|
||||
describe("should setup event types using assignAllTeamMembers true", () => {
|
||||
it("should not be able to setup team event type if no hosts nor assignAllTeamMembers provided", async () => {
|
||||
it("should be able to setup team event type if no hosts nor assignAllTeamMembers provided", async () => {
|
||||
const body: CreateTeamEventTypeInput_2024_06_14 = {
|
||||
title: "Coding consultation round robin",
|
||||
slug: `organizations-event-types-round-robin-${randomString()}`,
|
||||
@@ -279,7 +279,17 @@ describe("Assign all team members", () => {
|
||||
.send(body)
|
||||
.set(X_CAL_SECRET_KEY, oAuthClient.secret)
|
||||
.set(X_CAL_CLIENT_ID, oAuthClient.id)
|
||||
.expect(400);
|
||||
.expect(201);
|
||||
|
||||
const responseBody: ApiSuccessResponse<TeamEventTypeOutput_2024_06_14> = response.body;
|
||||
expect(responseBody.status).toEqual(SUCCESS_STATUS);
|
||||
|
||||
const data = responseBody.data;
|
||||
expect(data.title).toEqual(body.title);
|
||||
expect(data.hosts).toEqual([]);
|
||||
expect(data.schedulingType).toEqual("collective");
|
||||
const eventTypeHosts = await hostsRepositoryFixture.getEventTypeHosts(data.id);
|
||||
expect(eventTypeHosts.length).toEqual(0);
|
||||
});
|
||||
|
||||
it("should setup collective event type assignAllTeamMembers true", async () => {
|
||||
|
||||
@@ -108,13 +108,6 @@ export class InputOrganizationsEventTypesService {
|
||||
teamId: number,
|
||||
inputEventType: CreateTeamEventTypeInput_2024_06_14
|
||||
) {
|
||||
const hasHosts = !!inputEventType.hosts && !!inputEventType.hosts.length;
|
||||
const hasAssignAllTeamMembers = inputEventType.assignAllTeamMembers === true;
|
||||
|
||||
if (!hasHosts && !hasAssignAllTeamMembers) {
|
||||
throw new BadRequestException("Either hosts must be provided or assignAllTeamMembers must be true");
|
||||
}
|
||||
|
||||
const { hosts, assignAllTeamMembers, locations, ...rest } = inputEventType;
|
||||
|
||||
const eventType = this.inputEventTypesService.transformInputCreateEventType(rest);
|
||||
|
||||
Reference in new issue
Block a user