Skip to content

Commit 7a5735a

Browse files
Merge pull request #484 from telekom/fix/history-compare
Fix/history compare
2 parents f8b1735 + 0041a02 commit 7a5735a

File tree

5 files changed

+41
-10
lines changed

5 files changed

+41
-10
lines changed

report-ng/app/src/components/history/run-comparison/method-table.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
></a>
6767
<a if.bind="!methodHistory.methodRunId && !methodHistory.methodHistoryAvailable"
6868
innerhtml.bind="methodHistory.methodIdentifier"></a>
69+
<div if.bind="!methodHistory.currentStatus">(${methodHistory.methodIdentifier})</div>
6970
<div
7071
if.bind="methodHistory.changedFailureAspect && methodHistory.pastStatus === methodHistory.currentStatus"
7172
class="st1"

report-ng/app/src/components/history/run-comparison/method-table.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {bindable} from "aurelia-templating";
2424
import {bindingMode} from "aurelia-binding";
2525
import "./method-table.scss";
2626
import {IComparableMethod} from "./run-comparison";
27+
import {ClassName, ClassNameValueConverter} from "../../../value-converters/class-name-value-converter";
2728

2829
@autoinject()
2930
export class MethodTable {
@@ -37,4 +38,18 @@ export class MethodTable {
3738

3839
constructor() {
3940
}
41+
42+
methodsChanged() {
43+
if (this.methods) {
44+
let converter = new ClassNameValueConverter();
45+
this.methods = this.methods.sort((a, b) => {
46+
const aClass = converter.toView(a.classIdentifier, ClassName.simpleName);
47+
const bClass = converter.toView(b.classIdentifier, ClassName.simpleName);
48+
if (aClass < bClass) return -1;
49+
if (aClass > bClass) return 1;
50+
return 0;
51+
});
52+
}
53+
54+
}
4055
}

report-ng/app/src/components/history/run-comparison/run-comparison.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export interface IComparableMethod {
3636
methodHistoryAvailable: boolean
3737
}
3838

39+
interface IRunToCompare {
40+
historyIndex: number,
41+
startTime: number
42+
}
43+
44+
3945
@autoinject()
4046
export class RunComparison extends AbstractViewModel {
4147
private _historyStatistics: HistoryStatistics;
@@ -100,10 +106,14 @@ export class RunComparison extends AbstractViewModel {
100106
pastStatus = pastRun.context.resultStatus;
101107
}
102108

103-
if (currentStatus === ResultStatusType.PASSED && pastStatus === ResultStatusType.PASSED) {
109+
if (
110+
(currentStatus === ResultStatusType.PASSED && pastStatus === ResultStatusType.PASSED)
111+
|| pastStatus === ResultStatusType.FAILED_RETRIED
112+
|| currentStatus === ResultStatusType.FAILED_RETRIED) {
104113
return null;
105114
}
106115

116+
107117
if (method.runs.length > 1) {
108118
methodHistoryAvailable = true;
109119
}
@@ -143,7 +153,3 @@ export class RunComparison extends AbstractViewModel {
143153
}
144154
}
145155

146-
interface IRunToCompare {
147-
historyIndex: number,
148-
startTime: number
149-
}

report-ng/app/src/services/statistic-models.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,18 @@ export class HistoryStatistics {
229229

230230
clsStat.methods.forEach((method) => {
231231
let methodHistory = classHistory.methods.find(
232-
methodHistoryStatistics => methodHistoryStatistics.identifier === method.identifier && this._compareRelatedMethods(methodHistoryStatistics.relatedMethods, method.relatedMethods)
232+
methodHistoryStatistics => {
233+
// Retried methods have the same identifier, so we have duplicates in related methods array.
234+
const uniqueHistoryRelatedMethods = this._filterUniqueItems(methodHistoryStatistics.relatedMethods);
235+
const uniqueRelatedMethods = this._filterUniqueItems(method.relatedMethods);
236+
return methodHistoryStatistics.identifier === method.identifier
237+
&& this._compareRelatedMethods(uniqueHistoryRelatedMethods, uniqueRelatedMethods);
238+
}
233239
);
234-
235240
if (!methodHistory) {
236241
methodHistory = new MethodHistoryStatistics(method);
237242
classHistory.addMethod(methodHistory);
238243
}
239-
240244
methodHistory.addRun(method, currentHistoryIndex);
241245
});
242246
});
@@ -245,6 +249,11 @@ export class HistoryStatistics {
245249
this._classHistory = Array.from(classHistoryMap.values());
246250
}
247251

252+
private _filterUniqueItems(arr: string[]): string[] {
253+
const uniqueItems = new Set(arr);
254+
return Array.from(uniqueItems);
255+
}
256+
248257
private _compareRelatedMethods(arr1: string[], arr2: string[]): boolean {
249258
if (arr1.length !== arr2.length) {
250259
return false;

report-ng/app/src/value-converters/class-name-value-converter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ export class ClassNameValueConverter {
2828
switch (mode) {
2929
case ClassName.package:
3030
if (value.lastIndexOf('.') > 0) {
31-
return value.substr(0, value.lastIndexOf('.'));
31+
return value.substring(0, value.lastIndexOf('.'));
3232
} else {
3333
return '';
3434
}
3535
case ClassName.simpleName:
3636
if (value.lastIndexOf('.') > 0) {
37-
return value.substr(value.lastIndexOf('.') + 1);
37+
return value.substring(value.lastIndexOf('.') + 1);
3838
}
3939
case ClassName.full:
4040
return value;

0 commit comments

Comments
 (0)