Skip to content

Commit 4e4c9ad

Browse files
committed
merge now returns buildDto
1 parent e210f53 commit 4e4c9ad

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/test-variations/test-variations.controller.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { Controller, ParseUUIDPipe, Get, UseGuards, Param, Query, Put, Body } from '@nestjs/common';
2-
import { ApiTags, ApiParam, ApiBearerAuth, ApiQuery } from '@nestjs/swagger';
2+
import { ApiTags, ApiParam, ApiBearerAuth, ApiQuery, ApiOkResponse } from '@nestjs/swagger';
33
import { TestVariationsService } from './test-variations.service';
44
import { TestVariation, Baseline } from '@prisma/client';
55
import { JwtAuthGuard } from '../auth/guards/auth.guard';
66
import { PrismaService } from '../prisma/prisma.service';
77
import { IgnoreAreaDto } from '../test-runs/dto/ignore-area.dto';
88
import { CommentDto } from '../shared/dto/comment.dto';
9+
import { BuildDto } from 'src/builds/dto/build.dto';
910

1011
@ApiTags('test-variations')
1112
@Controller('test-variations')
@@ -16,17 +17,17 @@ export class TestVariationsController {
1617
@ApiQuery({ name: 'projectId', required: true })
1718
@ApiBearerAuth()
1819
@UseGuards(JwtAuthGuard)
19-
getList(@Query('projectId', new ParseUUIDPipe()) projectId): Promise<TestVariation[]> {
20+
getList(@Query('projectId', new ParseUUIDPipe()) projectId: string): Promise<TestVariation[]> {
2021
return this.prismaService.testVariation.findMany({
2122
where: { projectId },
2223
});
2324
}
2425

25-
@Get(':id')
26+
@Get('details/:id')
2627
@ApiQuery({ name: 'id', required: true })
2728
@ApiBearerAuth()
2829
@UseGuards(JwtAuthGuard)
29-
getDetails(@Param('id', new ParseUUIDPipe()) id): Promise<TestVariation & { baselines: Baseline[] }> {
30+
getDetails(@Param('id', new ParseUUIDPipe()) id: string): Promise<TestVariation & { baselines: Baseline[] }> {
3031
return this.testVariations.getDetails(id);
3132
}
3233

@@ -49,15 +50,13 @@ export class TestVariationsController {
4950
return this.testVariations.updateComment(id, body);
5051
}
5152

52-
@Get('merge')
53+
@Get('merge/')
5354
@ApiQuery({ name: 'projectId', required: true })
5455
@ApiQuery({ name: 'branchName', required: true })
56+
@ApiOkResponse({ type: BuildDto })
5557
@ApiBearerAuth()
5658
@UseGuards(JwtAuthGuard)
57-
merge(
58-
@Query('projectId', new ParseUUIDPipe()) projectId: string,
59-
@Query('branchName') branchName: string
60-
): Promise<void> {
59+
merge(@Query('projectId') projectId: string, @Query('branchName') branchName: string): Promise<BuildDto> {
6160
return this.testVariations.merge(projectId, branchName);
6261
}
6362
}

src/test-variations/test-variations.service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { BuildsService } from '../builds/builds.service';
99
import { TestRunsService } from '../test-runs/test-runs.service';
1010
import { PNG } from 'pngjs';
1111
import { CreateTestRequestDto } from 'src/test-runs/dto/create-test-request.dto';
12+
import { BuildDto } from 'src/builds/dto/build.dto';
1213

1314
@Injectable()
1415
export class TestVariationsService {
@@ -118,11 +119,11 @@ export class TestVariationsService {
118119
});
119120
}
120121

121-
async merge(projectId: string, branchName: string): Promise<void> {
122+
async merge(projectId: string, branchName: string): Promise<BuildDto> {
122123
const project: Project = await this.prismaService.project.findOne({ where: { id: projectId } });
123124

124125
// create build
125-
const build: Build = await this.buildsService.create({
126+
const build: BuildDto = await this.buildsService.create({
126127
branchName: project.mainBranchName,
127128
project: projectId,
128129
});
@@ -163,5 +164,7 @@ export class TestVariationsService {
163164
}
164165
})
165166
);
167+
168+
return build;
166169
}
167170
}

0 commit comments

Comments
 (0)