Skip to content

Commit 03bf37e

Browse files
committed
address review comments; some minor fixes
1 parent d0ba6ff commit 03bf37e

File tree

5 files changed

+35
-63
lines changed

5 files changed

+35
-63
lines changed

testplan/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
__version__ = "24.9.2"
55

6-
dev_build = int(os.environ.get("DEV_BUILD", "1"))
6+
dev_build = int(os.environ.get("DEV_BUILD", "0"))
77
dev_suffix = f"dev{int(time.time())}" if dev_build else ""
88

99
__build_version__ = f"{__version__}{dev_suffix}"

testplan/web_ui/testing/src/AssertionPane/AssertionTypes/TableAssertions/tableAssertionUtils.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,8 @@ export function prepareTableLogRowData(indexes, table, columns, display_index) {
226226

227227
indexes.forEach((index) => {
228228
let row = columns.reduce((accumulator, column, idx) => {
229-
if (Array.isArray(table[index])) accumulator[column] = table[index][idx];
230-
// TODO: remove this branch after 3 months 2021.06.01
231-
else accumulator[column] = table[index][column];
229+
// Array.isArray(table[index])
230+
accumulator[column] = table[index][idx];
232231
return accumulator;
233232
}, {});
234233
if (display_index) row["id"] = index;

testplan/web_ui/testing/src/Common/utils.js

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,12 @@ import _ from "lodash";
99
* Calculate execution time of an entry with timer field
1010
*/
1111
function calcExecutionTime(entry) {
12-
let elapsed = null;
12+
let elapsed = 0;
1313
if (entry.timer && entry.timer.run) {
14-
// TODO: remove the else branch after Aug. 1 2024
15-
if (Array.isArray(entry.timer.run) && !_.isEmpty(entry.timer.run)) {
16-
elapsed = 0;
17-
entry.timer.run.forEach((interval) => {
18-
elapsed +=
14+
entry.timer.run.forEach((interval) => {
15+
elapsed +=
1916
timeToTimestamp(interval.end) - timeToTimestamp(interval.start);
20-
});
21-
} else {
22-
elapsed =
23-
timeToTimestamp(entry.timer.run.end) -
24-
timeToTimestamp(entry.timer.run.start);
25-
}
17+
});
2618
}
2719
return elapsed;
2820
}
@@ -36,7 +28,7 @@ function calcElapsedTime(timerField) {
3628
elapsed = 0;
3729
timerField.forEach((interval) => {
3830
elapsed +=
39-
timeToTimestamp(interval.end) - timeToTimestamp(interval.start);
31+
timeToTimestamp(interval.end) - timeToTimestamp(interval.start);
4032
});
4133
}
4234
return elapsed < 0 ? null : elapsed;
@@ -168,12 +160,14 @@ function formatSeconds(durationInSeconds) {
168160
* @returns {string}
169161
*/
170162
function formatMilliseconds(durationInMilliseconds) {
171-
if (!_.isNumber(durationInMilliseconds)) { return "na"; };
163+
if (!_.isNumber(durationInMilliseconds)) {
164+
return "na";
165+
}
172166

173167
let secondsInMilliseconds = durationInMilliseconds % 60000;
174168
let seconds = secondsInMilliseconds / 1000;
175-
let minutesInMilliseconds = (durationInMilliseconds - secondsInMilliseconds)
176-
/ 60000;
169+
let minutesInMilliseconds =
170+
(durationInMilliseconds - secondsInMilliseconds) / 60000;
177171
let minutes = minutesInMilliseconds % 60;
178172
let hours = (minutesInMilliseconds - minutes) / 60;
179173

@@ -185,13 +179,11 @@ function formatMilliseconds(durationInMilliseconds) {
185179
let secondsDisplay = seconds.toFixed(3) + "s";
186180

187181
return (
188-
[hoursDisplay, minutesDisplay, secondsDisplay]
189-
.filter(Boolean)
190-
.join(" ") || "0s"
182+
[hoursDisplay, minutesDisplay, secondsDisplay].filter(Boolean).join(" ") ||
183+
"0s"
191184
);
192185
}
193186

194-
195187
/**
196188
* Formats the input number representing milliseconds into a string
197189
* with format H:m:s.SSS. Each value is displayed only if it is greater
@@ -200,14 +192,16 @@ function formatMilliseconds(durationInMilliseconds) {
200192
* @returns {string}
201193
*/
202194
function formatShortDuration(durationInMilliseconds) {
203-
if (!_.isNumber(durationInMilliseconds)) { return "na"; };
195+
if (!_.isNumber(durationInMilliseconds)) {
196+
return "na";
197+
}
204198

205199
durationInMilliseconds = _.round(durationInMilliseconds, -2);
206200

207201
let secondsInMilliseconds = durationInMilliseconds % 60000;
208202
let seconds = secondsInMilliseconds / 1000;
209-
let minutesInMilliseconds = (durationInMilliseconds - secondsInMilliseconds)
210-
/ 60000;
203+
let minutesInMilliseconds =
204+
(durationInMilliseconds - secondsInMilliseconds) / 60000;
211205
let minutes = minutesInMilliseconds % 60;
212206
let hours = (minutesInMilliseconds - minutes) / 60;
213207

@@ -219,19 +213,17 @@ function formatShortDuration(durationInMilliseconds) {
219213
let hoursDisplay = isDisplayedHours ? hours + "h" : "";
220214
let minutesDisplay = isDisplayedMinutes ? minutes + "m" : "";
221215
let secondsDisplay = isDisplayedSeconds
222-
? isDisplayedMilliseconds
223-
? seconds.toFixed(1) + "s"
224-
: seconds.toFixed(0) + "s"
225-
: null;
216+
? isDisplayedMilliseconds
217+
? seconds.toFixed(1) + "s"
218+
: seconds.toFixed(0) + "s"
219+
: null;
226220

227221
return (
228-
[hoursDisplay, minutesDisplay, secondsDisplay]
229-
.filter(Boolean)
230-
.join(":") || "0s"
222+
[hoursDisplay, minutesDisplay, secondsDisplay].filter(Boolean).join(":") ||
223+
"0s"
231224
);
232225
}
233226

234-
235227
export {
236228
calcExecutionTime,
237229
calcElapsedTime,
@@ -436,15 +428,15 @@ export const truncateString = (
436428
str,
437429
maxLength = 15,
438430
startLength = 7,
439-
endLength = 7
431+
endLength = 7
440432
) => {
441433
if (str.length <= maxLength) {
442434
return str;
443435
}
444436

445437
const startPortion = str.slice(0, startLength);
446438
const endPortion = str.slice(-1 * endLength);
447-
439+
448440
return `${startPortion}...${endPortion}`;
449441
};
450442

@@ -453,7 +445,7 @@ export const truncateString = (
453445
* @param {String} path
454446
*/
455447
export const getWorkspacePath = (path) => {
456-
const srcIndex = path.indexOf('/src/');
448+
const srcIndex = path.indexOf("/src/");
457449

458450
if (srcIndex !== -1) {
459451
return path.slice(srcIndex + 1);

testplan/web_ui/testing/src/Report/reportUtils.js

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,7 @@ const GetCenterPane = (
257257
/** TODO */
258258
const getAssertions = (selectedEntries, displayTime, UTCTime) => {
259259
// get timezone from nearest (test-level) report
260-
let IANAtz = ""; // default to utc
261-
for (let e of selectedEntries) {
262-
if (e.timezone) {
263-
IANAtz = e.timezone;
264-
break;
265-
}
266-
}
260+
const IANAtz = selectedEntries.find((e) => e.timezone)?.timezone || ""; // default to utc
267261

268262
// get all assertions from groups and list them sequentially in an array
269263
const getAssertionsRecursively = (links, entries) => {
@@ -328,21 +322,11 @@ const getAssertions = (selectedEntries, displayTime, UTCTime) => {
328322
let duration = "Unknown";
329323
if (selectedEntry.timer && selectedEntry.timer.run) {
330324
if (links[0].utc_time) {
331-
let previousEntryTime = null;
332-
// TODO: remove the else branch after Aug. 1 2024
333-
if (
334-
Array.isArray(selectedEntry.timer.run) &&
335-
!_.isEmpty(selectedEntry.timer.run)
336-
) {
337-
previousEntryTime = new Date(
338-
selectedEntry.timer.run.at(-1).start
339-
);
340-
} else {
341-
previousEntryTime = new Date(selectedEntry.timer.run.start);
342-
}
325+
const previousEntryTime = new Date(
326+
selectedEntry.timer.run.at(-1).start
327+
);
343328
const currentEntryTime = new Date(links[0].utc_time);
344-
const durationInMilliseconds = currentEntryTime - previousEntryTime;
345-
duration = formatMilliseconds(durationInMilliseconds);
329+
duration = formatMilliseconds(currentEntryTime - previousEntryTime);
346330
} else if (links[0].timestamp) {
347331
const previousEntryTime = selectedEntry.timer.run.at(-1).start;
348332
const currentEntryTime = links[0].timestamp;

tests/unit/testplan/runnable/interactive/test_api.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
from testplan.common import entity
99
from testplan.runnable.interactive import base, http
1010

11-
# XXX: tmp solution
12-
from testplan.common.utils.json import json_dumps, json_loads
13-
1411

1512
class TestRunnerIHandlerConfig(base.TestRunnerIHandlerConfig):
1613
"""Only for testing."""
@@ -216,7 +213,7 @@ def test_put_filtered(self, api_env):
216213
assert rsp.status_code == 200
217214

218215
ihandler.run_all_tests.assert_called_once_with(
219-
shallow_report=json_loads(json_dumps(json_report)),
216+
shallow_report=json_report,
220217
await_results=False,
221218
)
222219

0 commit comments

Comments
 (0)