Skip to content

Commit 5953681

Browse files
committed
Emit build change event when ignore area recalculated
1 parent 5d95b56 commit 5953681

File tree

2 files changed

+32
-27
lines changed

2 files changed

+32
-27
lines changed

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

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,10 @@ describe('TestRunsService', () => {
414414
});
415415
});
416416

417-
it('calculate no diff', async () => {
417+
it('recalculateDiff', async () => {
418418
const testRun = {
419419
id: 'id',
420+
buildId: 'buildId',
420421
imageName: 'imageName',
421422
baselineName: 'baselineName',
422423
diffTollerancePercent: 12,
@@ -443,6 +444,7 @@ describe('TestRunsService', () => {
443444
});
444445
service.findOne = testRunFindOneMock;
445446
service.getDiff = getDiffMock;
447+
service.emitUpdateBuildEvent = jest.fn();
446448

447449
await service.recalculateDiff(testRun.id);
448450

@@ -456,6 +458,7 @@ describe('TestRunsService', () => {
456458
testRun.diffTollerancePercent,
457459
testRun.ignoreAreas
458460
);
461+
expect(service.emitUpdateBuildEvent).toBeCalledWith(testRun.buildId);
459462
});
460463

461464
describe('saveDiffResult', () => {
@@ -478,32 +481,32 @@ describe('TestRunsService', () => {
478481
},
479482
});
480483
});
481-
});
482-
483-
it('with results', async () => {
484-
const diff: DiffResult = {
485-
status: TestStatus.unresolved,
486-
diffName: 'diff image name',
487-
pixelMisMatchCount: 11,
488-
diffPercent: 22,
489-
isSameDimension: true,
490-
};
491-
const id = 'some id';
492-
const testRunUpdateMock = jest.fn();
493-
service = await initService({
494-
testRunUpdateMock,
495-
});
496-
497-
await service.saveDiffResult(id, diff);
498484

499-
expect(testRunUpdateMock).toHaveBeenCalledWith({
500-
where: { id },
501-
data: {
502-
status: diff.status,
503-
diffName: diff.diffName,
504-
pixelMisMatchCount: diff.pixelMisMatchCount,
505-
diffPercent: diff.diffPercent,
506-
},
485+
it('with results', async () => {
486+
const diff: DiffResult = {
487+
status: TestStatus.unresolved,
488+
diffName: 'diff image name',
489+
pixelMisMatchCount: 11,
490+
diffPercent: 22,
491+
isSameDimension: true,
492+
};
493+
const id = 'some id';
494+
const testRunUpdateMock = jest.fn();
495+
service = await initService({
496+
testRunUpdateMock,
497+
});
498+
499+
await service.saveDiffResult(id, diff);
500+
501+
expect(testRunUpdateMock).toHaveBeenCalledWith({
502+
where: { id },
503+
data: {
504+
status: diff.status,
505+
diffName: diff.diffName,
506+
pixelMisMatchCount: diff.pixelMisMatchCount,
507+
diffPercent: diff.diffPercent,
508+
},
509+
});
507510
});
508511
});
509512

src/test-runs/test-runs.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ export class TestRunsService {
146146
await this.staticService.deleteImage(testRun.diffName);
147147

148148
const diffResult = this.getDiff(baseline, image, testRun.diffTollerancePercent, testRun.ignoreAreas);
149-
return this.saveDiffResult(id, diffResult);
149+
const updatedTestRun = await this.saveDiffResult(id, diffResult);
150+
this.emitUpdateBuildEvent(testRun.buildId);
151+
return updatedTestRun;
150152
}
151153

152154
async create(testVariation: TestVariation, createTestRequestDto: CreateTestRequestDto): Promise<TestRun> {

0 commit comments

Comments
 (0)