Skip to content

Commit 5f96973

Browse files
Merge pull request #68 from aquality-automation/feature/synk_lagacy_tests
Feature/synk lagacy tests
2 parents 6f1112b + 88d0716 commit 5f96973

11 files changed

+230
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Features:
66
- Remove Customers Feature -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/25)
77
- Add 'Steps' label into Test page -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/31)
88
- Add ID column to Suites List -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/18)
9+
- Add possibility to sync testsuites according to Not Executed results -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/32)
910
- Add Executor and Pass Rate column to Test Run List table -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/41)
1011

1112
Bugfixes:

src/app/elements/table/table.filter.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class TableFilterComponent implements OnInit, AfterViewInit, OnDestroy, O
3939
@Input() actionsHeader = true;
4040
@Input() allowRefresh = false;
4141
@Input() allowBulkUpdate = false;
42+
@Input() withSelector = false;
4243

4344
@Output() createEntity = new EventEmitter();
4445
@Output() dataChange = new EventEmitter();
@@ -116,7 +117,7 @@ export class TableFilterComponent implements OnInit, AfterViewInit, OnDestroy, O
116117
if (this.allowDelete || this.allowCreate || this.allowBulkUpdate) {
117118
this.columns.push({ name: 'Action', property: 'action', type: 'button', editable: true });
118119
}
119-
if (this.allowBulkUpdate) {
120+
if (this.allowBulkUpdate || this.withSelector) {
120121
this.columns.unshift({ name: 'Selector', property: 'ft_select', type: 'selector', editable: true, class: 'fit' });
121122
}
122123
}
@@ -185,7 +186,7 @@ export class TableFilterComponent implements OnInit, AfterViewInit, OnDestroy, O
185186
}
186187

