@@ -4,10 +4,9 @@ import { DEFAULT_EVENT_TYPES } from "@/ee/event-types/event-types_2024_04_15/con
4
4
import { HttpExceptionFilter } from "@/filters/http-exception.filter" ;
5
5
import { PrismaExceptionFilter } from "@/filters/prisma-exception.filter" ;
6
6
import { Locales } from "@/lib/enums/locales" ;
7
- import {
8
- CreateUserResponse ,
9
- UserReturned ,
10
- } from "@/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller" ;
7
+ import { CreateManagedUserOutput } from "@/modules/oauth-clients/controllers/oauth-client-users/outputs/create-managed-user.output" ;
8
+ import { GetManagedUserOutput } from "@/modules/oauth-clients/controllers/oauth-client-users/outputs/get-managed-user.output" ;
9
+ import { GetManagedUsersOutput } from "@/modules/oauth-clients/controllers/oauth-client-users/outputs/get-managed-users.output" ;
11
10
import { CreateManagedUserInput } from "@/modules/users/inputs/create-managed-user.input" ;
12
11
import { UpdateManagedUserInput } from "@/modules/users/inputs/update-managed-user.input" ;
13
12
import { UsersModule } from "@/modules/users/users.module" ;
@@ -81,7 +80,7 @@ describe("OAuth Client Users Endpoints", () => {
81
80
let schedulesRepositoryFixture : SchedulesRepositoryFixture ;
82
81
let profilesRepositoryFixture : ProfileRepositoryFixture ;
83
82
84
- let postResponseData : CreateUserResponse ;
83
+ let postResponseData : CreateManagedUserOutput [ "data" ] ;
85
84
86
85
const platformAdminEmail = "platform-sensei@mail.com" ;
87
86
let platformAdmin : User ;
@@ -150,6 +149,7 @@ describe("OAuth Client Users Endpoints", () => {
150
149
const requestBody : CreateManagedUserInput = {
151
150
email : userEmail ,
152
151
timeZone : "incorrect-time-zone" ,
152
+ name : "Alice Smith" ,
153
153
} ;
154
154
155
155
await request ( app . getHttpServer ( ) )
@@ -166,6 +166,7 @@ describe("OAuth Client Users Endpoints", () => {
166
166
weekStart : "Monday" ,
167
167
timeFormat : 24 ,
168
168
locale : Locales . FR ,
169
+ name : "Alice Smith" ,
169
170
} ;
170
171
171
172
const response = await request ( app . getHttpServer ( ) )
@@ -174,18 +175,15 @@ describe("OAuth Client Users Endpoints", () => {
174
175
. send ( requestBody )
175
176
. expect ( 201 ) ;
176
177
177
- const responseBody : ApiSuccessResponse < {
178
- user : Omit < User , "password" > ;
179
- accessToken : string ;
180
- refreshToken : string ;
181
- } > = response . body ;
178
+ const responseBody : CreateManagedUserOutput = response . body ;
182
179
183
180
postResponseData = responseBody . data ;
184
181
185
182
expect ( responseBody . status ) . toEqual ( SUCCESS_STATUS ) ;
186
183
expect ( responseBody . data ) . toBeDefined ( ) ;
187
184
expect ( responseBody . data . user . email ) . toEqual ( getOAuthUserEmail ( oAuthClient . id , requestBody . email ) ) ;
188
185
expect ( responseBody . data . user . timeZone ) . toEqual ( requestBody . timeZone ) ;
186
+ expect ( responseBody . data . user . name ) . toEqual ( requestBody . name ) ;
189
187
expect ( responseBody . data . user . weekStart ) . toEqual ( requestBody . weekStart ) ;
190
188
expect ( responseBody . data . user . timeFormat ) . toEqual ( requestBody . timeFormat ) ;
191
189
expect ( responseBody . data . user . locale ) . toEqual ( requestBody . locale ) ;
@@ -242,12 +240,13 @@ describe("OAuth Client Users Endpoints", () => {
242
240
. set ( "Origin" , `${ CLIENT_REDIRECT_URI } ` )
243
241
. expect ( 200 ) ;
244
242
245
- const responseBody : ApiSuccessResponse < UserReturned [ ] > = response . body ;
243
+ const responseBody : GetManagedUsersOutput = response . body ;
246
244
247
245
expect ( responseBody . status ) . toEqual ( SUCCESS_STATUS ) ;
248
246
expect ( responseBody . data ) . toBeDefined ( ) ;
249
247
expect ( responseBody . data ?. length ) . toBeGreaterThan ( 0 ) ;
250
248
expect ( responseBody . data [ 0 ] . email ) . toEqual ( postResponseData . user . email ) ;
249
+ expect ( responseBody . data [ 0 ] . name ) . toEqual ( postResponseData . user . name ) ;
251
250
} ) ;
252
251
253
252
it ( `/GET/:id` , async ( ) => {
@@ -257,7 +256,7 @@ describe("OAuth Client Users Endpoints", () => {
257
256
. set ( "Origin" , `${ CLIENT_REDIRECT_URI } ` )
258
257
. expect ( 200 ) ;
259
258
260
- const responseBody : ApiSuccessResponse < UserReturned > = response . body ;
259
+ const responseBody : GetManagedUserOutput = response . body ;
261
260
262
261
expect ( responseBody . status ) . toEqual ( SUCCESS_STATUS ) ;
263
262
expect ( responseBody . data ) . toBeDefined ( ) ;
@@ -333,7 +332,7 @@ describe("OAuth Client Users Endpoints", () => {
333
332
let eventTypesRepositoryFixture : EventTypesRepositoryFixture ;
334
333
let profileRepositoryFixture : ProfileRepositoryFixture ;
335
334
336
- let postResponseData : CreateUserResponse ;
335
+ let postResponseData : CreateManagedUserOutput [ "data" ] ;
337
336
338
337
const userEmail = "oauth-client-users-user@gmail.com" ;
339
338
const userTimeZone = "Europe/Rome" ;
@@ -479,6 +478,7 @@ describe("OAuth Client Users Endpoints", () => {
479
478
weekStart : "Monday" ,
480
479
timeFormat : 24 ,
481
480
locale : Locales . FR ,
481
+ name : "Alice Smith" ,
482
482
} ;
483
483
484
484
const response = await request ( app . getHttpServer ( ) )
@@ -487,19 +487,15 @@ describe("OAuth Client Users Endpoints", () => {
487
487
. send ( requestBody )
488
488
. expect ( 201 ) ;
489
489
490
- const responseBody : ApiSuccessResponse < {
491
- user : Omit < User , "password" > ;
492
- accessToken : string ;
493
- refreshToken : string ;
494
- } > = response . body ;
495
-
490
+ const responseBody : CreateManagedUserOutput = response . body ;
496
491
postResponseData = responseBody . data ;
497
492
498
493
expect ( responseBody . status ) . toEqual ( SUCCESS_STATUS ) ;
499
494
expect ( responseBody . data ) . toBeDefined ( ) ;
500
495
501
496
await userHasCorrectEventTypes ( responseBody . data . user . id ) ;
502
497
await teamHasCorrectEventTypes ( team1 . id ) ;
498
+ expect ( responseBody . data . user . name ) . toEqual ( requestBody . name ) ;
503
499
} ) ;
504
500
505
501
async function userHasCorrectEventTypes ( userId : number ) {
0 commit comments