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
1 change: 1 addition & 0 deletions modules/ui/src/app/app.store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ describe('AppStore', () => {
started: '2023-06-22T09:20:00.123Z',
finished: '2023-06-22T09:26:00.123Z',
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
tags: [],
tests: {
total: 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ describe('DownloadReportZipComponent', () => {
fixture = TestBed.createComponent(DownloadReportZipComponent);
compiled = fixture.nativeElement as HTMLElement;
component = fixture.componentInstance;
component.url = 'localhost:8080';
component.report = 'localhost:8080';
component.export = 'localhost:8080';
component.data = MOCK_PROGRESS_DATA_COMPLIANT;
});

Expand All @@ -64,7 +65,8 @@ describe('DownloadReportZipComponent', () => {
ariaLabel: 'Download zip',
data: {
profiles: [],
url: 'localhost:8080',
report: 'localhost:8080',
export: 'localhost:8080',
isPilot: false,
},
autoFocus: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export class DownloadReportZipComponent
implements OnInit
{
@Input() profiles: Profile[] = [];
@Input() url: string | null | undefined = null;
@Input() report: string | null | undefined = null;
@Input() export: string | null | undefined = null;

@HostListener('click', ['$event'])
@HostListener('keydown.enter', ['$event'])
Expand All @@ -56,7 +57,8 @@ export class DownloadReportZipComponent
ariaLabel: 'Download zip',
data: {
profiles: this.profiles,
url: this.url,
report: this.report,
export: this.export,
isPilot: this.data?.device.test_pack === TestingType.Pilot,
},
autoFocus: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ describe('DownloadZipModalComponent', () => {
provide: MAT_DIALOG_DATA,
useValue: {
profiles: [PROFILE_MOCK_2, PROFILE_MOCK],
url: 'localhost:8080',
report: 'localhost:8080',
export: 'localhost:8080',
},
},
{ provide: TestRunService, useValue: testRunServiceMock },
Expand All @@ -78,7 +79,8 @@ describe('DownloadZipModalComponent', () => {
TestBed.overrideProvider(MAT_DIALOG_DATA, {
useValue: {
profiles: [PROFILE_MOCK_2, PROFILE_MOCK, PROFILE_MOCK_3],
url: 'localhost:8080',
report: 'localhost:8080',
export: 'localhost:8080',
isPilot: true,
},
});
Expand Down Expand Up @@ -220,7 +222,8 @@ describe('DownloadZipModalComponent', () => {
TestBed.overrideProvider(MAT_DIALOG_DATA, {
useValue: {
profiles: [],
url: 'localhost:8080',
report: 'localhost:8080',
export: 'localhost:8080',
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ interface DialogData {
profiles: Profile[];
testrunStatus?: TestrunStatus;
isTestingComplete?: boolean;
url: string | null;
report: string | null;
export: string | null;
isPilot?: boolean;
}

Expand Down Expand Up @@ -123,9 +124,12 @@ export class DownloadZipModalComponent
);
return;
}
if (this.data.url != null && typeof result.profile === 'string') {
if (
(this.data.report != null || this.data.export != null) &&
typeof result.profile === 'string'
) {
this.testRunService.downloadZip(
this.getZipLink(this.data.url),
this.getZipLink(this.data),
result.profile
);
if (this.data.isPilot) {
Expand Down Expand Up @@ -177,7 +181,7 @@ export class DownloadZipModalComponent
return data.status;
}

private getZipLink(reportURL: string): string {
return reportURL.replace('report', 'export');
private getZipLink(data: DialogData): string {
return data.export || data.report!.replace('report', 'export');
}
}
8 changes: 8 additions & 0 deletions modules/ui/src/app/mocks/reports.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const HISTORY = [
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
},
Expand All @@ -34,6 +35,7 @@ export const HISTORY = [
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
started: '2023-07-23T10:11:00.123Z',
finished: '2023-07-23T10:17:10.123Z',
},
Expand All @@ -51,6 +53,7 @@ export const HISTORY = [
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
},
Expand All @@ -71,6 +74,7 @@ export const HISTORY_AFTER_REMOVE = [
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
},
Expand All @@ -88,6 +92,7 @@ export const HISTORY_AFTER_REMOVE = [
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
},
Expand All @@ -108,6 +113,7 @@ export const FORMATTED_HISTORY = [
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
deviceFirmware: '1.2.2',
Expand All @@ -130,6 +136,7 @@ export const FORMATTED_HISTORY = [
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
started: '2023-07-23T10:11:00.123Z',
finished: '2023-07-23T10:17:10.123Z',
deviceFirmware: '1.2.3',
Expand All @@ -152,6 +159,7 @@ export const FORMATTED_HISTORY = [
},
tags: [],
report: 'https://api.testrun.io/report.pdf',
export: 'https://api.testrun.io/export.pdf',
started: '2023-06-23T10:11:00.123Z',
finished: '2023-06-23T10:17:10.123Z',
deviceFirmware: '1.2.2',
Expand Down
1 change: 1 addition & 0 deletions modules/ui/src/app/mocks/testrun.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const PROGRESS_DATA_RESPONSE = (
finished,
tests,
report,
export: '',
tags: ['VSA', 'Other tag', 'And one more'],
} as TestrunStatus;
if (result) {
Expand Down
2 changes: 2 additions & 0 deletions modules/ui/src/app/model/testrun-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface TestrunStatus {
finished: string | null;
tests?: TestsResponse;
report: string;
export: string;
tags: string[] | null;
}

Expand Down Expand Up @@ -114,6 +115,7 @@ export const IDLE_STATUS = {
started: null,
finished: null,
report: '',
export: '',
mac_addr: '',
tests: {
total: 0,
Expand Down
3 changes: 2 additions & 1 deletion modules/ui/src/app/pages/reports/reports.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ <h2 class="title" tabindex="-1">Reports</h2>
<app-download-report-zip
*ngIf="data?.device"
[data]="data"
[url]="data.report"
[report]="data.report"
[export]="data.export"
[profiles]="vm.profiles">
<span class="download-report-zip-icon-container">
<mat-icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
<app-download-report-zip
id="downloadReportZip"
class="download-option zip"
[url]="data.report"
[report]="data.report"
[export]="data.export"
[profiles]="profiles">
<mat-option
(onSelectionChange)="onZipSelected($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ export class DownloadOptionsComponent {
}
const link = document.createElement('a');
link.href =
type === DownloadOption.PDF ? data.report : this.getZipLink(data.report);
type === DownloadOption.PDF ? data.report : this.getZipLink(data);
link.target = '_blank';
link.download = this.getReportTitle(data);
link.dispatchEvent(new MouseEvent('click'));
}

getZipLink(reportURL: string): string {
return reportURL.replace('report', 'export');
getZipLink(data: TestrunStatus): string {
return data.export || data.report.replace('report', 'export');
}

getReportTitle(data: TestrunStatus) {
Expand Down
1 change: 1 addition & 0 deletions modules/ui/src/app/services/test-run-mqtt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class TestRunMqttService {
return this.topic<TestrunStatus>(Topic.Status).pipe(
map(result => {
result.report = this.testrunService.changeReportURL(result.report);
result.export = this.testrunService.changeReportURL(result.export);
return result;
})
);
Expand Down
10 changes: 6 additions & 4 deletions modules/ui/src/app/services/test-run.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class TestRunService {
return '';
}
// replace url part before '/report' from static to dynamic API URL
return url.replace(/^.*(?=\/report)/, `${API_URL}`);
return url.replace(/^.*(?=\/report|\/export)/, `${API_URL}`);
}

fetchDevices(): Observable<Device[]> {
Expand All @@ -83,6 +83,7 @@ export class TestRunService {
return this.http.get<TestrunStatus>(`${API_URL}/system/status`).pipe(
map(result => {
result.report = this.changeReportURL(result.report);
result.export = this.changeReportURL(result.export);
return result;
}),
catchError(() => {
Expand Down Expand Up @@ -152,9 +153,10 @@ export class TestRunService {
getHistory(): Observable<TestrunStatus[] | null> {
return this.http.get<TestrunStatus[]>(`${API_URL}/reports`).pipe(
map(result => {
result.forEach(
item => (item.report = this.changeReportURL(item.report))
);
result.forEach(item => {
item.report = this.changeReportURL(item.report);
item.export = this.changeReportURL(item.export);
});
return result;
})
);
Expand Down
Loading