Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions src/test-runs/test-runs.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,10 @@ describe('TestRunsService', () => {
});
});

it('calculate no diff', async () => {
it('recalculateDiff', async () => {
const testRun = {
id: 'id',
buildId: 'buildId',
imageName: 'imageName',
baselineName: 'baselineName',
diffTollerancePercent: 12,
Expand All @@ -443,6 +444,7 @@ describe('TestRunsService', () => {
});
service.findOne = testRunFindOneMock;
service.getDiff = getDiffMock;
service.emitUpdateBuildEvent = jest.fn();

await service.recalculateDiff(testRun.id);

Expand All @@ -456,6 +458,7 @@ describe('TestRunsService', () => {
testRun.diffTollerancePercent,
testRun.ignoreAreas
);
expect(service.emitUpdateBuildEvent).toBeCalledWith(testRun.buildId);
});

describe('saveDiffResult', () => {
Expand All @@ -478,32 +481,32 @@ describe('TestRunsService', () => {
},
});
});
});

it('with results', async () => {
const diff: DiffResult = {
status: TestStatus.unresolved,
diffName: 'diff image name',
pixelMisMatchCount: 11,
diffPercent: 22,
isSameDimension: true,
};
const id = 'some id';
const testRunUpdateMock = jest.fn();
service = await initService({
testRunUpdateMock,
});

await service.saveDiffResult(id, diff);

expect(testRunUpdateMock).toHaveBeenCalledWith({
where: { id },
data: {
status: diff.status,
diffName: diff.diffName,
pixelMisMatchCount: diff.pixelMisMatchCount,
diffPercent: diff.diffPercent,
},
it('with results', async () => {
const diff: DiffResult = {
status: TestStatus.unresolved,
diffName: 'diff image name',
pixelMisMatchCount: 11,
diffPercent: 22,
isSameDimension: true,
};
const id = 'some id';
const testRunUpdateMock = jest.fn();
service = await initService({
testRunUpdateMock,
});

await service.saveDiffResult(id, diff);

expect(testRunUpdateMock).toHaveBeenCalledWith({
where: { id },
data: {
status: diff.status,
diffName: diff.diffName,
pixelMisMatchCount: diff.pixelMisMatchCount,
diffPercent: diff.diffPercent,
},
});
});
});

Expand Down
4 changes: 3 additions & 1 deletion src/test-runs/test-runs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ export class TestRunsService {
await this.staticService.deleteImage(testRun.diffName);

const diffResult = this.getDiff(baseline, image, testRun.diffTollerancePercent, testRun.ignoreAreas);
return this.saveDiffResult(id, diffResult);
const updatedTestRun = await this.saveDiffResult(id, diffResult);
this.emitUpdateBuildEvent(testRun.buildId);
return updatedTestRun;
}

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