Skip to content

Commit 5d800f4

Browse files
committed
users. e2e tests added
1 parent 402b5d9 commit 5d800f4

File tree

15 files changed

+199
-59
lines changed

15 files changed

+199
-59
lines changed

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"test:cov": "jest --coverage",
2020
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
2121
"test:e2e": "jest --config ./test/jest-e2e.json",
22-
"docker:build_api": "jest && docker build -t visualregressiontracker/api:$npm_package_version -f ./Dockerfile . && docker push visualregressiontracker/api:$npm_package_version",
22+
"docker:build_api": "npm run test && npm run test:e2e && docker build -t visualregressiontracker/api:$npm_package_version -f ./Dockerfile . && docker push visualregressiontracker/api:$npm_package_version",
2323
"docker:build_migration": "docker build -t visualregressiontracker/migration:0.0.2 -f ./prisma/Dockerfile ./prisma"
2424
},
2525
"dependencies": {
@@ -53,6 +53,7 @@
5353
"@nestjs/schematics": "^7.0.0",
5454
"@nestjs/testing": "^7.0.0",
5555
"@prisma/cli": "^2.0.0-beta.5",
56+
"@types/bcryptjs": "^2.4.2",
5657
"@types/express": "^4.17.3",
5758
"@types/jest": "25.1.4",
5859
"@types/node": "^13.9.1",
@@ -61,6 +62,7 @@
6162
"@types/pixelmatch": "^5.1.0",
6263
"@types/pngjs": "^3.4.2",
6364
"@types/supertest": "^2.0.8",
65+
"@types/uuid-apikey": "^1.4.0",
6466
"@typescript-eslint/eslint-plugin": "^2.23.0",
6567
"@typescript-eslint/parser": "^2.23.0",
6668
"eslint": "^6.8.0",

src/auth/auth.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export class AuthService {
2020
return uuidAPIKey.create({ noDashes: true }).apiKey;
2121
}
2222

23-
async compare(password1: string, password2: string): Promise<boolean> {
24-
return await compare(password1, password2);
23+
async compare(password: string, hashedPassword: string): Promise<boolean> {
24+
return await compare(password, hashedPassword);
2525
}
2626

2727
signToken(user: User): string {

src/auth/jwt.strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { PassportStrategy } from '@nestjs/passport';
33
import { Injectable, HttpException, HttpStatus } from '@nestjs/common';
44
import { JwtPayload } from './jwt-payload.model';
55
import { ConfigService } from '@nestjs/config';
6-
import { PrismaService } from 'src/prisma/prisma.service';
6+
import { PrismaService } from '../prisma/prisma.service';
77

88
@Injectable()
99
export class JwtStrategy extends PassportStrategy(Strategy) {

src/builds/builds.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Module } from '@nestjs/common';
22
import { BuildsService } from './builds.service';
33
import { BuildsController } from './builds.controller';
4-
import { UsersModule } from 'src/users/users.module';
5-
import { PrismaService } from 'src/prisma/prisma.service';
6-
import { TestRunsModule } from 'src/test-runs/test-runs.module';
4+
import { UsersModule } from '../users/users.module';
5+
import { PrismaService } from '../prisma/prisma.service';
6+
import { TestRunsModule } from '../test-runs/test-runs.module';
77

88
@Module({
99
imports: [UsersModule, TestRunsModule],

src/projects/projects.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Module } from '@nestjs/common';
22
import { ProjectsService } from './projects.service';
33
import { ProjectsController } from './projects.controller';
4-
import { BuildsModule } from 'src/builds/builds.module';
5-
import { TestVariationsModule } from 'src/test-variations/test-variations.module';
6-
import { PrismaService } from 'src/prisma/prisma.service';
4+
import { BuildsModule } from '../builds/builds.module';
5+
import { TestVariationsModule } from '../test-variations/test-variations.module';
6+
import { PrismaService } from '../prisma/prisma.service';
77

88
@Module({
99
imports: [BuildsModule, TestVariationsModule],

src/test-runs/test-runs.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Module } from '@nestjs/common';
22
import { TestRunsService } from './test-runs.service';
3-
import { SharedModule } from 'src/shared/shared.module';
4-
import { PrismaService } from 'src/prisma/prisma.service';
3+
import { SharedModule } from '../shared/shared.module';
4+
import { PrismaService } from '../prisma/prisma.service';
55
import { TestRunsController } from './test-runs.controller';
66

77
@Module({

src/test-variations/test-variations.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { Module } from '@nestjs/common';
22
import { TestVariationsService } from './test-variations.service';
33
import { TestVariationsController } from './test-variations.controller';
4-
import { TestRunsModule } from 'src/test-runs/test-runs.module';
5-
import { PrismaService } from 'src/prisma/prisma.service';
4+
import { PrismaService } from '../prisma/prisma.service';
65

76
@Module({
87
providers: [TestVariationsService, PrismaService],

src/test/test.module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Module } from '@nestjs/common';
22
import { TestService } from './test.service';
33
import { TestController } from './test.controller';
4-
import { TestRunsModule } from 'src/test-runs/test-runs.module';
5-
import { TestVariationsModule } from 'src/test-variations/test-variations.module';
6-
import { UsersModule } from 'src/users/users.module';
7-
import { PrismaService } from 'src/prisma/prisma.service';
4+
import { TestRunsModule } from '../test-runs/test-runs.module';
5+
import { TestVariationsModule } from '../test-variations/test-variations.module';
6+
import { UsersModule } from '../users/users.module';
7+
import { PrismaService } from '../prisma/prisma.service';
88

99
@Module({
1010
imports: [TestRunsModule, TestVariationsModule, UsersModule],

src/users/users.controller.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,14 @@ export class UsersController {
4949
return this.usersService.changePassword(user, password)
5050
}
5151

52-
@Get(':id')
53-
@ApiParam({ name: 'id', required: true })
54-
@ApiOkResponse({ type: UserDto })
55-
@ApiBearerAuth()
56-
@UseGuards(JwtAuthGuard)
57-
get(@Param('id', new ParseUUIDPipe()) id: string): Promise<UserDto> {
58-
return this.usersService.get(id);
59-
}
60-
61-
@Put(':id')
62-
@ApiParam({ name: 'id', required: true })
52+
@Put()
6353
@ApiOkResponse({ type: UserLoginResponseDto })
6454
@ApiBearerAuth()
6555
@UseGuards(JwtAuthGuard)
66-
updated(
67-
@Param('id', new ParseUUIDPipe()) id: string,
56+
update(
57+
@CurrentUser() user: User,
6858
@Body() updateUserDto: UpdateUserDto
6959
): Promise<UserLoginResponseDto> {
70-
return this.usersService.update(id, updateUserDto);
60+
return this.usersService.update(user.id, updateUserDto);
7161
}
7262
}

0 commit comments

Comments
 (0)