@camunda/e2e-test-suite 0.0.1146 → 0.0.1147
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/test-setup.js +60 -7
- package/package.json +1 -1
package/dist/test-setup.js
CHANGED
|
@@ -16,7 +16,64 @@ async function captureScreenshot(page, testInfo) {
|
|
|
16
16
|
if (testInfo.status === 'passed' || testInfo.status === 'skipped') {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
// Capture every open tab, not just the one handed in. Flows that reach
|
|
20
|
+
// Operate/Tasklist through a link (openAppTabWithRetry) assert against a
|
|
21
|
+
// second Page, so capturing only `page` attaches a picture of the tab the
|
|
22
|
+
// test had already left: a doc-handling failure asserting the Operate
|
|
23
|
+
// completed-icon attached the Modeler canvas instead, which is unusable for
|
|
24
|
+
// triage.
|
|
25
|
+
let targets = [page];
|
|
26
|
+
try {
|
|
27
|
+
targets = [
|
|
28
|
+
page,
|
|
29
|
+
...page
|
|
30
|
+
.context()
|
|
31
|
+
.pages()
|
|
32
|
+
.filter((candidate) => candidate !== page && !candidate.isClosed()),
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
catch (contextError) {
|
|
36
|
+
console.warn(`captureScreenshot: could not enumerate context pages (${contextError}). ` +
|
|
37
|
+
'Capturing the handed-in page only.');
|
|
38
|
+
}
|
|
39
|
+
let extraTabIndex = 1;
|
|
40
|
+
for (const target of targets) {
|
|
41
|
+
const screenshotPath = `test-results/screenshots/screenshot-${(0, crypto_1.randomUUID)()}.png`;
|
|
42
|
+
const isPrimaryTab = target === page;
|
|
43
|
+
let captured = false;
|
|
44
|
+
if (isPrimaryTab) {
|
|
45
|
+
captured = await screenshotWithViewportFallback(target, screenshotPath);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
try {
|
|
49
|
+
await target.screenshot({ path: screenshotPath, timeout: 30000 });
|
|
50
|
+
captured = true;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.warn(`captureScreenshot: extra-tab viewport capture failed (${error}). ` +
|
|
54
|
+
'Continuing without a screenshot; the test verdict is unaffected.');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!captured) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const attachmentName = isPrimaryTab
|
|
61
|
+
? 'screenshot'
|
|
62
|
+
: `screenshot-tab-${extraTabIndex++}`;
|
|
63
|
+
try {
|
|
64
|
+
await testInfo.attach(attachmentName, {
|
|
65
|
+
path: screenshotPath,
|
|
66
|
+
contentType: 'image/png',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.warn(`captureScreenshot: failed to attach ${attachmentName} (${error}). ` +
|
|
71
|
+
'Continuing without the attachment; the test verdict is unaffected.');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.captureScreenshot = captureScreenshot;
|
|
76
|
+
async function screenshotWithViewportFallback(page, screenshotPath) {
|
|
20
77
|
try {
|
|
21
78
|
await page.screenshot({
|
|
22
79
|
path: screenshotPath,
|
|
@@ -33,15 +90,11 @@ async function captureScreenshot(page, testInfo) {
|
|
|
33
90
|
catch (viewportError) {
|
|
34
91
|
console.warn(`captureScreenshot: viewport capture also failed (${viewportError}). ` +
|
|
35
92
|
'Continuing without a screenshot; the test verdict is unaffected.');
|
|
36
|
-
return;
|
|
93
|
+
return false;
|
|
37
94
|
}
|
|
38
95
|
}
|
|
39
|
-
|
|
40
|
-
path: screenshotPath,
|
|
41
|
-
contentType: 'image/png',
|
|
42
|
-
});
|
|
96
|
+
return true;
|
|
43
97
|
}
|
|
44
|
-
exports.captureScreenshot = captureScreenshot;
|
|
45
98
|
async function captureFailureVideo(page, testInfo) {
|
|
46
99
|
// Same policy as captureScreenshot above: skip on passed/skipped rather
|
|
47
100
|
// than requiring literally 'failed', so timed-out/interrupted tests keep
|