Skip to content

Commit 6691780

Browse files
author
Alexander Bainczyk
committed
Merge branch 'streamline-testing' into developer
2 parents 9707048 + c19bf8d commit 6691780

File tree

6 files changed

+31
-120
lines changed

6 files changed

+31
-120
lines changed

frontend/src/app/views/test-case-view/test-case-view.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<action-bar>
33
<div class="d-flex flex-row align-items-center">
44
<div class="btn-group btn-group-sm ml-auto">
5-
<button (click)="execute()" class="btn btn-primary">
5+
<button (click)="execute()" [disabled]="this.testConfig == undefined" class="btn btn-primary">
66
Execute
77
</button>
88
<button (click)="openTestConfigModal()" class="btn btn-primary">

frontend/src/app/views/test-case-view/test-case-view.component.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ export class TestCaseViewComponent implements OnInit, OnDestroy {
7272
ngOnInit(): void {
7373
window.addEventListener('keydown', this.keyDownHandler);
7474

75-
this.testConfig = {
76-
tests: [this.testCase],
77-
environment: this.project.getDefaultEnvironment(),
78-
driverConfig: new WebDriverConfig()
79-
};
80-
8175
this.symbolGroupApi.getAll(this.project.id).subscribe(
8276
groups => {
8377
SymbolGroupUtils.getSymbols(groups).forEach(s => this.symbolMap[s.id] = s);
@@ -90,7 +84,7 @@ export class TestCaseViewComponent implements OnInit, OnDestroy {
9084
const i = configs.findIndex(c => c.default);
9185
if (i > -1) {
9286
this.testConfig = configs[i];
93-
this.testConfig.environment = this.project.getEnvironmentById(this.testConfig.environment);
87+
this.testConfig.environment = this.project.getEnvironmentById(this.testConfig.environment.id);
9488
}
9589
});
9690
}
@@ -121,11 +115,9 @@ export class TestCaseViewComponent implements OnInit, OnDestroy {
121115

122116
this.saveTest().subscribe(
123117
() => {
124-
const config = JSON.parse(JSON.stringify(this.testConfig));
125-
config.tests = [this.testCase.id];
126-
config.environment = config.environment.id;
118+
this.testConfig.tests = [this.testCase.id];
127119

128-
this.testApi.executeMany(this.project.id, config).subscribe(
120+
this.testApi.executeMany(this.project.id, this.testConfig).subscribe(
129121
data => {
130122
this.currentTestRun = data;
131123
this.pollForResult();
@@ -141,11 +133,13 @@ export class TestCaseViewComponent implements OnInit, OnDestroy {
141133

142134
openTestConfigModal(): void {
143135
const modalRef = this.modalService.open(TestConfigModalComponent);
144-
modalRef.componentInstance.configuration = JSON.parse(JSON.stringify(this.testConfig));
136+
if (this.testConfig != null) {
137+
modalRef.componentInstance.configuration = JSON.parse(JSON.stringify(this.testConfig));
138+
}
145139
modalRef.componentInstance.project = this.project;
146-
modalRef.result.then(data => {
147-
this.toastService.success('The settings have been updated.');
148-
this.testConfig = data;
140+
modalRef.result.then((config) => {
141+
this.testConfig = config;
142+
this.toastService.success(`The config has been saved for the moment.`)
149143
}).catch(() => {});
150144
}
151145

frontend/src/app/views/test-suite-view/test-suite-view.component.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,11 @@
7070
</button>
7171
</div>
7272

73-
<div class="btn-group btn-group-sm float-right ml-2">
74-
<button (click)="openCreateTestConfigModal()" class="btn btn-success" ngbTooltip="Save configuration" placement="left">
75-
<i class="fas fa-fw fa-plus"></i> New Config
76-
</button>
77-
</div>
78-
7973
<div class="btn-group btn-group-sm float-right">
8074
<button (click)="executeSelected()" class="btn btn-primary" [disabled]="!selectedTests.isAnySelected() || this.testConfig == undefined">
8175
Execute
8276
</button>
83-
<button (click)="openEditTestConfigModal()" class="btn btn-primary" [disabled]="this.testConfig == undefined">
77+
<button (click)="openTestConfigModal()" class="btn btn-primary">
8478
<i class="fas fa-fw fa-cog"></i>
8579
</button>
8680
</div>

frontend/src/app/views/test-suite-view/test-suite-view.component.ts

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ import { AppStoreService } from '../../services/app-store.service';
3434
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
3535
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
3636
import { TestsImportModalComponent } from './tests-import-modal/tests-import-modal.component';
37-
import {
38-
TestConfigModalAction,
39-
TestConfigModalComponent
40-
} from '../tests-view/test-config-modal/test-config-modal.component';
37+
import { TestConfigModalComponent } from '../tests-view/test-config-modal/test-config-modal.component';
4138
import { TestsMoveModalComponent } from './tests-move-modal/tests-move-modal.component';
4239
import { TestReportStatus, TestStatus } from '../../entities/test-status';
4340
import { TestLockInfo, TestPresenceService } from '../../services/test-presence.service';
@@ -274,32 +271,16 @@ export class TestSuiteViewComponent implements OnInit, OnDestroy {
274271
&& this.testStatus.currentTest.id === test.id;
275272
}
276273

277-
openCreateTestConfigModal(): void {
274+
openTestConfigModal(): void {
278275
const modalRef = this.modalService.open(TestConfigModalComponent);
279-
modalRef.componentInstance.action = TestConfigModalAction.CREATE;
280-
modalRef.componentInstance.configuration = {};
281-
modalRef.componentInstance.configuration.driverConfig = {};
282-
modalRef.componentInstance.project = this.project;
283-
modalRef.result.then(_ => {
284-
this.testConfigApi.getAll(this.project.id).subscribe(
285-
testConfigs => {
286-
this.testConfigs = testConfigs;
287-
},
288-
console.error
289-
);
290-
}).catch(() => {
291-
});
292-
}
293-
294-
openEditTestConfigModal(): void {
295-
const modalRef = this.modalService.open(TestConfigModalComponent);
296-
modalRef.componentInstance.action = TestConfigModalAction.EDIT;
297-
modalRef.componentInstance.configuration = JSON.parse(JSON.stringify(this.testConfig));
276+
if (this.testConfig != null) {
277+
modalRef.componentInstance.configuration = JSON.parse(JSON.stringify(this.testConfig));
278+
}
298279
modalRef.componentInstance.project = this.project;
299280
modalRef.result.then(config => {
300-
const i = this.testConfigs.findIndex(value => value.id === config.id);
301-
this.testConfigs[i] = config;
302-
}).catch(() => {
281+
this.testConfig = config;
282+
this.toastService.success(`Config has been saved for the moment.`)
283+
}).catch(() => {
303284
});
304285
}
305286

@@ -415,7 +396,7 @@ export class TestSuiteViewComponent implements OnInit, OnDestroy {
415396
return {};
416397
}
417398

418-
if (this.report.status === TestReportStatus.IN_PROGRESS && this.testStatus != null) {
399+
if (this.report.status === TestReportStatus.IN_PROGRESS && this.testStatus?.currentTestRun?.results != null) {
419400
return this.testStatus.currentTestRun.results;
420401
}
421402

frontend/src/app/views/tests-view/test-config-modal/test-config-modal.component.html

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,51 +31,23 @@ <h4 class="modal-title">Configure the test run</h4>
3131

3232
<div class="list-group">
3333
<div
34-
(click)="selectedEnvironment = env"
34+
(click)="this.configuration.environmentId = env.id"
3535
*ngFor="let env of project.environments"
36-
[ngClass]="{'active': env.id === selectedEnvironment.id}"
36+
[ngClass]="{'active': env.id === this.configuration.environmentId}"
3737
class="list-group-item cursor-pointer"
3838
>
3939
{{env.name}}
4040
</div>
4141
</div>
4242
</ng-template>
4343
</ng-container>
44-
<ng-container ngbNavItem>
45-
<a ngbNavLink>Test</a>
46-
<ng-template ngbNavContent>
47-
<br>
48-
49-
<div class="form-group">
50-
<label>Name</label>
51-
<textarea
52-
[(ngModel)]="configuration.name"
53-
class="form-control"
54-
rows="1"
55-
placeholder="Enter a name for the test config"
56-
>
57-
</textarea>
58-
</div>
59-
<div class="form-group">
60-
<label>Description</label>
61-
<textarea
62-
[(ngModel)]="configuration.description"
63-
class="form-control"
64-
rows="3"
65-
placeholder="Enter a description for the test config"
66-
>
67-
</textarea>
68-
</div>
69-
</ng-template>
70-
</ng-container>
7144
</nav>
7245

7346
<div [ngbNavOutlet]="nav"></div>
7447

7548
</div>
7649

7750
<div class="modal-footer">
78-
<button *ngIf="action === TestConfigModalAction.CREATE" (click)="create()" class="btn btn-success btn-sm">Create</button>
79-
<button *ngIf="action === TestConfigModalAction.EDIT" (click)="update()" class="btn btn-primary btn-sm">Update</button>
51+
<button (click)="update()" [disabled]="!validConfig" class="btn btn-success btn-sm">Update</button>
8052
<button (click)="modal.dismiss(); $event.preventDefault()" class="btn btn-default btn-sm">Cancel</button>
8153
</div>

frontend/src/app/views/tests-view/test-config-modal/test-config-modal.component.ts

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -42,55 +42,25 @@ export class TestConfigModalComponent implements OnInit {
4242
@Input()
4343
project: Project;
4444

45-
/** The model for the url ids. */
46-
@Input()
47-
selectedEnvironment: ProjectEnvironment;
48-
49-
/** The action for which this modal has been opened. */
50-
@Input()
51-
action: TestConfigModalAction;
52-
5345
/** Constructor. */
5446
constructor(public modal: NgbActiveModal,
5547
public testConfigApi: TestConfigApiService,
5648
public toastService: ToastService) {
5749
}
5850

5951
ngOnInit(): void {
60-
this.selectedEnvironment = this.project.getDefaultEnvironment();
61-
}
62-
63-
create(): void {
64-
this.configuration.id = null;
65-
this.configuration.driverConfig.id = null;
66-
this.configuration.tests = [];
67-
this.configuration.project = this.project.id;
68-
this.configuration.environmentId = this.selectedEnvironment.id;
69-
70-
this.testConfigApi.create(this.project.id, this.configuration).subscribe(config => {
71-
this.toastService.success('The config has been created.');
72-
this.modal.close(config);
73-
}, res => {
74-
this.toastService.danger(`The config couldn't be created. ${res.error.message}`);
75-
this.modal.dismiss();
76-
});
52+
if (this.configuration == null) {
53+
this.configuration = {}
54+
this.configuration.driverConfig = {}
55+
this.configuration.environmentId = this.project.getDefaultEnvironment().id;
56+
}
7757
}
7858

79-
/**
80-
* Close the modal window and pass the configuration.
81-
*/
8259
update(): void {
83-
this.configuration.environmentId = this.selectedEnvironment.id;
84-
this.testConfigApi.update(this.project.id, this.configuration).subscribe(config => {
85-
this.toastService.success('The config has been updated.');
86-
this.modal.close(config);
87-
}, res => {
88-
this.toastService.danger(`The config couldn't be updated. ${res.error.message}`);
89-
this.modal.dismiss();
90-
});
60+
this.modal.close(this.configuration);
9161
}
9262

93-
get TestConfigModalAction() {
94-
return TestConfigModalAction;
63+
get validConfig(): boolean {
64+
return this.configuration.driverConfig.browser != null && this.configuration.driverConfig.platform != null
9565
}
9666
}

0 commit comments

Comments
 (0)