Skip to content

Commit 023791e

Browse files
committed
Add time tracking information to uploaded results
1 parent bd66a06 commit 023791e

13 files changed

+88
-10
lines changed

src/api/schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export interface CreateResultsRequestItem {
6666
tcaseId: string
6767
status: ResultStatus
6868
comment?: string
69+
timeTaken: number | null // In milliseconds
6970
}
7071

7172
export interface CreateResultsRequest {

src/tests/fixtures/playwright-json/comprehensive-test.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"stdout": [],
2323
"stderr": [],
2424
"retry": 0,
25+
"duration": 1000,
2526
"attachments": []
2627
}
2728
],
@@ -48,6 +49,7 @@
4849
"stdout": [],
4950
"stderr": [],
5051
"retry": 0,
52+
"duration": 6200,
5153
"attachments": []
5254
}
5355
],
@@ -74,6 +76,7 @@
7476
"stdout": [],
7577
"stderr": [],
7678
"retry": 0,
79+
"duration": 2000,
7780
"attachments": []
7881
}
7982
],
@@ -106,6 +109,7 @@
106109
"stdout": [],
107110
"stderr": [],
108111
"retry": 0,
112+
"duration": 1400,
109113
"attachments": []
110114
}
111115
],
@@ -132,6 +136,7 @@
132136
"stdout": [],
133137
"stderr": [],
134138
"retry": 0,
139+
"duration": 500,
135140
"attachments": []
136141
}
137142
],
@@ -158,6 +163,7 @@
158163
"stdout": [],
159164
"stderr": [],
160165
"retry": 0,
166+
"duration": 5050,
161167
"attachments": []
162168
}
163169
],
@@ -186,6 +192,7 @@
186192
"stdout": [],
187193
"stderr": [],
188194
"retry": 0,
195+
"duration": 0,
189196
"attachments": []
190197
}
191198
],
@@ -213,6 +220,7 @@
213220
"stdout": [],
214221
"stderr": [],
215222
"retry": 0,
223+
"duration": 0,
216224
"attachments": []
217225
}
218226
],
@@ -239,6 +247,7 @@
239247
],
240248
"stderr": [],
241249
"retry": 0,
250+
"duration": 0,
242251
"attachments": []
243252
}
244253
],
@@ -270,6 +279,7 @@
270279
],
271280
"stderr": [],
272281
"retry": 0,
282+
"duration": 0,
273283
"attachments": []
274284
}
275285
],
@@ -296,6 +306,7 @@
296306
],
297307
"stderr": [],
298308
"retry": 0,
309+
"duration": 10000,
299310
"attachments": []
300311
}
301312
],
@@ -318,6 +329,7 @@
318329
"stdout": [],
319330
"stderr": [],
320331
"retry": 0,
332+
"duration": 1000,
321333
"attachments": [
322334
{
323335
"name": "screenshot",

src/tests/fixtures/playwright-json/empty-tsuite.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"stdout": [],
1919
"stderr": [],
2020
"retry": 0,
21+
"duration": 0,
2122
"attachments": []
2223
}
2324
],

