@orion-qa/orion 3.3.0 → 3.4.1
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/.claude/skills/appium/SKILL.md +2 -2
- package/.claude/skills/appium/templates/ci/github-actions-android.yml +1 -1
- package/.claude/skills/appium/templates/ci/github-actions-ios.yml +1 -1
- package/.claude/skills/appium/templates/ci/github-actions-windows.yml +1 -1
- package/.claude/skills/automation-implementation/SKILL.md +2 -2
- package/.claude/skills/automation-strategy/SKILL.md +1 -0
- package/.claude/skills/cicd-integration/SKILL.md +1 -1
- package/.claude/skills/code-review/SKILL.md +1 -1
- package/.claude/skills/code-review/references/pattern-rules.md +1 -0
- package/.claude/skills/csharp/SKILL.md +1 -0
- package/.claude/skills/documentation/SKILL.md +1 -1
- package/.claude/skills/execution/SKILL.md +8 -8
- package/.claude/skills/failure-analysis/SKILL.md +1 -0
- package/.claude/skills/failure-analysis/references/bug-report-standard.md +27 -0
- package/.claude/skills/httpclient/templates/ci/github-actions.yml +2 -2
- package/.claude/skills/java/SKILL.md +1 -0
- package/.claude/skills/javascript/SKILL.md +1 -0
- package/.claude/skills/junit5/SKILL.md +1 -1
- package/.claude/skills/k6/SKILL.md +1 -1
- package/.claude/skills/k6/templates/project/tests/load/products.js +1 -1
- package/.claude/skills/karate/SKILL.md +1 -1
- package/.claude/skills/karate/templates/ci/github-actions.yml +2 -2
- package/.claude/skills/newman/templates/ci/github-actions.yml +2 -2
- package/.claude/skills/newman/templates/collection/src/config/env.js +1 -1
- package/.claude/skills/nunit/SKILL.md +1 -1
- package/.claude/skills/orion/SKILL.md +1 -1
- package/.claude/skills/orion/references/assess-fix.md +1 -1
- package/.claude/skills/orion/references/batch.md +1 -1
- package/.claude/skills/orion/references/capabilities.md +1 -1
- package/.claude/skills/orion/references/conversation.md +4 -4
- package/.claude/skills/orion/references/modes.md +1 -1
- package/.claude/skills/orion/references/plain-language.md +3 -2
- package/.claude/skills/orion/references/recovery-loop.md +2 -2
- package/.claude/skills/orion/references/setup-card.md +1 -1
- package/.claude/skills/orion/references/status-lines.md +4 -4
- package/.claude/skills/orion/references/task-brief.md +1 -1
- package/.claude/skills/orion/scripts/batch_state.mjs +1 -1
- package/.claude/skills/orion/scripts/done_check.mjs +7 -5
- package/.claude/skills/orion/scripts/quiet.mjs +1 -1
- package/.claude/skills/orion/templates/project-context/report.md +2 -2
- package/.claude/skills/pact/SKILL.md +1 -1
- package/.claude/skills/playwright/SKILL.md +2 -2
- package/.claude/skills/playwright/references/electron.md +1 -1
- package/.claude/skills/playwright/templates/README.md +1 -1
- package/.claude/skills/playwright/templates/ci/azure-pipelines.yml +1 -1
- package/.claude/skills/playwright/templates/ci/github-actions-dotnet.yml +2 -2
- package/.claude/skills/playwright/templates/ci/github-actions-javascript.yml +2 -2
- package/.claude/skills/playwright/templates/ci/github-actions-python.yml +2 -2
- package/.claude/skills/playwright/templates/ci/github-actions.yml +1 -1
- package/.claude/skills/playwright/templates/javascript/.prettierignore +6 -0
- package/.claude/skills/playwright/templates/javascript/.prettierrc.json +4 -0
- package/.claude/skills/playwright/templates/javascript/fixtures/index.js +56 -48
- package/.claude/skills/playwright/templates/javascript/package.json +4 -1
- package/.claude/skills/playwright/templates/javascript/pageObjects/basePage.js +5 -1
- package/.claude/skills/playwright/templates/javascript/playwright.config.js +6 -2
- package/.claude/skills/playwright/templates/javascript/reporters/summaryReporter.js +80 -17
- package/.claude/skills/playwright/templates/javascript/resources/desc/signIn.desc.js +10 -3
- package/.claude/skills/playwright/templates/javascript/src/config/env.js +12 -3
- package/.claude/skills/playwright/templates/javascript/src/config/flags.js +3 -1
- package/.claude/skills/playwright/templates/javascript/tests/api/session.spec.js +8 -4
- package/.claude/skills/playwright/templates/javascript/tests/unit/summaryReporter.test.js +30 -6
- package/.claude/skills/playwright/templates/javascript/utils/random.js +3 -1
- package/.claude/skills/playwright/templates/project/.prettierignore +6 -0
- package/.claude/skills/playwright/templates/project/.prettierrc.json +4 -0
- package/.claude/skills/playwright/templates/project/fixtures/index.ts +21 -15
- package/.claude/skills/playwright/templates/project/fixtures/session.ts +9 -2
- package/.claude/skills/playwright/templates/project/package.json +4 -1
- package/.claude/skills/playwright/templates/project/pageObjects/basePage.ts +5 -1
- package/.claude/skills/playwright/templates/project/playwright.config.ts +4 -2
- package/.claude/skills/playwright/templates/project/reporters/summaryReporter.ts +84 -17
- package/.claude/skills/playwright/templates/project/resources/desc/signIn.desc.ts +10 -3
- package/.claude/skills/playwright/templates/project/src/config/env.ts +15 -4
- package/.claude/skills/playwright/templates/project/src/services/apiClient.ts +5 -1
- package/.claude/skills/playwright/templates/project/tests/api/session.spec.ts +8 -4
- package/.claude/skills/playwright/templates/project/tests/unit/summaryReporter.test.ts +30 -6
- package/.claude/skills/playwright/templates/project/utils/formFill.ts +4 -1
- package/.claude/skills/playwright/templates/project/utils/random.ts +3 -1
- package/.claude/skills/playwright/templates/project/utils/redact.ts +4 -1
- package/.claude/skills/pytest/SKILL.md +1 -1
- package/.claude/skills/python/SKILL.md +1 -0
- package/.claude/skills/quality-checks/SKILL.md +1 -1
- package/.claude/skills/requests/templates/ci/github-actions.yml +2 -2
- package/.claude/skills/rest-assured/SKILL.md +2 -2
- package/.claude/skills/rest-assured/templates/ci/github-actions.yml +2 -2
- package/.claude/skills/selenium/SKILL.md +1 -1
- package/.claude/skills/selenium/templates/ci/github-actions-csharp.yml +2 -2
- package/.claude/skills/selenium/templates/ci/github-actions-java.yml +2 -2
- package/.claude/skills/selenium/templates/ci/github-actions-python.yml +2 -2
- package/.claude/skills/self-healing/SKILL.md +1 -1
- package/.claude/skills/test-design/SKILL.md +2 -1
- package/.claude/skills/test-design/references/test-case-standard.md +31 -0
- package/.claude/skills/test-reporting/references/report-levels.md +1 -1
- package/.claude/skills/test-reporting/references/tool-mapping.md +1 -1
- package/.claude/skills/testng/SKILL.md +1 -1
- package/.claude/skills/typescript/SKILL.md +1 -0
- package/.claude/skills/ui-observation/SKILL.md +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +8 -7
- package/assets/architecture.svg +1 -1
- package/assets/run-flow.svg +1 -1
- package/bin/orion.mjs +6 -6
- package/hosts/gemini-extension/gemini-extension.json +1 -1
- package/package.json +2 -2
|
@@ -35,7 +35,10 @@ const SUPPORT_PROJECTS = new Set(['setup', 'teardown']);
|
|
|
35
35
|
* @returns {string} Safe HTML text.
|
|
36
36
|
*/
|
|
37
37
|
function esc(s) {
|
|
38
|
-
return String(s).replace(
|
|
38
|
+
return String(s).replace(
|
|
39
|
+
/[&<>"']/g,
|
|
40
|
+
(c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c] || c,
|
|
41
|
+
);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
/**
|
|
@@ -71,12 +74,31 @@ function verdictOf(rows, support = []) {
|
|
|
71
74
|
const n = (o) => rows.filter((r) => r.outcome === o).length;
|
|
72
75
|
const [failed, flaky, skipped, passed] = [n('failed'), n('flaky'), n('skipped'), n('passed')];
|
|
73
76
|
const setup = support.find((r) => r.outcome === 'failed');
|
|
74
|
-
if (setup)
|
|
77
|
+
if (setup)
|
|
78
|
+
return {
|
|
79
|
+
mark: '❌',
|
|
80
|
+
label: 'Setup failed',
|
|
81
|
+
sentence: `${setup.title || 'The setup'} failed, so the tests that need it didn't run; ${passed} other tests passed.`,
|
|
82
|
+
tone: 'bad',
|
|
83
|
+
};
|
|
75
84
|
if (!rows.length) return { mark: '⚠️', label: 'Nothing ran', sentence: 'No tests matched this run.', tone: 'warn' };
|
|
76
|
-
if (failed)
|
|
85
|
+
if (failed)
|
|
86
|
+
return {
|
|
87
|
+
mark: '❌',
|
|
88
|
+
label: 'Failed',
|
|
89
|
+
sentence: `${failed} of ${rows.length} tests failed; ${passed} passed.`,
|
|
90
|
+
tone: 'bad',
|
|
91
|
+
};
|
|
77
92
|
if (flaky || skipped) {
|
|
78
|
-
const parts = [flaky && `${flaky} passed only on a retry`, skipped && `${skipped} skipped`]
|
|
79
|
-
|
|
93
|
+
const parts = [flaky && `${flaky} passed only on a retry`, skipped && `${skipped} skipped`]
|
|
94
|
+
.filter(Boolean)
|
|
95
|
+
.join(', ');
|
|
96
|
+
return {
|
|
97
|
+
mark: '⚠️',
|
|
98
|
+
label: 'Passed, with notes',
|
|
99
|
+
sentence: `${passed} of ${rows.length} tests passed; ${parts}.`,
|
|
100
|
+
tone: 'warn',
|
|
101
|
+
};
|
|
80
102
|
}
|
|
81
103
|
return { mark: '✅', label: 'All passed', sentence: `All ${rows.length} tests passed.`, tone: 'good' };
|
|
82
104
|
}
|
|
@@ -91,7 +113,9 @@ function renderSummary(run) {
|
|
|
91
113
|
const order = { failed: 0, flaky: 1, skipped: 2, passed: 3 };
|
|
92
114
|
const MARK = { passed: '✅', failed: '❌', flaky: '⚠️', skipped: '⏭' };
|
|
93
115
|
const groups = new Map();
|
|
94
|
-
for (const r of [...run.rows].sort(
|
|
116
|
+
for (const r of [...run.rows].sort(
|
|
117
|
+
(a, b) => order[a.outcome] - order[b.outcome] || a.id.localeCompare(b.id, 'en', { numeric: true }),
|
|
118
|
+
)) {
|
|
95
119
|
const key = r.story || r.file.split(':')[0];
|
|
96
120
|
if (!groups.has(key)) groups.set(key, []);
|
|
97
121
|
groups.get(key).push(r);
|
|
@@ -109,12 +133,17 @@ function renderSummary(run) {
|
|
|
109
133
|
<td class="num">${duration(r.durationMs)}${r.attempts > 1 ? ` <span class="muted">· ${r.attempts} tries</span>` : ''}</td>
|
|
110
134
|
</tr>`;
|
|
111
135
|
// Story cases first, then framework and unit checks (grouped by file).
|
|
112
|
-
const sections = [...groups]
|
|
136
|
+
const sections = [...groups]
|
|
137
|
+
.sort(([, a], [, b]) => Number(!a[0].story) - Number(!b[0].story))
|
|
138
|
+
.map(
|
|
139
|
+
([key, rows]) => `
|
|
113
140
|
<section>
|
|
114
141
|
<h2>${esc(key)} <span class="muted">${rows.filter((r) => r.outcome === 'passed').length}/${rows.length} passed</span></h2>
|
|
115
142
|
<div class="scroll"><table><thead><tr><th></th><th>Test</th><th>Project</th><th class="num">Time</th></tr></thead><tbody>${rows.map(row).join('')}
|
|
116
143
|
</tbody></table></div>
|
|
117
|
-
</section
|
|
144
|
+
</section>`,
|
|
145
|
+
)
|
|
146
|
+
.join('');
|
|
118
147
|
return `<!doctype html>
|
|
119
148
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
120
149
|
<title>Test run · ${esc(run.startedAt.toISOString().slice(0, 10))}</title>
|
|
@@ -196,20 +225,37 @@ class SummaryReporter {
|
|
|
196
225
|
const outcome = test.outcome();
|
|
197
226
|
const parts = parseTitle(test.title);
|
|
198
227
|
const failedRun = [...results].reverse().find((r) => r.status !== 'passed' && r.status !== 'skipped');
|
|
199
|
-
const message = failedRun && failedRun.error ?
|
|
200
|
-
const links =
|
|
201
|
-
|
|
202
|
-
|
|
228
|
+
const message = failedRun && failedRun.error ? failedRun.error.message || failedRun.error.value || '' : '';
|
|
229
|
+
const links =
|
|
230
|
+
outcome === 'unexpected' && failedRun
|
|
231
|
+
? failedRun.attachments
|
|
232
|
+
.filter((a) => a.path && /screenshot|trace/.test(a.name))
|
|
233
|
+
.map((a) => ({
|
|
234
|
+
name: a.name,
|
|
235
|
+
href: path
|
|
236
|
+
.relative(dir, /** @type {string} */ (a.path))
|
|
237
|
+
.split(path.sep)
|
|
238
|
+
.join('/'),
|
|
239
|
+
}))
|
|
240
|
+
: [];
|
|
203
241
|
return {
|
|
204
242
|
...parts,
|
|
205
243
|
acs: test.tags.filter((t) => /^@AC-/.test(t)).map((t) => t.slice(1)),
|
|
206
244
|
project: test.parent.project()?.name || '',
|
|
207
245
|
file: `${path.relative(paths.root, test.location.file).split(path.sep).join('/')}:${test.location.line}`,
|
|
208
|
-
outcome: /** @type {Row['outcome']} */ (
|
|
246
|
+
outcome: /** @type {Row['outcome']} */ (
|
|
247
|
+
{ expected: 'passed', unexpected: 'failed', flaky: 'flaky', skipped: 'skipped' }[outcome]
|
|
248
|
+
),
|
|
209
249
|
durationMs: last ? last.duration : 0,
|
|
210
250
|
attempts: results.length,
|
|
211
251
|
// eslint-disable-next-line no-control-regex
|
|
212
|
-
error:
|
|
252
|
+
error:
|
|
253
|
+
outcome === 'unexpected'
|
|
254
|
+
? redact(message.replace(/\u001b\[[0-9;]*m/g, ''))
|
|
255
|
+
.split('\n')
|
|
256
|
+
.slice(0, 12)
|
|
257
|
+
.join('\n')
|
|
258
|
+
: '',
|
|
213
259
|
links,
|
|
214
260
|
};
|
|
215
261
|
});
|
|
@@ -217,7 +263,17 @@ class SummaryReporter {
|
|
|
217
263
|
const support = all.filter((r) => SUPPORT_PROJECTS.has(r.project));
|
|
218
264
|
const projects = [...new Set(rows.map((r) => r.project))];
|
|
219
265
|
fs.mkdirSync(dir, { recursive: true });
|
|
220
|
-
fs.writeFileSync(
|
|
266
|
+
fs.writeFileSync(
|
|
267
|
+
this.outputFile,
|
|
268
|
+
renderSummary({
|
|
269
|
+
rows,
|
|
270
|
+
support,
|
|
271
|
+
startedAt: this.startedAt,
|
|
272
|
+
durationMs: full.duration,
|
|
273
|
+
baseUrl: this.baseUrl,
|
|
274
|
+
projects,
|
|
275
|
+
}),
|
|
276
|
+
);
|
|
221
277
|
// The same run as data, next to the page: every run (yours, CI's or an agent's) leaves results a script can read
|
|
222
278
|
// (Orion's results_parse.mjs), so nothing has to run again just to get a machine-readable report.
|
|
223
279
|
const data = {
|
|
@@ -227,8 +283,15 @@ class SummaryReporter {
|
|
|
227
283
|
// `all` was built from the same entries in the same order: match by position, since tests made in a loop share a line.
|
|
228
284
|
tests: [...this.results].map(([test, results], i) => {
|
|
229
285
|
const r = all[i];
|
|
230
|
-
return {
|
|
231
|
-
|
|
286
|
+
return {
|
|
287
|
+
title: test.title,
|
|
288
|
+
file: r ? r.file : '',
|
|
289
|
+
project: r ? r.project : '',
|
|
290
|
+
status: r ? r.outcome : 'failed',
|
|
291
|
+
duration_ms: r ? r.durationMs : 0,
|
|
292
|
+
attempts: results.length,
|
|
293
|
+
failure_sig: r && r.error ? r.error.split('\n')[0].slice(0, 200) : null,
|
|
294
|
+
};
|
|
232
295
|
}),
|
|
233
296
|
};
|
|
234
297
|
fs.writeFileSync(path.join(dir, 'results.json'), `${JSON.stringify(data, null, 2)}\n`);
|
|
@@ -8,21 +8,28 @@
|
|
|
8
8
|
/** @type {Record<string, import('../../utils/titles').TestDescription>} */
|
|
9
9
|
const SIGN_IN = {
|
|
10
10
|
'TS-0': {
|
|
11
|
-
id: 'TS-0',
|
|
11
|
+
id: 'TS-0',
|
|
12
|
+
ac: 'AC-0',
|
|
13
|
+
story: '{{STORY_KEY}}',
|
|
14
|
+
tags: ['@smoke'],
|
|
12
15
|
title: 'the test account signs in and the app greets the user',
|
|
13
16
|
preconditions: ['Signed in (the session the setup project saved)'],
|
|
14
17
|
steps: ['Open the home page'],
|
|
15
18
|
expected: 'The home page greets the user',
|
|
16
19
|
},
|
|
17
20
|
'TS-1': {
|
|
18
|
-
id: 'TS-1',
|
|
21
|
+
id: 'TS-1',
|
|
22
|
+
ac: 'AC-0',
|
|
23
|
+
story: '{{STORY_KEY}}',
|
|
19
24
|
title: 'a wrong password is refused with a message',
|
|
20
25
|
preconditions: ['Signed out'],
|
|
21
26
|
steps: ['Open the sign-in page', 'Enter the user name and a wrong password', 'Submit'],
|
|
22
27
|
expected: 'The form shows the wrong-password message',
|
|
23
28
|
},
|
|
24
29
|
'TS-2': {
|
|
25
|
-
id: 'TS-2',
|
|
30
|
+
id: 'TS-2',
|
|
31
|
+
ac: 'AC-0',
|
|
32
|
+
story: '{{STORY_KEY}}',
|
|
26
33
|
title: 'signing out returns to the sign-in page',
|
|
27
34
|
preconditions: ['Signed out (signs in on its own, so the shared session stays valid)'],
|
|
28
35
|
steps: ['Sign in', 'Open the account menu', 'Sign out'],
|
|
@@ -37,9 +37,16 @@ function installedChannel() {
|
|
|
37
37
|
const fs = require('node:fs');
|
|
38
38
|
const path = require('node:path');
|
|
39
39
|
/** Whether a file or folder exists. */
|
|
40
|
-
const exists = (p) => {
|
|
40
|
+
const exists = (p) => {
|
|
41
|
+
try {
|
|
42
|
+
return fs.statSync(p).isFile() || fs.statSync(p).isDirectory();
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
41
47
|
/** Whether one of the commands is on the PATH. */
|
|
42
|
-
const onPath = (names) =>
|
|
48
|
+
const onPath = (names) =>
|
|
49
|
+
(process.env.PATH || '').split(path.delimiter).some((d) => names.some((n) => exists(path.join(d, n))));
|
|
43
50
|
if (process.platform === 'win32') {
|
|
44
51
|
const roots = ['ProgramFiles', 'ProgramFiles(x86)', 'LOCALAPPDATA'].map((v) => process.env[v]).filter(Boolean);
|
|
45
52
|
if (roots.some((r) => exists(path.join(r, 'Google', 'Chrome', 'Application', 'chrome.exe')))) return 'chrome';
|
|
@@ -51,7 +58,9 @@ function installedChannel() {
|
|
|
51
58
|
return exists('/Applications/Microsoft Edge.app') ? 'msedge' : undefined;
|
|
52
59
|
}
|
|
53
60
|
if (exists('/opt/google/chrome/chrome') || onPath(['google-chrome', 'google-chrome-stable'])) return 'chrome';
|
|
54
|
-
return exists('/opt/microsoft/msedge/msedge') || onPath(['microsoft-edge', 'microsoft-edge-stable'])
|
|
61
|
+
return exists('/opt/microsoft/msedge/msedge') || onPath(['microsoft-edge', 'microsoft-edge-stable'])
|
|
62
|
+
? 'msedge'
|
|
63
|
+
: undefined;
|
|
55
64
|
}
|
|
56
65
|
|
|
57
66
|
const env = {
|
|
@@ -22,7 +22,9 @@ function numberFrom(name, fallback) {
|
|
|
22
22
|
*/
|
|
23
23
|
const PROFILE = (() => {
|
|
24
24
|
try {
|
|
25
|
-
return JSON.parse(
|
|
25
|
+
return JSON.parse(
|
|
26
|
+
require('node:fs').readFileSync(require('node:path').join(__dirname, '..', '..', 'timeouts.json'), 'utf-8'),
|
|
27
|
+
);
|
|
26
28
|
} catch {
|
|
27
29
|
return {};
|
|
28
30
|
}
|
|
@@ -8,8 +8,12 @@ const { test, expect } = require('../../fixtures');
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
test.describe('{{STORY_KEY}} session over HTTP', () => {
|
|
11
|
-
test(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
test(
|
|
12
|
+
'framework check, not a story case: the saved session opens the home page without a redirect to sign-in',
|
|
13
|
+
{ tag: ['@smoke'] },
|
|
14
|
+
async ({ apiClient }) => {
|
|
15
|
+
const response = await apiClient.get(ROUTES.home, { expectStatus: 200, maxRedirects: 0 });
|
|
16
|
+
expect(new URL(response.url()).pathname).not.toBe(new URL(ROUTES.login, response.url()).pathname);
|
|
17
|
+
},
|
|
18
|
+
);
|
|
15
19
|
});
|
|
@@ -7,12 +7,28 @@ const { renderSummary, parseTitle, verdictOf } = require('../../reporters/summar
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/** @returns {import('../../reporters/summaryReporter').Row} A passed row; fields overridden per test. */
|
|
10
|
-
const row = (over = {}) => ({
|
|
11
|
-
|
|
10
|
+
const row = (over = {}) => ({
|
|
11
|
+
id: 'TS-1',
|
|
12
|
+
story: 'EA-10',
|
|
13
|
+
title: 'the user signs in',
|
|
14
|
+
acs: ['AC-1'],
|
|
15
|
+
project: 'regression',
|
|
16
|
+
file: 'tests/ui/signIn.spec.js:8',
|
|
17
|
+
outcome: 'passed',
|
|
18
|
+
durationMs: 1200,
|
|
19
|
+
attempts: 1,
|
|
20
|
+
error: '',
|
|
21
|
+
links: [],
|
|
22
|
+
...over,
|
|
23
|
+
});
|
|
12
24
|
|
|
13
25
|
test.describe('summary reporter', () => {
|
|
14
26
|
test('parseTitle splits the case id, story and behaviour', () => {
|
|
15
|
-
expect(parseTitle('TS-3 [EA-10] wrong password shows an error')).toEqual({
|
|
27
|
+
expect(parseTitle('TS-3 [EA-10] wrong password shows an error')).toEqual({
|
|
28
|
+
id: 'TS-3',
|
|
29
|
+
story: 'EA-10',
|
|
30
|
+
title: 'wrong password shows an error',
|
|
31
|
+
});
|
|
16
32
|
expect(parseTitle('a test without an id')).toEqual({ id: '', story: '', title: 'a test without an id' });
|
|
17
33
|
});
|
|
18
34
|
|
|
@@ -20,12 +36,20 @@ test.describe('summary reporter', () => {
|
|
|
20
36
|
expect(verdictOf([row(), row({ outcome: 'failed' })]).label).toBe('Failed');
|
|
21
37
|
expect(verdictOf([row(), row({ outcome: 'flaky' })]).label).toBe('Passed, with notes');
|
|
22
38
|
expect(verdictOf([row(), row()]).sentence).toBe('All 2 tests passed.');
|
|
23
|
-
expect(verdictOf([row()], [row({ project: 'setup', title: 'sign in', outcome: 'failed' })]).label).toBe(
|
|
39
|
+
expect(verdictOf([row()], [row({ project: 'setup', title: 'sign in', outcome: 'failed' })]).label).toBe(
|
|
40
|
+
'Setup failed',
|
|
41
|
+
);
|
|
24
42
|
});
|
|
25
43
|
|
|
26
44
|
test('renderSummary shows the verdict first, escapes text and keeps a failure next to its test', () => {
|
|
27
|
-
const html = renderSummary({
|
|
28
|
-
|
|
45
|
+
const html = renderSummary({
|
|
46
|
+
rows: [row(), row({ id: 'TS-2', title: 'shows <b>', outcome: 'failed', error: 'Expected "Welcome"' })],
|
|
47
|
+
support: [],
|
|
48
|
+
startedAt: new Date('2026-11-13T10:00:00Z'),
|
|
49
|
+
durationMs: 4200,
|
|
50
|
+
baseUrl: 'https://test.example',
|
|
51
|
+
projects: ['regression'],
|
|
52
|
+
});
|
|
29
53
|
expect(html.indexOf('❌ Failed')).toBeLessThan(html.indexOf('<section>'));
|
|
30
54
|
expect(html).toContain('shows <b>');
|
|
31
55
|
expect(html.indexOf('TS-2')).toBeLessThan(html.indexOf('TS-1'));
|
|
@@ -12,7 +12,9 @@ const { randomBytes } = require('node:crypto');
|
|
|
12
12
|
* @returns {string} Lower-case letters and digits.
|
|
13
13
|
*/
|
|
14
14
|
function uniqueSuffix(length = 6) {
|
|
15
|
-
return randomBytes(Math.ceil(length / 2))
|
|
15
|
+
return randomBytes(Math.ceil(length / 2))
|
|
16
|
+
.toString('hex')
|
|
17
|
+
.slice(0, length);
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -39,16 +39,19 @@ export const test = base.extend<SuiteFixtures, WorkerFixtures>({
|
|
|
39
39
|
* stale (the setup project didn't run, e.g. UI mode with only the tests' project ticked, or the session is old).
|
|
40
40
|
* Normal runs, where setup has just signed in, reuse its session and do nothing here.
|
|
41
41
|
*/
|
|
42
|
-
session: [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
session: [
|
|
43
|
+
async ({ playwright, browserName, channel, headless, launchOptions }, use, workerInfo) => {
|
|
44
|
+
const projectUse = workerInfo.project.use;
|
|
45
|
+
if (projectUse.storageState === paths.userSession) {
|
|
46
|
+
/** Starts this project's browser, with its channel, only when the session must be renewed. */
|
|
47
|
+
const launch = () => playwright[browserName].launch({ ...launchOptions, channel, headless });
|
|
48
|
+
const why = await ensureSession(launch, projectUse);
|
|
49
|
+
if (why) logger.info(`Signed in again before the tests: ${why}`);
|
|
50
|
+
}
|
|
51
|
+
await use();
|
|
52
|
+
},
|
|
53
|
+
{ scope: 'worker', auto: true },
|
|
54
|
+
],
|
|
52
55
|
/**
|
|
53
56
|
* Playwright's browser context, plus the saved `sessionStorage` when `AUTH_SESSION_STORAGE=1` and the test
|
|
54
57
|
* starts signed in (Playwright's own saved state doesn't include it; this is its documented workaround).
|
|
@@ -57,11 +60,14 @@ export const test = base.extend<SuiteFixtures, WorkerFixtures>({
|
|
|
57
60
|
if (flags.authSessionStorage && storageState && fs.existsSync(paths.sessionStorage)) {
|
|
58
61
|
const origin = new URL(env.baseUrl() || 'http://localhost').origin;
|
|
59
62
|
const entries: Record<string, string> = JSON.parse(fs.readFileSync(paths.sessionStorage, 'utf-8'));
|
|
60
|
-
await context.addInitScript(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
await context.addInitScript(
|
|
64
|
+
({ origin: o, entries: e }) => {
|
|
65
|
+
if (window.location.origin === o) {
|
|
66
|
+
for (const [key, value] of Object.entries(e)) window.sessionStorage.setItem(key, String(value));
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{ origin, entries },
|
|
70
|
+
);
|
|
65
71
|
}
|
|
66
72
|
await use(context);
|
|
67
73
|
},
|
|
@@ -42,7 +42,11 @@ export async function signInAndSave(page: Page): Promise<void> {
|
|
|
42
42
|
* @param now The time to compare with, in ms.
|
|
43
43
|
* @returns e.g. `no saved session`, `saved 42 min ago (limit 15)`, `a cookie in it has expired`.
|
|
44
44
|
*/
|
|
45
|
-
export function staleReason(
|
|
45
|
+
export function staleReason(
|
|
46
|
+
file: string = paths.userSession,
|
|
47
|
+
maxAgeMinutes: number = flags.sessionMaxAgeMinutes,
|
|
48
|
+
now: number = Date.now(),
|
|
49
|
+
): string | null {
|
|
46
50
|
if (!fs.existsSync(file)) return 'no saved session';
|
|
47
51
|
const ageMinutes = (now - fs.statSync(file).mtimeMs) / 60000;
|
|
48
52
|
if (ageMinutes > maxAgeMinutes) return `saved ${Math.round(ageMinutes)} min ago (limit ${maxAgeMinutes})`;
|
|
@@ -64,7 +68,10 @@ export function staleReason(file: string = paths.userSession, maxAgeMinutes: num
|
|
|
64
68
|
* @param use The project's settings.
|
|
65
69
|
* @returns Why it signed in again, or `null` when the saved session was used.
|
|
66
70
|
*/
|
|
67
|
-
export async function ensureSession(
|
|
71
|
+
export async function ensureSession(
|
|
72
|
+
launch: () => Promise<Browser>,
|
|
73
|
+
use: Pick<BrowserContextOptions, 'baseURL' | 'httpCredentials'>,
|
|
74
|
+
): Promise<string | null> {
|
|
68
75
|
const why = staleReason();
|
|
69
76
|
if (!why) return null;
|
|
70
77
|
const browser = await launch();
|
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
"test:api": "playwright test --project=api",
|
|
10
10
|
"test:unit": "playwright test --project=unit",
|
|
11
11
|
"typecheck": "tsc --noEmit",
|
|
12
|
+
"format": "prettier --write \"**/*.{js,ts}\"",
|
|
13
|
+
"format:check": "prettier --check \"**/*.{js,ts}\"",
|
|
12
14
|
"report": "playwright show-report"
|
|
13
15
|
},
|
|
14
16
|
"devDependencies": {
|
|
15
17
|
"@playwright/test": "{{PLAYWRIGHT_VERSION}}",
|
|
16
18
|
"@types/node": "{{TYPES_NODE_VERSION}}",
|
|
17
|
-
"typescript": "{{TYPESCRIPT_VERSION}}"
|
|
19
|
+
"typescript": "{{TYPESCRIPT_VERSION}}",
|
|
20
|
+
"prettier": "{{PRETTIER_VERSION}}"
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -26,7 +26,11 @@ export abstract class BasePage {
|
|
|
26
26
|
async open(): Promise<this> {
|
|
27
27
|
if (/\{\{[A-Z_]+\}\}/.test(String(this.path))) {
|
|
28
28
|
// A starter copied but not filled: say so now, instead of opening /%7B%7BLOGIN_PATH%7D%7D and timing out.
|
|
29
|
-
throw new AutomationError(
|
|
29
|
+
throw new AutomationError(
|
|
30
|
+
'Open',
|
|
31
|
+
this.path,
|
|
32
|
+
'unfilled starter placeholder: fill it in resources/testData from the UI map',
|
|
33
|
+
);
|
|
30
34
|
}
|
|
31
35
|
let response;
|
|
32
36
|
try {
|
|
@@ -18,7 +18,7 @@ export default defineConfig({
|
|
|
18
18
|
fullyParallel: false,
|
|
19
19
|
workers: 1,
|
|
20
20
|
forbidOnly: !!process.env.CI,
|
|
21
|
-
//
|
|
21
|
+
// Retries stay off so a flaky test shows up instead of passing on a retry.
|
|
22
22
|
retries: 0,
|
|
23
23
|
// A missing screenshot baseline fails instead of being saved unseen; a person approves it first.
|
|
24
24
|
updateSnapshots: 'none',
|
|
@@ -29,7 +29,9 @@ export default defineConfig({
|
|
|
29
29
|
['list'],
|
|
30
30
|
[path.join(__dirname, 'reporters', 'summaryReporter.ts'), { outputFile: paths.summaryReport }],
|
|
31
31
|
['html', { open: 'never', outputFolder: paths.htmlReport }],
|
|
32
|
-
...(process.env.CI
|
|
32
|
+
...(process.env.CI
|
|
33
|
+
? [['junit', { outputFile: 'test-results/junit.xml' }] as ['junit', { outputFile: string }]]
|
|
34
|
+
: []),
|
|
33
35
|
],
|
|
34
36
|
use: {
|
|
35
37
|
baseURL: env.baseUrl(),
|
|
@@ -50,7 +50,12 @@ export interface Run {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/** What the page says first. */
|
|
53
|
-
interface Verdict {
|
|
53
|
+
interface Verdict {
|
|
54
|
+
mark: string;
|
|
55
|
+
label: string;
|
|
56
|
+
sentence: string;
|
|
57
|
+
tone: 'good' | 'warn' | 'bad';
|
|
58
|
+
}
|
|
54
59
|
|
|
55
60
|
/**
|
|
56
61
|
* Escapes text for HTML.
|
|
@@ -58,7 +63,11 @@ interface Verdict { mark: string; label: string; sentence: string; tone: 'good'
|
|
|
58
63
|
* @returns Safe HTML text.
|
|
59
64
|
*/
|
|
60
65
|
function esc(s: unknown): string {
|
|
61
|
-
return String(s).replace(
|
|
66
|
+
return String(s).replace(
|
|
67
|
+
/[&<>"']/g,
|
|
68
|
+
(c) =>
|
|
69
|
+
(({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }) as Record<string, string>)[c] || c,
|
|
70
|
+
);
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
/**
|
|
@@ -94,12 +103,31 @@ export function verdictOf(rows: Row[], support: Row[] = []): Verdict {
|
|
|
94
103
|
const n = (o: Row['outcome']) => rows.filter((r) => r.outcome === o).length;
|
|
95
104
|
const [failed, flaky, skipped, passed] = [n('failed'), n('flaky'), n('skipped'), n('passed')];
|
|
96
105
|
const setup = support.find((r) => r.outcome === 'failed');
|
|
97
|
-
if (setup)
|
|
106
|
+
if (setup)
|
|
107
|
+
return {
|
|
108
|
+
mark: '❌',
|
|
109
|
+
label: 'Setup failed',
|
|
110
|
+
sentence: `${setup.title || 'The setup'} failed, so the tests that need it didn't run; ${passed} other tests passed.`,
|
|
111
|
+
tone: 'bad',
|
|
112
|
+
};
|
|
98
113
|
if (!rows.length) return { mark: '⚠️', label: 'Nothing ran', sentence: 'No tests matched this run.', tone: 'warn' };
|
|
99
|
-
if (failed)
|
|
114
|
+
if (failed)
|
|
115
|
+
return {
|
|
116
|
+
mark: '❌',
|
|
117
|
+
label: 'Failed',
|
|
118
|
+
sentence: `${failed} of ${rows.length} tests failed; ${passed} passed.`,
|
|
119
|
+
tone: 'bad',
|
|
120
|
+
};
|
|
100
121
|
if (flaky || skipped) {
|
|
101
|
-
const parts = [flaky && `${flaky} passed only on a retry`, skipped && `${skipped} skipped`]
|
|
102
|
-
|
|
122
|
+
const parts = [flaky && `${flaky} passed only on a retry`, skipped && `${skipped} skipped`]
|
|
123
|
+
.filter(Boolean)
|
|
124
|
+
.join(', ');
|
|
125
|
+
return {
|
|
126
|
+
mark: '⚠️',
|
|
127
|
+
label: 'Passed, with notes',
|
|
128
|
+
sentence: `${passed} of ${rows.length} tests passed; ${parts}.`,
|
|
129
|
+
tone: 'warn',
|
|
130
|
+
};
|
|
103
131
|
}
|
|
104
132
|
return { mark: '✅', label: 'All passed', sentence: `All ${rows.length} tests passed.`, tone: 'good' };
|
|
105
133
|
}
|
|
@@ -114,7 +142,9 @@ export function renderSummary(run: Run): string {
|
|
|
114
142
|
const order: Record<Row['outcome'], number> = { failed: 0, flaky: 1, skipped: 2, passed: 3 };
|
|
115
143
|
const MARK: Record<Row['outcome'], string> = { passed: '✅', failed: '❌', flaky: '⚠️', skipped: '⏭' };
|
|
116
144
|
const groups = new Map<string, Row[]>();
|
|
117
|
-
for (const r of [...run.rows].sort(
|
|
145
|
+
for (const r of [...run.rows].sort(
|
|
146
|
+
(a, b) => order[a.outcome] - order[b.outcome] || a.id.localeCompare(b.id, 'en', { numeric: true }),
|
|
147
|
+
)) {
|
|
118
148
|
const key = r.story || r.file.split(':')[0];
|
|
119
149
|
if (!groups.has(key)) groups.set(key, []);
|
|
120
150
|
groups.get(key)!.push(r);
|
|
@@ -132,12 +162,17 @@ export function renderSummary(run: Run): string {
|
|
|
132
162
|
<td class="num">${duration(r.durationMs)}${r.attempts > 1 ? ` <span class="muted">· ${r.attempts} tries</span>` : ''}</td>
|
|
133
163
|
</tr>`;
|
|
134
164
|
// Story cases first, then framework and unit checks (grouped by file).
|
|
135
|
-
const sections = [...groups]
|
|
165
|
+
const sections = [...groups]
|
|
166
|
+
.sort(([, a], [, b]) => Number(!a[0].story) - Number(!b[0].story))
|
|
167
|
+
.map(
|
|
168
|
+
([key, rows]) => `
|
|
136
169
|
<section>
|
|
137
170
|
<h2>${esc(key)} <span class="muted">${rows.filter((r) => r.outcome === 'passed').length}/${rows.length} passed</span></h2>
|
|
138
171
|
<div class="scroll"><table><thead><tr><th></th><th>Test</th><th>Project</th><th class="num">Time</th></tr></thead><tbody>${rows.map(row).join('')}
|
|
139
172
|
</tbody></table></div>
|
|
140
|
-
</section
|
|
173
|
+
</section>`,
|
|
174
|
+
)
|
|
175
|
+
.join('');
|
|
141
176
|
return `<!doctype html>
|
|
142
177
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
143
178
|
<title>Test run · ${esc(run.startedAt.toISOString().slice(0, 10))}</title>
|
|
@@ -209,10 +244,19 @@ export default class SummaryReporter implements Reporter {
|
|
|
209
244
|
const outcome = test.outcome();
|
|
210
245
|
const parts = parseTitle(test.title);
|
|
211
246
|
const failedRun = [...results].reverse().find((r) => r.status !== 'passed' && r.status !== 'skipped');
|
|
212
|
-
const message = failedRun && failedRun.error ?
|
|
213
|
-
const links =
|
|
214
|
-
|
|
215
|
-
|
|
247
|
+
const message = failedRun && failedRun.error ? failedRun.error.message || failedRun.error.value || '' : '';
|
|
248
|
+
const links =
|
|
249
|
+
outcome === 'unexpected' && failedRun
|
|
250
|
+
? failedRun.attachments
|
|
251
|
+
.filter((a) => a.path && /screenshot|trace/.test(a.name))
|
|
252
|
+
.map((a) => ({
|
|
253
|
+
name: a.name,
|
|
254
|
+
href: path
|
|
255
|
+
.relative(dir, a.path as string)
|
|
256
|
+
.split(path.sep)
|
|
257
|
+
.join('/'),
|
|
258
|
+
}))
|
|
259
|
+
: [];
|
|
216
260
|
return {
|
|
217
261
|
...parts,
|
|
218
262
|
acs: test.tags.filter((t) => /^@AC-/.test(t)).map((t) => t.slice(1)),
|
|
@@ -222,7 +266,13 @@ export default class SummaryReporter implements Reporter {
|
|
|
222
266
|
durationMs: last ? last.duration : 0,
|
|
223
267
|
attempts: results.length,
|
|
224
268
|
// eslint-disable-next-line no-control-regex
|
|
225
|
-
error:
|
|
269
|
+
error:
|
|
270
|
+
outcome === 'unexpected'
|
|
271
|
+
? redact(message.replace(/\u001b\[[0-9;]*m/g, ''))
|
|
272
|
+
.split('\n')
|
|
273
|
+
.slice(0, 12)
|
|
274
|
+
.join('\n')
|
|
275
|
+
: '',
|
|
226
276
|
links,
|
|
227
277
|
};
|
|
228
278
|
});
|
|
@@ -230,7 +280,17 @@ export default class SummaryReporter implements Reporter {
|
|
|
230
280
|
const support = all.filter((r) => SUPPORT_PROJECTS.has(r.project));
|
|
231
281
|
const projects = [...new Set(rows.map((r) => r.project))];
|
|
232
282
|
fs.mkdirSync(dir, { recursive: true });
|
|
233
|
-
fs.writeFileSync(
|
|
283
|
+
fs.writeFileSync(
|
|
284
|
+
this.outputFile,
|
|
285
|
+
renderSummary({
|
|
286
|
+
rows,
|
|
287
|
+
support,
|
|
288
|
+
startedAt: this.startedAt,
|
|
289
|
+
durationMs: full.duration,
|
|
290
|
+
baseUrl: this.baseUrl,
|
|
291
|
+
projects,
|
|
292
|
+
}),
|
|
293
|
+
);
|
|
234
294
|
// The same run as data, next to the page: every run (yours, CI's or an agent's) leaves results a script can read
|
|
235
295
|
// (Orion's results_parse.mjs), so nothing has to run again just to get a machine-readable report.
|
|
236
296
|
const data = {
|
|
@@ -241,8 +301,15 @@ export default class SummaryReporter implements Reporter {
|
|
|
241
301
|
tests: [...this.results].map(([test, results], i) => {
|
|
242
302
|
const file = `${path.relative(paths.root, test.location.file).split(path.sep).join('/')}:${test.location.line}`;
|
|
243
303
|
const r = all[i];
|
|
244
|
-
return {
|
|
245
|
-
|
|
304
|
+
return {
|
|
305
|
+
title: test.title,
|
|
306
|
+
file,
|
|
307
|
+
project: r ? r.project : '',
|
|
308
|
+
status: r ? r.outcome : 'failed',
|
|
309
|
+
duration_ms: r ? r.durationMs : 0,
|
|
310
|
+
attempts: results.length,
|
|
311
|
+
failure_sig: r && r.error ? r.error.split('\n')[0].slice(0, 200) : null,
|
|
312
|
+
};
|
|
246
313
|
}),
|
|
247
314
|
};
|
|
248
315
|
fs.writeFileSync(path.join(dir, 'results.json'), `${JSON.stringify(data, null, 2)}\n`);
|