diff --git a/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.html b/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.html
index 93563201e..02fa4f2f8 100644
--- a/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.html
+++ b/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.html
@@ -60,10 +60,12 @@
+
+ {{ error$ | async }}
+
diff --git a/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.spec.ts b/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.spec.ts
index 9e5b71bcd..4f24ecaaa 100644
--- a/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.spec.ts
+++ b/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.spec.ts
@@ -178,10 +178,27 @@ describe('ProgressInitiateFormComponent', () => {
});
});
+ it('should not start if no test selected', () => {
+ component.firmware.setValue('firmware');
+ component.selectedDevice = device;
+ fixture.detectChanges();
+ component.test_modules.setValue([false, false]);
+
+ component.startTestRun();
+ fixture.detectChanges();
+
+ const error = compiled.querySelector('mat-error');
+ expect(error?.innerHTML).toContain(
+ 'At least one test has to be selected to start test run.'
+ );
+ });
+
describe('when selectedDevice is present and firmware is filled', () => {
beforeEach(() => {
component.firmware.setValue('firmware');
component.selectedDevice = device;
+ fixture.detectChanges();
+ component.test_modules.setValue([true, true]);
});
it('should call startTestRun with device', () => {
@@ -193,6 +210,9 @@ describe('ProgressInitiateFormComponent', () => {
mac_addr: '00:1e:42:35:73:c4',
firmware: 'firmware',
test_modules: {
+ connection: {
+ enabled: true,
+ },
dns: {
enabled: true,
},
@@ -309,7 +329,7 @@ describe('ProgressInitiateFormComponent', () => {
const tests = compiled.querySelectorAll('.device-form-test-modules p');
expect(testsForm).toBeTruthy();
- expect(tests[0].classList.contains('disabled')).toEqual(true);
+ expect(tests[0].classList.contains('disabled')).toEqual(false);
expect(tests.length).toEqual(2);
});
diff --git a/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.ts b/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.ts
index 3cd304b6a..505df7271 100644
--- a/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.ts
+++ b/modules/ui/src/app/pages/testrun/components/progress-initiate-form/progress-initiate-form.component.ts
@@ -37,6 +37,7 @@ import { take } from 'rxjs';
import { Store } from '@ngrx/store';
import { AppState } from '../../../../store/state';
import { selectDevices } from '../../../../store/selectors';
+import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
interface DialogData {
device?: Device;
@@ -59,6 +60,9 @@ export class ProgressInitiateFormComponent
prevDevice: Device | null = null;
setFirmwareFocus = false;
readonly DeviceView = DeviceView;
+ error$: BehaviorSubject = new BehaviorSubject(
+ null
+ );
constructor(
public override dialogRef: MatDialogRef,
@@ -76,6 +80,10 @@ export class ProgressInitiateFormComponent
return this.initiateForm.get('firmware') as AbstractControl;
}
+ get test_modules() {
+ return this.initiateForm.controls['test_modules'] as FormArray;
+ }
+
cancel(startTestrun: boolean): void {
this.dialogRef.close(startTestrun);
}
@@ -131,12 +139,29 @@ export class ProgressInitiateFormComponent
return;
}
+ if (this.isAllTestsDisabled()) {
+ this.error$.next(
+ 'At least one test has to be selected to start test run.'
+ );
+ return;
+ }
+
+ const testModules: { [key: string]: { enabled: boolean } } = {};
+ this.initiateForm.value.test_modules.forEach(
+ (enabled: boolean, i: number) => {
+ testModules[this.testModules[i]?.name] = {
+ enabled: enabled,
+ };
+ }
+ );
+
if (this.selectedDevice) {
this.testRunService.fetchVersion();
this.testRunService
.startTestrun({
...this.selectedDevice,
firmware: this.firmware.value.trim(),
+ test_modules: testModules,
})
.pipe(take(1))
.subscribe(() => {
@@ -151,4 +176,10 @@ export class ProgressInitiateFormComponent
test_modules: new FormArray([]),
});
}
+
+ private isAllTestsDisabled(): boolean {
+ return this.initiateForm.value.test_modules.every((enabled: boolean) => {
+ return !enabled;
+ });
+ }
}
diff --git a/modules/ui/src/app/services/test-run.service.ts b/modules/ui/src/app/services/test-run.service.ts
index aa3585a9b..be09c77dc 100644
--- a/modules/ui/src/app/services/test-run.service.ts
+++ b/modules/ui/src/app/services/test-run.service.ts
@@ -27,8 +27,6 @@ import {
TestrunStatus,
} from '../model/testrun-status';
import { Version } from '../model/version';
-import { Store } from '@ngrx/store';
-import { AppState } from '../store/state';
import { Certificate } from '../model/certificate';
const API_URL = `http://${window.location.hostname}:8000`;
@@ -80,10 +78,7 @@ export class TestRunService {
private version = new BehaviorSubject(null);
- constructor(
- private http: HttpClient,
- private store: Store
- ) {}
+ constructor(private http: HttpClient) {}
fetchDevices(): Observable {
return this.http.get(`${API_URL}/devices`);