Skip to content

Commit f6f9c0e

Browse files
feat(312): add optional comment property for test runs (#170)
1 parent 27b7134 commit f6f9c0e

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

src/test-runs/dto/create-test-request.dto.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
22
import { Transform } from 'class-transformer';
3-
import { IsOptional, IsUUID, IsNumber, IsBoolean } from 'class-validator';
3+
import { IsOptional, IsUUID, IsNumber, IsBoolean, IsString } from 'class-validator';
44
import { isArray } from 'lodash';
55
import { BaselineDataDto } from '../../shared/dto/baseline-data.dto';
66
import { IgnoreAreaDto } from './ignore-area.dto';
@@ -17,13 +17,13 @@ export class CreateTestRequestDto extends BaselineDataDto {
1717
@ApiPropertyOptional()
1818
@IsOptional()
1919
@IsNumber()
20-
@Transform(({value}) => parseFloat(value))
20+
@Transform(({ value }) => parseFloat(value))
2121
diffTollerancePercent?: number;
2222

2323
@ApiPropertyOptional()
2424
@IsBoolean()
2525
@IsOptional()
26-
@Transform(({value}) => {
26+
@Transform(({ value }) => {
2727
switch (value) {
2828
case 'true':
2929
return true;
@@ -37,11 +37,16 @@ export class CreateTestRequestDto extends BaselineDataDto {
3737

3838
@ApiPropertyOptional({ type: [IgnoreAreaDto] })
3939
@IsOptional()
40-
@Transform(({value}) => {
40+
@Transform(({ value }) => {
4141
if (isArray(value)) {
4242
return it;
4343
}
4444
return JSON.parse(value);
4545
})
4646
ignoreAreas?: IgnoreAreaDto[];
47+
48+
@ApiPropertyOptional()
49+
@IsOptional()
50+
@IsString()
51+
comment?: string;
4752
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ describe('TestRunsService', () => {
504504
device: 'device',
505505
branchName: 'develop',
506506
customTags: 'customTags',
507+
comment: 'new comment',
507508
};
508509
const testVariation: TestVariation = {
509510
id: '123',

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ export class TestRunsService {
3434
return list.map((item) => new TestRunDto(item));
3535
}
3636

37-
async findOne(
38-
id: string
39-
): Promise<
37+
async findOne(id: string): Promise<
4038
TestRun & {
4139
testVariation?: TestVariation;
4240
}
@@ -233,7 +231,7 @@ export class TestRunsService {
233231
baselineBranchName: testVariation.branchName,
234232
ignoreAreas: testVariation.ignoreAreas,
235233
tempIgnoreAreas: JSON.stringify(createTestRequestDto.ignoreAreas),
236-
comment: testVariation.comment,
234+
comment: createTestRequestDto.comment || testVariation.comment,
237235
diffTollerancePercent: createTestRequestDto.diffTollerancePercent,
238236
branchName: createTestRequestDto.branchName,
239237
merge: createTestRequestDto.merge,

test/test-runs.e2e-spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ describe('TestRuns (e2e)', () => {
218218
.field('diffTollerancePercent', '0.12')
219219
.field('merge', 'false')
220220
.field('ignoreAreas', '[]')
221+
.field('comment', 'Comment')
221222
.attach('image', image_v1)
222223
.expect(201);
223224
});

0 commit comments

Comments
 (0)