11import { Test , TestingModule } from '@nestjs/testing' ;
2- import { INestApplication } from '@nestjs/common' ;
2+ import { INestApplication , ValidationPipe } from '@nestjs/common' ;
33import { AppModule } from '../src/app.module' ;
44import { UsersService } from '../src/users/users.service' ;
55import { requestWithAuth , haveUserLogged } from './preconditions' ;
66import { ProjectsService } from '../src/projects/projects.service' ;
77import uuidAPIKey from 'uuid-apikey' ;
88import { UserLoginResponseDto } from 'src/users/dto/user-login-response.dto' ;
9+ import { ProjectDto } from 'src/projects/dto/project.dto' ;
910
10- const project = {
11+ const project : ProjectDto = {
1112 id : uuidAPIKey . create ( ) . uuid ,
1213 name : 'Test project' ,
14+ buildsCounter : 0 ,
15+ mainBranchName : 'master' ,
16+ createdAt : new Date ( ) ,
17+ updatedAt : new Date ( ) ,
18+ autoApproveFeature : true ,
19+ imageComparison : 'pixelmatch' ,
20+ maxBuildAllowed : 0 ,
21+ maxBranchLifetime : 0 ,
22+ imageComparisonConfig : '{}'
1323} ;
1424
1525const projectServiceMock = {
@@ -33,6 +43,7 @@ describe('Projects (e2e)', () => {
3343 . compile ( ) ;
3444
3545 app = moduleFixture . createNestApplication ( ) ;
46+ app . useGlobalPipes ( new ValidationPipe ( ) ) ;
3647 usersService = moduleFixture . get < UsersService > ( UsersService ) ;
3748
3849 await app . init ( ) ;
@@ -81,7 +92,11 @@ describe('Projects (e2e)', () => {
8192 it ( 'can delete' , async ( ) => {
8293 const res = await requestWithAuth ( app , 'delete' , `/projects/${ project . id } ` , loggedUser . token ) . send ( ) . expect ( 200 ) ;
8394
84- expect ( res . body ) . toStrictEqual ( projectServiceMock . remove ( ) ) ;
95+ expect ( res . body ) . toStrictEqual ( {
96+ ...projectServiceMock . remove ( ) ,
97+ createdAt : expect . any ( String ) ,
98+ updatedAt : expect . any ( String ) ,
99+ } ) ;
85100 } ) ;
86101
87102 it ( 'not valid UUID' , async ( ) => {
@@ -97,7 +112,11 @@ describe('Projects (e2e)', () => {
97112 it ( 'can edit' , async ( ) => {
98113 const res = await requestWithAuth ( app , 'put' , `/projects` , loggedUser . token ) . send ( project ) . expect ( 200 ) ;
99114
100- expect ( res . body ) . toStrictEqual ( projectServiceMock . update ( ) ) ;
115+ expect ( res . body ) . toStrictEqual ( {
116+ ...projectServiceMock . update ( ) ,
117+ createdAt : expect . any ( String ) ,
118+ updatedAt : expect . any ( String ) ,
119+ } ) ;
101120 } ) ;
102121
103122 it ( 'not valid token' , async ( ) => {
0 commit comments