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
2 changes: 1 addition & 1 deletion modules/ui/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('AppComponent', () => {
'getTestModules',
'testrunInProgress',
'fetchProfiles',
'getHistory',
'getReports',
]);

mockFocusManagerService = jasmine.createSpyObj('mockFocusManagerService', [
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/src/app/app.store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ describe('AppStore', () => {
},
started: '2023-06-22T09:20:00.123Z',
finished: '2023-06-22T09:26:00.123Z',
report: 'https://api.testrun.io/report.pdf',
report: 'report/123',
export: 'https://api.testrun.io/export.pdf',
tags: [],
tests: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<app-download-report
class="download-report-link-pdf"
[data]="data"
[href]="data.report"
[href]="getReportUrl(data)"
title="Download pdf for Testrun # {{ getTestRunId(data) }}">
<ng-content></ng-content>
</app-download-report>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ describe('DownloadReportComponent', () => {
) as HTMLAnchorElement;

expect(downloadReportLink).not.toBeNull();
expect(downloadReportLink.href).toEqual(
'https://api.testrun.io/report.pdf'
);
expect(downloadReportLink.href).toContain('report/123');
expect(downloadReportLink.download).toEqual(
'delta_03-din-cpu_1.2.2_compliant_22_jun_2023_9:20'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { ReportActionComponent } from '../report-action/report-action.component'
@Component({
selector: 'app-download-report-pdf',
templateUrl: './download-report-pdf.component.html',

imports: [DownloadReportComponent],
providers: [DatePipe],
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ describe('DownloadReportComponent', () => {
) as HTMLAnchorElement;

expect(downloadReportLink).not.toBeNull();
expect(downloadReportLink.href).toEqual(
'https://api.testrun.io/report.pdf'
);
expect(downloadReportLink.href).toContain('report/123');
expect(downloadReportLink.download).toEqual(
'delta_03-din-cpu_1.2.2_compliant_22_jun_2023_9:20'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('DownloadZipModalComponent', () => {
const testRunServiceMock = jasmine.createSpyObj('testRunServiceMock', [
'getRiskClass',
'downloadZip',
'getReportLink',
]);
const focusServiceMock: jasmine.SpyObj<FocusManagerService> =
jasmine.createSpyObj('focusServiceMock', ['focusFirstElementInContainer']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ export class DownloadZipModalComponent
}

private getZipLink(data: DialogData): string {
return data.export || data.report!.replace('report', 'export');
return this.testRunService.getReportLink(
data.export || data.report!.replace('report', 'export')
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@angular/core';
import { DatePipe } from '@angular/common';
import { TestrunStatus } from '../../model/testrun-status';
import { TestRunService } from '../../services/test-run.service';

@Component({
selector: 'app-report-action',
Expand All @@ -17,6 +18,7 @@ import { TestrunStatus } from '../../model/testrun-status';
})
export class ReportActionComponent {
private datePipe = inject(DatePipe);
private testRunService = inject(TestRunService);

@Input() data!: TestrunStatus;

Expand All @@ -32,4 +34,8 @@ export class ReportActionComponent {
getFormattedDateString(date: string | null) {
return date ? this.datePipe.transform(date, 'd MMM y H:mm') : '';
}

getReportUrl(data: TestrunStatus) {
return this.testRunService.getReportLink(data.report);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('TestingCompleteComponent', () => {
profiles: [],
testrunStatus: MOCK_PROGRESS_DATA_COMPLIANT,
isTestingComplete: true,
report: 'https://api.testrun.io/report.pdf',
report: 'report/123',
export: '',
isPilot: false,
},
Expand Down
62 changes: 27 additions & 35 deletions modules/ui/src/app/mocks/reports.mock.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { HistoryTestrun, TestrunStatus } from '../model/testrun-status';
import { HistoryTestrun, TestReportsList } from '../model/testrun-status';
import { MatTableDataSource } from '@angular/material/table';
import { DeviceStatus, TestingType } from '../model/device';

export const HISTORY = [
{
mac_addr: '01:02:03:04:05:06',
status: 'Complete',
result: 'Compliant',
device: {
Expand All @@ -15,16 +14,15 @@ export const HISTORY = [
firmware: '1.2.2',
test_pack: TestingType.Qualification,
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
report: 'report/123',
export: 'export/123',
delete: 'report/123',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
},
{
status: 'Complete',
result: 'Compliant',
mac_addr: '01:02:03:04:05:07',
device: {
status: DeviceStatus.VALID,
manufacturer: 'Delta',
Expand All @@ -33,14 +31,13 @@ export const HISTORY = [
firmware: '1.2.3',
test_pack: TestingType.Qualification,
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
report: 'report/1234',
export: 'export/1234',
delete: 'report/1234',
started: '2023-07-23T10:11:00.123Z',
finished: '2023-07-23T10:17:10.123Z',
},
{
mac_addr: null,
status: 'Complete',
result: 'Compliant',
device: {
Expand All @@ -51,17 +48,16 @@ export const HISTORY = [
firmware: '1.2.2',
test_pack: TestingType.Qualification,
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
report: 'report/12345',
export: 'export/12345',
delete: 'report/12345',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
},
] as TestrunStatus[];
] as TestReportsList;

export const HISTORY_AFTER_REMOVE = [
{
mac_addr: '01:02:03:04:05:06',
status: 'Complete',
result: 'Compliant',
device: {
Expand All @@ -72,14 +68,13 @@ export const HISTORY_AFTER_REMOVE = [
firmware: '1.2.2',
test_pack: TestingType.Qualification,
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
report: 'report/123',
export: 'export/123',
delete: 'report/123',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
},
{
mac_addr: null,
status: 'Complete',
result: 'Compliant',
device: {
Expand All @@ -90,19 +85,18 @@ export const HISTORY_AFTER_REMOVE = [
firmware: '1.2.2',
test_pack: TestingType.Qualification,
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
report: 'report/12345',
export: 'export/12345',
delete: 'report/12345',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
},
] as TestrunStatus[];
] as TestReportsList;

export const FORMATTED_HISTORY = [
{
status: 'Complete',
result: 'Compliant',
mac_addr: '01:02:03:04:05:06',
device: {
status: DeviceStatus.VALID,
manufacturer: 'Delta',
Expand All @@ -111,9 +105,9 @@ export const FORMATTED_HISTORY = [
firmware: '1.2.2',
test_pack: TestingType.Qualification,
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
report: 'report/123',
export: 'export/123',
delete: 'report/123',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
deviceFirmware: '1.2.2',
Expand All @@ -125,7 +119,6 @@ export const FORMATTED_HISTORY = [
{
status: 'Complete',
result: 'Compliant',
mac_addr: '01:02:03:04:05:07',
device: {
status: DeviceStatus.VALID,
manufacturer: 'Delta',
Expand All @@ -134,9 +127,9 @@ export const FORMATTED_HISTORY = [
firmware: '1.2.3',
test_pack: TestingType.Qualification,
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
report: 'report/1234',
export: 'export/1234',
delete: 'report/1234',
started: '2023-07-23T10:11:00.123Z',
finished: '2023-07-23T10:17:10.123Z',
deviceFirmware: '1.2.3',
Expand All @@ -146,7 +139,6 @@ export const FORMATTED_HISTORY = [
program: 'Device Qualification',
},
{
mac_addr: null,
status: 'Complete',
result: 'Compliant',
device: {
Expand All @@ -157,9 +149,9 @@ export const FORMATTED_HISTORY = [
firmware: '1.2.2',
test_pack: TestingType.Qualification,
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
report: 'report/12345',
export: 'export/12345',
delete: 'report/12345',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
deviceFirmware: '1.2.2',
Expand Down
6 changes: 3 additions & 3 deletions modules/ui/src/app/mocks/testrun.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const MOCK_PROGRESS_DATA_COMPLIANT: TestrunStatus =
StatusOfTestrun.Complete,
'2023-06-22T09:20:00.123Z',
TEST_DATA,
'https://api.testrun.io/report.pdf',
'report/123',
ResultOfTestrun.Compliant
);

Expand All @@ -140,15 +140,15 @@ export const MOCK_PROGRESS_DATA_NON_COMPLIANT: TestrunStatus =
StatusOfTestrun.Complete,
'2023-06-22T09:20:00.123Z',
TEST_DATA_RESULT,
'https://api.testrun.io/report.pdf',
'report/123',
ResultOfTestrun.NonCompliant
);

export const MOCK_PROGRESS_DATA_PROCEED: TestrunStatus = PROGRESS_DATA_RESPONSE(
StatusOfTestrun.Proceed,
'2023-06-22T09:20:00.123Z',
TEST_DATA_RESULT,
'https://api.testrun.io/report.pdf',
'report/123',
ResultOfTestrun.Compliant
);

Expand Down
26 changes: 20 additions & 6 deletions modules/ui/src/app/model/testrun-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@
*/
import { Device } from './device';

interface TestRun {
version: string;
}

export interface TestrunReport {
testrun: TestRun;
device: IDevice;
status: StatusOfTestrun;
result: ResultOfTestrun;
started: string;
finished: string;
report: string;
export: string;
folder_name: string;
delete: string;
}

export type TestReportsList = TestrunReport[];

export interface TestrunStatus {
mac_addr: string | null;
status: StatusOfTestrun;
Expand All @@ -29,7 +48,7 @@ export interface TestrunStatus {
tags: string[] | null;
}

export interface HistoryTestrun extends TestrunStatus {
export interface HistoryTestrun extends TestrunReport {
deviceFirmware: string;
deviceInfo: string;
testResult: string;
Expand Down Expand Up @@ -125,8 +144,3 @@ export const IDLE_STATUS = {
},
tags: [],
} as TestrunStatus;

export type TestrunStatusKey = keyof typeof StatusOfTestrun;
export type TestrunStatusValue = (typeof StatusOfTestrun)[TestrunStatusKey];
export type TestResultKey = keyof typeof StatusOfTestResult;
export type TestResultValue = (typeof StatusOfTestResult)[TestResultKey];
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { MatTooltipModule } from '@angular/material/tooltip';

@Component({
selector: 'app-delete-report',

imports: [MatButtonModule, MatTooltipModule],
templateUrl: './delete-report.component.html',
styleUrls: ['./delete-report.component.scss'],
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/src/app/pages/reports/reports.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ <h2 class="title" tabindex="-1">Reports</h2>
@if (data?.device) {
<app-delete-report
[data]="data"
(removeDevice)="removeDevice(data)">
(removeDevice)="removeReport(data)">
<mat-icon
class="delete-report-icon"
fontSet="material-symbols-outlined">
Expand Down
Loading
Loading