Skip to content

Commit 2f3bdc6

Browse files
authored
Merge pull request #62 from Visual-Regression-Tracker/122-build-status-merge-fix
122 build status merge fix
2 parents 1c8b8d2 + 8c6dd9a commit 2f3bdc6

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

src/test-runs/dto/testRunResult.dto.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import { TestRun, TestStatus, TestVariation } from '@prisma/client';
2+
import { ApiProperty } from '@nestjs/swagger';
23

34
export class TestRunResultDto {
5+
@ApiProperty()
46
id: string;
7+
@ApiProperty()
58
imageName: string;
9+
@ApiProperty()
610
diffName?: string;
11+
@ApiProperty()
712
diffPercent: number;
13+
@ApiProperty()
814
diffTollerancePercent?: number;
15+
@ApiProperty()
916
pixelMisMatchCount?: number;
17+
@ApiProperty()
1018
status: TestStatus;
19+
@ApiProperty()
1120
url: string;
21+
@ApiProperty()
1222
merge: boolean;
1323

1424
constructor(testRun: TestRun, testVariation: TestVariation) {

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

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const initModule = async ({
2222
baselineDeleteMock = jest.fn(),
2323
projectFindOneMock = jest.fn(),
2424
buildCreateMock = jest.fn(),
25+
buildStopMock = jest.fn(),
2526
testRunCreateMock = jest.fn(),
2627
testRunFindMany = jest.fn(),
2728
testRunDeleteMock = jest.fn(),
@@ -40,6 +41,7 @@ const initModule = async ({
4041
provide: BuildsService,
4142
useValue: {
4243
create: buildCreateMock,
44+
stop: buildStopMock,
4345
},
4446
},
4547
{
@@ -140,10 +142,7 @@ describe('TestVariationsService', () => {
140142
createdAt: new Date(),
141143
updatedAt: new Date(),
142144
};
143-
const variationFindManyMock = jest
144-
.fn()
145-
.mockResolvedValueOnce([variationMock])
146-
.mockResolvedValueOnce([undefined]);
145+
const variationFindManyMock = jest.fn().mockResolvedValueOnce([variationMock]).mockResolvedValueOnce([undefined]);
147146
const projectFindOneMock = jest.fn().mockReturnValueOnce(projectMock);
148147
service = await initModule({ variationFindManyMock, projectFindOneMock });
149148

@@ -203,10 +202,7 @@ describe('TestVariationsService', () => {
203202
createdAt: new Date(),
204203
updatedAt: new Date(),
205204
};
206-
const variationFindManyMock = jest
207-
.fn()
208-
.mockResolvedValueOnce([undefined])
209-
.mockResolvedValueOnce([variationMock]);
205+
const variationFindManyMock = jest.fn().mockResolvedValueOnce([undefined]).mockResolvedValueOnce([variationMock]);
210206
const projectFindOneMock = jest.fn().mockReturnValueOnce(projectMock);
211207
service = await initModule({ variationFindManyMock, projectFindOneMock });
212208

@@ -251,10 +247,7 @@ describe('TestVariationsService', () => {
251247
branchName: 'develop',
252248
};
253249

254-
const variationFindManyMock = jest
255-
.fn()
256-
.mockResolvedValueOnce([undefined])
257-
.mockResolvedValueOnce([undefined]);
250+
const variationFindManyMock = jest.fn().mockResolvedValueOnce([undefined]).mockResolvedValueOnce([undefined]);
258251
const projectFindOneMock = jest.fn().mockReturnValueOnce(projectMock);
259252
const variationCreateMock = jest.fn();
260253
service = await initModule({ variationFindManyMock, projectFindOneMock, variationCreateMock });
@@ -415,19 +408,17 @@ describe('TestVariationsService', () => {
415408
width: 10,
416409
height: 10,
417410
});
418-
const getImageMock = jest
419-
.fn()
420-
.mockReturnValueOnce(image)
421-
.mockReturnValueOnce(image)
422-
.mockReturnValueOnce(null);
411+
const getImageMock = jest.fn().mockReturnValueOnce(image).mockReturnValueOnce(image).mockReturnValueOnce(null);
423412
const findOrCreateMock = jest
424413
.fn()
425414
.mockResolvedValueOnce(testVariationMainBranch)
426415
.mockResolvedValueOnce(testVariationMainBranch);
427416
const testRunCreateMock = jest.fn();
417+
const buildStopMock = jest.fn();
428418
const service = await initModule({
429419
projectFindOneMock,
430420
buildCreateMock,
421+
buildStopMock,
431422
testRunCreateMock,
432423
variationFindManyMock,
433424
getImageMock,
@@ -454,7 +445,7 @@ describe('TestVariationsService', () => {
454445
branchName: project.mainBranchName,
455446
});
456447

457-
await new Promise(r => setTimeout(r, 1));
448+
await new Promise((r) => setTimeout(r, 1));
458449
expect(testRunCreateMock).toHaveBeenNthCalledWith(1, testVariationMainBranch, {
459450
...testVariation,
460451
buildId: build.id,
@@ -470,6 +461,7 @@ describe('TestVariationsService', () => {
470461
merge: true,
471462
});
472463
expect(testRunCreateMock).toHaveBeenCalledTimes(2);
464+
expect(buildStopMock).toHaveBeenCalledWith(build.id);
473465
});
474466

475467
it('delete', async () => {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ export class TestVariationsService {
139139
}
140140
});
141141

142-
return build;
142+
// stop build
143+
return this.buildsService.stop(build.id);
143144
}
144145

145146
async delete(id: string): Promise<TestVariation> {

0 commit comments

Comments
 (0)