Skip to content

Commit

Permalink
feat: add CSAT to V2 bookings return (#19278)
Browse files Browse the repository at this point in the history
* init

* test: v2 bookings returns rating

---------

Co-authored-by: supalarry <[email protected]>
Co-authored-by: Lauris Skraucis <[email protected]>
  • Loading branch information
3 people authored Feb 14, 2025
1 parent b2763a6 commit c17ac67
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ describe("Bookings Endpoints 2024-08-13", () => {
timeZone: "Europe/Rome",
},
},
rating: 10,
});

app = moduleRef.createNestApplication();
Expand Down Expand Up @@ -552,6 +553,30 @@ describe("Bookings Endpoints 2024-08-13", () => {
});
});

it("should should get a booking with rating", async () => {
return request(app.getHttpServer())
.get(`/v2/bookings/${bookingInThePast.uid}`)
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
.expect(200)
.then(async (response) => {
const responseBody: GetBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(responseDataIsBooking(responseBody.data)).toBe(true);

if (responseDataIsBooking(responseBody.data)) {
const data: BookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toEqual(bookingInThePast.id);
expect(data.uid).toEqual(bookingInThePast.uid);
expect(data.rating).toEqual(bookingInThePast.rating);
} else {
throw new Error(
"Invalid response data - expected booking but received array of possibily recurring bookings"
);
}
});
});

it("should should get 1 recurrence of a recurring booking", async () => {
const recurrenceUid = createdRecurringBooking[0].uid;
return request(app.getHttpServer())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export class OutputBookingsService_2024_08_13 {
absentHost: !!databaseBooking.noShowHost,
createdAt: databaseBooking.createdAt,
updatedAt: databaseBooking.updatedAt,
rating: databaseBooking.rating,
};

const bookingTransformed = plainToClass(BookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
Expand Down Expand Up @@ -227,6 +228,7 @@ export class OutputBookingsService_2024_08_13 {
bookingFieldsResponses: databaseBooking.responses,
createdAt: databaseBooking.createdAt,
updatedAt: databaseBooking.updatedAt,
rating: databaseBooking.rating,
};

const bookingTransformed = plainToClass(RecurringBookingOutput_2024_08_13, booking, {
Expand Down Expand Up @@ -274,6 +276,7 @@ export class OutputBookingsService_2024_08_13 {
absentHost: !!databaseBooking.noShowHost,
createdAt: databaseBooking.createdAt,
updatedAt: databaseBooking.updatedAt,
rating: databaseBooking.rating,
};

const parsed = plainToClass(GetSeatedBookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
Expand Down Expand Up @@ -380,6 +383,7 @@ export class OutputBookingsService_2024_08_13 {
absentHost: !!databaseBooking.noShowHost,
createdAt: databaseBooking.createdAt,
updatedAt: databaseBooking.updatedAt,
rating: databaseBooking.rating,
};

const parsed = plainToClass(GetRecurringSeatedBookingOutput_2024_08_13, booking, {
Expand Down
24 changes: 24 additions & 0 deletions apps/api/v2/swagger/documentation.json
Original file line number Diff line number Diff line change
Expand Up @@ -15376,6 +15376,10 @@
"key": "value"
}
},
"rating": {
"type": "number",
"example": 4
},
"attendees": {
"type": "array",
"items": {
Expand Down Expand Up @@ -15524,6 +15528,10 @@
"key": "value"
}
},
"rating": {
"type": "number",
"example": 4
},
"attendees": {
"type": "array",
"items": {
Expand Down Expand Up @@ -15775,6 +15783,10 @@
"key": "value"
}
},
"rating": {
"type": "number",
"example": 4
},
"seatUid": {
"type": "string",
"example": "3be561a9-31f1-4b8e-aefc-9d9a085f0dd1"
Expand Down Expand Up @@ -15910,6 +15922,10 @@
"key": "value"
}
},
"rating": {
"type": "number",
"example": 4
},
"seatUid": {
"type": "string",
"example": "3be561a9-31f1-4b8e-aefc-9d9a085f0dd1"
Expand Down Expand Up @@ -16090,6 +16106,10 @@
"key": "value"
}
},
"rating": {
"type": "number",
"example": 4
},
"attendees": {
"type": "array",
"items": {
Expand Down Expand Up @@ -16220,6 +16240,10 @@
"key": "value"
}
},
"rating": {
"type": "number",
"example": 4
},
"attendees": {
"type": "array",
"items": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ class BaseBookingOutput_2024_08_13 {
@IsOptional()
@Expose()
metadata?: Record<string, string>;

@ApiPropertyOptional({ type: Number, example: 4 })
@IsInt()
@IsOptional()
@Expose()
rating?: number;
}

export class BookingOutput_2024_08_13 extends BaseBookingOutput_2024_08_13 {
Expand Down

0 comments on commit c17ac67

Please sign in to comment.