Skip to content

Commit e6fe824

Browse files
committed
recalculateDiff added
1 parent 6f2d50d commit e6fe824

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

src/shared/static/static.service.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ import { ConfigService } from '@nestjs/config';
66

77
@Injectable()
88
export class StaticService {
9-
constructor(private configService: ConfigService) {
10-
}
9+
constructor(private configService: ConfigService) {}
1110

1211
saveImage(type: 'screenshot' | 'diff' | 'baseline', imageBuffer: Buffer): string {
13-
const imageName = `${Date.now()}.${type}.png`
12+
const imageName = `${Date.now()}.${type}.png`;
1413
writeFileSync(this.getImagePath(imageName), imageBuffer);
15-
return imageName
14+
return imageName;
1615
}
1716

1817
getImage(imageName: string): PNGWithMetadata {
19-
let image: PNGWithMetadata
18+
let image: PNGWithMetadata;
2019
try {
21-
image = PNG.sync.read(readFileSync(this.getImagePath(imageName)))
20+
image = PNG.sync.read(readFileSync(this.getImagePath(imageName)));
2221
} catch (ex) {
23-
console.log(`Cannot image: ${imageName}. ${ex}`)
22+
console.log(`Cannot image: ${imageName}. ${ex}`);
2423
}
2524
return image;
2625
}
2726

2827
async deleteImage(imageName: string): Promise<boolean> {
28+
if (!imageName) return;
2929
return new Promise((resolvePromise, reject) => {
3030
unlink(this.getImagePath(imageName), err => {
3131
if (err) {
@@ -37,18 +37,18 @@ export class StaticService {
3737
}
3838

3939
private getImagePath(imageName: string): string {
40-
const dir = this.configService.get('IMG_UPLOAD_FOLDER')
41-
this.ensureDirectoryExistence(dir)
40+
const dir = this.configService.get('IMG_UPLOAD_FOLDER');
41+
this.ensureDirectoryExistence(dir);
4242
return path.resolve(dir, imageName);
4343
}
4444

4545
private ensureDirectoryExistence(dir: string) {
46-
const filePath = path.resolve(dir)
46+
const filePath = path.resolve(dir);
4747
if (existsSync(filePath)) {
4848
return true;
4949
} else {
5050
mkdirSync(dir, { recursive: true });
51-
this.ensureDirectoryExistence(dir)
51+
this.ensureDirectoryExistence(dir);
5252
}
5353
}
5454
}

src/test-runs/test-runs.controller.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ export class TestRunsController {
1818
return this.testRunsService.findMany(buildId);
1919
}
2020

21+
@Get('recalculateDiff/:id')
22+
@ApiParam({ name: 'id', required: true })
23+
@ApiBearerAuth()
24+
@UseGuards(JwtAuthGuard)
25+
recalculateDiff(@Param('id', new ParseUUIDPipe()) id: string): Promise<TestRun> {
26+
return this.testRunsService.recalculateDiff(id);
27+
}
28+
2129
@Get('approve/:id')
2230
@ApiParam({ name: 'id', required: true })
2331
@ApiBearerAuth()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Injectable } from '@nestjs/common';
2-
import { PNG, PNGWithMetadata } from 'pngjs';
2+
import { PNG } from 'pngjs';
33
import Pixelmatch from 'pixelmatch';
44
import { CreateTestRequestDto } from '../test/dto/create-test-request.dto';
55
import { IgnoreAreaDto } from '../test/dto/ignore-area.dto';

0 commit comments

Comments
 (0)