diff --git a/modules/ui/src/app/app.component.spec.ts b/modules/ui/src/app/app.component.spec.ts
index 19b9ea807..146130188 100644
--- a/modules/ui/src/app/app.component.spec.ts
+++ b/modules/ui/src/app/app.component.spec.ts
@@ -118,7 +118,7 @@ describe('AppComponent', () => {
'getTestModules',
'testrunInProgress',
'fetchProfiles',
- 'getHistory',
+ 'getReports',
]);
mockFocusManagerService = jasmine.createSpyObj('mockFocusManagerService', [
diff --git a/modules/ui/src/app/app.store.spec.ts b/modules/ui/src/app/app.store.spec.ts
index 8c5deae4e..301a3d5b2 100644
--- a/modules/ui/src/app/app.store.spec.ts
+++ b/modules/ui/src/app/app.store.spec.ts
@@ -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: {
diff --git a/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.html b/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.html
index 48212b84a..f2892fe07 100644
--- a/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.html
+++ b/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.html
@@ -17,7 +17,7 @@
diff --git a/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.spec.ts b/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.spec.ts
index 01e5a09f8..a030f6dc2 100644
--- a/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.spec.ts
+++ b/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.spec.ts
@@ -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'
);
diff --git a/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.ts b/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.ts
index a1b09d5c1..8e2ac9959 100644
--- a/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.ts
+++ b/modules/ui/src/app/components/download-report-pdf/download-report-pdf.component.ts
@@ -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,
diff --git a/modules/ui/src/app/components/download-report/download-report.component.spec.ts b/modules/ui/src/app/components/download-report/download-report.component.spec.ts
index af711a26b..7b16cdce3 100644
--- a/modules/ui/src/app/components/download-report/download-report.component.spec.ts
+++ b/modules/ui/src/app/components/download-report/download-report.component.spec.ts
@@ -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'
);
diff --git a/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.spec.ts b/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.spec.ts
index 2ee9bd999..0b111010e 100644
--- a/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.spec.ts
+++ b/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.spec.ts
@@ -35,6 +35,7 @@ describe('DownloadZipModalComponent', () => {
const testRunServiceMock = jasmine.createSpyObj('testRunServiceMock', [
'getRiskClass',
'downloadZip',
+ 'getReportLink',
]);
const focusServiceMock: jasmine.SpyObj =
jasmine.createSpyObj('focusServiceMock', ['focusFirstElementInContainer']);
diff --git a/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.ts b/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.ts
index a88eabe0a..11800b374 100644
--- a/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.ts
+++ b/modules/ui/src/app/components/download-zip-modal/download-zip-modal.component.ts
@@ -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')
+ );
}
}
diff --git a/modules/ui/src/app/components/report-action/report-action.component.ts b/modules/ui/src/app/components/report-action/report-action.component.ts
index 5607a67f0..8191af453 100644
--- a/modules/ui/src/app/components/report-action/report-action.component.ts
+++ b/modules/ui/src/app/components/report-action/report-action.component.ts
@@ -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',
@@ -17,6 +18,7 @@ import { TestrunStatus } from '../../model/testrun-status';
})
export class ReportActionComponent {
private datePipe = inject(DatePipe);
+ private testRunService = inject(TestRunService);
@Input() data!: TestrunStatus;
@@ -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);
+ }
}
diff --git a/modules/ui/src/app/components/testing-complete/testing-complete.component.spec.ts b/modules/ui/src/app/components/testing-complete/testing-complete.component.spec.ts
index 087758dc3..7622d3977 100644
--- a/modules/ui/src/app/components/testing-complete/testing-complete.component.spec.ts
+++ b/modules/ui/src/app/components/testing-complete/testing-complete.component.spec.ts
@@ -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,
},
diff --git a/modules/ui/src/app/mocks/reports.mock.ts b/modules/ui/src/app/mocks/reports.mock.ts
index 5cfff1e06..3de61cc84 100644
--- a/modules/ui/src/app/mocks/reports.mock.ts
+++ b/modules/ui/src/app/mocks/reports.mock.ts
@@ -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: {
@@ -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',
@@ -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: {
@@ -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: {
@@ -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: {
@@ -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',
@@ -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',
@@ -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',
@@ -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',
@@ -146,7 +139,6 @@ export const FORMATTED_HISTORY = [
program: 'Device Qualification',
},
{
- mac_addr: null,
status: 'Complete',
result: 'Compliant',
device: {
@@ -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',
diff --git a/modules/ui/src/app/mocks/testrun.mock.ts b/modules/ui/src/app/mocks/testrun.mock.ts
index 023dfb300..bcf41c929 100644
--- a/modules/ui/src/app/mocks/testrun.mock.ts
+++ b/modules/ui/src/app/mocks/testrun.mock.ts
@@ -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
);
@@ -140,7 +140,7 @@ 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
);
@@ -148,7 +148,7 @@ 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
);
diff --git a/modules/ui/src/app/model/testrun-status.ts b/modules/ui/src/app/model/testrun-status.ts
index af681fe0f..4559f25ac 100644
--- a/modules/ui/src/app/model/testrun-status.ts
+++ b/modules/ui/src/app/model/testrun-status.ts
@@ -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;
@@ -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;
@@ -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];
diff --git a/modules/ui/src/app/pages/reports/components/delete-report/delete-report.component.ts b/modules/ui/src/app/pages/reports/components/delete-report/delete-report.component.ts
index 20127628f..474e3d12f 100644
--- a/modules/ui/src/app/pages/reports/components/delete-report/delete-report.component.ts
+++ b/modules/ui/src/app/pages/reports/components/delete-report/delete-report.component.ts
@@ -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'],
diff --git a/modules/ui/src/app/pages/reports/reports.component.html b/modules/ui/src/app/pages/reports/reports.component.html
index 9503aab81..970b1487f 100644
--- a/modules/ui/src/app/pages/reports/reports.component.html
+++ b/modules/ui/src/app/pages/reports/reports.component.html
@@ -160,7 +160,7 @@ Reports
@if (data?.device) {
+ (removeDevice)="removeReport(data)">
diff --git a/modules/ui/src/app/pages/reports/reports.component.spec.ts b/modules/ui/src/app/pages/reports/reports.component.spec.ts
index a9f444d21..c2ab6eb6b 100644
--- a/modules/ui/src/app/pages/reports/reports.component.spec.ts
+++ b/modules/ui/src/app/pages/reports/reports.component.spec.ts
@@ -77,7 +77,7 @@ describe('ReportsComponent', () => {
});
};
beforeEach(() => {
- mockService = jasmine.createSpyObj(['getResultClass']);
+ mockService = jasmine.createSpyObj(['getResultClass', 'getReportLink']);
mockReportsStore = jasmine.createSpyObj('ReportsStore', [
'deleteReport',
'setSelectedRow',
@@ -89,8 +89,9 @@ describe('ReportsComponent', () => {
'setActiveFiler',
'setFilterOpened',
'updateSort',
- 'getHistory',
'getReports',
+ 'getReports',
+ 'fetchReports',
]);
mockLiveAnnouncer = jasmine.createSpyObj(['announce']);
@@ -118,7 +119,7 @@ describe('ReportsComponent', () => {
it('should get reports', fakeAsync(() => {
component.ngOnInit();
- expect(mockReportsStore.getReports).toHaveBeenCalled();
+ expect(mockReportsStore.fetchReports).toHaveBeenCalled();
}));
});
@@ -294,12 +295,8 @@ describe('ReportsComponent', () => {
it('#removeDevice should call delete report', () => {
const data = HISTORY[0];
- component.removeDevice(data);
- expect(mockReportsStore.deleteReport).toHaveBeenCalledWith({
- mac_addr: data.mac_addr,
- deviceMacAddr: data.device.mac_addr,
- started: data.started,
- });
+ component.removeReport(data);
+ expect(mockReportsStore.deleteReport).toHaveBeenCalledWith('report/123');
});
});
diff --git a/modules/ui/src/app/pages/reports/reports.component.ts b/modules/ui/src/app/pages/reports/reports.component.ts
index 356212aaf..a530f97f1 100644
--- a/modules/ui/src/app/pages/reports/reports.component.ts
+++ b/modules/ui/src/app/pages/reports/reports.component.ts
@@ -24,8 +24,9 @@ import {
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { TestRunService } from '../../services/test-run.service';
import {
+ HistoryTestrun,
StatusResultClassName,
- TestrunStatus,
+ TestrunReport,
} from '../../model/testrun-status';
import { CommonModule, DatePipe } from '@angular/common';
import { MatSort, MatSortModule, Sort } from '@angular/material/sort';
@@ -85,7 +86,7 @@ export class ReportsComponent implements OnInit, OnDestroy {
viewModel$ = this.store.viewModel$;
ngOnInit() {
- this.store.getReports();
+ this.store.fetchReports();
const sort = this.sort();
if (sort) {
this.store.updateSort(sort);
@@ -183,7 +184,7 @@ export class ReportsComponent implements OnInit, OnDestroy {
this.store.setSelectedRow(row);
}
- trackByStarted(index: number, item: TestrunStatus) {
+ trackByStarted(index: number, item: HistoryTestrun) {
return item.started;
}
@@ -207,12 +208,8 @@ export class ReportsComponent implements OnInit, OnDestroy {
}
}
- removeDevice(data: TestrunStatus) {
- this.store.deleteReport({
- mac_addr: data.mac_addr,
- deviceMacAddr: data.device.mac_addr,
- started: data.started,
- });
+ removeReport(data: TestrunReport) {
+ this.store.deleteReport(data.delete);
this.focusNextButton();
}
}
diff --git a/modules/ui/src/app/pages/reports/reports.store.spec.ts b/modules/ui/src/app/pages/reports/reports.store.spec.ts
index 9aec5e9ff..228518deb 100644
--- a/modules/ui/src/app/pages/reports/reports.store.spec.ts
+++ b/modules/ui/src/app/pages/reports/reports.store.spec.ts
@@ -161,7 +161,7 @@ describe('ReportsStore', () => {
});
describe('effects', () => {
- describe('getHistory', () => {
+ describe('getReports', () => {
it('should update store', done => {
store.overrideSelector(selectReports, [...HISTORY]);
store.refreshState();
@@ -171,7 +171,7 @@ describe('ReportsStore', () => {
done();
});
- reportsStore.getHistory();
+ reportsStore.getReports();
});
});
@@ -181,11 +181,7 @@ describe('ReportsStore', () => {
store.overrideSelector(selectReports, [...HISTORY]);
store.refreshState();
- reportsStore.deleteReport({
- mac_addr: '01:02:03:04:05:07',
- deviceMacAddr: '01:02:03:04:05:07',
- started: '2023-07-23T10:11:00.123Z',
- });
+ reportsStore.deleteReport('report/1234');
expect(store.dispatch).toHaveBeenCalledWith(
setReports({ reports: HISTORY_AFTER_REMOVE })
@@ -198,11 +194,7 @@ describe('ReportsStore', () => {
store.overrideSelector(selectReports, [...HISTORY_AFTER_REMOVE]);
store.refreshState();
- reportsStore.deleteReport({
- mac_addr: null,
- deviceMacAddr: '01:02:03:04:05:08',
- started: '2023-06-23T10:11:00.123Z',
- });
+ reportsStore.deleteReport('report/12345');
expect(store.dispatch).toHaveBeenCalledWith(
setReports({ reports: [HISTORY_AFTER_REMOVE[0]] })
diff --git a/modules/ui/src/app/pages/reports/reports.store.ts b/modules/ui/src/app/pages/reports/reports.store.ts
index 4b53ddaf0..6dce5e217 100644
--- a/modules/ui/src/app/pages/reports/reports.store.ts
+++ b/modules/ui/src/app/pages/reports/reports.store.ts
@@ -4,6 +4,8 @@ import { MatRow, MatTableDataSource } from '@angular/material/table';
import {
HistoryTestrun,
StatusOfTestrun,
+ TestReportsList,
+ TestrunReport,
TestrunStatus,
} from '../../model/testrun-status';
import { DateRange, Filters } from '../../model/filters';
@@ -64,7 +66,7 @@ export class ReportsStore extends ComponentStore {
profiles: this.profiles$,
});
- setDataSource = this.updater((state, reports: TestrunStatus[]) => {
+ setDataSource = this.updater((state, reports: TestReportsList) => {
const data = this.formateData(reports);
const dataSource = new MatTableDataSource(data);
@@ -121,23 +123,17 @@ export class ReportsStore extends ComponentStore {
};
});
- deleteReport = this.effect<{
- mac_addr: string | null;
- deviceMacAddr: string;
- started: string | null;
- }>(trigger$ => {
+ deleteReport = this.effect(trigger$ => {
return trigger$.pipe(
- exhaustMap(({ mac_addr, deviceMacAddr, started }) => {
- return this.testRunService
- .deleteReport(mac_addr || deviceMacAddr, started || '')
- .pipe(
- withLatestFrom(this.history$),
- tap(([remove, current]) => {
- if (remove) {
- this.removeReport(mac_addr, deviceMacAddr, started, current);
- }
- })
- );
+ exhaustMap(url => {
+ return this.testRunService.deleteReport(url).pipe(
+ withLatestFrom(this.history$),
+ tap(([remove, current]) => {
+ if (remove) {
+ this.removeReport(url, current);
+ }
+ })
+ );
})
);
});
@@ -208,7 +204,7 @@ export class ReportsStore extends ComponentStore {
);
});
- getHistory = this.effect(() => {
+ getReports = this.effect(() => {
return this.history$.pipe(
withLatestFrom(this.filteredValues$),
tap(([reports, filteredValues]) => {
@@ -218,7 +214,7 @@ export class ReportsStore extends ComponentStore {
);
});
- getReports = this.effect(trigger$ => {
+ fetchReports = this.effect(trigger$ => {
return trigger$.pipe(
tap(() => {
this.store.dispatch(fetchReports());
@@ -226,20 +222,10 @@ export class ReportsStore extends ComponentStore {
);
});
- private removeReport(
- mac_addr: string | null,
- deviceMacAddr: string,
- started: string | null,
- current: TestrunStatus[]
- ) {
+ private removeReport(url: string, current: TestReportsList) {
const history = [...current];
- const idx = history.findIndex(
- report =>
- report.mac_addr === mac_addr &&
- report.device.mac_addr === deviceMacAddr &&
- report.started === started
- );
- if (typeof idx === 'number') {
+ const idx = history.findIndex(report => report.delete === url);
+ if (idx > -1) {
history.splice(idx, 1);
this.store.dispatch(setReports({ reports: history }));
}
@@ -255,7 +241,7 @@ export class ReportsStore extends ComponentStore {
this.setIsFiltersEmpty(this.isFiltersEmpty(filteredValues));
}
- private formateData(data: TestrunStatus[]): HistoryTestrun[] {
+ private formateData(data: TestReportsList): HistoryTestrun[] {
return data.map(item => {
return {
...item,
@@ -268,7 +254,7 @@ export class ReportsStore extends ComponentStore {
});
}
- private getTestResult(item: TestrunStatus): string {
+ private getTestResult(item: TestrunReport): string {
let result = '';
if (item.device.test_pack === TestingType.Qualification) {
if (
diff --git a/modules/ui/src/app/services/test-run.service.spec.ts b/modules/ui/src/app/services/test-run.service.spec.ts
index 5c77a30ee..9e1850209 100644
--- a/modules/ui/src/app/services/test-run.service.spec.ts
+++ b/modules/ui/src/app/services/test-run.service.spec.ts
@@ -26,6 +26,7 @@ import { MOCK_PROGRESS_DATA_IN_PROGRESS } from '../mocks/testrun.mock';
import {
StatusOfTestResult,
StatusOfTestrun,
+ TestReportsList,
TestrunStatus,
} from '../model/testrun-status';
import { device, DEVICES_FORM, MOCK_MODULES } from '../mocks/device.mock';
@@ -223,26 +224,26 @@ describe('TestRunService', () => {
});
});
- describe('getHistory', () => {
+ describe('getReports', () => {
it('should return reports', () => {
- let result: TestrunStatus[] | null = null;
+ let result: TestReportsList | null = null;
const reports = [
{
status: 'Complete',
device: device,
- report: 'https://api.testrun.io/report.pdf',
+ report: 'report/123',
started: '2023-06-22T10:11:00.123Z',
finished: '2023-06-22T10:17:00.123Z',
},
- ] as TestrunStatus[];
+ ] as TestReportsList;
- service.getHistory().subscribe(res => {
+ service.getReports().subscribe(res => {
expect(res).toEqual(result);
});
result = reports;
- service.getHistory();
+ service.getReports();
const req = httpTestingController.expectOne(
'http://localhost:8000/reports'
);
@@ -461,36 +462,24 @@ describe('TestRunService', () => {
it('deleteReport should have necessary request data', () => {
const apiUrl = 'http://localhost:8000/report';
- service.deleteReport(device.mac_addr, '').subscribe(res => {
+ service.deleteReport('report').subscribe(res => {
expect(res).toEqual(true);
});
const req = httpTestingController.expectOne(apiUrl);
expect(req.request.method).toBe('DELETE');
- expect(req.request.body).toEqual(
- JSON.stringify({
- mac_addr: device.mac_addr,
- timestamp: '',
- })
- );
req.flush({});
});
it('deleteReport should return false when error happens', () => {
const apiUrl = 'http://localhost:8000/report';
- service.deleteReport(device.mac_addr, '').subscribe(res => {
+ service.deleteReport('report').subscribe(res => {
expect(res).toEqual(false);
});
const req = httpTestingController.expectOne(apiUrl);
expect(req.request.method).toBe('DELETE');
- expect(req.request.body).toEqual(
- JSON.stringify({
- mac_addr: device.mac_addr,
- timestamp: '',
- })
- );
req.error(new ErrorEvent(''));
});
@@ -704,4 +693,11 @@ describe('TestRunService', () => {
req.flush(result);
});
});
+
+ describe('getReportLink', () => {
+ it('should return link', () => {
+ const link = service.getReportLink('url');
+ expect(link.includes('url')).toBeTrue();
+ });
+ });
});
diff --git a/modules/ui/src/app/services/test-run.service.ts b/modules/ui/src/app/services/test-run.service.ts
index ba5733cc0..b8142fecd 100644
--- a/modules/ui/src/app/services/test-run.service.ts
+++ b/modules/ui/src/app/services/test-run.service.ts
@@ -24,6 +24,7 @@ import {
StatusOfTestResult,
StatusOfTestrun,
StatusResultClassName,
+ TestReportsList,
TestrunStatus,
} from '../model/testrun-status';
import { Version } from '../model/version';
@@ -151,6 +152,7 @@ export class TestRunService {
catchError(() => of(false))
);
}
+
deleteDevice(device: Device): Observable {
return this.http
.delete(`${API_URL}/device`, {
@@ -162,8 +164,8 @@ export class TestRunService {
);
}
- getHistory(): Observable {
- return this.http.get(`${API_URL}/reports`).pipe(
+ getReports(): Observable {
+ return this.http.get(`${API_URL}/reports`).pipe(
map(result => {
result.forEach(item => {
item.report = this.changeReportURL(item.report);
@@ -241,15 +243,15 @@ export class TestRunService {
});
}
- deleteReport(mac_addr: string, started: string): Observable {
- return this.http
- .delete(`${API_URL}/report`, {
- body: JSON.stringify({ mac_addr, timestamp: started }),
- })
- .pipe(
- catchError(() => of(false)),
- map(res => !!res)
- );
+ getReportLink(url: string): string {
+ return `${API_URL}/${url}`;
+ }
+
+ deleteReport(url: string): Observable {
+ return this.http.delete(`${API_URL}/${url}`).pipe(
+ catchError(() => of(false)),
+ map(res => !!res)
+ );
}
fetchProfiles(): Observable {
diff --git a/modules/ui/src/app/store/actions.ts b/modules/ui/src/app/store/actions.ts
index 65fae5fb8..da981b607 100644
--- a/modules/ui/src/app/store/actions.ts
+++ b/modules/ui/src/app/store/actions.ts
@@ -18,7 +18,7 @@ import { createAction, props } from '@ngrx/store';
import { Adapters, InterfacesValidation, SystemConfig } from '../model/setting';
import { SystemInterfaces } from '../model/setting';
import { Device, TestModule } from '../model/device';
-import { TestrunStatus } from '../model/testrun-status';
+import { TestReportsList, TestrunStatus } from '../model/testrun-status';
import { Profile } from '../model/profile';
export const fetchInterfacesSuccess = createAction(
@@ -125,7 +125,7 @@ export const fetchReports = createAction('[Shared] Fetch reports');
export const setReports = createAction(
'[Shared] Set Reports',
- props<{ reports: TestrunStatus[] }>()
+ props<{ reports: TestReportsList }>()
);
export const setTestModules = createAction(
diff --git a/modules/ui/src/app/store/effects.spec.ts b/modules/ui/src/app/store/effects.spec.ts
index 952b9dbf6..2b23ae542 100644
--- a/modules/ui/src/app/store/effects.spec.ts
+++ b/modules/ui/src/app/store/effects.spec.ts
@@ -76,7 +76,7 @@ describe('Effects', () => {
'testrunInProgress',
'stopTestrun',
'fetchProfiles',
- 'getHistory',
+ 'getReports',
]);
testRunServiceMock.getSystemInterfaces.and.returnValue(of({}));
testRunServiceMock.getSystemConfig.and.returnValue(of({ network: {} }));
@@ -85,7 +85,7 @@ describe('Effects', () => {
of(MOCK_PROGRESS_DATA_IN_PROGRESS)
);
testRunServiceMock.fetchProfiles.and.returnValue(of([]));
- testRunServiceMock.getHistory.and.returnValue(of([]));
+ testRunServiceMock.getReports.and.returnValue(of([]));
mockMqttService.getInternetConnection.and.returnValue(
of({ connection: false })
);
@@ -358,7 +358,7 @@ describe('Effects', () => {
describe('onFetchReports$', () => {
it(' should call setReports on success', done => {
- testRunServiceMock.getHistory.and.returnValue(of([]));
+ testRunServiceMock.getReports.and.returnValue(of([]));
actions$ = of(actions.fetchReports());
effects.onFetchReports$.subscribe(action => {
@@ -372,7 +372,7 @@ describe('Effects', () => {
});
it('should call setReports with empty array if null is returned', done => {
- testRunServiceMock.getHistory.and.returnValue(of(null));
+ testRunServiceMock.getReports.and.returnValue(of(null));
actions$ = of(actions.fetchReports());
effects.onFetchReports$.subscribe(action => {
@@ -386,7 +386,7 @@ describe('Effects', () => {
});
it('should call setReports with empty array if error happens', done => {
- testRunServiceMock.getHistory.and.returnValue(
+ testRunServiceMock.getReports.and.returnValue(
throwError(
new HttpErrorResponse({ error: { error: 'error' }, status: 500 })
)
diff --git a/modules/ui/src/app/store/effects.ts b/modules/ui/src/app/store/effects.ts
index 278cc1bb0..233e01f4a 100644
--- a/modules/ui/src/app/store/effects.ts
+++ b/modules/ui/src/app/store/effects.ts
@@ -35,7 +35,7 @@ import { selectIsOpenWaitSnackBar, selectSystemStatus } from './selectors';
import {
IDLE_STATUS,
StatusOfTestrun,
- TestrunStatus,
+ TestReportsList,
} from '../model/testrun-status';
import {
fetchSystemStatusSuccess,
@@ -253,8 +253,8 @@ export class AppEffects {
return this.actions$.pipe(
ofType(AppActions.fetchReports),
switchMap(() =>
- this.testrunService.getHistory().pipe(
- map((reports: TestrunStatus[] | null) => {
+ this.testrunService.getReports().pipe(
+ map((reports: TestReportsList | null) => {
if (reports !== null) {
return AppActions.setReports({ reports });
}
diff --git a/modules/ui/src/app/store/state.ts b/modules/ui/src/app/store/state.ts
index 9d5613730..62160da3a 100644
--- a/modules/ui/src/app/store/state.ts
+++ b/modules/ui/src/app/store/state.ts
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import { TestrunStatus } from '../model/testrun-status';
+import { TestReportsList, TestrunStatus } from '../model/testrun-status';
import { Device, TestModule } from '../model/device';
import { Adapters, SystemConfig, SystemInterfaces } from '../model/setting';
import { Profile } from '../model/profile';
@@ -42,7 +42,7 @@ export interface AppState {
isStopTestrun: boolean;
isOpenWaitSnackBar: boolean;
deviceInProgress: Device | null;
- reports: TestrunStatus[];
+ reports: TestReportsList;
testModules: TestModule[];
adapters: Adapters;
internetConnection: boolean | null;