simplify3x-connect 0.28.0 → 0.31.0

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.
Files changed (226) hide show
  1. package/README.md +150 -55
  2. package/dist/adapters/http.d.ts.map +1 -1
  3. package/dist/adapters/http.js +3 -2
  4. package/dist/adapters/http.js.map +1 -1
  5. package/dist/adapters/simplifyqa/adapter.d.ts +442 -4
  6. package/dist/adapters/simplifyqa/adapter.d.ts.map +1 -1
  7. package/dist/adapters/simplifyqa/adapter.js +2321 -83
  8. package/dist/adapters/simplifyqa/adapter.js.map +1 -1
  9. package/dist/adapters/simplifyqa/executionFailures.d.ts +59 -1
  10. package/dist/adapters/simplifyqa/executionFailures.d.ts.map +1 -1
  11. package/dist/adapters/simplifyqa/executionFailures.js +429 -39
  12. package/dist/adapters/simplifyqa/executionFailures.js.map +1 -1
  13. package/dist/adapters/simplifyqa/failureAnalysis.d.ts +45 -0
  14. package/dist/adapters/simplifyqa/failureAnalysis.d.ts.map +1 -0
  15. package/dist/adapters/simplifyqa/failureAnalysis.js +373 -0
  16. package/dist/adapters/simplifyqa/failureAnalysis.js.map +1 -0
  17. package/dist/adapters/simplifyqa/failureAnalysisCard.d.ts +31 -0
  18. package/dist/adapters/simplifyqa/failureAnalysisCard.d.ts.map +1 -0
  19. package/dist/adapters/simplifyqa/failureAnalysisCard.js +371 -0
  20. package/dist/adapters/simplifyqa/failureAnalysisCard.js.map +1 -0
  21. package/dist/adapters/simplifyqa/failureAnalysisRun.d.ts +41 -0
  22. package/dist/adapters/simplifyqa/failureAnalysisRun.d.ts.map +1 -0
  23. package/dist/adapters/simplifyqa/failureAnalysisRun.js +138 -0
  24. package/dist/adapters/simplifyqa/failureAnalysisRun.js.map +1 -0
  25. package/dist/adapters/simplifyqa/failureAnalysisTypes.d.ts +84 -0
  26. package/dist/adapters/simplifyqa/failureAnalysisTypes.d.ts.map +1 -0
  27. package/dist/adapters/simplifyqa/failureAnalysisTypes.js +2 -0
  28. package/dist/adapters/simplifyqa/failureAnalysisTypes.js.map +1 -0
  29. package/dist/adapters/simplifyqa/failureHistory.d.ts +163 -0
  30. package/dist/adapters/simplifyqa/failureHistory.d.ts.map +1 -0
  31. package/dist/adapters/simplifyqa/failureHistory.js +174 -0
  32. package/dist/adapters/simplifyqa/failureHistory.js.map +1 -0
  33. package/dist/adapters/simplifyqa/failureImages.d.ts +13 -0
  34. package/dist/adapters/simplifyqa/failureImages.d.ts.map +1 -0
  35. package/dist/adapters/simplifyqa/failureImages.js +38 -0
  36. package/dist/adapters/simplifyqa/failureImages.js.map +1 -0
  37. package/dist/adapters/simplifyqa/failurePatterns.d.ts +54 -0
  38. package/dist/adapters/simplifyqa/failurePatterns.d.ts.map +1 -0
  39. package/dist/adapters/simplifyqa/failurePatterns.js +223 -0
  40. package/dist/adapters/simplifyqa/failurePatterns.js.map +1 -0
  41. package/dist/adapters/simplifyqa/failureReport.d.ts +35 -41
  42. package/dist/adapters/simplifyqa/failureReport.d.ts.map +1 -1
  43. package/dist/adapters/simplifyqa/failureReport.js +94 -249
  44. package/dist/adapters/simplifyqa/failureReport.js.map +1 -1
  45. package/dist/adapters/simplifyqa/failureReportModel.d.ts +73 -0
  46. package/dist/adapters/simplifyqa/failureReportModel.d.ts.map +1 -0
  47. package/dist/adapters/simplifyqa/failureReportModel.js +199 -0
  48. package/dist/adapters/simplifyqa/failureReportModel.js.map +1 -0
  49. package/dist/adapters/simplifyqa/failureReview.d.ts +36 -0
  50. package/dist/adapters/simplifyqa/failureReview.d.ts.map +1 -0
  51. package/dist/adapters/simplifyqa/failureReview.js +384 -0
  52. package/dist/adapters/simplifyqa/failureReview.js.map +1 -0
  53. package/dist/adapters/simplifyqa/failureSuggest.d.ts +13 -0
  54. package/dist/adapters/simplifyqa/failureSuggest.d.ts.map +1 -0
  55. package/dist/adapters/simplifyqa/failureSuggest.js +54 -0
  56. package/dist/adapters/simplifyqa/failureSuggest.js.map +1 -0
  57. package/dist/adapters/simplifyqa/failureTypes.d.ts +22 -1
  58. package/dist/adapters/simplifyqa/failureTypes.d.ts.map +1 -1
  59. package/dist/adapters/simplifyqa/loopConditions.d.ts +57 -0
  60. package/dist/adapters/simplifyqa/loopConditions.d.ts.map +1 -0
  61. package/dist/adapters/simplifyqa/loopConditions.js +145 -0
  62. package/dist/adapters/simplifyqa/loopConditions.js.map +1 -0
  63. package/dist/adapters/simplifyqa/mapper.d.ts.map +1 -1
  64. package/dist/adapters/simplifyqa/mapper.js +3 -1
  65. package/dist/adapters/simplifyqa/mapper.js.map +1 -1
  66. package/dist/adapters/simplifyqa/searchEngine.d.ts.map +1 -1
  67. package/dist/adapters/simplifyqa/searchEngine.js +6 -3
  68. package/dist/adapters/simplifyqa/searchEngine.js.map +1 -1
  69. package/dist/adapters/simplifyqa/searchRegistry.d.ts +7 -2
  70. package/dist/adapters/simplifyqa/searchRegistry.d.ts.map +1 -1
  71. package/dist/adapters/simplifyqa/searchRegistry.js +21 -2
  72. package/dist/adapters/simplifyqa/searchRegistry.js.map +1 -1
  73. package/dist/adapters/simplifyqa/spreadsheet.d.ts +15 -0
  74. package/dist/adapters/simplifyqa/spreadsheet.d.ts.map +1 -0
  75. package/dist/adapters/simplifyqa/spreadsheet.js +196 -0
  76. package/dist/adapters/simplifyqa/spreadsheet.js.map +1 -0
  77. package/dist/adapters/types.d.ts +24 -0
  78. package/dist/adapters/types.d.ts.map +1 -1
  79. package/dist/config.d.ts +0 -1
  80. package/dist/config.d.ts.map +1 -1
  81. package/dist/config.js +15 -12
  82. package/dist/config.js.map +1 -1
  83. package/dist/connection.d.ts +4 -1
  84. package/dist/connection.d.ts.map +1 -1
  85. package/dist/connection.js +12 -5
  86. package/dist/connection.js.map +1 -1
  87. package/dist/defaults.d.ts +45 -0
  88. package/dist/defaults.d.ts.map +1 -0
  89. package/dist/defaults.js +50 -0
  90. package/dist/defaults.js.map +1 -0
  91. package/dist/domain/types.d.ts +37 -0
  92. package/dist/domain/types.d.ts.map +1 -1
  93. package/dist/domain/types.js.map +1 -1
  94. package/dist/drafts/store.d.ts +0 -1
  95. package/dist/drafts/store.d.ts.map +1 -1
  96. package/dist/drafts/store.js +8 -3
  97. package/dist/drafts/store.js.map +1 -1
  98. package/dist/export/json.d.ts +4 -0
  99. package/dist/export/json.d.ts.map +1 -0
  100. package/dist/export/json.js +5 -0
  101. package/dist/export/json.js.map +1 -0
  102. package/dist/export/layout.d.ts +119 -0
  103. package/dist/export/layout.d.ts.map +1 -0
  104. package/dist/export/layout.js +198 -0
  105. package/dist/export/layout.js.map +1 -0
  106. package/dist/export/pdf.d.ts +67 -0
  107. package/dist/export/pdf.d.ts.map +1 -0
  108. package/dist/export/pdf.js +279 -0
  109. package/dist/export/pdf.js.map +1 -0
  110. package/dist/export/xlsx.d.ts +52 -0
  111. package/dist/export/xlsx.d.ts.map +1 -0
  112. package/dist/export/xlsx.js +251 -0
  113. package/dist/export/xlsx.js.map +1 -0
  114. package/dist/gateway.d.ts.map +1 -1
  115. package/dist/gateway.js +13 -3
  116. package/dist/gateway.js.map +1 -1
  117. package/dist/httpMain.js +3 -2
  118. package/dist/httpMain.js.map +1 -1
  119. package/dist/initAgents.d.ts.map +1 -1
  120. package/dist/initAgents.js +13 -5
  121. package/dist/initAgents.js.map +1 -1
  122. package/dist/mcpResult.d.ts +4 -3
  123. package/dist/mcpResult.d.ts.map +1 -1
  124. package/dist/mcpResult.js +4 -2
  125. package/dist/mcpResult.js.map +1 -1
  126. package/dist/mount.d.ts +7 -1
  127. package/dist/mount.d.ts.map +1 -1
  128. package/dist/mount.js +14 -7
  129. package/dist/mount.js.map +1 -1
  130. package/dist/requestConnection.d.ts.map +1 -1
  131. package/dist/requestConnection.js +8 -3
  132. package/dist/requestConnection.js.map +1 -1
  133. package/dist/server.d.ts +9 -0
  134. package/dist/server.d.ts.map +1 -1
  135. package/dist/server.js +53 -4
  136. package/dist/server.js.map +1 -1
  137. package/dist/tools/attachment.tools.d.ts.map +1 -1
  138. package/dist/tools/attachment.tools.js +54 -1
  139. package/dist/tools/attachment.tools.js.map +1 -1
  140. package/dist/tools/backlog.tools.d.ts.map +1 -1
  141. package/dist/tools/backlog.tools.js +41 -0
  142. package/dist/tools/backlog.tools.js.map +1 -1
  143. package/dist/tools/defectFromStep.tools.d.ts +16 -0
  144. package/dist/tools/defectFromStep.tools.d.ts.map +1 -0
  145. package/dist/tools/defectFromStep.tools.js +90 -0
  146. package/dist/tools/defectFromStep.tools.js.map +1 -0
  147. package/dist/tools/defectUpdate.tools.d.ts +15 -0
  148. package/dist/tools/defectUpdate.tools.d.ts.map +1 -0
  149. package/dist/tools/defectUpdate.tools.js +120 -0
  150. package/dist/tools/defectUpdate.tools.js.map +1 -0
  151. package/dist/tools/discovery.tools.d.ts +2 -0
  152. package/dist/tools/discovery.tools.d.ts.map +1 -1
  153. package/dist/tools/discovery.tools.js +8 -3
  154. package/dist/tools/discovery.tools.js.map +1 -1
  155. package/dist/tools/environment.tools.d.ts +18 -0
  156. package/dist/tools/environment.tools.d.ts.map +1 -0
  157. package/dist/tools/environment.tools.js +86 -0
  158. package/dist/tools/environment.tools.js.map +1 -0
  159. package/dist/tools/executionPlan.tools.d.ts.map +1 -1
  160. package/dist/tools/executionPlan.tools.js +37 -11
  161. package/dist/tools/executionPlan.tools.js.map +1 -1
  162. package/dist/tools/failure.tools.d.ts +12 -4
  163. package/dist/tools/failure.tools.d.ts.map +1 -1
  164. package/dist/tools/failure.tools.js +264 -33
  165. package/dist/tools/failure.tools.js.map +1 -1
  166. package/dist/tools/failureAnalysisStore.d.ts +30 -0
  167. package/dist/tools/failureAnalysisStore.d.ts.map +1 -0
  168. package/dist/tools/failureAnalysisStore.js +84 -0
  169. package/dist/tools/failureAnalysisStore.js.map +1 -0
  170. package/dist/tools/failureExport.tools.d.ts +26 -0
  171. package/dist/tools/failureExport.tools.d.ts.map +1 -0
  172. package/dist/tools/failureExport.tools.js +201 -0
  173. package/dist/tools/failureExport.tools.js.map +1 -0
  174. package/dist/tools/import.tools.d.ts +21 -0
  175. package/dist/tools/import.tools.d.ts.map +1 -0
  176. package/dist/tools/import.tools.js +187 -0
  177. package/dist/tools/import.tools.js.map +1 -0
  178. package/dist/tools/outDir.d.ts +9 -0
  179. package/dist/tools/outDir.d.ts.map +1 -0
  180. package/dist/tools/outDir.js +28 -0
  181. package/dist/tools/outDir.js.map +1 -0
  182. package/dist/tools/preference.tools.d.ts.map +1 -1
  183. package/dist/tools/preference.tools.js +29 -6
  184. package/dist/tools/preference.tools.js.map +1 -1
  185. package/dist/tools/query.tools.js +1 -1
  186. package/dist/tools/query.tools.js.map +1 -1
  187. package/dist/tools/releaseSprint.tools.d.ts +14 -0
  188. package/dist/tools/releaseSprint.tools.d.ts.map +1 -0
  189. package/dist/tools/releaseSprint.tools.js +130 -0
  190. package/dist/tools/releaseSprint.tools.js.map +1 -0
  191. package/dist/tools/report.tools.d.ts +2 -0
  192. package/dist/tools/report.tools.d.ts.map +1 -1
  193. package/dist/tools/report.tools.js +18 -4
  194. package/dist/tools/report.tools.js.map +1 -1
  195. package/dist/tools/run.tools.d.ts +7 -0
  196. package/dist/tools/run.tools.d.ts.map +1 -1
  197. package/dist/tools/run.tools.js +64 -9
  198. package/dist/tools/run.tools.js.map +1 -1
  199. package/dist/tools/schemas.d.ts +177 -0
  200. package/dist/tools/schemas.d.ts.map +1 -1
  201. package/dist/tools/schemas.js +4 -0
  202. package/dist/tools/schemas.js.map +1 -1
  203. package/dist/tools/tasks.tools.d.ts.map +1 -1
  204. package/dist/tools/tasks.tools.js +101 -0
  205. package/dist/tools/tasks.tools.js.map +1 -1
  206. package/dist/tools/testCaseLint.d.ts.map +1 -1
  207. package/dist/tools/testCaseLint.js +20 -0
  208. package/dist/tools/testCaseLint.js.map +1 -1
  209. package/dist/tools/testcase.tools.d.ts +4 -0
  210. package/dist/tools/testcase.tools.d.ts.map +1 -1
  211. package/dist/tools/testcase.tools.js +28 -0
  212. package/dist/tools/testcase.tools.js.map +1 -1
  213. package/dist/tools/testdata.tools.d.ts.map +1 -1
  214. package/dist/tools/testdata.tools.js +42 -1
  215. package/dist/tools/testdata.tools.js.map +1 -1
  216. package/dist/vendor/logger.d.ts +3 -5
  217. package/dist/vendor/logger.d.ts.map +1 -1
  218. package/dist/vendor/logger.js +13 -8
  219. package/dist/vendor/logger.js.map +1 -1
  220. package/dist/version.d.ts +1 -1
  221. package/dist/version.js +1 -1
  222. package/package.json +9 -5
  223. package/dist/tools/xlsx.d.ts +0 -8
  224. package/dist/tools/xlsx.d.ts.map +0 -1
  225. package/dist/tools/xlsx.js +0 -113
  226. package/dist/tools/xlsx.js.map +0 -1
