Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests sorting #525

Merged
merged 18 commits into from
Aug 6, 2020
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to AET will be documented in this file.
## Unreleased

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

## Version 3.3.0

Expand Down
1 change: 1 addition & 0 deletions report/src/main/webapp/app/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ require.config({
//sidepanel
'sidepanelDirective': 'layout/sidepanel/sidepanel.directive',
'sidepanelStatusFilterDirective': 'layout/sidepanel/sidepanelStatusFilter.directive',
'sidepanelOrderDirective': 'layout/sidepanel/sidepanelOrder.directive',
'sidepanelSearchDirective': 'layout/sidepanel/sidepanelSearch.directive',
'sidepanelToggleLinkDirective': 'layout/sidepanel/toggleLink.directive',
'sidepanelSaveChangesDirective': 'layout/sidepanel/saveChanges.directive',
Expand Down
1 change: 1 addition & 0 deletions report/src/main/webapp/app/app.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ define(['angularAMD',
// sidepanel
'sidepanelDirective',
'sidepanelStatusFilterDirective',
'sidepanelOrderDirective',
'sidepanelSearchDirective',
'sidepanelToggleLinkDirective',
'sidepanelSaveChangesDirective',
Expand Down
11 changes: 7 additions & 4 deletions report/src/main/webapp/app/components/hidePopovers.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ define(['angularAMD'], function (angularAMD) {
restrict: 'A',
link: function (scope, $element) {
$element.on('click', function (e) {
if (!$(e.target).parents().hasClass('pop') && !$(
e.target).parents().hasClass('popover')) {
$('[data-toggle="popover"], .pop').popover('hide');
}
$('[data-toggle="popover"]').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
(($(this).popover('hide').data('bs.popover')||{}).inState||{}).click = false;
}
});
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ define([], function () {
urlStats[status] = urlStats[status] ? urlStats[status] + 1 : 1;
});
vm.testWrappers.push({
name: test.name,
test: test,
stats: urlStats
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="page-main">
<div class="row reports-list">
<div class="reports-list-item {{test.getStatus()}}"
ng-repeat="testWrapper in suiteView.testWrappers | aetTestStatusFilter:$root.activeFilters | aetTestSearchFilter:$root.searchText | orderBy:'name'"
ng-repeat="testWrapper in suiteView.testWrappers | aetTestStatusFilter:$root.activeFilters | aetTestSearchFilter:$root.searchText | orderBy:$root.orderAttribute:$root.orderIsReverse"
ng-init="test = testWrapper.test; stats = testWrapper.stats;"
ng-class="test.getStatus()">
<a ui-sref="test({'suite':data.project,'test':test.name})">
Expand Down
45 changes: 44 additions & 1 deletion report/src/main/webapp/app/layout/sidepanel/sidepanel.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,49 @@
</div>
</div>
</div>
<!--
Ordering
-->
<div class="form-group order-group">
<div class="order-dropdown" data-aet-sidepanel-order data-toggle="popover">
<div class="filter-list">
<div>
<p data-ng-bind="$root.orderLabel"></p>
<div class="fontawesome">
<div data-toggle="popover"
data-content="Change tests order"
data-trigger="hover"
data-container="body">
<i class="fas fa-angle-down fa-lg"></i>
</div>
</div>
</div>
<form class="dropdown-menu">
<div class="dropdown-field">
<button data-ordering-attribute="name" class="dropdown-item">Sort by name</button>
</div>
<div class="dropdown-field">
<button data-ordering-attribute="+" class="dropdown-item">Sort by suite ordering</button>
</div>
</form>
</div>
</div>
<div class="order-reversal-icon">
<div class="fontawesome" data-ng-click="changeSortingOrder()">
<div data-toggle="popover"
data-content="Reverse tests order"
data-trigger="hover"
data-container="body">
<div data-ng-if="$root.orderIsReverse">
<i class="fas fa-lg fa-sort-amount-up"></i>
</div>
<div data-ng-if="!$root.orderIsReverse">
<i class="fas fa-lg fa-sort-amount-down"></i>
</div>
</div>
</div>
</div>
</div>
</div>

<!--
Expand Down Expand Up @@ -126,7 +169,7 @@
</div>

<div class="aside-report-container" ng-class="sidepanel.thereAreChangesToSave() ? 'aside-report-container_short' : ''">
<div ng-repeat="test in sidepanel.tests | orderBy:'name'"
<div ng-repeat="test in sidepanel.tests | orderBy:$root.orderAttribute:$root.orderIsReverse"
class="aside-report {{filteredUrls.length > 0 ? 'is-visible' : 'is-hidden'}}">
<a ui-sref="test({'suite':$root.params.project, 'test':test.name})" ui-sref-active="is-active"
class="test-name {{filteredUrls.length > 0 ? 'is-visible' : 'is-hidden'}}" aet-toggle-link
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* AET
*
* Copyright (C) 2013 Cognifide Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
define(['angularAMD'], function (angularAMD) {
'use strict';
angularAMD.directive('aetSidepanelOrder',
['$rootScope', '$timeout', SidepanelOrderDirective]);

function SidepanelOrderDirective($rootScope, $timeout) {
return {
restrict: 'AE',
link: init,
controller: function ($scope) {
$scope.changeSortingOrder = changeSortingOrder;
}
};

function init(scope, $element) {
updateOrdering('name', 'Sort by name');
$element.popover({
placement: 'bottom',
trigger: 'click',
content: function () {
return $element.find('.dropdown-menu').html();
},
html: true
}).parent().on('click', 'button', function (event) {
onOrderSelected(event, $element);
});
}

function onOrderSelected(event, $element) {
(($element.popover('hide').data('bs.popover')||{}).inState||{}).click = false;
var orderingAttribute = $(event.target).data('ordering-attribute');
var label = $(event.target).text();
updateOrdering(orderingAttribute, label);
}

function updateOrdering(orderingAttribute, labelText){
$timeout(function() {
$rootScope.orderAttribute = orderingAttribute;
$rootScope.orderLabel = labelText;
});
}

function changeSortingOrder() {
$timeout(function() {
$rootScope.orderIsReverse = !$rootScope.orderIsReverse;
});
}
}
});
33 changes: 32 additions & 1 deletion report/src/main/webapp/assets/sass/_filters.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,33 @@
cursor: pointer;
}
}

&.order-group {

.order-dropdown {
position: relative;
width: calc(100% - 32px);
float: left;
}

.order-reversal-icon {
width: 24px;
height: 12px;
color: white;
float: right;
cursor: pointer;
position: relative;

.fontawesome{
right: 0;
top: 7px;
}
}
}
}

input,
.filter-list {
.filter-list, select {
background-color: $grayish;
border: 0 none;
color: $white;
Expand Down Expand Up @@ -106,6 +129,14 @@
color: $text-color;
display: inline;
}

button{
background: transparent;
border: none;
width: 100%;
height: 100%;
text-align: left;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import com.google.common.base.MoreObjects;
import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -71,7 +71,7 @@ public TestSuiteRun(TestSuiteRun testSuiteRun, String name, String domain, List<
}

private Map<String, TestRun> getMap(List<TestRun> testRunList) {
Map<String, TestRun> result = new HashMap<>();
Map<String, TestRun> result = new LinkedHashMap<>();
for (TestRun testRun : testRunList) {
result.put(testRun.getName(), testRun);
}
Expand Down