-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_pages_report_history.mjs
More file actions
1996 lines (1906 loc) · 69.5 KB
/
Copy pathtest_pages_report_history.mjs
File metadata and controls
1996 lines (1906 loc) · 69.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import assert from 'node:assert/strict';
import { mkdir, mkdtemp, readFile, writeFile } from 'node:fs/promises';
import http from 'node:http';
import os from 'node:os';
import path from 'node:path';
import test from 'node:test';
import { buildPagesReport } from '../../scripts/build-pages-report.mjs';
import {
findShellReport,
testRunDump,
} from '../../scripts/omarchy-shell-evidence.mjs';
import { reportCases } from '../../scripts/report-cases.mjs';
import { renderReportSummary } from '../../scripts/render-ci-report-summary.mjs';
import { verifyPublishedReport } from '../../scripts/verify-pages-report.mjs';
test('publishes the Markdown evidence table for same-repository pull requests', async () => {
for (const workflow of [
'midscene-ubuntu-22.04.yml',
'midscene-omarchy-4.0.3.yml',
]) {
const source = await readFile(
new URL(`../../.github/workflows/${workflow}`, import.meta.url),
'utf8',
);
const pagesJob = source.slice(source.indexOf(' pages-report:'));
assert.match(
pagesJob,
/github\.event\.pull_request\.head\.repo\.full_name == github\.repository/,
`${workflow} must publish its report and Summary table for trusted PRs`,
);
assert.doesNotMatch(
pagesJob,
/github\.ref_name == vars\.PAGES_REPORT_BRANCH/,
`${workflow} must not suppress the PR Summary table behind a branch check`,
);
}
});
test('records every shard and renders the Summary before Pages deployment', async () => {
for (const workflow of [
'midscene-ubuntu-22.04.yml',
'midscene-omarchy-4.0.3.yml',
]) {
const source = await readFile(
new URL(`../../.github/workflows/${workflow}`, import.meta.url),
'utf8',
);
assert.match(source, /Record shard result for report aggregation/);
assert.match(
source,
/if: always\(\) && !cancelled\(\)/,
`${workflow} must preserve failure evidence without extending manually cancelled runs`,
);
assert.match(
source,
/^\s*max-parallel: 5$/m,
`${workflow} must run its independent VM shards in parallel`,
);
assert.match(source, /if-no-files-found: error/);
assert.match(source, /Create bundle even when every shard failed early/);
assert.match(
source,
/Upload .*shard report[\s\S]*?overwrite: true/,
`${workflow} must replace a rerun shard artifact instead of keeping duplicate names`,
);
assert.match(
source,
/Upload combined report bundle[\s\S]*?overwrite: true/,
`${workflow} must replace the previous attempt's combined bundle`,
);
}
const deploy = await readFile(
new URL('../../.github/workflows/deploy-midscene-report.yml', import.meta.url),
'utf8',
);
const summary = deploy.indexOf('Add complete evidence table');
const deployment = deploy.indexOf('Deploy report history to GitHub Pages');
const deployJob = deploy.indexOf('\n deploy:');
assert.ok(summary > 0 && summary < deployment);
assert.match(
deploy.slice(summary, deployment),
/steps\.build-report\.outcome == 'success'/,
);
assert.ok(deployJob > summary);
assert.doesNotMatch(deploy.slice(0, deployJob), /environment:/);
assert.match(
deploy,
/name: \$\{\{ inputs\.artifact-name \}\}-pages-\$\{\{ github\.run_attempt \}\}/,
);
assert.match(
deploy,
/artifact_name: \$\{\{ inputs\.artifact-name \}\}-pages-\$\{\{ github\.run_attempt \}\}/,
);
assert.match(
deploy,
/name: \$\{\{ inputs\.artifact-name \}\}-manifest-\$\{\{ github\.run_attempt \}\}/,
);
});
test('rerun aggregation excludes the previous combined report artifact', async () => {
const source = await readFile(
new URL('../../.github/workflows/midscene-omarchy-4.0.3.yml', import.meta.url),
'utf8',
);
assert.match(source, /pattern: omarchy-midscene-omarchy-\*/);
assert.doesNotMatch(source, /pattern: omarchy-midscene-\*\s*$/m);
});
test('assigns every product case to exactly one balanced shard', async () => {
const shardCounts = new Map();
let caseCount = 0;
for (const file of [
'onboarding.yaml',
'onboarding-regressions.yaml',
'runtime.yaml',
]) {
const source = await readFile(
new URL(`../e2e/cases/${file}`, import.meta.url),
'utf8',
);
const cases = source
.split(/(?=^ - name:)/m)
.filter((section) => section.startsWith(' - name:'));
for (const testCase of cases) {
const tags = [...testCase.matchAll(/^ tags: \[([^\]]+)\]$/gm)];
assert.equal(tags.length, 1, testCase.split('\n')[0]);
const shards = tags[0][1].split(',').map((tag) => tag.trim())
.filter((tag) => /^shard-[1-4]$/.test(tag));
assert.equal(shards.length, 1, testCase.split('\n')[0]);
shardCounts.set(shards[0], (shardCounts.get(shards[0]) ?? 0) + 1);
caseCount += 1;
}
}
assert.equal(caseCount, 14);
assert.deepEqual(Object.fromEntries(shardCounts), {
'shard-1': 2,
'shard-2': 3,
'shard-3': 5,
'shard-4': 4,
});
});
test('keeps visual E2E interactions at task level with proven tap exceptions', async () => {
for (const file of [
'onboarding.yaml',
'onboarding-regressions.yaml',
'polishing.yaml',
'runtime.yaml',
]) {
const source = await readFile(
new URL(`../e2e/cases/${file}`, import.meta.url),
'utf8',
);
const oneShotActions = source.match(
/^\s+-\s+(?:aiTap|aiScroll|aiInput|computer\.inputText|computer\.tapPoint|computer\.selectTriggerPreset):.*$/gm,
) ?? [];
assert.deepEqual(
oneShotActions.map((line) => line.trim()),
file === 'onboarding.yaml'
? [
'- aiTap: The large blue full-width Open Doubao sign-in button near the bottom of the central Sign in panel, around 50% width and 73% screen height',
'- aiTap: The blue Simulate successful sign-in button in the CI-only modal, around 50% width and 43% screen height',
'- aiTap: Check microphone · 3 seconds button on the Microphone step',
'- aiTap: Right-arrow Next button in the fixed top navigation',
'- aiScroll:',
'- aiTap: Test endpoint button in the Voice polishing section',
'- aiTap: Right-arrow Next button in the fixed top navigation',
'- aiTap: Start voice test button',
'- aiTap: Finish & check result button',
'- aiTap: Enabled Finish setup button that says Voice test passed and nothing pasted or sent',
]
: file === 'onboarding-regressions.yaml'
? [
'- aiTap: The large blue full-width Open Doubao sign-in button near the bottom of the central Sign in panel, around 50% width and 73% screen height',
'- aiTap: The large blue full-width Open Doubao sign-in button near the bottom of the central Sign in panel, around 50% width and 73% screen height',
'- aiTap: The blue Simulate successful sign-in button in the CI-only modal, around 50% width and 43% screen height',
'- aiTap: The large blue full-width Open Doubao sign-in button near the bottom of the central Sign in panel, around 50% width and 73% screen height',
'- aiTap: The blue Simulate successful sign-in button in the CI-only modal, around 50% width and 43% screen height',
'- computer.tapPoint: { target: Left-arrow Previous button in the fixed top navigation, point: { x: 240, y: 203 } }',
'- computer.tapPoint: { target: Right-arrow Next button in the fixed top navigation, point: { x: 1038, y: 203 } }',
'- computer.selectTriggerPreset: { preset: Disabled }',
'- computer.tapPoint: { target: Right-arrow Next button in the fixed top navigation, point: { x: 1038, y: 203 } }',
'- computer.selectTriggerPreset: { preset: F8 }',
'- computer.tapPoint: { target: Right-arrow Next button in the fixed top navigation, point: { x: 1038, y: 203 } }',
'- computer.tapPoint: { target: Left-arrow Previous button in the fixed top navigation, point: { x: 240, y: 203 } }',
'- aiScroll:',
'- computer.tapPoint: { target: Enabled Voice polishing switch, point: { x: 1180, y: 316 } }',
'- computer.tapPoint: { target: Disabled Voice polishing switch in the collapsed card, point: { x: 1166, y: 554 } }',
'- aiScroll:',
'- aiScroll:',
'- computer.inputText: { target: The text entry to the right of Model containing synthetic-model, value: ci-fail-model, point: { x: 850, y: 477 } }',
'- aiTap: Test endpoint button in the Voice polishing section',
'- computer.inputText: { target: The text entry to the right of Model containing ci-fail-model, value: ci-ok-model, point: { x: 850, y: 477 } }',
'- aiTap: Test failed — try again button in the Voice polishing section',
'- aiTap: Right-arrow Next button in the fixed top navigation',
'- aiScroll:',
'- computer.tapPoint: { target: Left-arrow Previous button in the fixed top navigation, point: { x: 240, y: 203 } }',
'- aiTap: Check microphone · 3 seconds button on the Microphone step',
'- aiTap: Right-arrow Next button in the fixed top navigation',
'- aiScroll:',
'- aiTap: Start voice test button in the Voice test section',
'- aiTap: Cancel test button in the active voice test',
'- aiTap: Start voice test button in the Voice test section',
'- aiTap: Finish & check result button in the active voice test',
'- aiTap: The Recognition service dropdown currently showing Doubao account',
'- aiTap: Volcengine API option in the open Recognition service dropdown',
'- aiTap: Test API key button on the Recognition step',
'- aiTap: Right-arrow Next button in the fixed top navigation',
'- aiTap: Recognition service dropdown currently showing Doubao account',
'- aiTap: Deepgram Nova-3 (English) option in the opened dropdown',
'- aiScroll:',
'- computer.inputText:',
'- aiTap: Test API key button below the API Key field',
'- aiTap: The microphone dropdown currently showing Synthetic microphone one',
'- aiTap: Synthetic microphone two option in the open microphone dropdown',
'- aiTap: Right-arrow Next button in the fixed top navigation',
'- aiScroll:',
'- aiTap: Left-arrow Previous button in the fixed top navigation',
'- aiTap: Check microphone · 3 seconds button on the Microphone step',
'- aiTap: Right-arrow Next button in the fixed top navigation',
'- aiScroll:',
'- aiTap: The trigger selection dropdown currently showing fn',
'- aiTap: Record a shortcut… option in the open trigger selection dropdown',
'- aiTap: Right-arrow Next button in the fixed top navigation',
'- aiTap: Left-arrow Previous button in the fixed top navigation',
]
: [],
`${file} must express visual interactions as task-level aiAct steps except for proven failures`,
);
assert.doesNotMatch(
source,
/^\s+-\s+wait:/gm,
`${file} must wait for a visible state with aiWaitFor instead of sleeping`,
);
}
});
test('captures both legacy and current Midscene report step lists', async () => {
const source = await readFile(
new URL('../e2e/capture-report-preview.mjs', import.meta.url),
'utf8',
);
assert.match(
source,
/\.runner-detail-step-group > button, .*\.runner-detail-step-list > button/,
);
assert.match(
source,
/\.runner-detail-step-group > button\.is-selected, .*\.runner-detail-step-list > button\.is-selected/,
);
assert.match(source, /waitUntil: 'domcontentloaded'/);
assert.match(source, /timeout: 120_000/);
});
function runnerScript({
assertionCount = 0,
assertionAttempts,
project,
status = 'success',
startedAt,
screenshotMode = 'inline',
}) {
const attempts =
assertionAttempts ??
(assertionCount
? [Array.from({ length: assertionCount }, () => 'success')]
: [[status === 'success' ? 'success' : 'failed']]);
const reportId = 'runner-report-1';
const executions = attempts.flatMap((statuses, attemptIndex) =>
statuses.map((stepStatus, stepIndex) => ({
id: `execution-${attemptIndex}-${stepIndex}`,
tasks: [
{
status: stepStatus === 'success' ? 'finished' : 'failed',
type: 'Insight',
subType: 'Assert',
uiContext: {
screenshot: {
id: `screenshot-${attemptIndex}-${stepIndex}`,
mimeType: 'image/jpeg',
storage: 'inline',
},
},
thought:
stepStatus === 'success'
? `AI explanation ${attemptIndex}-${stepIndex}`
: `AI failure explanation ${attemptIndex}-${stepIndex}`,
},
],
})),
);
const run = {
startedAt,
status,
summary: {
total: 1,
passed: status === 'success' ? 1 : 0,
failed: status === 'success' ? 0 : 1,
},
projects: [
{
name: project,
documents: [
{
cases: [
{
caseId: `case-${project}`,
name: `${project} visual case`,
status,
attempts: attempts.map((statuses, attemptIndex) => ({
status: statuses.every((item) => item === 'success')
? 'success'
: 'failed',
durationMs: 12000 + attemptIndex * 1000,
steps: statuses.map((stepStatus, stepIndex) => ({
id: `assert-${attemptIndex}-${stepIndex}`,
node: assertionCount || assertionAttempts ? 'aiAssert' : 'aiAct',
title: `Evidence ${attemptIndex}-${stepIndex}`,
status: stepStatus,
durationMs: 4000 + stepIndex * 500,
...(stepStatus === 'failed'
? {
error: {
message: `Fixture error ${attemptIndex}-${stepIndex}`,
},
}
: {}),
agentDetails: [{ reportId, executionId: `execution-${attemptIndex}-${stepIndex}` }],
})),
})),
},
],
},
],
},
],
};
return `<script type="midscene_web_dump" data-report-id="${reportId}"${
screenshotMode === 'directory'
? ' data-screenshot-mode="directory"'
: ''
}>${JSON.stringify({ executions })}</script>
${
screenshotMode === 'inline'
? attempts
.flatMap((statuses, attemptIndex) =>
statuses.map(
(_stepStatus, stepIndex) =>
`<script type="midscene-image" data-id="screenshot-${attemptIndex}-${stepIndex}">data:image/jpeg;base64,/9j/2Q==</script>`,
),
)
.join('\n')
: ''
}
<script type="midscene_test_run_dump">${JSON.stringify(run)}</script>`;
}
function runnerWithoutScreenshot({ project, startedAt }) {
const run = {
startedAt,
status: 'failed',
summary: { total: 2, passed: 0, failed: 1, notRun: 1 },
projects: [
{
name: project,
documents: [
{
cases: [
{
caseId: `case-${project}`,
name: `${project} damaged-agent case`,
status: 'failed',
attempts: [
{
status: 'failed',
durationMs: 480000,
steps: [
{
id: 'act-without-execution',
node: 'aiAct',
title: 'Timed-out action',
status: 'failed',
error: {
message:
'AI call hard timeout; no stable Agent execution reference was captured',
},
},
],
},
],
},
],
},
{
cases: [
{
caseId: `not-run-${project}`,
name: `${project} not-run case`,
status: 'not-run',
attempts: [],
},
],
},
],
},
],
};
return `<script type="midscene_test_run_dump">${JSON.stringify(run)}</script>`;
}
const fixtureHtml = `<!doctype html><html><body>report
<script type="midscene_web_dump">{"usage":{"_midscene_call_id":"call-1","time_cost":2500,"total_tokens":120}}</script>
<script type="midscene_web_dump">{"message":"raw
control character","usage":{"_midscene_call_id":"call-2","time_cost":3500,"total_tokens":180}}</script>
${runnerScript({ project: 'ubuntu', startedAt: '2026-09-15T12:00:00Z' })}
</body></html>`;
const shellPrompts = [
'The Omarchy system menu is open and Shutdown is readable.',
'Exactly one row in the open system menu is highlighted.',
'The Omarchy bar is visible on the left.',
];
const shellFixtureHtml = `<!doctype html><html><body>${shellPrompts
.map(
(prompt, index) => `
<script type="midscene_web_dump">${JSON.stringify({
executions: [
{
tasks: [
{
status: 'finished',
subType: 'Assert',
param: { dataDemand: prompt },
output: true,
uiContext: { screenshot: { id: `image-${index}` } },
},
],
},
],
})}</script>
<script type="midscene-image" data-id="image-${index}">data:image/jpeg;base64,/9j/2Q==</script>`,
)
.join('')}${runnerScript({ assertionCount: 3, project: 'omarchy-shell', startedAt: '2026-09-15T12:05:00Z' })}</body></html>`;
async function fixtureDirectory(root) {
const reportDirectory = path.join(root, 'artifact', 'report');
await mkdir(reportDirectory, { recursive: true });
await writeFile(path.join(reportDirectory, 'test-run-ubuntu.html'), fixtureHtml);
await writeFile(path.join(reportDirectory, 'agent-detail.html'), '<html>intermediate Agent report</html>');
await writeFile(path.join(path.dirname(reportDirectory), 'report-preview.png'), 'preview');
await writeFile(
path.join(path.dirname(reportDirectory), 'case-preview-ubuntu-case-ubuntu.jpg'),
'ubuntu case preview',
);
return path.dirname(reportDirectory);
}
async function startServer(handler) {
const server = http.createServer(handler);
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
const address = server.address();
return {
url: `http://127.0.0.1:${address.port}/`,
close: () => new Promise((resolve) => server.close(resolve)),
};
}
function options(reportDirectory, siteDirectory, pagesUrl, runId = '200') {
return {
'report-dir': reportDirectory,
'site-dir': siteDirectory,
'run-id': runId,
'workflow-url': `https://github.com/quanru/doubao-say/actions/runs/${runId}`,
'generated-at': '2026-09-15T12:00:00Z',
retention: '10',
'pages-url': pagesUrl,
label: 'Ubuntu 22.04',
'primary-project': 'ubuntu',
};
}
test('simulates a first deployment when Pages returns 404', async (context) => {
const root = await mkdtemp(path.join(os.tmpdir(), 'pages-first-'));
const reportDirectory = await fixtureDirectory(root);
const siteDirectory = path.join(root, 'site');
const server = await startServer((_request, response) => {
response.writeHead(404).end();
});
context.after(server.close);
const manifest = await buildPagesReport({
...options(reportDirectory, siteDirectory, server.url),
'auxiliary-project': 'ubuntu-polishing',
'auxiliary-report-label': 'Polishing overlay report',
});
assert.equal(manifest.reports.length, 1);
assert.equal(manifest.reports[0].runId, '200');
assert.equal(manifest.reports[0].reportPath, 'reports/200/index.html');
assert.equal(manifest.reports[0].successRate, 100);
assert.equal(manifest.reports[0].averageDurationMs, 3000);
assert.equal(manifest.reports[0].modelCallCount, 2);
assert.equal(manifest.reports[0].tokenUsage, 300);
const indexHtml = await readFile(
path.join(siteDirectory, 'index.html'),
'utf8',
);
assert.match(indexHtml, /Run ID/);
assert.match(indexHtml, /Distribution/);
assert.match(indexHtml, /Ubuntu 22\.04/);
const runIndex = await readFile(
path.join(siteDirectory, 'reports', '200', 'index.html'),
'utf8',
);
assert.match(runIndex, /Node screenshot/);
assert.match(runIndex, /AI response \/ error/);
assert.match(runIndex, /ubuntu visual case/);
assert.match(
runIndex,
/native-report\.html#runner-step=assert-0-0/,
);
assert.equal(
await readFile(
path.join(siteDirectory, 'reports', '200', 'native-report.html'),
'utf8',
),
fixtureHtml,
);
assert.deepEqual(manifest.reports[0].files, [
'reports/200/index.html',
'reports/200/native-report.html',
'reports/200/report-preview.png',
'reports/200/case-preview-ubuntu-case-ubuntu.jpg',
]);
assert.equal(manifest.reports[0].entries.length, 1);
assert.equal(
await readFile(
path.join(siteDirectory, 'reports', '200', 'report-preview.png'),
'utf8',
),
'preview',
);
});
test('publishes 1.13.0 directory-mode screenshots next to the native report', async (context) => {
const root = await mkdtemp(path.join(os.tmpdir(), 'pages-directory-'));
const reportRoot = path.join(root, 'artifact');
const htmlDirectory = path.join(
reportRoot,
'report',
'midscene-e2e-20260921045854-d9ab4bd0',
);
await mkdir(path.join(htmlDirectory, 'screenshots'), {
recursive: true,
});
const html = runnerScript({
project: 'ubuntu',
startedAt: '2026-09-15T12:00:00Z',
screenshotMode: 'directory',
});
await writeFile(path.join(htmlDirectory, 'index.html'), html);
await writeFile(
path.join(htmlDirectory, 'screenshots', 'screenshot-0-0.jpeg'),
'directory screenshot bytes',
);
// 1.13.0 also writes standalone computer-*.html agent reports without a
// runner dump; they must not be treated as undeclared report projects.
await writeFile(
path.join(reportRoot, 'report', 'computer-2026-09-21_04-58-55.html'),
'<html>standalone computer agent report</html>',
);
await writeFile(
path.join(reportRoot, 'report-preview.png'),
'preview',
);
await writeFile(
path.join(reportRoot, 'case-preview-ubuntu-case-ubuntu.jpg'),
'ubuntu case preview',
);
const siteDirectory = path.join(root, 'site');
const server = await startServer((_request, response) => {
response.writeHead(404).end();
});
context.after(server.close);
const manifest = await buildPagesReport(
options(reportRoot, siteDirectory, server.url),
);
assert.equal(
await readFile(
path.join(
siteDirectory,
'reports',
'200',
'screenshots',
'screenshot-0-0.jpeg',
),
'utf8',
),
'directory screenshot bytes',
);
assert.ok(
manifest.reports[0].files.includes(
'reports/200/screenshots/screenshot-0-0.jpeg',
),
);
assert.deepEqual(manifest.reports[0].files, [
'reports/200/index.html',
'reports/200/native-report.html',
'reports/200/report-preview.png',
'reports/200/case-preview-ubuntu-case-ubuntu.jpg',
'reports/200/screenshots/screenshot-0-0.jpeg',
]);
});
test('combines independently executed shards into one report table', async (context) => {
const root = await mkdtemp(path.join(os.tmpdir(), 'pages-shards-'));
const reportDirectory = path.join(root, 'bundle');
for (const project of ['ubuntu-shard-1', 'ubuntu-shard-2']) {
const shardDirectory = path.join(reportDirectory, project);
const htmlDirectory = path.join(shardDirectory, 'report');
await mkdir(htmlDirectory, { recursive: true });
await writeFile(
path.join(htmlDirectory, `test-run-${project}.html`),
runnerScript({ project, startedAt: '2026-09-15T12:00:00Z' }),
);
await writeFile(
path.join(shardDirectory, `report-preview-${project}.png`),
`${project} preview`,
);
await writeFile(
path.join(
shardDirectory,
`case-preview-${project}-case-${project}.jpg`,
),
`${project} case preview`,
);
}
const siteDirectory = path.join(root, 'site');
const server = await startServer((_request, response) =>
response.writeHead(404).end(),
);
context.after(server.close);
const manifest = await buildPagesReport({
...options(reportDirectory, siteDirectory, server.url),
'report-groups': JSON.stringify([
{
role: 'primary',
label: 'Doubao Say',
projects: ['ubuntu-shard-1', 'ubuntu-shard-2'],
},
]),
});
const [entry] = manifest.reports[0].entries;
assert.deepEqual(entry.projects, ['ubuntu-shard-1', 'ubuntu-shard-2']);
assert.equal(entry.cases.length, 2);
assert.equal(entry.scenarios.total, 2);
assert.notEqual(entry.cases[0].reportPath, entry.cases[1].reportPath);
const runIndex = await readFile(
path.join(siteDirectory, 'reports', '200', 'index.html'),
'utf8',
);
assert.match(
runIndex,
/native-report-ubuntu-shard-1\.html#runner-step=assert-0-0/,
);
assert.match(
runIndex,
/native-report-ubuntu-shard-2\.html#runner-step=assert-0-0/,
);
const summary = renderReportSummary({
manifest,
pagesUrl: 'https://example.test/doubao-say/',
producerResult: 'success',
runId: '200',
summaryTitle: 'Ubuntu',
});
assert.match(
summary,
/native-report-ubuntu-shard-1\.html#runner-step=assert-0-0/,
);
assert.match(
summary,
/native-report-ubuntu-shard-2\.html#runner-step=assert-0-0/,
);
assert.match(summary, /\| ubuntu-shard-1 \| \[ubuntu-shard-1 visual case\]/);
assert.match(summary, /\| ubuntu-shard-2 \| \[ubuntu-shard-2 visual case\]/);
});
test('keeps a complete Markdown table when a shard produces no native report', async (context) => {
const root = await mkdtemp(path.join(os.tmpdir(), 'pages-partial-shards-'));
const reportDirectory = path.join(root, 'reports');
const shardDirectory = path.join(reportDirectory, 'ubuntu-shard-1');
await mkdir(path.join(shardDirectory, 'report'), { recursive: true });
await writeFile(
path.join(shardDirectory, 'report', 'test-run-ubuntu-shard-1.html'),
runnerScript({
project: 'ubuntu-shard-1',
startedAt: '2026-09-15T12:00:00Z',
}),
);
await writeFile(
path.join(shardDirectory, 'report-preview-ubuntu-shard-1.png'),
'preview',
);
await writeFile(
path.join(
shardDirectory,
'case-preview-ubuntu-shard-1-case-ubuntu-shard-1.jpg',
),
'case preview',
);
await writeFile(
path.join(shardDirectory, 'ci-shard-status-ubuntu-shard-2.json'),
JSON.stringify({
project: 'ubuntu-shard-2',
result: 'failure',
stage: 'workflow setup before test execution',
}),
);
const siteDirectory = path.join(root, 'site');
const server = await startServer((_request, response) =>
response.writeHead(404).end(),
);
context.after(server.close);
const manifest = await buildPagesReport({
...options(reportDirectory, siteDirectory, server.url),
'report-groups': JSON.stringify([
{
role: 'primary',
label: 'Doubao Say',
projects: ['ubuntu-shard-1', 'ubuntu-shard-2'],
},
]),
});
const [entry] = manifest.reports[0].entries;
assert.equal(entry.cases.length, 2);
assert.equal(entry.cases[1].selection, 'workflow-failure');
assert.match(entry.cases[1].description, /workflow setup/);
await readFile(
path.join(
siteDirectory,
'reports',
'200',
'shard-failure-ubuntu-shard-2.svg',
),
);
const summary = renderReportSummary({
manifest,
pagesUrl: 'https://example.test/doubao-say/',
producerResult: 'failure',
runId: '200',
summaryTitle: 'Ubuntu',
});
assert.match(summary, /ubuntu-shard-1 visual case/);
assert.match(summary, /ubuntu-shard-2 CI shard/);
assert.match(summary, /CI failure before node capture/);
assert.match(summary, /workflow setup before test execution/);
assert.doesNotMatch(summary, /runner-step=.*infrastructure-ubuntu-shard-2/);
});
test('uses a failure row when node evidence extraction fails', async (context) => {
const root = await mkdtemp(path.join(os.tmpdir(), 'pages-capture-failed-'));
const reportDirectory = await fixtureDirectory(root);
await writeFile(
path.join(reportDirectory, 'ci-shard-status-ubuntu.json'),
JSON.stringify({
project: 'ubuntu',
result: 'failure',
stage: 'report evidence capture',
testOutcome: 'success',
captureOutcome: 'failure',
}),
);
const siteDirectory = path.join(root, 'site');
const server = await startServer((_request, response) =>
response.writeHead(404).end(),
);
context.after(server.close);
const manifest = await buildPagesReport({
...options(reportDirectory, siteDirectory, server.url),
'report-groups': JSON.stringify([
{ role: 'primary', label: 'Doubao Say', projects: ['ubuntu'] },
]),
});
const [testCase] = manifest.reports[0].entries[0].cases;
assert.equal(testCase.selection, 'workflow-failure');
assert.match(testCase.description, /report evidence capture/);
});
test('publishes the Doubao Say report as the primary CI entrance', async (context) => {
const root = await mkdtemp(path.join(os.tmpdir(), 'pages-omarchy-'));
const reportDirectory = await fixtureDirectory(root);
await writeFile(
path.join(reportDirectory, 'report', 'test-run-shell.html'),
shellFixtureHtml,
);
await writeFile(path.join(reportDirectory, 'report-preview.png'), 'preview');
await writeFile(
path.join(reportDirectory, 'auxiliary-report-preview.png'),
'auxiliary preview',
);
await writeFile(
path.join(reportDirectory, 'case-preview-omarchy-shell-case-omarchy-shell.jpg'),
'shell case preview',
);
const siteDirectory = path.join(root, 'site');
const server = await startServer((_request, response) =>
response.writeHead(404).end(),
);
context.after(server.close);
const manifest = await buildPagesReport({
...options(reportDirectory, siteDirectory, server.url),
'auxiliary-project': 'omarchy-shell',
'auxiliary-report-label': 'Omarchy visual checks',
});
assert.equal(manifest.reports[0].testCount, 2);
assert.equal(manifest.reports[0].successRate, 100);
assert.deepEqual(manifest.reports[0].entries, [
{
role: 'primary',
project: 'ubuntu',
label: 'Doubao Say',
status: 'success',
previewStep: 'last',
reportPath: 'reports/200/native-report.html',
previewPath: 'reports/200/report-preview.png',
scenarios: { passed: 1, total: 1 },
assertions: { passed: 0, total: 0 },
cases: [
{
caseId: 'case-ubuntu',
name: 'ubuntu visual case',
status: 'success',
durationMs: 12000,
stepId: 'assert-0-0',
selection: 'last-screenshot',
description: 'AI explanation 0-0',
descriptionKind: 'ai',
previewPath: 'reports/200/case-preview-ubuntu-case-ubuntu.jpg',
},
],
},
{
role: 'auxiliary',
project: 'omarchy-shell',
label: 'Omarchy visual checks',
status: 'success',
previewStep: 'last',
reportPath: 'reports/200/auxiliary-report.html',
previewPath: 'reports/200/auxiliary-report-preview.png',
scenarios: { passed: 1, total: 1 },
assertions: { passed: 3, total: 3 },
cases: [
{
caseId: 'case-omarchy-shell',
name: 'omarchy-shell visual case',
status: 'success',
durationMs: 12000,
stepId: 'assert-0-2',
selection: 'last-screenshot',
description: 'AI explanation 0-2',
descriptionKind: 'ai',
previewPath:
'reports/200/case-preview-omarchy-shell-case-omarchy-shell.jpg',
},
],
},
]);
assert.deepEqual(manifest.reports[0].files, [
'reports/200/index.html',
'reports/200/native-report.html',
'reports/200/auxiliary-report.html',
'reports/200/report-preview.png',
'reports/200/auxiliary-report-preview.png',
'reports/200/case-preview-ubuntu-case-ubuntu.jpg',
'reports/200/case-preview-omarchy-shell-case-omarchy-shell.jpg',
]);
const publishedIndex = await readFile(
path.join(siteDirectory, 'reports', '200', 'index.html'),
'utf8',
);
assert.match(publishedIndex, /Doubao Say/);
assert.match(publishedIndex, /Omarchy visual checks/);
assert.match(publishedIndex, /AI response \/ error/);
assert.equal(
await readFile(
path.join(siteDirectory, 'reports', '200', 'native-report.html'),
'utf8',
),
fixtureHtml,
);
assert.equal(
await readFile(
path.join(siteDirectory, 'reports', '200', 'auxiliary-report.html'),
'utf8',
),
shellFixtureHtml,
);
assert.equal(
await readFile(
path.join(siteDirectory, 'reports', '200', 'report-preview.png'),
'utf8',
),
'preview',
);
assert.equal(
await readFile(
path.join(
siteDirectory,
'reports',
'200',
'auxiliary-report-preview.png',
),
'utf8',
),
'auxiliary preview',
);
});
test('reports visual assertions from the final retry attempt only', async (context) => {
const root = await mkdtemp(path.join(os.tmpdir(), 'pages-retry-'));
const reportDirectory = path.join(root, 'artifact', 'report');
await mkdir(reportDirectory, { recursive: true });
const retriedReport = `<!doctype html><html><body>${runnerScript({
assertionAttempts: [['failed'], ['success', 'success']],
project: 'ubuntu',
startedAt: '2026-09-15T12:00:00Z',
})}</body></html>`;
await writeFile(
path.join(reportDirectory, 'test-run-retried.html'),
retriedReport,
);
await writeFile(
path.join(path.dirname(reportDirectory), 'report-preview.png'),
'preview',
);
await writeFile(
path.join(
path.dirname(reportDirectory),
'case-preview-ubuntu-case-ubuntu.jpg',
),
'retry preview',
);
const siteDirectory = path.join(root, 'site');
const server = await startServer((_request, response) =>
response.writeHead(404).end(),
);
context.after(server.close);
const manifest = await buildPagesReport(
options(path.dirname(reportDirectory), siteDirectory, server.url),
);
assert.deepEqual(manifest.reports[0].entries[0].assertions, {
passed: 2,
total: 2,
});
});
test('publishes a failed shell report with its result in history', async (context) => {
const root = await mkdtemp(path.join(os.tmpdir(), 'pages-failed-'));
const reportDirectory = await fixtureDirectory(root);
await writeFile(
path.join(reportDirectory, 'report', 'test-run-shell.html'),
shellFixtureHtml
.replace('"output":true', '"output":false')
.replace(
'"status":"success","summary":{"total":1,"passed":1,"failed":0}',
'"status":"failed","summary":{"total":1,"passed":0,"failed":1}',
),
);
await writeFile(path.join(reportDirectory, 'report-preview.png'), 'failed');
await writeFile(
path.join(reportDirectory, 'auxiliary-report-preview.png'),
'auxiliary failed',
);
await writeFile(
path.join(
reportDirectory,
'case-preview-omarchy-shell-case-omarchy-shell.jpg',
),
'shell failure preview',
);
const siteDirectory = path.join(root, 'site');
const server = await startServer((_request, response) =>
response.writeHead(404).end(),
);
context.after(server.close);