simplify3x-connect 0.28.1 → 0.31.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/README.md +150 -55
- package/dist/adapters/http.d.ts.map +1 -1
- package/dist/adapters/http.js +3 -2
- package/dist/adapters/http.js.map +1 -1
- package/dist/adapters/simplifyqa/adapter.d.ts +464 -4
- package/dist/adapters/simplifyqa/adapter.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/adapter.js +2474 -103
- package/dist/adapters/simplifyqa/adapter.js.map +1 -1
- package/dist/adapters/simplifyqa/executionFailures.d.ts +59 -1
- package/dist/adapters/simplifyqa/executionFailures.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/executionFailures.js +429 -39
- package/dist/adapters/simplifyqa/executionFailures.js.map +1 -1
- package/dist/adapters/simplifyqa/failureAnalysis.d.ts +45 -0
- package/dist/adapters/simplifyqa/failureAnalysis.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureAnalysis.js +373 -0
- package/dist/adapters/simplifyqa/failureAnalysis.js.map +1 -0
- package/dist/adapters/simplifyqa/failureAnalysisCard.d.ts +31 -0
- package/dist/adapters/simplifyqa/failureAnalysisCard.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureAnalysisCard.js +371 -0
- package/dist/adapters/simplifyqa/failureAnalysisCard.js.map +1 -0
- package/dist/adapters/simplifyqa/failureAnalysisRun.d.ts +41 -0
- package/dist/adapters/simplifyqa/failureAnalysisRun.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureAnalysisRun.js +138 -0
- package/dist/adapters/simplifyqa/failureAnalysisRun.js.map +1 -0
- package/dist/adapters/simplifyqa/failureAnalysisTypes.d.ts +84 -0
- package/dist/adapters/simplifyqa/failureAnalysisTypes.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureAnalysisTypes.js +2 -0
- package/dist/adapters/simplifyqa/failureAnalysisTypes.js.map +1 -0
- package/dist/adapters/simplifyqa/failureHistory.d.ts +163 -0
- package/dist/adapters/simplifyqa/failureHistory.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureHistory.js +174 -0
- package/dist/adapters/simplifyqa/failureHistory.js.map +1 -0
- package/dist/adapters/simplifyqa/failureImages.d.ts +13 -0
- package/dist/adapters/simplifyqa/failureImages.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureImages.js +38 -0
- package/dist/adapters/simplifyqa/failureImages.js.map +1 -0
- package/dist/adapters/simplifyqa/failurePatterns.d.ts +54 -0
- package/dist/adapters/simplifyqa/failurePatterns.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failurePatterns.js +223 -0
- package/dist/adapters/simplifyqa/failurePatterns.js.map +1 -0
- package/dist/adapters/simplifyqa/failureReport.d.ts +35 -41
- package/dist/adapters/simplifyqa/failureReport.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failureReport.js +94 -249
- package/dist/adapters/simplifyqa/failureReport.js.map +1 -1
- package/dist/adapters/simplifyqa/failureReportModel.d.ts +73 -0
- package/dist/adapters/simplifyqa/failureReportModel.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureReportModel.js +199 -0
- package/dist/adapters/simplifyqa/failureReportModel.js.map +1 -0
- package/dist/adapters/simplifyqa/failureReview.d.ts +36 -0
- package/dist/adapters/simplifyqa/failureReview.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureReview.js +384 -0
- package/dist/adapters/simplifyqa/failureReview.js.map +1 -0
- package/dist/adapters/simplifyqa/failureSuggest.d.ts +13 -0
- package/dist/adapters/simplifyqa/failureSuggest.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureSuggest.js +54 -0
- package/dist/adapters/simplifyqa/failureSuggest.js.map +1 -0
- package/dist/adapters/simplifyqa/failureTypes.d.ts +22 -1
- package/dist/adapters/simplifyqa/failureTypes.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/loopConditions.d.ts +57 -0
- package/dist/adapters/simplifyqa/loopConditions.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/loopConditions.js +145 -0
- package/dist/adapters/simplifyqa/loopConditions.js.map +1 -0
- package/dist/adapters/simplifyqa/mapper.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/mapper.js +3 -1
- package/dist/adapters/simplifyqa/mapper.js.map +1 -1
- package/dist/adapters/simplifyqa/searchEngine.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/searchEngine.js +6 -3
- package/dist/adapters/simplifyqa/searchEngine.js.map +1 -1
- package/dist/adapters/simplifyqa/searchRegistry.d.ts +7 -2
- package/dist/adapters/simplifyqa/searchRegistry.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/searchRegistry.js +21 -2
- package/dist/adapters/simplifyqa/searchRegistry.js.map +1 -1
- package/dist/adapters/simplifyqa/spreadsheet.d.ts +15 -0
- package/dist/adapters/simplifyqa/spreadsheet.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/spreadsheet.js +196 -0
- package/dist/adapters/simplifyqa/spreadsheet.js.map +1 -0
- package/dist/adapters/types.d.ts +24 -0
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/config.d.ts +0 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -12
- package/dist/config.js.map +1 -1
- package/dist/connection.d.ts +4 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +12 -5
- package/dist/connection.js.map +1 -1
- package/dist/defaults.d.ts +45 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +50 -0
- package/dist/defaults.js.map +1 -0
- package/dist/domain/types.d.ts +40 -2
- package/dist/domain/types.d.ts.map +1 -1
- package/dist/domain/types.js.map +1 -1
- package/dist/drafts/store.d.ts +0 -1
- package/dist/drafts/store.d.ts.map +1 -1
- package/dist/drafts/store.js +8 -3
- package/dist/drafts/store.js.map +1 -1
- package/dist/export/json.d.ts +4 -0
- package/dist/export/json.d.ts.map +1 -0
- package/dist/export/json.js +5 -0
- package/dist/export/json.js.map +1 -0
- package/dist/export/layout.d.ts +119 -0
- package/dist/export/layout.d.ts.map +1 -0
- package/dist/export/layout.js +198 -0
- package/dist/export/layout.js.map +1 -0
- package/dist/export/pdf.d.ts +67 -0
- package/dist/export/pdf.d.ts.map +1 -0
- package/dist/export/pdf.js +279 -0
- package/dist/export/pdf.js.map +1 -0
- package/dist/export/xlsx.d.ts +52 -0
- package/dist/export/xlsx.d.ts.map +1 -0
- package/dist/export/xlsx.js +251 -0
- package/dist/export/xlsx.js.map +1 -0
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +13 -3
- package/dist/gateway.js.map +1 -1
- package/dist/httpMain.js +3 -2
- package/dist/httpMain.js.map +1 -1
- package/dist/initAgents.d.ts.map +1 -1
- package/dist/initAgents.js +13 -5
- package/dist/initAgents.js.map +1 -1
- package/dist/mcpResult.d.ts +4 -3
- package/dist/mcpResult.d.ts.map +1 -1
- package/dist/mcpResult.js +4 -2
- package/dist/mcpResult.js.map +1 -1
- package/dist/mount.d.ts +7 -1
- package/dist/mount.d.ts.map +1 -1
- package/dist/mount.js +14 -7
- package/dist/mount.js.map +1 -1
- package/dist/requestConnection.d.ts.map +1 -1
- package/dist/requestConnection.js +8 -3
- package/dist/requestConnection.js.map +1 -1
- package/dist/server.d.ts +9 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +53 -4
- package/dist/server.js.map +1 -1
- package/dist/tools/attachment.tools.d.ts.map +1 -1
- package/dist/tools/attachment.tools.js +54 -1
- package/dist/tools/attachment.tools.js.map +1 -1
- package/dist/tools/backlog.tools.d.ts.map +1 -1
- package/dist/tools/backlog.tools.js +41 -0
- package/dist/tools/backlog.tools.js.map +1 -1
- package/dist/tools/defectFromStep.tools.d.ts +16 -0
- package/dist/tools/defectFromStep.tools.d.ts.map +1 -0
- package/dist/tools/defectFromStep.tools.js +90 -0
- package/dist/tools/defectFromStep.tools.js.map +1 -0
- package/dist/tools/defectUpdate.tools.d.ts +15 -0
- package/dist/tools/defectUpdate.tools.d.ts.map +1 -0
- package/dist/tools/defectUpdate.tools.js +120 -0
- package/dist/tools/defectUpdate.tools.js.map +1 -0
- package/dist/tools/discovery.tools.d.ts +2 -0
- package/dist/tools/discovery.tools.d.ts.map +1 -1
- package/dist/tools/discovery.tools.js +8 -3
- package/dist/tools/discovery.tools.js.map +1 -1
- package/dist/tools/environment.tools.d.ts +18 -0
- package/dist/tools/environment.tools.d.ts.map +1 -0
- package/dist/tools/environment.tools.js +86 -0
- package/dist/tools/environment.tools.js.map +1 -0
- package/dist/tools/executionPlan.tools.d.ts.map +1 -1
- package/dist/tools/executionPlan.tools.js +37 -11
- package/dist/tools/executionPlan.tools.js.map +1 -1
- package/dist/tools/failure.tools.d.ts +12 -4
- package/dist/tools/failure.tools.d.ts.map +1 -1
- package/dist/tools/failure.tools.js +264 -33
- package/dist/tools/failure.tools.js.map +1 -1
- package/dist/tools/failureAnalysisStore.d.ts +30 -0
- package/dist/tools/failureAnalysisStore.d.ts.map +1 -0
- package/dist/tools/failureAnalysisStore.js +84 -0
- package/dist/tools/failureAnalysisStore.js.map +1 -0
- package/dist/tools/failureExport.tools.d.ts +26 -0
- package/dist/tools/failureExport.tools.d.ts.map +1 -0
- package/dist/tools/failureExport.tools.js +201 -0
- package/dist/tools/failureExport.tools.js.map +1 -0
- package/dist/tools/import.tools.d.ts +21 -0
- package/dist/tools/import.tools.d.ts.map +1 -0
- package/dist/tools/import.tools.js +187 -0
- package/dist/tools/import.tools.js.map +1 -0
- package/dist/tools/outDir.d.ts +9 -0
- package/dist/tools/outDir.d.ts.map +1 -0
- package/dist/tools/outDir.js +28 -0
- package/dist/tools/outDir.js.map +1 -0
- package/dist/tools/preference.tools.d.ts.map +1 -1
- package/dist/tools/preference.tools.js +29 -6
- package/dist/tools/preference.tools.js.map +1 -1
- package/dist/tools/query.tools.js +1 -1
- package/dist/tools/query.tools.js.map +1 -1
- package/dist/tools/releaseSprint.tools.d.ts +14 -0
- package/dist/tools/releaseSprint.tools.d.ts.map +1 -0
- package/dist/tools/releaseSprint.tools.js +130 -0
- package/dist/tools/releaseSprint.tools.js.map +1 -0
- package/dist/tools/report.tools.d.ts +2 -0
- package/dist/tools/report.tools.d.ts.map +1 -1
- package/dist/tools/report.tools.js +18 -4
- package/dist/tools/report.tools.js.map +1 -1
- package/dist/tools/run.tools.d.ts +7 -0
- package/dist/tools/run.tools.d.ts.map +1 -1
- package/dist/tools/run.tools.js +80 -18
- package/dist/tools/run.tools.js.map +1 -1
- package/dist/tools/schemas.d.ts +177 -0
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +4 -0
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/suiteManage.tools.d.ts.map +1 -1
- package/dist/tools/suiteManage.tools.js +24 -2
- package/dist/tools/suiteManage.tools.js.map +1 -1
- package/dist/tools/tasks.tools.d.ts.map +1 -1
- package/dist/tools/tasks.tools.js +101 -0
- package/dist/tools/tasks.tools.js.map +1 -1
- package/dist/tools/testCaseLint.d.ts.map +1 -1
- package/dist/tools/testCaseLint.js +20 -0
- package/dist/tools/testCaseLint.js.map +1 -1
- package/dist/tools/testcase.tools.d.ts +4 -0
- package/dist/tools/testcase.tools.d.ts.map +1 -1
- package/dist/tools/testcase.tools.js +28 -0
- package/dist/tools/testcase.tools.js.map +1 -1
- package/dist/tools/testdata.tools.d.ts.map +1 -1
- package/dist/tools/testdata.tools.js +42 -1
- package/dist/tools/testdata.tools.js.map +1 -1
- package/dist/vendor/logger.d.ts +3 -5
- package/dist/vendor/logger.d.ts.map +1 -1
- package/dist/vendor/logger.js +13 -8
- package/dist/vendor/logger.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -6
- package/dist/tools/xlsx.d.ts +0 -8
- package/dist/tools/xlsx.d.ts.map +0 -1
- package/dist/tools/xlsx.js +0 -113
- package/dist/tools/xlsx.js.map +0 -1
|
@@ -9,13 +9,61 @@ import { notDeleted, pickArray, str } from './mapper.js';
|
|
|
9
9
|
import { mapLimit } from './mapLimit.js';
|
|
10
10
|
import { causeSignature, currentRuns, EXECUTION_TYPE_BY_KIND, failureState, groupBy, iterationLabel, lastTouchedStep, numberSteps, parseEntityCode, realFailures, reportStepLabel, runKey, runLabel, } from './stepRules.js';
|
|
11
11
|
import { apiBrief, buildFlow, functionCallsLine, notRunLines, stepData } from './flow.js';
|
|
12
|
+
import { createHistoryCache, executionInfo, FAILED_SEARCH_LIMIT, REVIEW_LOG_LINES, failingSinceOf, lastPassedOf, PASSED_SEARCH_LIMIT, passedRunFor, pickComparisonRow, } from './failureHistory.js';
|
|
13
|
+
import { maskDeep, maskWith, protectedOf } from './failureReport.js';
|
|
14
|
+
import { normaliseImageUrl } from './failureImages.js';
|
|
12
15
|
import { categoryOf, cleanLogLines, extractCause, isNoiseLine, trimTrace } from './failureCategory.js';
|
|
13
16
|
/** Log lines kept per failed step by default — the tail nearest the failure (ai-assistant FAILURE_LOG_TAIL). */
|
|
14
17
|
export const FAILURE_LOG_TAIL = 30;
|
|
18
|
+
/** Longest test case description kept (after markup is stripped). */
|
|
19
|
+
export const MAX_DESCRIPTION_CHARS = 500;
|
|
20
|
+
/** Plain text of a description that may be HTML; non-strings and empty results give undefined. */
|
|
21
|
+
function cleanDescription(v) {
|
|
22
|
+
if (typeof v !== 'string')
|
|
23
|
+
return undefined;
|
|
24
|
+
const t = v.replace(/<[^>]*>/g, ' ').replace(/ /gi, ' ').replace(/\s+/g, ' ').trim();
|
|
25
|
+
if (!t)
|
|
26
|
+
return undefined;
|
|
27
|
+
return t.length > MAX_DESCRIPTION_CHARS ? `${t.slice(0, MAX_DESCRIPTION_CHARS - 1)}…` : t;
|
|
28
|
+
}
|
|
15
29
|
/** Distinct error lines kept per failed step. */
|
|
16
30
|
const MAX_ERROR_LINES = 5;
|
|
17
|
-
/** Failed iterations analysed per
|
|
31
|
+
/** Failed iterations analysed per analysis (the assistant's MAX_RUNS); the rest are counted only. */
|
|
18
32
|
const MAX_FAILURE_RUNS = 300;
|
|
33
|
+
/** Notes that say the same thing for every execution — shown once per analysis, without an execution ref. */
|
|
34
|
+
export const NOTE_RUN_LEVEL = 'Some iterations failed with no failed step (manual verdict or a stop) — their focus is the last step that ran, and the cause is the run-level exception.';
|
|
35
|
+
export const NOTE_SCREENSHOT_URLS = 'Screenshot URLs are SQA artifact paths; they need the SQA bearer token to download.';
|
|
36
|
+
export const NOTE_FULL_LOGS = 'Full logs are kept for a limited number of representative iterations; the others keep their error lines and log count.';
|
|
37
|
+
export const GENERIC_NOTES = new Set([NOTE_RUN_LEVEL, NOTE_SCREENSHOT_URLS, NOTE_FULL_LOGS]);
|
|
38
|
+
/** A Mask from a set of protected values. */
|
|
39
|
+
function maskOf(values) {
|
|
40
|
+
const mv = maskWith(values);
|
|
41
|
+
return (x) => mv(x) ?? x;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* One raw step-result row with its free-text fields masked (expected / actual / exception, logs,
|
|
45
|
+
* API data, unprotected test data values) — BEFORE anything is extracted, cut or truncated, so a
|
|
46
|
+
* protected value never shows even in part. Ids, urls and the protected entries themselves are left
|
|
47
|
+
* alone (protected entries are always shown as *** where they are rendered).
|
|
48
|
+
*/
|
|
49
|
+
function maskRow(r, m) {
|
|
50
|
+
if (!r || typeof r !== 'object')
|
|
51
|
+
return r;
|
|
52
|
+
const out = { ...r };
|
|
53
|
+
for (const k of ['expectedResult', 'actualResult', 'exception'])
|
|
54
|
+
if (typeof out[k] === 'string')
|
|
55
|
+
out[k] = m(out[k]);
|
|
56
|
+
const logs = r.executionLogData?.executionLogs;
|
|
57
|
+
if (Array.isArray(logs)) {
|
|
58
|
+
out.executionLogData = { ...r.executionLogData, executionLogs: logs.map((l) => (typeof l === 'string' ? m(l) : l)) };
|
|
59
|
+
}
|
|
60
|
+
if (r.apiData)
|
|
61
|
+
out.apiData = maskDeep(r.apiData, m);
|
|
62
|
+
if (Array.isArray(r.testdata)) {
|
|
63
|
+
out.testdata = r.testdata.map((d) => (d && typeof d === 'object' && d.protected !== true && typeof d.value === 'string' ? { ...d, value: m(d.value) } : d));
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
19
67
|
/** Step-result reads in flight at once. */
|
|
20
68
|
const FAILURE_CONCURRENCY = 5;
|
|
21
69
|
/** Cause groups whose representative keeps full logs — the output goes into the client's context. */
|
|
@@ -109,13 +157,105 @@ function logField(logs, re) {
|
|
|
109
157
|
}
|
|
110
158
|
return undefined;
|
|
111
159
|
}
|
|
160
|
+
/** Raw image fields, most preferred first (see normalizeFailureStep). */
|
|
161
|
+
const BASELINE_FIELDS = ['copiedBaseLinepath', 'recordedBaseLinePath', 'recordedBaseline'];
|
|
162
|
+
const THUMBNAIL_FIELDS = ['recordedThumbnailPath', 'copiedThumbnailpath', 'executedThumbnailPath', 'executedThumbnail'];
|
|
163
|
+
/** The non-empty string values of `keys` on `row`, in `keys` order, names matched case-insensitively. */
|
|
164
|
+
function fieldsCI(row, keys) {
|
|
165
|
+
if (!row || typeof row !== 'object')
|
|
166
|
+
return [];
|
|
167
|
+
const byLower = new Map();
|
|
168
|
+
for (const [k, v] of Object.entries(row)) {
|
|
169
|
+
const lk = k.toLowerCase();
|
|
170
|
+
if (!byLower.has(lk) || (typeof v === 'string' && v.trim()))
|
|
171
|
+
byLower.set(lk, v);
|
|
172
|
+
}
|
|
173
|
+
return keys
|
|
174
|
+
.map((k) => byLower.get(k.toLowerCase()))
|
|
175
|
+
.filter((v) => typeof v === 'string' && v.trim().length > 0);
|
|
176
|
+
}
|
|
112
177
|
function absUrl(base, value) {
|
|
113
178
|
if (!value)
|
|
114
179
|
return '';
|
|
115
180
|
return value.startsWith('/') ? `${base}${value}` : value;
|
|
116
181
|
}
|
|
182
|
+
/** Longest API response body kept for the passed step of a comparison (stored with the analysis). */
|
|
183
|
+
export const PASSED_API_BODY_CHARS = 4000;
|
|
184
|
+
/** Assertions kept for the passed step (the review shows 10), and the longest string value in each. */
|
|
185
|
+
const PASSED_API_ASSERTIONS = 10, PASSED_ASSERTION_CHARS = 300;
|
|
186
|
+
/**
|
|
187
|
+
* The part of an API step the review shows, compact: the response status and body (cut to
|
|
188
|
+
* `PASSED_API_BODY_CHARS`) and the assertions. undefined when there is neither.
|
|
189
|
+
*/
|
|
190
|
+
export function compactApiData(v) {
|
|
191
|
+
const a = v;
|
|
192
|
+
if (!a || typeof a !== 'object')
|
|
193
|
+
return undefined;
|
|
194
|
+
const res = a.responseData;
|
|
195
|
+
const body = res?.responseBody === undefined || res?.responseBody === null ? undefined
|
|
196
|
+
: (typeof res.responseBody === 'string' ? res.responseBody : JSON.stringify(res.responseBody));
|
|
197
|
+
const response = res && (res.statusCode !== undefined || body)
|
|
198
|
+
? { ...(res.statusCode !== undefined ? { statusCode: res.statusCode } : {}), ...(body ? { responseBody: body.slice(0, PASSED_API_BODY_CHARS) } : {}) }
|
|
199
|
+
: undefined;
|
|
200
|
+
const assertions = (Array.isArray(a.assertions) ? a.assertions : [])
|
|
201
|
+
.filter((c) => !!c && typeof c === 'object')
|
|
202
|
+
.slice(0, PASSED_API_ASSERTIONS)
|
|
203
|
+
.map((c) => Object.fromEntries(Object.entries(c).map(([k, x]) => [k, typeof x === 'string' ? x.slice(0, PASSED_ASSERTION_CHARS) : x])));
|
|
204
|
+
if (!response && !assertions.length)
|
|
205
|
+
return undefined;
|
|
206
|
+
return { ...(response ? { responseData: response } : {}), ...(assertions.length ? { assertions } : {}) };
|
|
207
|
+
}
|
|
208
|
+
/** Every match of `re` (group 1) in `logs`, in order. */
|
|
209
|
+
function logFields(logs, re) {
|
|
210
|
+
const out = [];
|
|
211
|
+
for (const line of logs) {
|
|
212
|
+
const m = re.exec(line);
|
|
213
|
+
if (m)
|
|
214
|
+
out.push((m[1] ?? '').trim());
|
|
215
|
+
}
|
|
216
|
+
return out;
|
|
217
|
+
}
|
|
218
|
+
/** "xpath and Value: //a" / "Attribute Name: Xpath1 Value: //a" → "xpath = //a". */
|
|
219
|
+
const locatorPair = (v) => {
|
|
220
|
+
const m = /^(?:Attribute Name:\s*)?(.*?)\s+(?:and\s+)?Value:\s*(.*)$/i.exec(v);
|
|
221
|
+
return m ? `${m[1].trim()} = ${m[2].trim()}` : v;
|
|
222
|
+
};
|
|
223
|
+
/** The object locator fields a step-result row may carry: `locators` / `attributes`, on the row or
|
|
224
|
+
* its object (`objectData` / `object`); the default (`unique`) one first. */
|
|
225
|
+
function objectLocators(row) {
|
|
226
|
+
for (const holder of [row, row?.objectData, row?.object]) {
|
|
227
|
+
if (!holder || typeof holder !== 'object')
|
|
228
|
+
continue;
|
|
229
|
+
for (const key of ['locators', 'attributes']) {
|
|
230
|
+
const list = (Array.isArray(holder[key]) ? holder[key] : [])
|
|
231
|
+
.filter((l) => l && typeof l === 'object' && typeof l.value === 'string' && l.value.trim());
|
|
232
|
+
if (!list.length)
|
|
233
|
+
continue;
|
|
234
|
+
const sorted = [...list.filter((l) => l.unique === true), ...list.filter((l) => l.unique !== true)];
|
|
235
|
+
return sorted.map((l) => `${String(l.name ?? 'locator')} = ${l.value.trim()}${l.unique === true ? ' (default)' : ''}`).join(', ');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The locator a step used: the last "Locator Used" log line (else the value after replacement),
|
|
242
|
+
* the template before replacement when there was one, then the object's locator fields.
|
|
243
|
+
*/
|
|
244
|
+
export function locatorOf(logs, row) {
|
|
245
|
+
const used = logFields(logs, /Locator Used\s+LocatorName:\s*(.+?)\s*$/i).pop();
|
|
246
|
+
const after = logFields(logs, /After Replacement\s+(.+?)\s*$/i).pop();
|
|
247
|
+
const before = logFields(logs, /Before Replacement\s+(.+?)\s*$/i).pop();
|
|
248
|
+
const main = used ?? after;
|
|
249
|
+
const parts = [];
|
|
250
|
+
if (main)
|
|
251
|
+
parts.push(`${locatorPair(main)}${before ? ` (before replacement: ${locatorPair(before)})` : ''}`);
|
|
252
|
+
const obj = objectLocators(row);
|
|
253
|
+
if (obj)
|
|
254
|
+
parts.push(`object locators: ${obj}`);
|
|
255
|
+
return parts.length ? parts.join(' · ') : undefined;
|
|
256
|
+
}
|
|
117
257
|
/** One raw step-result row → the failure-analysis step (cleaned, tailed logs; cause; category). */
|
|
118
|
-
function normalizeFailureStep(s, base, opts) {
|
|
258
|
+
export function normalizeFailureStep(s, base, opts) {
|
|
119
259
|
const status = String(s?.status ?? '').toUpperCase();
|
|
120
260
|
const state = failureState(status, s?.stepType);
|
|
121
261
|
const allLogs = Array.isArray(s?.executionLogData?.executionLogs)
|
|
@@ -148,12 +288,34 @@ function normalizeFailureStep(s, base, opts) {
|
|
|
148
288
|
: [];
|
|
149
289
|
const objectName = logField(allLogs, /Object Name:\s*(.+?)\s*$/i);
|
|
150
290
|
const actionName = logField(allLogs, /Action Name\s*:\s*(.+?)\s*$/i);
|
|
151
|
-
const locator =
|
|
291
|
+
const locator = locatorOf(allLogs, s);
|
|
152
292
|
const fnName = str(s?.functionData ?? {}, 'functionName', 'functionCode');
|
|
153
293
|
const cause = failedStep ? extractCause(s) : undefined;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
294
|
+
// Baseline / thumbnails: absolute on the SQA host; placeholders ("undefined.png") and off-host
|
|
295
|
+
// values are left out, each with a note (the review shows the note in place of the image).
|
|
296
|
+
// Baseline = EXECUTION time: the run's copy (copiedBaseLinepath — what the report shows and what
|
|
297
|
+
// "Mark as baseline" updates) first, then the recorded path. Thumbnail = RECORDING time: the
|
|
298
|
+
// recorded element crop (recordedThumbnailPath) first, then the run's copy. Names are matched
|
|
299
|
+
// case-insensitively (the API mixes "BaseLine" / "Baseline").
|
|
300
|
+
// The first usable value wins; a note only when none is usable.
|
|
301
|
+
const imageNotes = [];
|
|
302
|
+
const image = (keys, what) => {
|
|
303
|
+
let skipped;
|
|
304
|
+
for (const raw of fieldsCI(s, keys)) {
|
|
305
|
+
const r = normaliseImageUrl(base, raw);
|
|
306
|
+
if (r && 'url' in r)
|
|
307
|
+
return r.url;
|
|
308
|
+
if (r && skipped === undefined)
|
|
309
|
+
skipped = r.skipped;
|
|
310
|
+
}
|
|
311
|
+
if (skipped !== undefined)
|
|
312
|
+
imageNotes.push(`${what} skipped: ${skipped}`);
|
|
313
|
+
return undefined;
|
|
314
|
+
};
|
|
315
|
+
const recordedBaseline = image(BASELINE_FIELDS, 'baseline');
|
|
316
|
+
const recordedThumbnail = image(THUMBNAIL_FIELDS, 'element thumbnail');
|
|
317
|
+
// The failed step's last lines, kept for the review even where `logs` is later cleared.
|
|
318
|
+
const logTail = opts.includeLogs && failedStep ? cleaned.slice(-REVIEW_LOG_LINES) : [];
|
|
157
319
|
return {
|
|
158
320
|
seq: typeof s?.seq === 'number' ? s.seq : 0,
|
|
159
321
|
...(typeof s?.reportSeq === 'number' || typeof s?.reportSeq === 'string' ? { reportSeq: s.reportSeq } : {}),
|
|
@@ -171,11 +333,12 @@ function normalizeFailureStep(s, base, opts) {
|
|
|
171
333
|
...(str(s, 'exception') ? { exception: trimTrace(str(s, 'exception')) } : {}),
|
|
172
334
|
errorLines: evidenceLines,
|
|
173
335
|
logs,
|
|
336
|
+
...(logTail.length ? { logTail } : {}),
|
|
174
337
|
logCount: allLogs.length,
|
|
175
338
|
screenshots,
|
|
176
339
|
...(recordedBaseline ? { recordedBaseline } : {}),
|
|
177
340
|
...(recordedThumbnail ? { recordedThumbnail } : {}),
|
|
178
|
-
...(
|
|
341
|
+
...(imageNotes.length ? { imageNotes } : {}),
|
|
179
342
|
...(td.length ? { testdata: td } : {}),
|
|
180
343
|
...(s?.networkLogs && (Array.isArray(s.networkLogs) ? s.networkLogs.length > 0 : Object.keys(s.networkLogs).length > 0) ? { networkLogs: s.networkLogs } : {}),
|
|
181
344
|
...(s?.apiData ? { apiData: s.apiData } : {}),
|
|
@@ -262,7 +425,9 @@ export class ExecutionFailureAnalysis {
|
|
|
262
425
|
throw new Error(`${entity.code} has no runs in execution ${execRef}.`);
|
|
263
426
|
}
|
|
264
427
|
const failedRuns = runs.filter((r) => String(r?.status ?? '').toUpperCase() === 'FAILED');
|
|
265
|
-
const
|
|
428
|
+
const maxRuns = Math.max(0, input.maxFailedRuns ?? MAX_FAILURE_RUNS);
|
|
429
|
+
const detailedGroups = Math.max(0, input.detailedGroups ?? MAX_DETAILED_GROUPS);
|
|
430
|
+
const toAnalyse = failedRuns.slice(0, maxRuns);
|
|
266
431
|
// ---------------------------------------------------------------- 3. each failed iteration
|
|
267
432
|
const opts = {
|
|
268
433
|
includeLogs: input.includeLogs !== false,
|
|
@@ -279,7 +444,7 @@ export class ExecutionFailureAnalysis {
|
|
|
279
444
|
if (execException) {
|
|
280
445
|
for (const { it } of analysed) {
|
|
281
446
|
if (it.source === 'run_level' && !it.exception) {
|
|
282
|
-
it.exception = execException;
|
|
447
|
+
it.exception = maskOf(it.protectedValues ?? [])(execException);
|
|
283
448
|
it.category = categoryOf(execException);
|
|
284
449
|
}
|
|
285
450
|
}
|
|
@@ -294,7 +459,7 @@ export class ExecutionFailureAnalysis {
|
|
|
294
459
|
// Most evidence wins: a screenshot on the focus step, then logs; the newest on a tie.
|
|
295
460
|
const evidence = (it) => (it.focus?.screenshots.length ? 2 : 0) + (it.focus?.logCount ? 1 : 0);
|
|
296
461
|
const rep = g.items.reduce((best, a) => (evidence(a.it) > evidence(best.it) ? a : best), g.items[0]);
|
|
297
|
-
if (id <=
|
|
462
|
+
if (id <= detailedGroups)
|
|
298
463
|
representatives.add(rep.it);
|
|
299
464
|
return {
|
|
300
465
|
id,
|
|
@@ -354,6 +519,8 @@ export class ExecutionFailureAnalysis {
|
|
|
354
519
|
for (const it of e.failedIterations) {
|
|
355
520
|
if (e.name)
|
|
356
521
|
it.testcaseName = e.name;
|
|
522
|
+
if (e.description)
|
|
523
|
+
it.testcaseDescription = e.description;
|
|
357
524
|
if (e.versionName)
|
|
358
525
|
it.versionName = e.versionName;
|
|
359
526
|
}
|
|
@@ -388,20 +555,18 @@ export class ExecutionFailureAnalysis {
|
|
|
388
555
|
else if (!failedRuns.length)
|
|
389
556
|
notes.push(`No failed iterations — all ${runs.length} run(s) are ${[...new Set(runs.map((r) => String(r?.status ?? '?')))].join('/')}.`);
|
|
390
557
|
if (failedRuns.length > toAnalyse.length) {
|
|
391
|
-
|
|
558
|
+
// The limit is the analysis's (shared by its executions), not what was left of it here.
|
|
559
|
+
notes.push(`${failedRuns.length - toAnalyse.length} more failed iterations were not analysed (limit ${MAX_FAILURE_RUNS} per analysis).`);
|
|
392
560
|
}
|
|
393
561
|
const unread = analysed.filter((a) => a.it.readError).length;
|
|
394
562
|
if (unread)
|
|
395
|
-
notes.push(`${unread} failed iteration(s) could not be read; they are
|
|
396
|
-
if (groups.length >
|
|
397
|
-
notes.push(
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
if (analysed.some((a) => a.it.failedSteps.some((s) => s.screenshots.length))) {
|
|
403
|
-
notes.push('Screenshot URLs are SQA artifact paths; they need the SQA bearer token to download.');
|
|
404
|
-
}
|
|
563
|
+
notes.push(`${unread} failed iteration(s) could not be read; they are counted by their run-level exception.`);
|
|
564
|
+
if (groups.length > detailedGroups)
|
|
565
|
+
notes.push(NOTE_FULL_LOGS);
|
|
566
|
+
if (analysed.some((a) => a.it.source === 'run_level' && !a.it.readError))
|
|
567
|
+
notes.push(NOTE_RUN_LEVEL);
|
|
568
|
+
if (analysed.some((a) => a.it.failedSteps.some((s) => s.screenshots.length)))
|
|
569
|
+
notes.push(NOTE_SCREENSHOT_URLS);
|
|
405
570
|
const startedAt = str(execDoc, 'startTime', 'createdAt');
|
|
406
571
|
const endedAt = str(execDoc, 'endTime');
|
|
407
572
|
return {
|
|
@@ -416,6 +581,7 @@ export class ExecutionFailureAnalysis {
|
|
|
416
581
|
type: execType,
|
|
417
582
|
status: String(execDoc.status ?? ''),
|
|
418
583
|
...(str(execDoc, 'executionTypeCode') ? { executionTypeCode: str(execDoc, 'executionTypeCode') } : {}),
|
|
584
|
+
...(execDoc.executionTypeId !== undefined && execDoc.executionTypeId !== null ? { executionTypeId: String(execDoc.executionTypeId) } : {}),
|
|
419
585
|
...(str(execDoc, 'executionTypeName') ? { executionTypeName: str(execDoc, 'executionTypeName') } : {}),
|
|
420
586
|
...(str(execDoc, 'environmentType') ? { environment: str(execDoc, 'environmentType') } : {}),
|
|
421
587
|
...(typeof execDoc.childExecution === 'boolean' ? { childExecution: execDoc.childExecution } : {}),
|
|
@@ -439,6 +605,213 @@ export class ExecutionFailureAnalysis {
|
|
|
439
605
|
notes,
|
|
440
606
|
};
|
|
441
607
|
}
|
|
608
|
+
/**
|
|
609
|
+
* The failing step of `it` as it ran in the last PASSED execution of the same test case.
|
|
610
|
+
* null when there is no last pass or no failed step (run-level / no step id); `found:false` when
|
|
611
|
+
* the step is not in the passed run.
|
|
612
|
+
*/
|
|
613
|
+
async compareWithLastPass(it, history, executionItemId, rowsCache) {
|
|
614
|
+
const lp = history.lastPassed;
|
|
615
|
+
if (!lp)
|
|
616
|
+
return null;
|
|
617
|
+
// No failed step (run-level, or no step id): nothing to compare. null, never found:false — that
|
|
618
|
+
// would read as "the step is not in the passed version" (a NEW_CHANGE hint).
|
|
619
|
+
const stepId = it.focus?.stepId;
|
|
620
|
+
if (!stepId || it.source === 'run_level')
|
|
621
|
+
return null;
|
|
622
|
+
// The passed run of the SAME iteration when there is one (ITR-2 with ITR-2's data), else the first.
|
|
623
|
+
// It may have passed in another execution than the last pass (any suite / plan / standalone).
|
|
624
|
+
const { runId, executionId } = passedRunFor(lp, it.iteration);
|
|
625
|
+
const base = {
|
|
626
|
+
executionId,
|
|
627
|
+
...(lp.executionCode && executionId === lp.executionId ? { executionCode: lp.executionCode } : {}),
|
|
628
|
+
runId,
|
|
629
|
+
found: false,
|
|
630
|
+
};
|
|
631
|
+
// One read per passed run for the whole analysis: iterations / test cases that last passed in
|
|
632
|
+
// the same run share it. A failed read is not kept, so the next comparison retries.
|
|
633
|
+
const cacheKey = `${executionId}:${runId}`;
|
|
634
|
+
let pending = rowsCache?.get(cacheKey);
|
|
635
|
+
if (!pending) {
|
|
636
|
+
pending = this.fetchStepRows(Number(executionId), runId, Number(executionItemId));
|
|
637
|
+
if (rowsCache) {
|
|
638
|
+
rowsCache.set(cacheKey, pending);
|
|
639
|
+
pending.catch(() => rowsCache.delete(cacheKey));
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
const rows = await pending;
|
|
643
|
+
const raw = pickComparisonRow(rows, stepId);
|
|
644
|
+
if (!raw)
|
|
645
|
+
return base;
|
|
646
|
+
// Masked with every protected value of the passed run AND of the failing iteration.
|
|
647
|
+
const row = maskRow(raw, maskOf([...protectedOf(rows), ...(it.protectedValues ?? [])]));
|
|
648
|
+
const step = normalizeFailureStep(row, this.deps.baseUrl, { includeLogs: true, maxLogLines: REVIEW_LOG_LINES, includeScreenshots: true });
|
|
649
|
+
const value = step.actual ?? step.expected;
|
|
650
|
+
const data = stepData({ testdata: step.testdata });
|
|
651
|
+
const api = apiBrief(step.apiData);
|
|
652
|
+
const screenshots = step.screenshots.filter((a) => a.absoluteUrl);
|
|
653
|
+
const screenshot = screenshots[0];
|
|
654
|
+
const apiData = compactApiData(step.apiData);
|
|
655
|
+
const baseline = {
|
|
656
|
+
...(step.recordedBaseline ? { baseline: step.recordedBaseline } : {}),
|
|
657
|
+
...(step.recordedThumbnail ? { thumbnail: step.recordedThumbnail } : {}),
|
|
658
|
+
};
|
|
659
|
+
return {
|
|
660
|
+
...base,
|
|
661
|
+
found: true,
|
|
662
|
+
status: step.status,
|
|
663
|
+
...(value ? { value } : {}),
|
|
664
|
+
...(step.expected !== undefined ? { expected: step.expected } : {}),
|
|
665
|
+
...(step.actual !== undefined ? { actual: step.actual } : {}),
|
|
666
|
+
...(data ? { data } : {}),
|
|
667
|
+
...(api ? { api } : {}),
|
|
668
|
+
...(apiData ? { apiData } : {}),
|
|
669
|
+
...(step.locator ? { locator: step.locator } : {}),
|
|
670
|
+
...(step.logs.length ? { logs: step.logs } : {}),
|
|
671
|
+
...(screenshot ? { screenshot } : {}),
|
|
672
|
+
...(screenshots.length ? { screenshots } : {}),
|
|
673
|
+
...(Object.keys(baseline).length ? { baseline } : {}),
|
|
674
|
+
...(step.imageNotes?.length ? { imageNotes: step.imageNotes } : {}),
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* History of each failed test case of `ctx`, searched across EVERY execution of the test case
|
|
679
|
+
* (standalone, any suite, any plan) that ran before `ctx.execution`: `/exec/report/search` on the
|
|
680
|
+
* run rows by `executionItemId` — the newest PASSED runs, then the FAILED runs after that pass
|
|
681
|
+
* (every earlier failure when it never passed, which also tells "never passed" from "first
|
|
682
|
+
* execution"). `cache` is shared by one analysis: one search per test case however many of its
|
|
683
|
+
* executions it failed in, and one read per execution shown. A failed run search makes that test
|
|
684
|
+
* case `unknown` — never first-execution / never-passed.
|
|
685
|
+
*/
|
|
686
|
+
async failureHistory(ctx, cache = createHistoryCache([ctx])) {
|
|
687
|
+
const current = Number(ctx.execution.id);
|
|
688
|
+
// Today's own runs (and their copies in a parent execution) are never history.
|
|
689
|
+
const exclude = new Set(ctx.testcases.flatMap((t) => t.failedIterations.map((it) => it.runId)));
|
|
690
|
+
// Runs that ended once this execution had started are not earlier (today's / concurrent runs).
|
|
691
|
+
const startedAt = ctx.execution.startedAt;
|
|
692
|
+
const bound = { before: current, exclude, ...(startedAt ? { startedAt } : {}) };
|
|
693
|
+
const items = [...new Map(ctx.testcases.map((t) => [String(t.executionItemId), t])).values()];
|
|
694
|
+
const out = new Map();
|
|
695
|
+
await mapLimit(items, FAILURE_CONCURRENCY, async (tc) => {
|
|
696
|
+
const key = String(tc.executionItemId);
|
|
697
|
+
const item = Number(key);
|
|
698
|
+
if (!key || !Number.isFinite(item) || !Number.isFinite(current)) {
|
|
699
|
+
out.set(key, { status: 'unknown' });
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
let lastPassed;
|
|
703
|
+
try {
|
|
704
|
+
const iteration = tc.failedIterations[0]?.iteration;
|
|
705
|
+
const opts = { ...bound, ...(iteration ? { iteration } : {}) };
|
|
706
|
+
const shared = await this.runsOf(cache, item, 'PASSED', Math.max(cache.before, current));
|
|
707
|
+
lastPassed = lastPassedOf(shared.rows, opts);
|
|
708
|
+
// The shared search reaches the newest analysed execution: later passes can fill it.
|
|
709
|
+
if (!lastPassed && cache.before > current && shared.rows.length >= PASSED_SEARCH_LIMIT) {
|
|
710
|
+
lastPassed = lastPassedOf((await this.runsOf(cache, item, 'PASSED', current)).rows, opts);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
catch {
|
|
714
|
+
out.set(key, { status: 'unknown' });
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
let failingSince;
|
|
718
|
+
let failingSinceUnavailable = false;
|
|
719
|
+
try {
|
|
720
|
+
// From the NEWEST pass, even when an older same-iteration pass is the one compared.
|
|
721
|
+
const after = lastPassed?.runs?.[0]?.endedAt ?? lastPassed?.endedAt;
|
|
722
|
+
const failed = await this.runsOf(cache, item, 'FAILED', Math.max(cache.before, current));
|
|
723
|
+
failingSince = failingSinceOf(failed.rows, { ...bound, ...(after ? { after } : {}), limit: FAILED_SEARCH_LIMIT });
|
|
724
|
+
}
|
|
725
|
+
catch {
|
|
726
|
+
// Without a pass, "never passed" and "first execution" cannot be told apart.
|
|
727
|
+
if (!lastPassed) {
|
|
728
|
+
out.set(key, { status: 'unknown' });
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
failingSinceUnavailable = true;
|
|
732
|
+
}
|
|
733
|
+
const h = { status: lastPassed ? 'passed-before' : failingSince ? 'never-passed' : 'first-execution' };
|
|
734
|
+
if (failingSinceUnavailable)
|
|
735
|
+
h.failingSinceUnavailable = true;
|
|
736
|
+
if (lastPassed)
|
|
737
|
+
h.lastPassed = lastPassed;
|
|
738
|
+
if (failingSince)
|
|
739
|
+
h.failingSince = failingSince;
|
|
740
|
+
if (lastPassed?.versionId && tc.versionId && lastPassed.versionId !== tc.versionId) {
|
|
741
|
+
h.editedSincePass = {
|
|
742
|
+
from: lastPassed.versionId, to: String(tc.versionId), ...(tc.versionName ? { toName: tc.versionName } : {}),
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
out.set(key, h);
|
|
746
|
+
});
|
|
747
|
+
// Where it passed / started failing: each execution read once per analysis, best-effort.
|
|
748
|
+
const shown = [...out.values()].flatMap((h) => [
|
|
749
|
+
...(h.lastPassed ? [h.lastPassed] : []), ...(h.failingSince ? [h.failingSince] : []),
|
|
750
|
+
]);
|
|
751
|
+
const ids = [...new Set(shown.map((w) => w.executionId))];
|
|
752
|
+
const docs = new Map(await mapLimit(ids, FAILURE_CONCURRENCY, async (id) => [id, await this.executionDoc(cache, id)]));
|
|
753
|
+
for (const w of shown)
|
|
754
|
+
Object.assign(w, executionInfo(docs.get(w.executionId)));
|
|
755
|
+
return out;
|
|
756
|
+
}
|
|
757
|
+
/** One run search per (test case, status, bound) per analysis. */
|
|
758
|
+
runsOf(cache, item, status, before) {
|
|
759
|
+
const key = JSON.stringify([item, status, before]);
|
|
760
|
+
let p = cache.runs.get(key);
|
|
761
|
+
if (!p) {
|
|
762
|
+
p = this.searchRuns(item, status, before);
|
|
763
|
+
cache.runs.set(key, p);
|
|
764
|
+
}
|
|
765
|
+
return p;
|
|
766
|
+
}
|
|
767
|
+
/** `/exec/report/search` (executionRuns): runs of one test case in any execution before `before`,
|
|
768
|
+
* newest first. No date comparison is sent — the server's search treats a string value as an
|
|
769
|
+
* exact match (operators apply to integers / date-typed fields only), so a `gt` on the ISO endTime
|
|
770
|
+
* silently matched nothing; the "after the last pass" bound is applied in code. */
|
|
771
|
+
async searchRuns(item, status, before) {
|
|
772
|
+
const passed = status === 'PASSED';
|
|
773
|
+
const raw = await this.deps.http.postJson('/exec/report/search', {
|
|
774
|
+
searchFields: [
|
|
775
|
+
{ column: 'endTime', sort: 'dsc' },
|
|
776
|
+
{ column: 'deleted', value: false },
|
|
777
|
+
{ column: 'projectId', value: this.deps.projectId, regEx: false },
|
|
778
|
+
{ column: 'executionItemId', value: item, regEx: false },
|
|
779
|
+
{ column: 'status', value: status, regEx: false },
|
|
780
|
+
{ column: 'executionId', value: before, operator: 'lt' },
|
|
781
|
+
],
|
|
782
|
+
startIndex: 0,
|
|
783
|
+
limit: passed ? PASSED_SEARCH_LIMIT : FAILED_SEARCH_LIMIT,
|
|
784
|
+
});
|
|
785
|
+
const total = Number(raw?.totalCount ?? raw?.total);
|
|
786
|
+
return { rows: pickArray(raw, 'data', 'content'), ...(Number.isFinite(total) ? { total } : {}) };
|
|
787
|
+
}
|
|
788
|
+
/** An execution doc, read once per analysis; null when it cannot be read. */
|
|
789
|
+
executionDoc(cache, id) {
|
|
790
|
+
let p = cache.executions.get(id);
|
|
791
|
+
if (!p) {
|
|
792
|
+
p = this.deps.fetchExecDoc(Number(id), this.deps.projectId).catch(() => null);
|
|
793
|
+
cache.executions.set(id, p);
|
|
794
|
+
}
|
|
795
|
+
return p;
|
|
796
|
+
}
|
|
797
|
+
/** Version NAMES for "edited since pass" (`fromName` / `toName`), resolved the way the failure
|
|
798
|
+
* table names versions (`/tm/tcfnversion/search`); best-effort, ids stay when a lookup fails. */
|
|
799
|
+
async nameHistoryVersions(history) {
|
|
800
|
+
const edits = [...history.values()].map((h) => h.editedSincePass).filter((e) => !!e);
|
|
801
|
+
const ids = [...new Set(edits.flatMap((e) => [...(e.fromName ? [] : [e.from]), ...(e.toName ? [] : [e.to])]))];
|
|
802
|
+
if (!ids.length)
|
|
803
|
+
return;
|
|
804
|
+
const versions = await this.searchByIds('/tm/tcfnversion/search', ids, ['id', 'name']).catch(() => []);
|
|
805
|
+
const name = new Map(versions.map((v) => [String(v.id), str(v, 'name')]));
|
|
806
|
+
for (const e of edits) {
|
|
807
|
+
const from = e.fromName ?? name.get(e.from);
|
|
808
|
+
const to = e.toName ?? name.get(e.to);
|
|
809
|
+
if (from)
|
|
810
|
+
e.fromName = from;
|
|
811
|
+
if (to)
|
|
812
|
+
e.toName = to;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
442
815
|
/**
|
|
443
816
|
* One run's whole-test-case context (flow.ts): its FLOW around the failure, the written steps it
|
|
444
817
|
* never reached, how this function call compares with the run's other calls of it, and how the
|
|
@@ -449,7 +822,10 @@ export class ExecutionFailureAnalysis {
|
|
|
449
822
|
const automated = String(run.type ?? '').toUpperCase() !== 'MANUAL';
|
|
450
823
|
// Read again rather than kept from analyseFailedIteration: holding every failed run's raw rows
|
|
451
824
|
// (full logs) until grouping is done costs far more memory than one read per representative.
|
|
452
|
-
const
|
|
825
|
+
const rawRows = await this.fetchStepRows(execNum, String(run.id), Number(run.executionItemId ?? 0));
|
|
826
|
+
const secrets = new Set([...protectedOf(rawRows), ...(it.protectedValues ?? [])]);
|
|
827
|
+
const m = maskOf(secrets);
|
|
828
|
+
const rows = rawRows.map((r) => maskRow(r, m));
|
|
453
829
|
const focusId = it.focus?.rowId;
|
|
454
830
|
const built = buildFlow(rows, { automated, ...(focusId ? { focusId } : {}) });
|
|
455
831
|
const out = { lines: built.lines, warnings: built.warnings };
|
|
@@ -460,7 +836,7 @@ export class ExecutionFailureAnalysis {
|
|
|
460
836
|
const focusIdx = focusId ? rows.findIndex((r) => String(r?.id) === String(focusId)) : -1;
|
|
461
837
|
const stopped = focusIdx >= 0 && !rows.slice(focusIdx + 1).some((r) => /^(PASSED|FAILED)$/i.test(String(r?.status ?? '')));
|
|
462
838
|
if (it.source === 'step' && stopped) {
|
|
463
|
-
const notRun = notRunLines(await ctx.written(), built.furthestStepIds);
|
|
839
|
+
const notRun = notRunLines(await ctx.written(), built.furthestStepIds).map(m);
|
|
464
840
|
if (notRun.length)
|
|
465
841
|
out.notRun = notRun;
|
|
466
842
|
}
|
|
@@ -494,8 +870,10 @@ export class ExecutionFailureAnalysis {
|
|
|
494
870
|
if (passed.length && stepId) {
|
|
495
871
|
const p = passed[0];
|
|
496
872
|
try {
|
|
497
|
-
const
|
|
498
|
-
const
|
|
873
|
+
const rawP = await this.fetchStepRows(execNum, String(p.id), Number(p.executionItemId ?? 0));
|
|
874
|
+
const pm = maskOf([...secrets, ...protectedOf(rawP)]);
|
|
875
|
+
const found = rawP.find((r) => String(r?.stepId ?? '') === stepId);
|
|
876
|
+
const same = found ? maskRow(found, pm) : undefined;
|
|
499
877
|
const data = same ? stepData(same) : '';
|
|
500
878
|
// What the passing call returned — e.g. it created the record the failing ones then collide with.
|
|
501
879
|
const api = same ? apiBrief(same.apiData) : '';
|
|
@@ -512,33 +890,37 @@ export class ExecutionFailureAnalysis {
|
|
|
512
890
|
/** Test case names and version names for the failure table — one search each, best-effort (a
|
|
513
891
|
* failed lookup leaves the column empty, never the analysis). */
|
|
514
892
|
async nameEntries(entries) {
|
|
515
|
-
const { http, projectId } = this.deps;
|
|
516
893
|
const tcIds = [...new Set(entries.map((e) => Number(e.executionItemId)).filter((n) => Number.isFinite(n) && n > 0))];
|
|
517
894
|
const versionIds = [...new Set(entries.map((e) => e.versionId).filter((v) => !!v))];
|
|
518
|
-
const search = async (path, column, ids, select) => {
|
|
519
|
-
if (!ids.length)
|
|
520
|
-
return [];
|
|
521
|
-
const raw = await http.postJson(path, {
|
|
522
|
-
searchFields: [{ column: 'deleted', value: false }, { column: 'projectId', value: projectId }, { column, value: ids }],
|
|
523
|
-
startIndex: 0, limit: ids.length, skipStartIndex: 1, selectFields: select,
|
|
524
|
-
});
|
|
525
|
-
return pickArray(raw, 'data', 'content');
|
|
526
|
-
};
|
|
527
895
|
const [tcs, versions] = await Promise.all([
|
|
528
|
-
|
|
529
|
-
|
|
896
|
+
this.searchByIds('/tm/testcase/search', tcIds, ['id', 'code', 'name', 'description']).catch(() => []),
|
|
897
|
+
this.searchByIds('/tm/tcfnversion/search', versionIds, ['id', 'name']).catch(() => []),
|
|
530
898
|
]);
|
|
531
899
|
const tcName = new Map(tcs.map((t) => [String(t.id), str(t, 'name')]));
|
|
900
|
+
const tcDesc = new Map(tcs.map((t) => [String(t.id), cleanDescription(t.description)]));
|
|
532
901
|
const vName = new Map(versions.map((v) => [String(v.id), str(v, 'name')]));
|
|
533
902
|
for (const e of entries) {
|
|
534
903
|
const n = e.name ?? tcName.get(e.executionItemId);
|
|
535
904
|
if (n)
|
|
536
905
|
e.name = n;
|
|
906
|
+
const d = tcDesc.get(e.executionItemId);
|
|
907
|
+
if (d)
|
|
908
|
+
e.description = d;
|
|
537
909
|
const v = e.versionId ? vName.get(e.versionId) : undefined;
|
|
538
910
|
if (v)
|
|
539
911
|
e.versionName = v;
|
|
540
912
|
}
|
|
541
913
|
}
|
|
914
|
+
/** Rows of a TM search by id, one request; [] for no ids. */
|
|
915
|
+
async searchByIds(path, ids, select) {
|
|
916
|
+
if (!ids.length)
|
|
917
|
+
return [];
|
|
918
|
+
const raw = await this.deps.http.postJson(path, {
|
|
919
|
+
searchFields: [{ column: 'deleted', value: false }, { column: 'projectId', value: this.deps.projectId }, { column: 'id', value: ids }],
|
|
920
|
+
startIndex: 0, limit: ids.length, skipStartIndex: 1, selectFields: select,
|
|
921
|
+
});
|
|
922
|
+
return pickArray(raw, 'data', 'content');
|
|
923
|
+
}
|
|
542
924
|
/** One failed run → its failure focus. A run whose steps cannot be read is still returned (with
|
|
543
925
|
* `readError`) so it is counted and grouped by its run-level exception, never dropped. */
|
|
544
926
|
async analyseFailedIteration(execNum, run, base, opts) {
|
|
@@ -553,14 +935,19 @@ export class ExecutionFailureAnalysis {
|
|
|
553
935
|
...(str(run, 'startTime') ? { startedAt: str(run, 'startTime') } : {}),
|
|
554
936
|
...(str(run, 'endTime') ? { endedAt: str(run, 'endTime') } : {}),
|
|
555
937
|
...(typeof run.executionDuration === 'number' ? { durationMs: run.executionDuration } : {}),
|
|
556
|
-
...(str(run, 'exception') ? { exception: str(run, 'exception') } : {}),
|
|
557
938
|
source: 'none',
|
|
558
939
|
failedSteps: [],
|
|
559
940
|
stepCounts: { total: 0, passed: 0, failed: 0, skipped: 0, notExecuted: 0 },
|
|
560
941
|
};
|
|
561
942
|
try {
|
|
562
943
|
const all = await this.fetchStepRows(execNum, String(run.id), Number(run.executionItemId ?? 0));
|
|
563
|
-
|
|
944
|
+
// Every protected value typed anywhere in this run — a password entered at a PASSED step can
|
|
945
|
+
// surface in a later failed step's actual value or logs. Masked before anything is extracted.
|
|
946
|
+
const secrets = protectedOf(all);
|
|
947
|
+
if (secrets.length)
|
|
948
|
+
it.protectedValues = secrets;
|
|
949
|
+
const m = maskOf(secrets);
|
|
950
|
+
const steps = keepStepRows(all).map((s) => normalizeFailureStep(maskRow(s, m), base, opts));
|
|
564
951
|
numberSteps(steps, String(run.type ?? '').toUpperCase() !== 'MANUAL');
|
|
565
952
|
for (const s of steps) {
|
|
566
953
|
// A FUNCTION heading carries its child's verdict — counting it says one result twice.
|
|
@@ -594,6 +981,9 @@ export class ExecutionFailureAnalysis {
|
|
|
594
981
|
it.source = 'run_level';
|
|
595
982
|
}
|
|
596
983
|
finally {
|
|
984
|
+
const runException = str(run, 'exception');
|
|
985
|
+
if (runException)
|
|
986
|
+
it.exception = maskOf(it.protectedValues ?? [])(runException);
|
|
597
987
|
it.category = it.source === 'step' && it.focus?.category ? it.focus.category : categoryOf(it.exception);
|
|
598
988
|
if (str(run, 'code'))
|
|
599
989
|
it.testcaseCode = str(run, 'code');
|