@@ -0,0 +1,199 @@
1
+ import { CATEGORY_ORDER, NO_SUITE, categoryOfTestcase, filterTestcases, summarise } from './failureAnalysis.js';
2
+ import { FAILING_SINCE_UNAVAILABLE, FIRST_EXECUTION, HISTORY_UNAVAILABLE, NEVER_PASSED, editedText, failedRunsText, lastPassedText, whereText, } from './failureHistory.js';
3
+ import { MIN_MASKED_LEN, maskWith } from './failureReport.js';
4
+ export { maskWith };
5
+ const TOP_PATTERNS = 3;
6
+ const suiteLabel = (s) => s.code ?? s.name ?? (s.id !== undefined ? `SU-${s.id}` : NO_SUITE);
7
+ /** Values of every protected test data entry in the analysis (each iteration's whole-run set and
8
+ * its failed steps' test data), longest first. */
9
+ export function protectedValues(a) {
10
+ const out = new Set();
11
+ for (const tc of a.testcases) {
12
+ for (const { it } of tc.failedIterations) {
13
+ for (const v of it.protectedValues ?? [])
14
+ if (v.length >= MIN_MASKED_LEN)
15
+ out.add(v);
16
+ for (const step of [it.focus, ...it.failedSteps]) {
17
+ for (const d of step?.testdata ?? []) {
18
+ if (d['protected'] !== true)
19
+ continue;
20
+ const v = d['value'];
21
+ if (v === undefined || v === null)
22
+ continue;
23
+ const s = String(v);
24
+ if (s.length >= MIN_MASKED_LEN)
25
+ out.add(s);
26
+ }
27
+ }
28
+ }
29
+ }
30
+ return [...out].sort((x, y) => y.length - x.length);
31
+ }
32
+ /** `TC-1542 (v1.0)` — the same label as the card's root-cause table. Only the DATA parts (version /
33
+ * name) are masked — never the TC code. */
34
+ const testcaseLabel = (tc, mask) => `${tc.code ?? (tc.name !== undefined ? mask(tc.name) : tc.key)}${tc.versionName ? ` (${mask(tc.versionName)})` : ''}`;
35
+ const failedStepOf = (it) => {
36
+ const f = it.focus;
37
+ if (!f)
38
+ return it.exception ?? '';
39
+ return f.trail || (f.reportStep ? `step ${f.reportStep}` : f.description);
40
+ };
41
+ export function buildReportModel(a, filter, now) {
42
+ const mask = maskWith(protectedValues(a));
43
+ const tcs = filterTestcases(a, filter);
44
+ const groupById = new Map(a.groups.map((g) => [g.id, g]));
45
+ const groupOfIteration = new Map();
46
+ for (const g of a.groups)
47
+ for (const k of g.iterationKeys)
48
+ groupOfIteration.set(k, g);
49
+ const reportUrlOf = new Map(a.executions.map((e) => [String(e.id), e.reportUrl]));
50
+ const patternName = (g) => g ? (mask(a.verdicts[g.id]?.pattern ?? g.cause) ?? '') : 'UNCLASSIFIED';
51
+ const categoryOfGroup = (g) => (g && a.verdicts[g.id]?.category) || 'UNCLASSIFIED';
52
+ const wanted = filter.pattern === undefined ? undefined : [].concat(filter.pattern);
53
+ // testcases: one row per failed iteration (only those in the pattern filter, if any)
54
+ const rows = [];
55
+ for (const tc of tcs) {
56
+ const h = tc.history;
57
+ // Full text: "30 Oct 2026 in EX-51030 (SU-116 Name)" / "EX-51200 (PL-98 Name), 3 runs". Suite /
58
+ // plan and version names are data (masked); the EX / SU / PL refs are scaffold (never masked).
59
+ const named = { mask: (s) => mask(s) ?? '' };
60
+ const lastPassed = h?.status === 'unknown' ? HISTORY_UNAVAILABLE
61
+ : h?.status === 'never-passed' ? NEVER_PASSED
62
+ : h?.status === 'first-execution' ? FIRST_EXECUTION
63
+ : h?.lastPassed ? lastPassedText(h.lastPassed, named) : undefined;
64
+ const lastPassedAt = h?.status === 'unknown' || h?.status === 'never-passed' || h?.status === 'first-execution'
65
+ ? undefined : h?.lastPassed?.endedAt;
66
+ const failingSince = h?.failingSince
67
+ ? `${whereText(h.failingSince, named)}, ${failedRunsText(h.failingSince)}`
68
+ : h?.failingSinceUnavailable ? FAILING_SINCE_UNAVAILABLE : undefined;
69
+ const e = h?.editedSincePass;
70
+ const edited = e
71
+ ? editedText({
72
+ ...e,
73
+ ...(e.fromName !== undefined ? { fromName: mask(e.fromName) ?? '' } : {}),
74
+ ...(e.toName !== undefined ? { toName: mask(e.toName) ?? '' } : {}),
75
+ }, mask(tc.versionName))
76
+ : undefined;
77
+ const reportUrl = reportUrlOf.get(tc.executionId);
78
+ for (const { key, it } of tc.failedIterations) {
79
+ const g = groupOfIteration.get(key);
80
+ if (wanted && !(g && wanted.includes(g.id)))
81
+ continue;
82
+ const verdict = g ? a.verdicts[g.id] : undefined;
83
+ const reason = mask(verdict?.rootCause ?? it.focus?.cause ?? it.exception ?? '') ?? '';
84
+ const expected = mask(it.focus?.expected);
85
+ const actual = mask(it.focus?.actual);
86
+ // Every screenshot of the failed step (the focus, else the first failed step that has some — as
87
+ // the review shows them) and of the same step in the last pass.
88
+ const shotStep = [it.focus, ...(it.failedSteps ?? [])].find((s) => s?.screenshots?.some((y) => y.absoluteUrl));
89
+ const shots = (shotStep?.screenshots ?? []).map((y) => y.absoluteUrl).filter((u) => !!u);
90
+ const shot = shots[0];
91
+ const cmp = a.comparisons[key];
92
+ const passShots = (cmp?.screenshots ?? (cmp?.screenshot ? [cmp.screenshot] : [])).map((y) => y.absoluteUrl).filter((u) => !!u);
93
+ const passShot = passShots[0];
94
+ // The baseline of the failed step (the run's copy first; its thumbnail when there is no full baseline), else
95
+ // the passed step's.
96
+ const baseline = it.focus?.recordedBaseline ?? it.focus?.recordedThumbnail
97
+ ?? cmp?.baseline?.baseline ?? cmp?.baseline?.thumbnail;
98
+ rows.push({
99
+ suite: suiteLabel(tc.suite),
100
+ source: tc.sourceCode ?? suiteLabel(tc.suite),
101
+ code: tc.code ?? '',
102
+ name: mask(tc.name) ?? '',
103
+ iteration: it.iteration ?? it.label,
104
+ failedStep: mask(failedStepOf(it)) ?? '',
105
+ ...(expected !== undefined ? { expected } : {}),
106
+ ...(actual !== undefined ? { actual } : {}),
107
+ pattern: patternName(g),
108
+ category: categoryOfGroup(g),
109
+ reason,
110
+ ...(lastPassed !== undefined ? { lastPassed } : {}),
111
+ ...(failingSince !== undefined ? { failingSince } : {}),
112
+ ...(lastPassedAt ? { lastPassedAt } : {}),
113
+ ...(h?.failingSince?.endedAt ? { failingSinceAt: h.failingSince.endedAt } : {}),
114
+ ...(edited !== undefined ? { editedSincePass: edited } : {}),
115
+ ...(shot ? { screenshotUrl: shot } : {}),
116
+ ...(reportUrl ? { reportUrl } : {}),
117
+ ...(passShot ? { lastPassedScreenshotUrl: passShot } : {}),
118
+ ...(baseline ? { baselineUrl: baseline } : {}),
119
+ ...(shots.length ? { screenshotUrls: shots } : {}),
120
+ ...(passShots.length ? { lastPassedScreenshotUrls: passShots } : {}),
121
+ });
122
+ }
123
+ }
124
+ // patterns (the root-cause table): groups that still have a filtered test case, most first
125
+ const patterns = [];
126
+ for (const g of a.groups) {
127
+ if (wanted && !wanted.includes(g.id))
128
+ continue;
129
+ const inGroup = tcs.filter((tc) => tc.groups.includes(g.id));
130
+ if (!inGroup.length)
131
+ continue;
132
+ const v = a.verdicts[g.id];
133
+ const rep = a.testcases.flatMap((t) => t.failedIterations).find((f) => f.key === g.representativeKey);
134
+ const shot = rep?.it.focus?.screenshots[0]?.absoluteUrl;
135
+ patterns.push({
136
+ id: g.id,
137
+ pattern: patternName(g),
138
+ category: categoryOfGroup(g),
139
+ confidence: v?.confidence ?? 'unverified',
140
+ rootCause: v ? (mask(v.rootCause) ?? '') : `(suggested: ${g.suggested.category ?? '—'})`,
141
+ testcases: inGroup.length,
142
+ testcaseIds: [...new Set(inGroup.map((tc) => testcaseLabel(tc, mask)))],
143
+ ...(shot ? { screenshotUrl: shot } : {}),
144
+ });
145
+ }
146
+ patterns.sort((x, y) => y.testcases - x.testcases || x.id - y.id);
147
+ // suites (grouped by source: a section per suite / plan / source)
148
+ const bySuite = new Map();
149
+ for (const tc of tcs) {
150
+ const k = tc.sourceCode ?? suiteLabel(tc.suite);
151
+ bySuite.set(k, [...(bySuite.get(k) ?? []), tc]);
152
+ }
153
+ const suites = [...bySuite].map(([suite, list]) => {
154
+ const byCategory = Object.fromEntries(CATEGORY_ORDER.map((c) => [c, 0]));
155
+ const perPattern = new Map();
156
+ for (const tc of list) {
157
+ byCategory[categoryOfTestcase(a, tc)] += 1;
158
+ const name = patternName(groupById.get(tc.primaryGroup));
159
+ perPattern.set(name, (perPattern.get(name) ?? 0) + 1);
160
+ }
161
+ const topPatterns = [...perPattern].sort((x, y) => y[1] - x[1]).slice(0, TOP_PATTERNS).map(([n]) => n);
162
+ return { suite, failed: list.length, byCategory, topPatterns };
163
+ });
164
+ const filterParts = [];
165
+ if (filter.suiteId !== undefined)
166
+ filterParts.push(`suite ${filter.suiteId}`);
167
+ if (wanted)
168
+ filterParts.push(`pattern ${wanted.join(', ')}`);
169
+ if (filter.category !== undefined)
170
+ filterParts.push(`category ${filter.category}`);
171
+ // failure-analysis_<suite|all>[_<category>][_p<ids>]_<analysisId>_<date>: different filters or
172
+ // analyses never overwrite each other's files.
173
+ const date = now.toISOString().slice(0, 10);
174
+ const safe = (v) => v.replace(/[^A-Za-z0-9_-]/g, '');
175
+ const stem = [
176
+ 'failure-analysis',
177
+ safe(filter.suiteId ?? '') || 'all',
178
+ filter.category,
179
+ wanted ? `p${wanted.join('-')}` : undefined,
180
+ safe(a.id) || undefined,
181
+ date,
182
+ ].filter((p) => !!p).join('_');
183
+ return {
184
+ title: 'Failure Analysis Report',
185
+ fileStem: stem,
186
+ scope: {
187
+ executions: a.executions.map((e) => e.code ?? String(e.id)),
188
+ suites: [...bySuite.keys()],
189
+ filters: filterParts.length ? filterParts.join(' · ') : 'none',
190
+ generatedAt: now.toISOString(),
191
+ },
192
+ summary: summarise(a, filter),
193
+ totals: { failedTestcases: tcs.length, failedIterations: rows.length, passedTestcases: a.passedTestcases },
194
+ patterns,
195
+ suites,
196
+ testcases: rows,
197
+ };
198
+ }
199
+ //# sourceMappingURL=failureReportModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failureReportModel.js","sourceRoot":"","sources":["../../../src/adapters/simplifyqa/failureReportModel.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAChH,OAAO,EACL,yBAAyB,EAAE,eAAe,EAAE,mBAAmB,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,GACrI,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,CAAC;AAmCpB,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,MAAM,UAAU,GAAG,CAAC,CAAW,EAAU,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAG/G;mDACmD;AACnD,MAAM,UAAU,eAAe,CAAC,CAAkB;IAChD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,EAAE,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;QAC7B,KAAK,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,gBAAgB,EAAE,CAAC;YACzC,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,eAAe,IAAI,EAAE;gBAAE,IAAI,CAAC,CAAC,MAAM,IAAI,cAAc;oBAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACrF,KAAK,MA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AAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;QAC3C,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,SAAS;QACvB,IAAI;KACL,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE5C,OAAO;QACL,KAAK,EAAE,yBAAyB;QAChC,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE;YACL,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC3D,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;YAC3B,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;YAC9D,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE;SAC/B;QACD,OAAO,EAAE,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC;QAC7B,MAAM,EAAE,EAAE,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC,eAAe,EAAE;QAC1G,QAAQ;QACR,MAAM;QACN,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { REVIEW_LOG_LINES } from './failureHistory.js';
2
+ import type { AnalysisTestcase, FailureAnalysis } from './failureAnalysisTypes.js';
3
+ export { REVIEW_LOG_LINES };
4
+ /** Images per review page at most; images per test case at most; text per page at most (chars). */
5
+ export declare const MAX_REVIEW_IMAGES = 18, MAX_TESTCASE_IMAGES = 12, REVIEW_TEXT_CAP = 18000;
6
+ /** One image slot. `url` set → fetch it and show `caption` above it; when it is not set or cannot be
7
+ * fetched, `missing` is shown in its place. */
8
+ export type ReviewImage = {
9
+ caption: string;
10
+ url?: string;
11
+ missing: string;
12
+ /** The test case label (masked) and the slot, e.g. "TC-12" / "baseline". */
13
+ label: string;
14
+ kind: string;
15
+ };
16
+ export type ReviewView = {
17
+ text: string;
18
+ /** Test case keys whose blocks this page rendered (to add to `reviewedKeys`). */
19
+ testcaseKeys: string[];
20
+ /** Their pattern groups (marked evidenceShown). */
21
+ groups: number[];
22
+ images: ReviewImage[];
23
+ };
24
+ /** Every failed test case in review order: its main pattern's position, then its key. */
25
+ export declare function reviewOrder(a: FailureAnalysis): AnalysisTestcase[];
26
+ /** "Reviewed k/total test cases individually." while the review is incomplete; undefined once done. */
27
+ export declare function reviewedLine(a: FailureAnalysis): string | undefined;
28
+ /**
29
+ * The review pages, in review order: each is filled with test cases until the next one would take
30
+ * the page past MAX_REVIEW_IMAGES images (a test case costs its distinct images, at most
31
+ * MAX_TESTCASE_IMAGES) or past the text budget (blocks measured with 3 log lines); at least one
32
+ * test case per page. Depends only on the analysis, so every page agrees on the paging.
33
+ */
34
+ export declare function reviewPages(a: FailureAnalysis): AnalysisTestcase[][];
35
+ export declare function renderReviewPage(a: FailureAnalysis, requested: number): ReviewView;
36
+ //# sourceMappingURL=failureReview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failureReview.d.ts","sourceRoot":"","sources":["../../../src/adapters/simplifyqa/failureReview.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAQnF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,mGAAmG;AACnG,eAAO,MAAM,iBAAiB,KAAK,EAAE,mBAAmB,KAAK,EAAE,eAAe,QAAS,CAAC;AAmBxF;gDACgD;AAChD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAC/C,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;CAC7B,CAAC;AACF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mDAAmD;IACnD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB,CAAC;AAKF,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,CAAC,EAAE,eAAe,GAAG,gBAAgB,EAAE,CAIlE;AAQD,uGAAuG;AACvG,wBAAgB,YAAY,CAAC,CAAC,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAInE;AAkLD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,eAAe,GAAG,gBAAgB,EAAE,EAAE,CA0BpE;AAoDD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,CAyElF"}
@@ -0,0 +1,384 @@
1
+ import { REVIEW_LOG_LINES } from './failureHistory.js';
2
+ import { NO_SUITE } from './failureAnalysis.js';
3
+ import { historyParts, testcaseLabel } from './failureAnalysisCard.js';
4
+ import { maskWith, protectedValues } from './failureReportModel.js';
5
+ import { apiLines, collapseRepeats, truncate } from './failureReport.js';
6
+ import { looksLikeImage } from './failureImages.js';
7
+ import { stepData } from './flow.js';
8
+ export { REVIEW_LOG_LINES };
9
+ /** Images per review page at most; images per test case at most; text per page at most (chars). */
10
+ export const MAX_REVIEW_IMAGES = 18, MAX_TESTCASE_IMAGES = 12, REVIEW_TEXT_CAP = 18000;
11
+ /** API response body shown per step; the passed step's body is cut to CUT_API_BODY_CHARS when the
12
+ * page is still over the cap after the logs were cut. */
13
+ const REVIEW_API_BODY_CHARS = 4000, CUT_API_BODY_CHARS = 500;
14
+ /** Text levels tried, in order, until the page fits REVIEW_TEXT_CAP: logs are cut first, then the
15
+ * passed step's API body. */
16
+ const LEVELS = [
17
+ { logs: REVIEW_LOG_LINES, passBody: REVIEW_API_BODY_CHARS },
18
+ { logs: 3, passBody: REVIEW_API_BODY_CHARS },
19
+ { logs: 0, passBody: REVIEW_API_BODY_CHARS },
20
+ { logs: 0, passBody: CUT_API_BODY_CHARS },
21
+ ];
22
+ /** The level pages are packed at. */
23
+ const PACK_LEVEL = { logs: 3, passBody: REVIEW_API_BODY_CHARS };
24
+ const MAX_LOG_CHARS = 500;
25
+ const MAX_OTHER_ITERATIONS = 5;
26
+ const execRef = (id, code) => code ?? `EX-${id}`;
27
+ const isFetchable = (url) => /^https?:\/\//i.test(url) && looksLikeImage(url);
28
+ /** Every failed test case in review order: its main pattern's position, then its key. */
29
+ export function reviewOrder(a) {
30
+ const rank = new Map(a.groups.map((g, i) => [g.id, i]));
31
+ const r = (tc) => rank.get(tc.primaryGroup) ?? Number.MAX_SAFE_INTEGER;
32
+ return [...a.testcases].sort((x, y) => r(x) - r(y) || (x.key < y.key ? -1 : x.key > y.key ? 1 : 0));
33
+ }
34
+ /** The keys already reviewed that are failed test cases of this analysis. */
35
+ const reviewedOf = (a, extra = []) => {
36
+ const keys = new Set(a.testcases.map((t) => t.key));
37
+ return new Set([...(a.reviewedKeys ?? []), ...extra].filter((k) => keys.has(k)));
38
+ };
39
+ /** "Reviewed k/total test cases individually." while the review is incomplete; undefined once done. */
40
+ export function reviewedLine(a) {
41
+ const total = a.testcases.length;
42
+ const k = reviewedOf(a).size;
43
+ return total && k < total ? `Reviewed ${k}/${total} test cases individually.` : undefined;
44
+ }
45
+ /** The iteration a test case is reviewed by: its first in its main pattern, else its first. */
46
+ function mainIteration(a, tc) {
47
+ const g = a.groups.find((x) => x.id === tc.primaryGroup);
48
+ return tc.failedIterations.find((f) => g?.iterationKeys.includes(f.key)) ?? tc.failedIterations[0];
49
+ }
50
+ const suiteText = (tc) => tc.suite.code ?? (tc.suite.id !== undefined ? `SU-${tc.suite.id}` : tc.suite.name ?? NO_SUITE);
51
+ function logBlock(lines, n, m, indent) {
52
+ // Retries log the same line again and again: consecutive repeats collapse to "line (×n)".
53
+ const tail = collapseRepeats((lines ?? []).map((l) => m(l))).slice(-n);
54
+ if (!n || !tail.length)
55
+ return [];
56
+ return [`${indent}- Logs (last ${tail.length}):`, `${indent} \`\`\`text`, ...tail.map((l) => `${indent} ${truncate(l, MAX_LOG_CHARS)}`), `${indent} \`\`\``];
57
+ }
58
+ /** "Locator: `…`" — the locator a step used (it can embed test data, so it is masked). */
59
+ const locatorLine = (locator, m) => (locator ? [` - Locator: \`${truncate(m(locator), 300)}\``] : []);
60
+ function failedStepLines(it, logs, m) {
61
+ const s = it.focus;
62
+ if (!s) {
63
+ return [`- **Failed step:** none — the run failed with no failed step${it.exception ? `: ${truncate(m(it.exception), 400)}` : ''}`];
64
+ }
65
+ const where = s.trail ?? (s.reportStep ? `step ${s.reportStep}` : `step ${s.seq}`);
66
+ const out = [`- **Failed step:** ${where}${s.reportStep ? ` (report step ${s.reportStep})` : ''} — ${truncate(m(s.description), 200)} \`${s.status}\``];
67
+ if (s.objectName || s.actionName)
68
+ out.push(` - Object: ${m(s.objectName ?? '-')} · Action: ${m(s.actionName ?? '-')}`);
69
+ out.push(...locatorLine(s.locator, m));
70
+ if (s.expected !== undefined)
71
+ out.push(` - Expected: ${truncate(m(s.expected), 400)}`);
72
+ if (s.actual !== undefined)
73
+ out.push(` - Actual: ${truncate(m(s.actual), 400)}`);
74
+ const errors = [...new Set([s.cause, ...s.errorLines, s.exception].filter((x) => !!x))].slice(0, 3);
75
+ for (const e of errors)
76
+ out.push(` - Error: ${truncate(m(e), 300)}`);
77
+ const data = stepData({ testdata: s.testdata });
78
+ if (data)
79
+ out.push(` - Test data: ${truncate(m(data), 300)}`);
80
+ out.push(...apiLines(s.apiData, m, { bodyChars: REVIEW_API_BODY_CHARS, indent: ' ' }));
81
+ out.push(...logBlock(s.logTail, logs, m, ' '));
82
+ return out;
83
+ }
84
+ /** A failure with no failed step (run-level, or no step id) has nothing to compare with the last pass. */
85
+ const NO_STEP = 'no failed step to compare';
86
+ const noStep = (it) => !it.focus?.stepId;
87
+ function passedStepLines(tc, it, cmp, level, m) {
88
+ if (noStep(it) && tc.history?.lastPassed)
89
+ return [`- **Same step in the last passed run:** ${NO_STEP}`];
90
+ if (!cmp) {
91
+ return tc.history?.lastPassed
92
+ ? ['- **Same step in the last passed run:** not compared']
93
+ : ['- **Same step in the last passed run:** no last passed run'];
94
+ }
95
+ const ref = execRef(cmp.executionId, cmp.executionCode);
96
+ if (!cmp.found)
97
+ return [`- **Same step in the last passed run (${ref}):** this step does not exist in the passed version`];
98
+ const out = [`- **Same step in the last passed run (${ref}):** ${cmp.status ?? 'status not recorded'}`];
99
+ out.push(...locatorLine(cmp.locator, m));
100
+ if (cmp.expected !== undefined)
101
+ out.push(` - Expected: ${truncate(m(cmp.expected), 400)}`);
102
+ if (cmp.actual !== undefined)
103
+ out.push(` - Actual: ${truncate(m(cmp.actual), 400)}`);
104
+ if (cmp.expected === undefined && cmp.actual === undefined && cmp.value)
105
+ out.push(` - Value: ${truncate(m(cmp.value), 400)}`);
106
+ if (cmp.data)
107
+ out.push(` - Test data: ${truncate(m(cmp.data), 300)}`);
108
+ // The full API (status, body, assertions) as for the failed step; an analysis stored before the
109
+ // API was kept in full has only its one-line summary.
110
+ const api = apiLines(cmp.apiData, m, { bodyChars: level.passBody, indent: ' ' });
111
+ if (api.length)
112
+ out.push(...api);
113
+ else if (cmp.api)
114
+ out.push(` - API: ${truncate(m(cmp.api), 300)}`);
115
+ out.push(...logBlock(cmp.logs, level.logs, m, ' '));
116
+ return out;
117
+ }
118
+ /** The note for an image slot with no usable value when the step was read ("<slot> skipped: …"). */
119
+ const skippedNote = (notes, what) => notes?.find((n) => n.startsWith(`${what} skipped: `))?.slice(what.length + ' skipped: '.length);
120
+ /** Distinct urls among the slots — what a test case costs in images. */
121
+ const sentCount = (slots) => new Set(slots.flatMap((s) => (s.url ? [s.url] : []))).size;
122
+ /**
123
+ * Every image slot of one test case, in the fixed order: the failed screenshots (this run), today's
124
+ * baseline, the element thumbnail, the last passed screenshots, the passed run's baseline, and the
125
+ * passed step's thumbnail (a note when it is today's). Over MAX_TESTCASE_IMAGES, a step's
126
+ * screenshots are cut to its first and last (the larger step first). Captions carry the masked
127
+ * label (a name when there is no code).
128
+ */
129
+ function testcaseImages(a, tc, m) {
130
+ const f = mainIteration(a, tc);
131
+ const label = tc.code ?? (tc.name !== undefined ? m(tc.name) : tc.key);
132
+ const it = f?.it;
133
+ const s = it?.focus;
134
+ const cmp = f ? a.comparisons[f.key] : undefined;
135
+ const slot = (kind, caption, url, none) => {
136
+ if (url === undefined)
137
+ return { caption, label, kind, missing: `${label} · ${kind}: ${none}` };
138
+ if (!isFetchable(url))
139
+ return { caption, label, kind, missing: `${label} · ${kind}: not an image ("${truncate(url, 80)}")` };
140
+ return { caption, label, kind, url, missing: `${caption}: could not be fetched` };
141
+ };
142
+ const note = (kind, text) => ({ caption: `${label} · ${kind}`, label, kind, missing: `${label} · ${kind}: ${text}` });
143
+ const numbered = (n, i) => (n > 1 ? ` ${i + 1}/${n}` : '');
144
+ const execCode = a.executions.find((e) => String(e.id) === tc.executionId)?.code;
145
+ const shotStep = it ? [it.focus, ...it.failedSteps].find((x) => x?.screenshots.some((y) => y.absoluteUrl)) : undefined;
146
+ const shotUrls = (shotStep?.screenshots ?? []).map((y) => y.absoluteUrl).filter((u) => !!u);
147
+ const failedShots = shotUrls.length
148
+ ? shotUrls.map((u, i) => slot('failed screenshot', `${label} · failed screenshot${numbered(shotUrls.length, i)} (${execRef(tc.executionId, execCode)}, this run)`, u, 'none recorded'))
149
+ : [slot('failed screenshot', `${label} · failed screenshot (${execRef(tc.executionId, execCode)}, this run)`, undefined, 'none recorded')];
150
+ const today = [
151
+ slot('baseline', `${label} · baseline (execution time, this run — page with the element boxed in red)`, s?.recordedBaseline, skippedNote(s?.imageNotes, 'baseline') ?? 'none recorded'),
152
+ slot('element thumbnail', `${label} · element thumbnail (recording time)`, s?.recordedThumbnail, skippedNote(s?.imageNotes, 'element thumbnail') ?? 'none recorded'),
153
+ ];
154
+ const compared = !!cmp && cmp.found && !(it && noStep(it));
155
+ const passNone = !tc.history?.lastPassed ? 'no last passed run'
156
+ : it && noStep(it) ? NO_STEP
157
+ : !cmp ? 'not compared'
158
+ : !cmp.found ? 'this step does not exist in the passed version' : 'none recorded';
159
+ const passRef = cmp ? execRef(cmp.executionId, cmp.executionCode) : '';
160
+ const passUrls = compared ? (cmp.screenshots ?? (cmp.screenshot ? [cmp.screenshot] : [])).map((y) => y.absoluteUrl).filter((u) => !!u) : [];
161
+ const passShots = passUrls.length
162
+ ? passUrls.map((u, i) => slot('last passed', `${label} · last passed screenshot${numbered(passUrls.length, i)} (${passRef})`, u, passNone))
163
+ : [slot('last passed', compared || (cmp && !(it && noStep(it))) ? `${label} · last passed screenshot (${passRef})` : `${label} · last passed`, undefined, passNone)];
164
+ const passed = [];
165
+ if (compared) {
166
+ passed.push(slot('passed baseline', `${label} · baseline (execution time, last passed ${passRef})`, cmp.baseline?.baseline, skippedNote(cmp.imageNotes, 'baseline') ?? 'none recorded'));
167
+ const thumb = cmp.baseline?.thumbnail;
168
+ if (thumb !== undefined) {
169
+ passed.push(thumb === s?.recordedThumbnail
170
+ ? note('passed thumbnail', 'same element thumbnail as today')
171
+ : slot('passed thumbnail', `${label} · element thumbnail of the passed step (recording time)`, thumb, 'none recorded'));
172
+ }
173
+ }
174
+ // Over the per-test-case cap: cut the step with more screenshots to its first and last, then the other.
175
+ const all = () => [...failed, ...today, ...pass, ...passed];
176
+ let failed = failedShots;
177
+ let pass = passShots;
178
+ const cut = (shots, kind) => {
179
+ const sent = shots.filter((x) => x.url);
180
+ if (sent.length <= 2)
181
+ return shots;
182
+ return [sent[0], note(kind, `+${sent.length - 2} more screenshots (links in the export)`), sent[sent.length - 1]];
183
+ };
184
+ const order = sentCount(failedShots) >= sentCount(passShots) ? ['failed', 'pass'] : ['pass', 'failed'];
185
+ for (const which of order) {
186
+ if (sentCount(all()) <= MAX_TESTCASE_IMAGES)
187
+ break;
188
+ if (which === 'failed')
189
+ failed = cut(failed, 'failed screenshot');
190
+ else
191
+ pass = cut(pass, 'last passed');
192
+ }
193
+ return all();
194
+ }
195
+ function testcaseBlock(a, tc, level, m) {
196
+ const f = mainIteration(a, tc);
197
+ const head = [
198
+ testcaseLabel(tc, m),
199
+ tc.code !== undefined && tc.name !== undefined ? truncate(m(tc.name), 80) : undefined,
200
+ `pattern #${tc.primaryGroup}`,
201
+ suiteText(tc),
202
+ ].filter((x) => !!x);
203
+ const out = [`### ${head.join(' · ')}`];
204
+ if (f)
205
+ out.push(`- **Iteration:** ${f.it.iteration ?? f.it.label} · key \`${f.key}\``);
206
+ const others = tc.failedIterations.filter((x) => x !== f);
207
+ if (others.length) {
208
+ const groupOf = (k) => a.groups.find((g) => g.iterationKeys.includes(k))?.id;
209
+ const shown = others.slice(0, MAX_OTHER_ITERATIONS).map((x) => `${x.it.iteration ?? x.it.label} (pattern #${groupOf(x.key) ?? '?'})`);
210
+ out.push(`- **Also failed:** ${shown.join(', ')}${others.length > shown.length ? `, +${others.length - shown.length} more` : ''}`);
211
+ }
212
+ const hist = historyParts(tc.history, tc.versionName, m, 'edited since pass');
213
+ out.push(`- **History:** ${hist.length ? hist.join(' · ') : 'not read'}`);
214
+ if (f)
215
+ out.push(...failedStepLines(f.it, level.logs, m), ...passedStepLines(tc, f.it, a.comparisons[f.key], level, m));
216
+ return out.join('\n');
217
+ }
218
+ const maskOf = (a) => {
219
+ const masker = maskWith(protectedValues(a));
220
+ return (x) => masker(x) ?? x;
221
+ };
222
+ /**
223
+ * The review pages, in review order: each is filled with test cases until the next one would take
224
+ * the page past MAX_REVIEW_IMAGES images (a test case costs its distinct images, at most
225
+ * MAX_TESTCASE_IMAGES) or past the text budget (blocks measured with 3 log lines); at least one
226
+ * test case per page. Depends only on the analysis, so every page agrees on the paging.
227
+ */
228
+ export function reviewPages(a) {
229
+ const m = maskOf(a);
230
+ // Room for the page around the blocks, at its WORST: every note, an out-of-range line and the
231
+ // longest footer ("Not reviewed yet" listing every page). Measured with the test case count as
232
+ // the page count (never fewer pages than that), so a packed page never has to drop a block — a
233
+ // dropped block would be dropped again on every visit and never be reviewed.
234
+ const budget = REVIEW_TEXT_CAP - pageChrome(a, a.testcases.length).length;
235
+ const pages = [];
236
+ let cur = [];
237
+ let images = 0;
238
+ let size = 0;
239
+ for (const tc of reviewOrder(a)) {
240
+ const cost = sentCount(testcaseImages(a, tc, m));
241
+ const len = testcaseBlock(a, tc, PACK_LEVEL, m).length + 2;
242
+ if (cur.length && (images + cost > MAX_REVIEW_IMAGES || size + len > budget)) {
243
+ pages.push(cur);
244
+ cur = [];
245
+ images = 0;
246
+ size = 0;
247
+ }
248
+ cur.push(tc);
249
+ images += cost;
250
+ size += len;
251
+ }
252
+ if (cur.length)
253
+ pages.push(cur);
254
+ return pages;
255
+ }
256
+ const KB = Math.round(REVIEW_TEXT_CAP / 1000);
257
+ const headOf = (a) => `**Failure analysis \`${a.id}\` — review of every failed test case**`;
258
+ function introOf(a, page, pages, first, last, total, requested) {
259
+ const intro = [
260
+ headOf(a),
261
+ `Page ${page} of ${pages} · failed test cases ${first}–${last} of ${total}, in pattern order.`,
262
+ 'For each test case: compare the last passed step with the failed step side by side — expected, actual, test data, API status / body / assertions, locator, logs, version — and the images below (failed screenshots, today\'s baseline, the element thumbnail, the last passed screenshots, the passed run\'s baseline). '
263
+ + 'State what changed and what stayed the same in one line (e.g. "same data, same locator, same page; only the actual message changed"), then decide the category. Evidence for classifying — do not paste.',
264
+ ];
265
+ if (requested !== page)
266
+ intro.push(`Page ${requested} does not exist; showing page ${page} of ${pages}.`);
267
+ return intro;
268
+ }
269
+ /** The footer: how many are reviewed, then Next / the pages not reviewed yet / what to do now. */
270
+ function footerOf(a, page, pages, total, reviewed, missing) {
271
+ const out = [`Reviewed ${reviewed}/${total} failed test cases.`];
272
+ if (page < pages) {
273
+ out.push(`Next: failure_analysis({ analysisId: "${a.id}", review: true, page: ${page + 1} })`);
274
+ }
275
+ else if (missing.length) {
276
+ out.push(`Not reviewed yet: page ${missing.join(', ')} — failure_analysis({ analysisId: "${a.id}", review: true, page: ${missing[0]} }).`);
277
+ }
278
+ else {
279
+ out.push('Review complete. For every test case you should now have one line of what changed and what stayed the same between the last passed and the failed step. Now call failure_analysis_classify ONCE with a verdict for every pattern — use `splitOut` for test cases whose review shows a different cause and `mergeInto` for groups that share one — then reply with the classified card.');
280
+ }
281
+ return out;
282
+ }
283
+ function notesOf(level, dropped) {
284
+ return [
285
+ ...(level.logs < REVIEW_LOG_LINES ? [`_(log lines cut to ${level.logs} per step to keep this page under ${KB} KB.)_`] : []),
286
+ ...(level.passBody < REVIEW_API_BODY_CHARS ? [`_(the last passed step's API body cut to ${level.passBody} characters to keep this page under ${KB} KB.)_`] : []),
287
+ ...(dropped ? [`_(${dropped} test case(s) of this page not shown — over the size cap; they are not counted as reviewed.)_`] : []),
288
+ ];
289
+ }
290
+ /** Everything on a page around its blocks, at its longest for `pages` pages: the intro with an
291
+ * out-of-range line, every note, and both long footers. */
292
+ function pageChrome(a, pages) {
293
+ const n = Math.max(1, pages);
294
+ const total = a.testcases.length;
295
+ const every = Array.from({ length: n }, (_, i) => i + 1);
296
+ const footer = [footerOf(a, n, n, total, total, every), footerOf(a, n, n, total, total, [])]
297
+ .map((f) => f.join('\n')).sort((x, y) => y.length - x.length)[0];
298
+ return [
299
+ ...introOf(a, n, n, total, total, total, Number.MAX_SAFE_INTEGER),
300
+ ...notesOf({ logs: 0, passBody: CUT_API_BODY_CHARS }, total),
301
+ '', '', footer, `Next: failure_analysis({ analysisId: "${a.id}", review: true, page: ${n} })`,
302
+ ].join('\n');
303
+ }
304
+ export function renderReviewPage(a, requested) {
305
+ const m = maskOf(a);
306
+ const all = reviewOrder(a);
307
+ if (!all.length)
308
+ return { text: `${headOf(a)}\n\nNo failed test cases to review.`, testcaseKeys: [], groups: [], images: [] };
309
+ const pageList = reviewPages(a);
310
+ const pages = pageList.length;
311
+ const page = Math.min(Math.max(1, Math.floor(requested)), pages);
312
+ const mine = pageList[page - 1];
313
+ const start = pageList.slice(0, page - 1).reduce((n, p) => n + p.length, 0);
314
+ const pageOf = new Map(pageList.flatMap((p, i) => p.map((t) => [t.key, i + 1])));
315
+ // ---- Text: logs are cut first, then the passed step's API body; then whole test case blocks are
316
+ // dropped from the end (never a cut inside a block, so no code fence is left open). Only the
317
+ // blocks rendered count as reviewed. Pages are packed (reviewPages) so that a drop does not happen.
318
+ const intro = introOf(a, page, pages, start + 1, start + mine.length, all.length, requested);
319
+ const footerFor = (keys) => {
320
+ const reviewed = reviewedOf(a, keys);
321
+ const missing = [...new Set(all.filter((t) => !reviewed.has(t.key)).map((t) => pageOf.get(t.key) ?? 1))].sort((x, y) => x - y);
322
+ return footerOf(a, page, pages, all.length, reviewed.size, missing);
323
+ };
324
+ const kb = KB;
325
+ const render = (level, n) => {
326
+ const notes = notesOf(level, mine.length - n);
327
+ const shown = mine.slice(0, n);
328
+ return [...intro, ...notes, '', shown.map((tc) => testcaseBlock(a, tc, level, m)).join('\n\n'), '', ...footerFor(shown.map((t) => t.key))].join('\n');
329
+ };
330
+ let rendered = mine.length;
331
+ let text = '';
332
+ for (const level of LEVELS) {
333
+ text = render(level, rendered);
334
+ if (text.length <= REVIEW_TEXT_CAP)
335
+ break;
336
+ }
337
+ const tightest = LEVELS[LEVELS.length - 1];
338
+ while (text.length > REVIEW_TEXT_CAP && rendered > 1) {
339
+ rendered--;
340
+ text = render(tightest, rendered);
341
+ }
342
+ if (text.length > REVIEW_TEXT_CAP) {
343
+ // One block alone is over the cap: cut it, close any open code fence, keep the footer.
344
+ const footer = footerFor([mine[0].key]).join('\n');
345
+ const tail = `\n…(cut to stay under ${kb} KB)\n\n${footer}`;
346
+ let body = text.slice(0, REVIEW_TEXT_CAP - tail.length - 8);
347
+ if ((body.match(/```/g) ?? []).length % 2 === 1)
348
+ body += '\n```';
349
+ text = `${body}${tail}`;
350
+ }
351
+ const shown = mine.slice(0, rendered);
352
+ // ---- Images of the rendered test cases: every slot, a url sent once per page, at most MAX_REVIEW_IMAGES.
353
+ const images = [];
354
+ const firstCaption = new Map();
355
+ let sent = 0;
356
+ for (const tc of shown) {
357
+ for (const img of testcaseImages(a, tc, m)) {
358
+ if (img.url === undefined) {
359
+ images.push(img);
360
+ continue;
361
+ }
362
+ const { url: _url, ...rest } = img;
363
+ const dup = firstCaption.get(img.url);
364
+ if (dup !== undefined) {
365
+ images.push({ ...rest, missing: `${img.label} · ${img.kind}: same image as ${dup}` });
366
+ continue;
367
+ }
368
+ if (sent >= MAX_REVIEW_IMAGES) {
369
+ images.push({ ...rest, missing: `${img.label} · ${img.kind}: not sent (${MAX_REVIEW_IMAGES} images per page)` });
370
+ continue;
371
+ }
372
+ firstCaption.set(img.url, img.caption);
373
+ sent++;
374
+ images.push(img);
375
+ }
376
+ }
377
+ return {
378
+ text,
379
+ testcaseKeys: shown.map((t) => t.key),
380
+ groups: [...new Set(shown.map((t) => t.primaryGroup))].filter((g) => a.groups.some((x) => x.id === g)).sort((x, y) => x - y),
381
+ images,
382
+ };
383
+ }
384
+ //# sourceMappingURL=failureReview.js.map