Skip to content

Commit de02c1f

Browse files
authored
Merge pull request #525 from wblachowski/feature/tests-ordering
Tests sorting
2 parents 62b3e3f + a74a6de commit de02c1f

10 files changed

Lines changed: 156 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All notable changes to AET will be documented in this file.
1010
## Unreleased
1111

1212
**List of changes that are finished but not yet released in any final version.**
13+
- [PR-525](https://github.com/Cognifide/aet/pull/525) Added tests ordering. ([#509](https://github.com/Cognifide/aet/issues/509))
1314

1415
- [PR-524](https://github.com/Cognifide/aet/pull/524) Remove handling unescaped URLs in suites
1516
- [PR-526](https://github.com/Cognifide/aet/pull/526) Added sending urls to collectors in packets. ([#431](https://github.com/Cognifide/aet/issues/431))

report/src/main/webapp/app/app.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ require.config({
6161
//sidepanel
6262
'sidepanelDirective': 'layout/sidepanel/sidepanel.directive',
6363
'sidepanelStatusFilterDirective': 'layout/sidepanel/sidepanelStatusFilter.directive',
64+
'sidepanelOrderDirective': 'layout/sidepanel/sidepanelOrder.directive',
6465
'sidepanelSearchDirective': 'layout/sidepanel/sidepanelSearch.directive',
6566
'sidepanelToggleLinkDirective': 'layout/sidepanel/toggleLink.directive',
6667
'sidepanelSaveChangesDirective': 'layout/sidepanel/saveChanges.directive',

report/src/main/webapp/app/app.module.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ define(['angularAMD',
5656
// sidepanel
5757
'sidepanelDirective',
5858
'sidepanelStatusFilterDirective',
59+
'sidepanelOrderDirective',
5960
'sidepanelSearchDirective',
6061
'sidepanelToggleLinkDirective',
6162
'sidepanelSaveChangesDirective',

report/src/main/webapp/app/components/hidePopovers.directive.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ define(['angularAMD'], function (angularAMD) {
2222
restrict: 'A',
2323
link: function (scope, $element) {
2424
$element.on('click', function (e) {
25-
if (!$(e.target).parents().hasClass('pop') && !$(
26-
e.target).parents().hasClass('popover')) {
27-
$('[data-toggle="popover"], .pop').popover('hide');
28-
}
25+
$('[data-toggle="popover"]').each(function () {
26+
//the 'is' for buttons that trigger popups
27+
//the 'has' for icons within a button that triggers a popup
28+
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
29+
(($(this).popover('hide').data('bs.popover')||{}).inState||{}).click = false;
30+
}
31+
});
2932
});
3033
}
3134
};

report/src/main/webapp/app/layout/main/suite/mainView.suite.controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ define([], function () {
4040
urlStats[status] = urlStats[status] ? urlStats[status] + 1 : 1;
4141
});
4242
vm.testWrappers.push({
43+
name: test.name,
4344
test: test,
4445
stats: urlStats
4546
});

report/src/main/webapp/app/layout/main/suite/mainView.suite.view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<div class="page-main">
2121
<div class="row reports-list">
2222
<div class="reports-list-item {{test.getStatus()}}"
23-
ng-repeat="testWrapper in suiteView.testWrappers | aetTestStatusFilter:$root.activeFilters | aetTestSearchFilter:$root.searchText | orderBy:'name'"
23+
ng-repeat="testWrapper in suiteView.testWrappers | aetTestStatusFilter:$root.activeFilters | aetTestSearchFilter:$root.searchText | orderBy:$root.orderAttribute:$root.orderIsReverse"
2424
ng-init="test = testWrapper.test; stats = testWrapper.stats;"
2525
ng-class="test.getStatus()">
2626
<a ui-sref="test({'suite':data.project,'test':test.name})">

report/src/main/webapp/app/layout/sidepanel/sidepanel.view.html

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,49 @@
9696
</div>
9797
</div>
9898
</div>
99+
<!--
100+
Ordering
101+
-->
102+
<div class="form-group order-group">
103+
<div class="order-dropdown" data-aet-sidepanel-order data-toggle="popover">
104+
<div class="filter-list">
105+
<div>
106+
<p data-ng-bind="$root.orderLabel"></p>
107+
<div class="fontawesome">
108+
<div data-toggle="popover"
109+
data-content="Change tests order"
110+
data-trigger="hover"
111+
data-container="body">
112+
<i class="fas fa-angle-down fa-lg"></i>
113+
</div>
114+
</div>
115+
</div>
116+
<form class="dropdown-menu">
117+
<div class="dropdown-field">
118+
<button data-ordering-attribute="name" class="dropdown-item">Sort by name</button>
119+
</div>
120+
<div class="dropdown-field">
121+
<button data-ordering-attribute="+" class="dropdown-item">Sort by suite ordering</button>
122+
</div>
123+
</form>
124+
</div>
125+
</div>
126+
<div class="order-reversal-icon">
127+
<div class="fontawesome" data-ng-click="changeSortingOrder()">
128+
<div data-toggle="popover"
129+
data-content="Reverse tests order"
130+
data-trigger="hover"
131+
data-container="body">
132+
<div data-ng-if="$root.orderIsReverse">
133+
<i class="fas fa-lg fa-sort-amount-up"></i>
134+
</div>
135+
<div data-ng-if="!$root.orderIsReverse">
136+
<i class="fas fa-lg fa-sort-amount-down"></i>
137+
</div>
138+
</div>
139+
</div>
140+
</div>
141+
</div>
99142
</div>
100143

101144
<!--
@@ -126,7 +169,7 @@
126169
</div>
127170

128171
<div class="aside-report-container" ng-class="sidepanel.thereAreChangesToSave() ? 'aside-report-container_short' : ''">
129-
<div ng-repeat="test in sidepanel.tests | orderBy:'name'"
172+
<div ng-repeat="test in sidepanel.tests | orderBy:$root.orderAttribute:$root.orderIsReverse"
130173
class="aside-report {{filteredUrls.length > 0 ? 'is-visible' : 'is-hidden'}}">
131174
<a ui-sref="test({'suite':$root.params.project, 'test':test.name})" ui-sref-active="is-active"
132175
class="test-name {{filteredUrls.length > 0 ? 'is-visible' : 'is-hidden'}}" aet-toggle-link
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* AET
3+
*
4+
* Copyright (C) 2013 Cognifide Limited
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
define(['angularAMD'], function (angularAMD) {
19+
'use strict';
20+
angularAMD.directive('aetSidepanelOrder',
21+
['$rootScope', '$timeout', SidepanelOrderDirective]);
22+
23+
function SidepanelOrderDirective($rootScope, $timeout) {
24+
return {
25+
restrict: 'AE',
26+
link: init,
27+
controller: function ($scope) {
28+
$scope.changeSortingOrder = changeSortingOrder;
29+
}
30+
};
31+
32+
function init(scope, $element) {
33+
updateOrdering('name', 'Sort by name');
34+
$element.popover({
35+
placement: 'bottom',
36+
trigger: 'click',
37+
content: function () {
38+
return $element.find('.dropdown-menu').html();
39+
},
40+
html: true
41+
}).parent().on('click', 'button', function (event) {
42+
onOrderSelected(event, $element);
43+
});
44+
}
45+
46+
function onOrderSelected(event, $element) {
47+
(($element.popover('hide').data('bs.popover')||{}).inState||{}).click = false;
48+
var orderingAttribute = $(event.target).data('ordering-attribute');
49+
var label = $(event.target).text();
50+
updateOrdering(orderingAttribute, label);
51+
}
52+
53+
function updateOrdering(orderingAttribute, labelText){
54+
$timeout(function() {
55+
$rootScope.orderAttribute = orderingAttribute;
56+
$rootScope.orderLabel = labelText;
57+
});
58+
}
59+
60+
function changeSortingOrder() {
61+
$timeout(function() {
62+
$rootScope.orderIsReverse = !$rootScope.orderIsReverse;
63+
});
64+
}
65+
}
66+
});

report/src/main/webapp/assets/sass/_filters.scss

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,33 @@
3838
cursor: pointer;
3939
}
4040
}
41+
42+
&.order-group {
43+
44+
.order-dropdown {
45+
position: relative;
46+
width: calc(100% - 32px);
47+
float: left;
48+
}
49+
50+
.order-reversal-icon {
51+
width: 24px;
52+
height: 12px;
53+
color: white;
54+
float: right;
55+
cursor: pointer;
56+
position: relative;
57+
58+
.fontawesome{
59+
right: 0;
60+
top: 7px;
61+
}
62+
}
63+
}
4164
}
4265

4366
input,
44-
.filter-list {
67+
.filter-list, select {
4568
background-color: $grayish;
4669
border: 0 none;
4770
color: $white;
@@ -106,6 +129,14 @@
106129
color: $text-color;
107130
display: inline;
108131
}
132+
133+
button{
134+
background: transparent;
135+
border: none;
136+
width: 100%;
137+
height: 100%;
138+
text-align: left;
139+
}
109140
}
110141
}
111142
}

test-executor/src/main/java/com/cognifide/aet/executor/model/TestSuiteRun.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import com.google.common.base.MoreObjects;
1919
import java.io.Serializable;
20-
import java.util.HashMap;
20+
import java.util.LinkedHashMap;
2121
import java.util.List;
2222
import java.util.Map;
2323

@@ -71,7 +71,7 @@ public TestSuiteRun(TestSuiteRun testSuiteRun, String name, String domain, List<
7171
}
7272

7373
private Map<String, TestRun> getMap(List<TestRun> testRunList) {
74-
Map<String, TestRun> result = new HashMap<>();
74+
Map<String, TestRun> result = new LinkedHashMap<>();
7575
for (TestRun testRun : testRunList) {
7676
result.put(testRun.getName(), testRun);
7777
}

0 commit comments

Comments
 (0)