187188
bulkUpdate() {
188-
const entitiesToUpdate = this.filteredData.filter(entity => entity.ft_select === true || entity.ft_select === 1);
189+
const entitiesToUpdate = this.getSelectedEntitites();
189190
entitiesToUpdate.forEach(entity => {
190191
for (const property in this.bulkChangeEntity) {
191192
if (property) {
@@ -198,6 +199,10 @@ export class TableFilterComponent implements OnInit, AfterViewInit, OnDestroy, O
198199
this.bulkChangeEntity = {};
199200
}
200201

202+
getSelectedEntitites() {
203+
return this.filteredData.filter(entity => entity.ft_select === true || entity.ft_select === 1);
204+
}
205+
201206
manageColumns() {
202207
this.hideManageColumnsModal = false;
203208
}

src/app/pages/project/project.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { StepsListComponent } from './steps/steps-list/steps-list.component';
5454
import { StepsService } from '../../services/steps.service';
5555
import { StepsContainerComponent } from './test/steps-container/steps-container.component';
5656
import { TestViewCanDeactivate } from '../../shared/guards/can-deactivate-guard.service';
57+
import { SyncSuiteModalComponent } from './testsuite/sync-suite-modal/sync-suite-modal.component';
5758

5859
@NgModule({
5960
imports: [
@@ -95,7 +96,8 @@ import { TestViewCanDeactivate } from '../../shared/guards/can-deactivate-guard.
9596
SuiteDashboardComponent,
9697
StepsListComponent,
9798
StepsContainerComponent,
98-
SafePipe
99+
SafePipe,
100+
SyncSuiteModalComponent
99101
],
100102
providers: [
101103
ProjectService,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.mt-overlay{
2+
display: block;
3+
}
4+
5+
.simple-modal{
6+
top: 220px;
7+
}
8+
9+
.modal-message{
10+
max-height: 500px;
11+
padding-top: 10px;
12+
padding-bottom: 10px;
13+
border-bottom: solid 1px lightgray;
14+
}
15+
16+
.panel-body {
17+
padding-bottom: 10px;
18+
}
19+
20+
.table-holder {
21+
padding-bottom: 0px;
22+
padding-top: 0px;
23+
max-height: 700px;
24+
overflow: auto;
25+
}
26+
27+
.modal-buttons label {
28+
margin-top: 15px;
29+
text-transform: none;
30+
}
31+
32+
.modal-buttons input{
33+
margin-top: 20px;
34+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<div class="overlay mt-overlay">
2+
<div class="simple-modal panel" [ngClass]="{
3+
'panel-warning':type=='warning',
4+
'panel-danger':type=='error',
5+
'panel-info':type=='info',
6+
'panel-success':type=='success',
7+
'panel-primary':type==''
8+
}">
9+
<div class="panel-heading col-sm-12">
10+
<h4 class="panel-title pull-left">{{title}}</h4>
11+
<span (click)="hideModal()" class="glyphicon glyphicon-remove clickable-element pull-right"
12+
aria-hidden="true"></span>
13+
</div>
14+
<div class="panel-body">
15+
<div class="col-sm-12 modal-message">
16+
<div class="col-sm-7">
17+
<lookup-autocomplete id="sync-suite-selector" [allowEmptyValue]="false"
18+
[propertiesToShow]="['name']" [array]="suites" [model]="suite" [disabled]="false"
19+
placeholder="Select Suite" (modelChange)="suiteChange($event)" title="Suite to sync">
20+
</lookup-autocomplete>
21+
</div>
22+
<div class="col-sm-2">
23+
<input id="not-executed-for" class="form-control" placeholder="#" [(ngModel)]="notExecutedFor"
24+
title="Number of Not Executed results in a row" />
25+
</div>
26+
<div class="col-sm-2">
27+
<button id="find-tests-to-sync" (click)="findTests()" class="btn btn-success">Find
28+
Tests</button>
29+
</div>
30+
</div>
31+
<div class="col-sm-12 modal-buttons">
32+
<div class="col-sm-7">
33+
<label for="remove-not-executed">Remove 'Not Executed' results till first meaningful</label>
34+
</div>
35+
<div class="col-sm-1">
36+
<input type="checkbox" id="remove-not-executed" [(ngModel)]="removeNotExecuted"
37+
title="Check if you want to remove all Not Executed results till first meaningful result." />
38+
</div>
39+
<div class="col-sm-4 modal-buttons-form">
40+
<button [id]="button.name" autofocus (click)="accept(button.execute)"
41+
[disabled]="button.execute && !suite" class="btn btn-sm btn-default"
42+
*ngFor="let button of buttons">{{button.name}}</button>
43+
</div>
44+
</div>
45+
</div>
46+
47+
<div class="table-holder panel-body">
48+
<table-filter id="sync-test-table" *ngIf="cols" #syncTestTable [rowsOnPage]="10" [queryParams]="false"
49+
[data]="tests" [columns]="cols" [defaultSortBy]="{ property: 'name', order: 'desc' }"
50+
[columnManagement]="false" [rowsOnPageSet]="[10]" [withSelector]="true">
51+
</table-filter>
52+
</div>
53+
</div>
54+
</div>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { Component, Input, Output, EventEmitter, OnInit, ViewChild } from '@angular/core';
2+
import { BasePopupComponent } from '../../../../elements/modals/basePopup.component';
3+
import { Test } from '../../../../shared/models/test';
4+
import { SimpleRequester } from '../../../../services/simple-requester';
5+
import { TestSuite } from '../../../../shared/models/testSuite';
6+
import { TableFilterComponent } from '../../../../elements/table/table.filter.component';
7+
import { TestSuiteService } from '../../../../services/testSuite.service';
8+
9+
@Component({
10+
selector: 'sync-suite-modal',
11+
templateUrl: 'sync-suite-modal.component.html',
12+
styleUrls: ['sync-suite-modal.component.css'],
13+
providers: [
14+
SimpleRequester
15+
]
16+
})
17+
export class SyncSuiteModalComponent extends BasePopupComponent implements OnInit {
18+
title = 'Sync suite';
19+
@Input() type = 'info';
20+
@Input() buttons = [{ name: 'Sync', execute: true }, { name: 'Cancel', execute: false }];
21+
@Input() suites: TestSuite[];
22+
@Input() suite: TestSuite;
23+
@Output() testSyncTo = new EventEmitter();
24+
@ViewChild(TableFilterComponent) syncTestTable: TableFilterComponent;
25+
tests: Test[] = [];
26+
testsToSync: Test[] = [];
27+
notExecutedFor = 5;
28+
removeNotExecuted = true;
29+
cols = [
30+
{
31+
name: 'Name',
32+
property: 'name',
33+
filter: true,
34+
sorting: true,
35+
type: 'text'
36+
}
37+
];
38+
39+
constructor(
40+
private testSuiteService: TestSuiteService,
41+
) {
42+
super();
43+
}
44+
45+
async accept(execute: boolean) {
46+
this.testsToSync = this.syncTestTable.getSelectedEntitites();
47+
if (execute) {
48+
if (this.testsToSync.length > 0) {
49+
if (this.testsToSync.length > 50) {
50+
this.testSuiteService.handleInfo(`You are running synchronization for ${this.testsToSync.length},
51+
be patient it will take some time.`);
52+
}
53+
await this.testSuiteService.syncSuite(this.testsToSync, this.suite.id, this.removeNotExecuted);
54+
this.testSuiteService.handleSuccess('Tests were synchronized!');
55+
} else {
56+
this.testSuiteService.handleWarning('No tests selected', 'You should select at least one test to sync!');
57+
return;
58+
}
59+
}
60+
this.onClick(execute);
61+
}
62+
63+
suiteChange(suite: TestSuite) {
64+
this.suite = suite;
65+
}
66+
67+
async findTests() {
68+
this.tests = await this.testSuiteService.findTestToSync(this.notExecutedFor, this.suite.id);
69+
if (this.tests.length < 1) {
70+
this.testSuiteService.handleWarning('No tests found',
71+
`No test were stored with Not Executed result for at least ${this.notExecutedFor
72+
} last test runs for ${this.suite.name} suite!`);
73+
}
74+
}
75+
}

src/app/pages/project/testsuite/view/testsuite-view.component.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { TableFilterComponent } from '../../../../elements/table/table.filter.co
2626
})
2727
export class TestSuiteViewComponent implements OnInit {
2828
hideMoveModal = true;
29+
syncTestsModal = false;
2930
MoveModalTitle = 'Move Test';
3031
hideModal = true;
3132
removeModalTitle: string;
@@ -254,8 +255,8 @@ export class TestSuiteViewComponent implements OnInit {
254255
this.hideModal = false;
255256
}
256257

257-
execute($event: any) {
258-
if ($event) {
258+
async execute(answer: any) {
259+
if (await answer) {
259260
this.testService.removeTest(this.testToRemove).subscribe();
260261
this.testSuite.tests = this.testSuite.tests.filter(x => x !== this.testToRemove);
261262
}
@@ -270,8 +271,8 @@ export class TestSuiteViewComponent implements OnInit {
270271
this.hideMoveModal = false;
271272
}
272273

273-
moveToExecute($event) {
274-
if ($event) {
274+
moveToExecute(answer) {
275+
if (answer) {
275276
this.testSuiteService.getTestSuiteWithChilds({ id: this.route.snapshot.params['testsuiteId'] }).then(testSuites => {
276277
this.testSuite = testSuites[0];
277278
this.child.data = this.testSuite.tests;
@@ -294,4 +295,17 @@ export class TestSuiteViewComponent implements OnInit {
294295
moveToWasClosed($event) {
295296
this.hideMoveModal = true;
296297
}
298+
299+
syncSuiteClosed() {
300+
this.syncTestsModal = false;
301+
}
302+
303+
syncSuite() {
304+
this.syncTestsModal = true;
305+
}
306+
307+
async syncTests(answer) {
308+
await answer;
309+
this.syncSuiteClosed();
310+
}
297311
}

src/app/pages/project/testsuite/view/testsuite.view.component.html

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,32 @@
22
<simple-popup *ngIf="!hideModal" [title]="removeModalTitle" [message]="removeModalMessage" [type]="'warning'"
33
[buttons]="[{name:'yes', execute:true }, {name:'no', execute:false}]" (execute)="execute($event)"
44
(closed)="wasClosed($event)"></simple-popup>
5-
<move-test-modal *ngIf="!hideMoveModal" [title]="MoveModalTitle"
6-
[tests]="testSuite.tests" [buttons]="[{name:'Move', execute:true }, {name:'Cancel', execute:false}]"
7-
(execute)="moveToExecute($event)" (closed)="moveToWasClosed($event)"></move-test-modal>
5+
<move-test-modal *ngIf="!hideMoveModal" [title]="MoveModalTitle" [tests]="testSuite.tests"
6+
[buttons]="[{name:'Move', execute:true }, {name:'Cancel', execute:false}]" (execute)="moveToExecute($event)"
7+
(closed)="moveToWasClosed($event)"></move-test-modal>
8+
<sync-suite-modal *ngIf="syncTestsModal" [suites]="testSuites" (execute)="syncTests($event)"
9+
(closed)="syncSuiteClosed($event)" [suite]="selectedTestSuite"></sync-suite-modal>
810
<div class="row">
911
<div class="col-sm-4">
1012
<h2 class="pull-left" id="suite-view">Test Suite:</h2>
11-
<lookup-autocomplete id="page-label-lookup" class="pull-left page-label-lookup"
12-
[allowEmptyValue]="true" [propertiesToShow]="['name']" [array]="testSuites" [model]="selectedTestSuite"
13-
[disabled]="false" placeholder="All Tests" (modelChange)="suiteChange($event)"></lookup-autocomplete>
13+
<lookup-autocomplete id="page-label-lookup" class="pull-left page-label-lookup" [allowEmptyValue]="true"
14+
[propertiesToShow]="['name']" [array]="testSuites" [model]="selectedTestSuite" [disabled]="false"
15+
placeholder="All Tests" (modelChange)="suiteChange($event)"></lookup-autocomplete>
1416
</div>
1517
<div class="col-md-8">
1618
<div class="btn-group pull-right" role="group">
1719
<button class="btn btn-primary" routerLink="/project/{{testSuite.project_id}}/testrun/matrix"
1820
[queryParams]="{suite:testSuite.id}">Suite Matrix</button>
19-
<button id="move-test-btn"*ngIf="userService.IsLocalAdmin() || userService.IsLocalManager() || userService.IsManager()"
21+
<button id="move-test-btn"
22+
*ngIf="userService.IsLocalAdmin() || userService.IsLocalManager() || userService.IsManager()"
2023
class="btn btn-primary" (click)="moveTestOpen()">Move Test</button>
2124
<button [disabled]="!testSuite.tests" (click)="ExportToCSV()" class="btn">Export to CSV</button>
2225
<button (click)="openTestCreation()"
2326
*ngIf="userService.HaveAnyLocalPermissionsExceptViewerWithoutPUpdating() || userService.IsManager()"
2427
class="btn btn-primary">Add Test</button>
28+
<button (click)="syncSuite()"
29+
*ngIf="userService.HaveAnyLocalPermissionsExceptViewerWithoutPUpdating() || userService.IsManager()"
30+
class="btn btn-primary">Sync</button>
2531
</div>
2632
</div>
2733
<hr class="col-sm-12 no-padding">
@@ -51,10 +57,9 @@ <h2 class="pull-left" id="suite-view">Test Suite:</h2>
5157
</div>
5258
</div>
5359
<div class="panel-body">
54-
<table-filter id="test-table" *ngIf="tbCols && testSuite && testSuite.tests" #table [rowsOnPageSet]="[5,10,20]" [rowsOnPage]="20"
55-
[queryParams]="true" [data]="testSuite.tests" [columns]="tbCols"
56-
[defaultSortBy]="{ property: 'name', order: 'desc' }"
57-
[allowDelete]="allowEdit"
58-
[allowBulkUpdate]="allowEdit" (rowClick)="rowClicked($event)" (dataChange)="testUpdate($event)"
59-
(action)="handleAction($event)" (bulkChanges)="bulkUpdate($event)"></table-filter>
60+
<table-filter id="test-table" *ngIf="tbCols && testSuite && testSuite.tests" #table [rowsOnPageSet]="[5,10,20]"
61+
[rowsOnPage]="20" [queryParams]="true" [data]="testSuite.tests" [columns]="tbCols"
62+
[defaultSortBy]="{ property: 'name', order: 'desc' }" [allowDelete]="allowEdit" [allowBulkUpdate]="allowEdit"
63+
(rowClick)="rowClicked($event)" (dataChange)="testUpdate($event)" (action)="handleAction($event)"
64+
(bulkChanges)="bulkUpdate($event)"></table-filter>
6065
</div>

src/app/services/simple-requester.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ export class SimpleRequester extends Http {
3636
}
3737
}
3838

39-
public doPost(url: string, object?) {
39+
public doPost(url: string, object?, params: { [key: string]: any | any[]; } = null, showLoading: boolean = false) {
4040
let jsonString = JSON.stringify(object);
4141
if (typeof jsonString === 'undefined') { jsonString = '{}'; }
4242
const headers = new Headers();
4343
this.createAuthorizationHeader(headers);
44-
return this.intercept(super.post(this.api + url, jsonString, { headers: headers }), true);
44+
return this.intercept(super.post(this.api + url, jsonString, { headers: headers, params }), showLoading);
4545
}
4646

4747
public doPut(url: string, object?) {
@@ -90,6 +90,7 @@ export class SimpleRequester extends Http {
9090
intercept(observable: Observable<Response>, showLoading: boolean, handleError: boolean = true): Observable<Response> {
9191
if (showLoading) {
9292
this.globaldata.requestQuery++;
93+
this.turnOnModal();
9394
}
9495
return observable
9596
.catch((err, source) => {
@@ -155,4 +156,11 @@ export class SimpleRequester extends Http {
155156
message
156157
);
157158
}
159+
160+
handleInfo(message: string) {
161+
this.notificationsService.info(
162+
`Information`,
163+
message
164+
);
165+
}
158166
}

src/app/services/test.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ export class TestService extends SimpleRequester {
5252

5353
removeTest(test: Test) {
5454
return this.doDelete(`/test?id=${test.id}&projectId=${test.project_id}`)
55-
.map(() => this.handleSuccess(`Test '${test.name}' was deleted.`));
55+
.map(() => this.handleSuccess(`Test '${test.name}' was deleted.`));
5656
}
5757
}

0 commit comments

Comments
 (0)