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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { RouterTestingModule } from '@angular/router/testing';
import { Component } from '@angular/core';
import { MOCK_PROGRESS_DATA_COMPLIANT } from '../../mocks/testrun.mock';
import { DeviceStatus } from '../../model/device';

describe('DownloadReportZipComponent', () => {
let component: DownloadReportZipComponent;
Expand Down Expand Up @@ -68,6 +69,14 @@ describe('DownloadReportZipComponent', () => {
report: 'localhost:8080',
export: 'localhost:8080',
isPilot: false,
device: {
status: DeviceStatus.VALID,
manufacturer: 'Delta',
model: '03-DIN-CPU',
mac_addr: '01:02:03:04:05:06',
firmware: '1.2.2',
},
started: '2023-06-22T09:20:00.123Z',
},
autoFocus: true,
hasBackdrop: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export class DownloadReportZipComponent
report: this.report,
export: this.export,
isPilot: this.data?.device.test_pack === TestingType.Pilot,
device: this.data?.device,
started: this.data?.started,
},
autoFocus: true,
hasBackdrop: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { FocusManagerService } from '../../services/focus-manager.service';
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
import { RouterTestingModule } from '@angular/router/testing';
import { Component } from '@angular/core';
import { device } from '../../mocks/device.mock';

describe('DownloadZipModalComponent', () => {
// @ts-expect-error data layer should be defined
Expand Down Expand Up @@ -67,6 +68,8 @@ describe('DownloadZipModalComponent', () => {
profiles: [PROFILE_MOCK_2, PROFILE_MOCK],
report: 'localhost:8080',
export: 'localhost:8080',
device: device,
started: '2026-02-02 17:24:52',
},
},
{ provide: TestRunService, useValue: testRunServiceMock },
Expand All @@ -83,6 +86,8 @@ describe('DownloadZipModalComponent', () => {
report: 'localhost:8080',
export: 'localhost:8080',
isPilot: true,
device: device,
started: '2026-02-02 17:24:52',
},
});

Expand Down Expand Up @@ -225,6 +230,8 @@ describe('DownloadZipModalComponent', () => {
profiles: [],
report: 'localhost:8080',
export: 'localhost:8080',
device: device,
started: '2026-02-02 17:24:52',
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
import { DownloadReportComponent } from '../download-report/download-report.component';
import { Subject, takeUntil, timer } from 'rxjs';
import { FocusManagerService } from '../../services/focus-manager.service';
import { Device } from '../../model/device';

interface DialogData {
profiles: Profile[];
Expand All @@ -41,6 +42,8 @@ interface DialogData {
report: string | null;
export: string | null;
isPilot?: boolean;
device: Device;
started: string | null;
}

export enum DialogCloseAction {
Expand All @@ -56,7 +59,6 @@ export interface DialogCloseResult {

@Component({
selector: 'app-download-zip-modal',

imports: [
CommonModule,
MatDialogActions,
Expand Down Expand Up @@ -133,7 +135,8 @@ export class DownloadZipModalComponent
) {
this.testRunService.downloadZip(
this.getZipLink(this.data),
result.profile
result.profile,
this.getZipName(this.data)
);
if (this.data.isPilot) {
// @ts-expect-error data layer is not null
Expand Down Expand Up @@ -189,4 +192,8 @@ export class DownloadZipModalComponent
data.export || data.report!.replace('report', 'export')
);
}

private getZipName(data: DialogData) {
return `${data.device.manufacturer}_${data.device.model}_${data.device.firmware}_${data.started}`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
DownloadZipModalComponent,
} from '../download-zip-modal/download-zip-modal.component';
import { FocusManagerService } from '../../services/focus-manager.service';
import { DeviceStatus } from '../../model/device';

describe('TestingCompleteComponent', () => {
let component: TestingCompleteComponent;
Expand Down Expand Up @@ -68,6 +69,14 @@ describe('TestingCompleteComponent', () => {
report: '/report/123',
export: '',
isPilot: false,
device: {
status: DeviceStatus.VALID,
manufacturer: 'Delta',
model: '03-DIN-CPU',
mac_addr: '01:02:03:04:05:06',
firmware: '1.2.2',
},
started: '2023-06-22T09:20:00.123Z',
},
autoFocus: 'first-tabbable',
ariaDescribedBy: 'testing-result-main-info',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export class TestingCompleteComponent implements OnDestroy, OnInit {
report: this.data?.report,
export: this.data?.export,
isPilot: this.data?.device.test_pack === TestingType.Pilot,
device: this.data?.device,
started: this.data?.started,
},
autoFocus: 'first-tabbable',
ariaDescribedBy: 'testing-result-main-info',
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/src/app/services/test-run.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ describe('TestRunService', () => {
const spyObj = jasmine.createSpyObj('a', ['click', 'dispatchEvent']);
spyOn(document, 'createElement').and.returnValue(spyObj);

service.downloadZip('localhost:8080/export/test', '');
service.downloadZip('localhost:8080/export/test', '', 'report');
const req = httpTestingController.expectOne('localhost:8080/export/test');
req.flush(new Blob());
tick();
Expand Down
4 changes: 2 additions & 2 deletions modules/ui/src/app/services/test-run.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export class TestRunService {
.pipe(map(() => true));
}

downloadZip(url: string, profile: string) {
downloadZip(url: string, profile: string, name: string) {
this.http
.post(url, JSON.stringify({ profile }), {
responseType: 'blob',
Expand All @@ -319,7 +319,7 @@ export class TestRunService {
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.target = '_blank';
link.download = fileName ?? 'report.zip';
link.download = fileName ?? `${name}.zip`;
link.dispatchEvent(new MouseEvent('click'));
});
}
Expand Down
Loading