src/tests/fixtures/playwright-json/matching-tcases.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"stdout": [],
1919
"stderr": [],
2020
"retry": 0,
21+
"duration": 1000,
2122
"attachments": [
2223
{
2324
"name": "attachment",
@@ -46,6 +47,7 @@
4647
"stdout": [],
4748
"stderr": [],
4849
"retry": 0,
50+
"duration": 1000,
4951
"attachments": [
5052
{
5153
"name": "attachment",
@@ -80,6 +82,7 @@
8082
"stdout": [],
8183
"stderr": [],
8284
"retry": 0,
85+
"duration": 1000,
8386
"attachments": [
8487
{
8588
"name": "attachment",
@@ -112,6 +115,7 @@
112115
"stdout": [],
113116
"stderr": [],
114117
"retry": 0,
118+
"duration": 1000,
115119
"attachments": [
116120
{
117121
"name": "attachment",
@@ -140,6 +144,7 @@
140144
"stdout": [],
141145
"stderr": [],
142146
"retry": 0,
147+
"duration": 1000,
143148
"attachments": [
144149
{
145150
"name": "attachment",

src/tests/fixtures/playwright-json/missing-attachments.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"stdout": [],
1919
"stderr": [],
2020
"retry": 0,
21+
"duration": 1000,
2122
"attachments": [
2223
{
2324
"name": "attachment",
@@ -46,6 +47,7 @@
4647
"stdout": [],
4748
"stderr": [],
4849
"retry": 0,
50+
"duration": 1000,
4951
"attachments": [
5052
{
5153
"name": "attachment",
@@ -80,6 +82,7 @@
8082
"stdout": [],
8183
"stderr": [],
8284
"retry": 0,
85+
"duration": 1000,
8386
"attachments": [
8487
{
8588
"name": "attachment",
@@ -112,6 +115,7 @@
112115
"stdout": [],
113116
"stderr": [],
114117
"retry": 0,
118+
"duration": 1000,
115119
"attachments": [
116120
{
117121
"name": "attachment",
@@ -140,6 +144,7 @@
140144
"stdout": [],
141145
"stderr": [],
142146
"retry": 0,
147+
"duration": 1000,
143148
"attachments": [
144149
{
145150
"name": "attachment",

src/tests/fixtures/playwright-json/missing-tcases.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"stdout": [],
1919
"stderr": [],
2020
"retry": 0,
21+
"duration": 1000,
2122
"attachments": [
2223
{
2324
"name": "attachment",
@@ -46,6 +47,7 @@
4647
"stdout": [],
4748
"stderr": [],
4849
"retry": 0,
50+
"duration": 1000,
4951
"attachments": [
5052
{
5153
"name": "attachment",
@@ -80,6 +82,7 @@
8082
"stdout": [],
8183
"stderr": [],
8284
"retry": 0,
85+
"duration": 1000,
8386
"attachments": [
8487
{
8588
"name": "attachment",
@@ -108,6 +111,7 @@
108111
"stdout": [],
109112
"stderr": [],
110113
"retry": 0,
114+
"duration": 1000,
111115
"attachments": [
112116
{
113117
"name": "attachment",
@@ -140,6 +144,7 @@
140144
"stdout": [],
141145
"stderr": [],
142146
"retry": 0,
147+
"duration": 1000,
143148
"attachments": [
144149
{
145150
"name": "attachment",
@@ -168,6 +173,7 @@
168173
"stdout": [],
169174
"stderr": [],
170175
"retry": 0,
176+
"duration": 1000,
171177
"attachments": [
172178
{
173179
"name": "attachment",

src/tests/fixtures/playwright-json/without-markers.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"stdout": [],
1919
"stderr": [],
2020
"retry": 0,
21+
"duration": 10686,
2122
"attachments": []
2223
}
2324
],
@@ -40,6 +41,7 @@
4041
"stdout": [],
4142
"stderr": [],
4243
"retry": 0,
44+
"duration": 5712,
4345
"attachments": []
4446
}
4547
],
@@ -62,6 +64,7 @@
6264
"stdout": [],
6365
"stderr": [],
6466
"retry": 0,
67+
"duration": 1231,
6568
"attachments": []
6669
}
6770
],

src/tests/junit-xml-parsing.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, test, describe } from 'vitest'
2+
import { readFile } from 'node:fs/promises'
23
import { parseJUnitXml } from '../utils/result-upload/junitXmlParser'
3-
import { readFile } from 'fs/promises'
44

55
const xmlBasePath = './src/tests/fixtures/junit-xml'
66

@@ -43,6 +43,7 @@ describe('Junit XML parsing', () => {
4343
expect(tc).toHaveProperty('status')
4444
expect(tc).toHaveProperty('message')
4545
expect(tc).toHaveProperty('attachments')
46+
expect(tc).toHaveProperty('timeTaken')
4647
expect(Array.isArray(tc.attachments)).toBe(true)
4748
})
4849
})
@@ -64,9 +65,7 @@ describe('Junit XML parsing', () => {
6465
// Verify we have the expected failure scenarios
6566
expect(failureTests.some((tc) => tc.name.includes('only type'))).toBe(true)
6667
expect(failureTests.some((tc) => tc.name.includes('type and message'))).toBe(true)
67-
expect(failureTests.some((tc) => tc.name.includes('type, message and text content'))).toBe(
68-
true
69-
)
68+
expect(failureTests.some((tc) => tc.name.includes('type, message and text content'))).toBe(true)
7069

7170
// Verify we have the expected error scenarios
7271
expect(errorTests.some((tc) => tc.name.includes('only type'))).toBe(true)
@@ -180,7 +179,7 @@ describe('Junit XML parsing', () => {
180179
const xml = `<?xml version="1.0" encoding="UTF-8"?>
181180
<testsuites name="Test Suite">
182181
<testsuite name="Sample Suite">
183-
<testcase name="Test with stderr">
182+
<testcase name="Test with stderr" time="10.5">
184183
<system-out>stdout content</system-out>
185184
<system-err>stderr content</system-err>
186185
</testcase>
@@ -194,6 +193,7 @@ describe('Junit XML parsing', () => {
194193

195194
expect(testcases).toHaveLength(1)
196195
expect(testcases[0].status).toBe('passed')
196+
expect(testcases[0].timeTaken).toBe(10500)
197197
// Should include stdout but not stderr for passed tests
198198
expect(testcases[0].message).toContain('stdout content')
199199
expect(testcases[0].message).not.toContain('stderr content')
@@ -203,7 +203,7 @@ describe('Junit XML parsing', () => {
203203
const xml = `<?xml version="1.0" encoding="UTF-8"?>
204204
<testsuites name="Test Suite">
205205
<testsuite name="Sample Suite">
206-
<testcase name="Failed test with output">
206+
<testcase name="Failed test with output" time="0">
207207
<failure message="Test failed">Failure details</failure>
208208
<system-out>stdout from failed test</system-out>
209209
<system-err>stderr from failed test</system-err>
@@ -218,6 +218,7 @@ describe('Junit XML parsing', () => {
218218

219219
expect(testcases).toHaveLength(1)
220220
expect(testcases[0].status).toBe('failed')
221+
expect(testcases[0].timeTaken).toBe(null)
221222
// Should include both stdout and stderr for failed tests
222223
expect(testcases[0].message).toContain('Failure details')
223224
expect(testcases[0].message).toContain('stdout from failed test')
@@ -228,7 +229,7 @@ describe('Junit XML parsing', () => {
228229
const xml = `<?xml version="1.0" encoding="UTF-8"?>
229230
<testsuites name="Test Suite">
230231
<testsuite name="Sample Suite">
231-
<testcase name="Passed test with output">
232+
<testcase name="Passed test with output" time="1">
232233
<system-out>stdout content</system-out>
233234
<system-err>stderr content</system-err>
234235
</testcase>
@@ -242,6 +243,7 @@ describe('Junit XML parsing', () => {
242243

243244
expect(testcases).toHaveLength(1)
244245
expect(testcases[0].status).toBe('passed')
246+
expect(testcases[0].timeTaken).toBe(1000)
245247
// Should not include stdout or stderr for passed tests
246248
expect(testcases[0].message).toBe('')
247249
})

0 commit comments

Comments
 (0)