11import {
22 designReview1 ,
33 designReview3 ,
4+ designReview5 ,
45 prismaDesignReview1 ,
56 prismaDesignReview2 ,
67 prismaDesignReview3 ,
8+ prismaDesignReview5 ,
79 sharedDesignReview1 ,
810 teamType1
911} from './test-data/design-reviews.test-data' ;
10- import { aquaman , batman , theVisitor , wonderwoman } from './test-data/users.test-data' ;
12+ import {
13+ aquaman ,
14+ batman ,
15+ batmanScheduleSettings ,
16+ batmanWithScheduleSettings ,
17+ superman ,
18+ theVisitor ,
19+ wonderwoman
20+ } from './test-data/users.test-data' ;
1121import prisma from '../src/prisma/prisma' ;
1222import {
1323 AccessDeniedAdminOnlyException ,
@@ -249,7 +259,7 @@ describe('Design Reviews', () => {
249259 [ ] ,
250260 [ 1 , 4 , 2 , 3 ]
251261 )
252- ) . rejects . toThrow ( new HttpException ( 400 , 'meeting times must be consecutive' ) ) ;
262+ ) . rejects . toThrow ( new HttpException ( 400 , 'Meeting times have to be consecutive' ) ) ;
253263 } ) ;
254264
255265 test ( 'Edit Design Review fails when meeting times are consecutive and *above* 83' , async ( ) => {
@@ -271,7 +281,7 @@ describe('Design Reviews', () => {
271281 [ ] ,
272282 [ 84 , 85 ]
273283 )
274- ) . rejects . toThrow ( new HttpException ( 400 , 'meeting time must be between 0-83' ) ) ;
284+ ) . rejects . toThrow ( new HttpException ( 400 , 'Meeting times have to be in range 0-83' ) ) ;
275285 } ) ;
276286
277287 test ( 'Edit Design Review fails when no docTemplateLink, and status is scheduled or done' , async ( ) => {
@@ -485,4 +495,54 @@ describe('Design Reviews', () => {
485495 ) . rejects . toThrow ( new NotFoundException ( 'WBS Element' , 15 ) ) ;
486496 } ) ;
487497 } ) ;
498+
499+ describe ( 'Mark user confirmed tests' , ( ) => {
500+ test ( 'mark user confirmed succeeds' , async ( ) => {
501+ vi . spyOn ( prisma . design_Review , 'findUnique' ) . mockResolvedValue ( prismaDesignReview5 ) ;
502+ vi . spyOn ( prisma . schedule_Settings , 'upsert' ) . mockResolvedValue ( batmanScheduleSettings ) ;
503+ const result = await DesignReviewsService . markUserConfirmed (
504+ prismaDesignReview5 . designReviewId ,
505+ [ 1 , 2 ] ,
506+ batmanWithScheduleSettings
507+ ) ;
508+
509+ expect ( prisma . design_Review . findUnique ) . toHaveBeenCalledTimes ( 1 ) ;
510+ expect ( result . confirmedMembers ) . toEqual ( designReview5 . confirmedMembers ) ;
511+ } ) ;
512+
513+ test ( 'Design Review was not found' , async ( ) => {
514+ vi . spyOn ( prisma . design_Review , 'findUnique' ) . mockResolvedValue ( null ) ;
515+ await expect ( ( ) =>
516+ DesignReviewsService . markUserConfirmed ( prismaDesignReview5 . designReviewId , [ 0 , 1 , 2 ] , batman )
517+ ) . rejects . toThrow ( new NotFoundException ( 'Design Review' , prismaDesignReview5 . designReviewId ) ) ;
518+ } ) ;
519+
520+ test ( 'Design Review was deleted' , async ( ) => {
521+ vi . spyOn ( prisma . design_Review , 'findUnique' ) . mockResolvedValue ( { ...prismaDesignReview1 , dateDeleted : new Date ( ) } ) ;
522+ await expect ( ( ) =>
523+ DesignReviewsService . markUserConfirmed ( prismaDesignReview5 . designReviewId , [ 0 , 1 , 2 ] , batman )
524+ ) . rejects . toThrow ( new DeletedException ( 'Design Review' , prismaDesignReview5 . designReviewId ) ) ;
525+ } ) ;
526+
527+ test ( 'User was not in required/optional members of design review' , async ( ) => {
528+ vi . spyOn ( prisma . design_Review , 'findUnique' ) . mockResolvedValue ( prismaDesignReview5 ) ;
529+ await expect ( ( ) =>
530+ DesignReviewsService . markUserConfirmed ( prismaDesignReview5 . designReviewId , [ 0 , 1 , 2 ] , superman )
531+ ) . rejects . toThrow ( new HttpException ( 400 , 'Current user is not in the list of this design reviews members' ) ) ;
532+ } ) ;
533+
534+ test ( 'Availabilities were invalid - out of bounds' , async ( ) => {
535+ vi . spyOn ( prisma . design_Review , 'findUnique' ) . mockResolvedValue ( prismaDesignReview5 ) ;
536+ await expect ( ( ) =>
537+ DesignReviewsService . markUserConfirmed ( prismaDesignReview5 . designReviewId , [ 0 , 85 ] , batman )
538+ ) . rejects . toThrow ( new HttpException ( 400 , 'Meeting times have to be in range 0-83' ) ) ;
539+ } ) ;
540+
541+ test ( 'Availabilities were invalid - non-consecutive' , async ( ) => {
542+ vi . spyOn ( prisma . design_Review , 'findUnique' ) . mockResolvedValue ( prismaDesignReview5 ) ;
543+ await expect ( ( ) =>
544+ DesignReviewsService . markUserConfirmed ( prismaDesignReview5 . designReviewId , [ 1 , 3 ] , batman )
545+ ) . rejects . toThrow ( new HttpException ( 400 , 'Meeting times have to be consecutive' ) ) ;
546+ } ) ;
547+ } ) ;
488548} ) ;
0 commit comments