simplify3x-connect 0.31.10 → 0.31.12
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 +18 -0
- package/dist/adapters/simplifyqa/adapter.d.ts +27 -1
- package/dist/adapters/simplifyqa/adapter.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/adapter.js +363 -14
- package/dist/adapters/simplifyqa/adapter.js.map +1 -1
- package/dist/adapters/simplifyqa/failureAnalysisCard.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failureAnalysisCard.js +3 -2
- package/dist/adapters/simplifyqa/failureAnalysisCard.js.map +1 -1
- package/dist/adapters/simplifyqa/failureSuggest.js +1 -1
- package/dist/adapters/simplifyqa/failureSuggest.js.map +1 -1
- package/dist/adapters/simplifyqa/searchRegistry.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/searchRegistry.js +22 -0
- package/dist/adapters/simplifyqa/searchRegistry.js.map +1 -1
- package/dist/adapters/types.d.ts +7 -1
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/cli.js +7 -1
- package/dist/cli.js.map +1 -1
- package/dist/domain/types.d.ts +67 -0
- package/dist/domain/types.d.ts.map +1 -1
- package/dist/domain/types.js.map +1 -1
- package/dist/initAgents.d.ts.map +1 -1
- package/dist/initAgents.js +18 -3
- package/dist/initAgents.js.map +1 -1
- package/dist/integration/actions.d.ts +85 -0
- package/dist/integration/actions.d.ts.map +1 -0
- package/dist/integration/actions.js +391 -0
- package/dist/integration/actions.js.map +1 -0
- package/dist/integration/apply.d.ts +105 -0
- package/dist/integration/apply.d.ts.map +1 -0
- package/dist/integration/apply.js +345 -0
- package/dist/integration/apply.js.map +1 -0
- package/dist/integration/clients.d.ts +129 -0
- package/dist/integration/clients.d.ts.map +1 -0
- package/dist/integration/clients.js +332 -0
- package/dist/integration/clients.js.map +1 -0
- package/dist/integration/defaults.d.ts +14 -0
- package/dist/integration/defaults.d.ts.map +1 -0
- package/dist/integration/defaults.js +61 -0
- package/dist/integration/defaults.js.map +1 -0
- package/dist/integration/dummyData.d.ts +11 -0
- package/dist/integration/dummyData.d.ts.map +1 -0
- package/dist/integration/dummyData.js +112 -0
- package/dist/integration/dummyData.js.map +1 -0
- package/dist/integration/normalize.d.ts +71 -0
- package/dist/integration/normalize.d.ts.map +1 -0
- package/dist/integration/normalize.js +194 -0
- package/dist/integration/normalize.js.map +1 -0
- package/dist/integration/setupCommand.d.ts +17 -0
- package/dist/integration/setupCommand.d.ts.map +1 -0
- package/dist/integration/setupCommand.js +126 -0
- package/dist/integration/setupCommand.js.map +1 -0
- package/dist/integration/types.d.ts +84 -0
- package/dist/integration/types.d.ts.map +1 -0
- package/dist/integration/types.js +2 -0
- package/dist/integration/types.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +5 -0
- package/dist/server.js.map +1 -1
- package/dist/tools/discovery.tools.d.ts.map +1 -1
- package/dist/tools/discovery.tools.js +70 -0
- package/dist/tools/discovery.tools.js.map +1 -1
- package/dist/tools/failure.tools.d.ts.map +1 -1
- package/dist/tools/failure.tools.js +7 -10
- package/dist/tools/failure.tools.js.map +1 -1
- package/dist/tools/failureExport.tools.d.ts.map +1 -1
- package/dist/tools/failureExport.tools.js +2 -3
- package/dist/tools/failureExport.tools.js.map +1 -1
- package/dist/tools/integration.tools.d.ts +16 -0
- package/dist/tools/integration.tools.d.ts.map +1 -0
- package/dist/tools/integration.tools.js +704 -0
- package/dist/tools/integration.tools.js.map +1 -0
- package/dist/tools/run.tools.d.ts +11 -0
- package/dist/tools/run.tools.d.ts.map +1 -1
- package/dist/tools/run.tools.js +117 -6
- package/dist/tools/run.tools.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ import { ExecutionFailureAnalysis, fetchFailureImage } from './executionFailures
|
|
|
20
20
|
import { log } from '../../log.js';
|
|
21
21
|
import { applyHealPlan as applyHealPlanCore } from './heal/apply.js';
|
|
22
22
|
import { applyCollectionSteps, buildTestcasePayload, deriveTcType, extractApiParamNames, extractParamNames, extractValueParamNames, fromSqaStep, isApiRequestStep, isBlankStep, runtimeSlotValue, looksSensitive, normalizeSuiteEntry, notDeleted, numericId, paramDefault, pickArray, str, withoutBlankSteps, SUITE_UPDATE_ALLOWED_KEYS, TECH_BY_STEPTYPE, toDefectSummary, toEpic, toEpicSummary, toFeature, toFeatureSummary, toFunction, toFunctionSummary, toModuleSaved, toModuleSummary, toObject, toImageUrl, toReleaseSummary, toSavedRef, toSprintSummary, toStory, toStorySummary, toSuite, toSuiteSummary, toTaskSummary, toTcSummary, toTestCase, toVersionEntries, withTotal, } from './mapper.js';
|
|
23
|
+
import { iterationLabel } from './stepRules.js';
|
|
23
24
|
/** A DESKTOP save reuses only DESKTOP objects. Matching by name alone merged desktop locators into an iOS object
|
|
24
25
|
* that happened to share the name ("Login"); a new DESKTOP object is created instead. Every other technology
|
|
25
26
|
* keeps matching by name alone. */
|
|
@@ -82,6 +83,55 @@ function mapRunState(s) {
|
|
|
82
83
|
default: return 'error';
|
|
83
84
|
}
|
|
84
85
|
}
|
|
86
|
+
/** Review/Approve states that lock a report against re-execution (suite-re-execution.component.ts:45). */
|
|
87
|
+
const RE_EXEC_LOCKED = ['REVIEW PENDING', 'REVIEWED', 'APPROVE PENDING', 'APPROVED'];
|
|
88
|
+
/** Suite re-execution (sqa-ui suite-re-execution → execution popup 'RE'): picks the earlier run's items to run again,
|
|
89
|
+
* by `tcIds` (id / TC-code) or every FAILED one, and returns their `testcaseId|versionId|stepId` keys — the triple the
|
|
90
|
+
* UI matches suite rows on. Throws with the reason (and the choices) when the pick is empty or unknown. */
|
|
91
|
+
export function selectReExecutionKeys(items, pick) {
|
|
92
|
+
const key = (id, v, s) => `${String(id ?? '')}|${String(v ?? '')}|${String(s ?? '')}`;
|
|
93
|
+
const label = (it) => `${str(it, 'code') ?? `TC-${it?.id}`}${it?.name ? ` — ${it.name}` : ''} (${String(it?.status ?? '').toLowerCase() || 'no status'})`;
|
|
94
|
+
let chosen;
|
|
95
|
+
if (pick.failedOnly) {
|
|
96
|
+
chosen = items.filter((it) => String(it?.status ?? '').toUpperCase() === 'FAILED');
|
|
97
|
+
if (!chosen.length)
|
|
98
|
+
throw new Error(`Nothing to re-execute: no test case FAILED in that run. Its test cases:\n${items.map((it) => `- ${label(it)}`).join('\n')}`);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
const wanted = pick.tcIds ?? [];
|
|
102
|
+
const unknown = [];
|
|
103
|
+
chosen = [];
|
|
104
|
+
for (const w of wanted) {
|
|
105
|
+
const n = numericId(String(w));
|
|
106
|
+
const hit = items.find((it) => String(it?.id) === n || str(it, 'code') === String(w));
|
|
107
|
+
if (hit) {
|
|
108
|
+
if (!chosen.includes(hit))
|
|
109
|
+
chosen.push(hit);
|
|
110
|
+
}
|
|
111
|
+
else
|
|
112
|
+
unknown.push(String(w));
|
|
113
|
+
}
|
|
114
|
+
if (unknown.length || !chosen.length) {
|
|
115
|
+
throw new Error(`${unknown.length ? `Not in that run: ${unknown.join(', ')}. ` : 'No test cases picked. '}Its test cases:\n${items.map((it) => `- ${label(it)}`).join('\n')}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return new Set(chosen.map((it) => key(it?.id, it?.versionId, it?.stepId)));
|
|
119
|
+
}
|
|
120
|
+
/** One TC execution logs one run row per testdata ITERATION. With 2+ rows, report each row's state
|
|
121
|
+
* (ITR-1 passed / ITR-2 failed) and an overall state that stays `running` until every row settles;
|
|
122
|
+
* a single row returns no `iterations` so the caller shows that run's steps as before. */
|
|
123
|
+
function iterationRollup(runs, chosen) {
|
|
124
|
+
const state = mapRunState(str(chosen, 'status') ?? '');
|
|
125
|
+
if (runs.length < 2)
|
|
126
|
+
return { state };
|
|
127
|
+
const byItr = [...runs].sort((a, b) => (Number(a?.itr) || 0) - (Number(b?.itr) || 0));
|
|
128
|
+
const iterations = byItr.map((r, i) => ({
|
|
129
|
+
label: iterationLabel(r) ?? `ITR-${i + 1}`,
|
|
130
|
+
state: mapRunState(str(r, 'status') ?? ''),
|
|
131
|
+
}));
|
|
132
|
+
const pending = iterations.some((it) => it.state === 'running' || it.state === 'queued');
|
|
133
|
+
return { state: pending ? 'running' : state, iterations };
|
|
134
|
+
}
|
|
85
135
|
/** Formula names round-trip with parens on ("FIRST_NAME()") from the backend and sometimes with a full
|
|
86
136
|
* signature ("FIRST_NAME(country,sex)") from a caller. Reduce both to the bare identifier. */
|
|
87
137
|
function bareFormulaName(s) {
|
|
@@ -869,6 +919,7 @@ const NEEDS_PROJECT = 'No project selected. Find your projects with sqa_query({
|
|
|
869
919
|
export class SimplifyQaAdapter {
|
|
870
920
|
constructor(cfg, transport) {
|
|
871
921
|
this.cfg = cfg;
|
|
922
|
+
this.supportsSuiteReExecution = true;
|
|
872
923
|
this.agentHop = null;
|
|
873
924
|
// Formula list rarely changes during a session; cache the fetch response so the model can call
|
|
874
925
|
// tc_list_formulas without paying a round trip each time. Instance-scoped: switchProject rebuilds
|
|
@@ -3793,7 +3844,11 @@ export class SimplifyQaAdapter {
|
|
|
3793
3844
|
* has no limit/offset of its own and always wants the WHOLE project tree; `searchBody`'s default
|
|
3794
3845
|
* page size (100) previously truncated any project with more modules than that silently. */
|
|
3795
3846
|
async listModules() {
|
|
3796
|
-
|
|
3847
|
+
return this.modulesOfProject(this.requireProjectId());
|
|
3848
|
+
}
|
|
3849
|
+
/** Every module of ANY project the caller can read — `listModules` for the active project, and the
|
|
3850
|
+
* destination lookup of a cross-project copy. */
|
|
3851
|
+
async modulesOfProject(projectId) {
|
|
3797
3852
|
const PAGE = 100;
|
|
3798
3853
|
const SAFETY_CAP = 5000;
|
|
3799
3854
|
const rows = [];
|
|
@@ -6054,6 +6109,247 @@ export class SimplifyQaAdapter {
|
|
|
6054
6109
|
productUrl: this.productUrlFor({ kind: 'testcase', id: newId }),
|
|
6055
6110
|
};
|
|
6056
6111
|
}
|
|
6112
|
+
/** Copy test cases and/or functions from the active project into ANOTHER project — the UI's "Copy to project"
|
|
6113
|
+
* popup: `POST /tm/tcfnCopy/copytc` (one request per kind: `type` is TC or FN). The backend copies the chosen
|
|
6114
|
+
* versions with their steps, objects, parameters, nested functions and test data (for the chosen environments),
|
|
6115
|
+
* renames a duplicate name to `<name>_copyN`, and answers BEFORE it has finished — so after the call this looks
|
|
6116
|
+
* for the copies in the destination (rows carrying `projectLevelcopiedFrom`) and reports what it found. */
|
|
6117
|
+
async copyTestCasesToProject(input) {
|
|
6118
|
+
const sourceProjectId = this.requireProjectId();
|
|
6119
|
+
const uniq = (xs) => [...new Set((xs ?? []).map((t) => String(t).trim()).filter(Boolean))];
|
|
6120
|
+
const tcIds = uniq(input.tcIds);
|
|
6121
|
+
const fnIds = uniq(input.functionIds);
|
|
6122
|
+
if (!tcIds.length && !fnIds.length)
|
|
6123
|
+
throw new Error('tcIds or functionIds is required — what to copy.');
|
|
6124
|
+
tcIds.forEach((t) => assertBusinessKeyKind(t, 'TC'));
|
|
6125
|
+
fnIds.forEach((t) => assertBusinessKeyKind(t, 'FN'));
|
|
6126
|
+
// Same rule as tc_clone's tdCopy: the user decides about test data, the tool never assumes it.
|
|
6127
|
+
if (input.confirm && input.copyTestData === undefined) {
|
|
6128
|
+
throw new Error('Ask the user: "Copy the test data too?" — then pass copyTestData:true (values are copied for the chosen environments) or copyTestData:false (only the empty ITR-1 structure). Nothing was copied.');
|
|
6129
|
+
}
|
|
6130
|
+
if (input.copyTestData === false && (input.environments ?? []).length) {
|
|
6131
|
+
throw new Error('environments and copyTestData:false contradict each other — with no test data there is no environment to choose.');
|
|
6132
|
+
}
|
|
6133
|
+
// Destination project: id, code or exact name, among the projects this user can see.
|
|
6134
|
+
const wantProject = String(input.destinationProject ?? '').trim();
|
|
6135
|
+
if (!wantProject)
|
|
6136
|
+
throw new Error('destinationProject is required (project id, code or name).');
|
|
6137
|
+
const projects = await this.listProjects();
|
|
6138
|
+
const pw = wantProject.toLowerCase();
|
|
6139
|
+
const pHits = projects.filter((p) => p.id === wantProject || (p.code ?? '').toLowerCase() === pw || p.name.trim().toLowerCase() === pw);
|
|
6140
|
+
if (pHits.length !== 1) {
|
|
6141
|
+
throw new Error(pHits.length
|
|
6142
|
+
? `Project "${wantProject}" matches ${pHits.length} projects (${pHits.map((p) => `${p.name} [id ${p.id}]`).join(', ')}). Pass the project id.`
|
|
6143
|
+
: `Project "${wantProject}" was not found among your projects (${projects.map((p) => `${p.name} [id ${p.id}]`).join(', ') || 'none'}).`);
|
|
6144
|
+
}
|
|
6145
|
+
const dest = pHits[0];
|
|
6146
|
+
const destProjectId = Number.parseInt(dest.id, 10);
|
|
6147
|
+
if (destProjectId === sourceProjectId)
|
|
6148
|
+
throw new Error('The destination is the active project — use tc_clone / fn_clone to copy within a project.');
|
|
6149
|
+
// Only into a project the caller may copy into — the privileges the backend itself checks on the destination
|
|
6150
|
+
// (one per kind). Checked before anything of that project is read, and on a preview too.
|
|
6151
|
+
const access = await this.getProjectPrivileges(dest.id);
|
|
6152
|
+
if (!access.tokenValid)
|
|
6153
|
+
throw new Error('Your SimplifyQA token is not valid, so access to the destination project cannot be checked. Reconnect and try again.');
|
|
6154
|
+
if (!access.hasRole)
|
|
6155
|
+
throw new Error(`You have no access to project "${dest.name}" — you can only copy into projects you are a member of.`);
|
|
6156
|
+
const needs = [];
|
|
6157
|
+
if (tcIds.length)
|
|
6158
|
+
needs.push(['copy_testcase_across_project', 'test cases']);
|
|
6159
|
+
if (fnIds.length)
|
|
6160
|
+
needs.push(['copy_function_across_projects', 'functions']);
|
|
6161
|
+
for (const [privilege, what] of needs) {
|
|
6162
|
+
if (!access.privileges.includes(privilege)) {
|
|
6163
|
+
throw new Error(`Your role${access.roleName ? ` "${access.roleName}"` : ''} in "${dest.name}" does not allow copying ${what} into it (missing privilege ${privilege}). Ask a project admin to grant it.`);
|
|
6164
|
+
}
|
|
6165
|
+
}
|
|
6166
|
+
// Destination module.
|
|
6167
|
+
const modules = await this.modulesOfProject(destProjectId);
|
|
6168
|
+
const wantModule = String(input.destinationModule ?? '').trim();
|
|
6169
|
+
let module;
|
|
6170
|
+
if (wantModule) {
|
|
6171
|
+
const mw = wantModule.toLowerCase();
|
|
6172
|
+
const mHits = modules.filter((m) => m.id === wantModule || m.name.trim().toLowerCase() === mw);
|
|
6173
|
+
if (mHits.length !== 1) {
|
|
6174
|
+
throw new Error(mHits.length
|
|
6175
|
+
? `Module "${wantModule}" matches ${mHits.length} modules in ${dest.name} (${mHits.map((m) => `${m.name} [id ${m.id}]`).join(', ')}). Pass the module id.`
|
|
6176
|
+
: `Module "${wantModule}" was not found in ${dest.name}. Modules: ${modules.map((m) => `${m.name} [id ${m.id}]`).join(', ') || 'none'}.`);
|
|
6177
|
+
}
|
|
6178
|
+
module = mHits[0];
|
|
6179
|
+
}
|
|
6180
|
+
else {
|
|
6181
|
+
module = modules.find((m) => m.isRoot) ?? modules.find((m) => m.name.trim().toLowerCase() === 'default module');
|
|
6182
|
+
if (!module)
|
|
6183
|
+
throw new Error(`${dest.name} has no root module to default to — pass destinationModule.`);
|
|
6184
|
+
}
|
|
6185
|
+
const destModuleId = Number.parseInt(module.id, 10);
|
|
6186
|
+
// Sources and their versions. `versionsBy` (per item) beats `versions` (for all).
|
|
6187
|
+
const clean = (xs) => (xs ?? []).map((v) => String(v).trim()).filter(Boolean);
|
|
6188
|
+
const globalVersions = clean(input.versions);
|
|
6189
|
+
const perItem = Object.entries(input.versionsBy ?? {}).map(([k, v]) => ({ key: k.trim().toUpperCase(), versions: clean(v), used: false }));
|
|
6190
|
+
const items = [];
|
|
6191
|
+
const entries = [];
|
|
6192
|
+
const lists = { TC: [], FN: [] };
|
|
6193
|
+
const moduleOf = { TC: 0, FN: 0 };
|
|
6194
|
+
const norm = (n) => n.trim().toLowerCase().replace(/^v/, '').replace(/\.0+$/, '');
|
|
6195
|
+
for (const kind of ['TC', 'FN']) {
|
|
6196
|
+
for (const ref of kind === 'TC' ? tcIds : fnIds) {
|
|
6197
|
+
const id = Number.parseInt(numericId(ref), 10);
|
|
6198
|
+
const doc = kind === 'TC'
|
|
6199
|
+
? await this.fetchRawTestcase(ref)
|
|
6200
|
+
: await this.fetchRawFunctionDoc(ref, sourceProjectId);
|
|
6201
|
+
if (!doc || Object.keys(doc).length === 0 || doc.deleted === true)
|
|
6202
|
+
throw new Error(`${kind === 'TC' ? 'test case' : 'function'} ${ref} not found`);
|
|
6203
|
+
// Only the active project's own items: a lookup by id must not read another project's.
|
|
6204
|
+
const owner = Number.parseInt(str(doc, 'projectId') ?? '', 10);
|
|
6205
|
+
if (Number.isFinite(owner) && owner !== sourceProjectId) {
|
|
6206
|
+
throw new Error(`${ref} belongs to project ${owner}, not the active project (${sourceProjectId}). Switch to its project first.`);
|
|
6207
|
+
}
|
|
6208
|
+
const code = str(doc, 'code') ?? ref;
|
|
6209
|
+
const versionRows = kind === 'TC' ? (Array.isArray(doc.versions) ? doc.versions : []) : await this.fetchFunctionVersionRows(String(id));
|
|
6210
|
+
const names = versionRows.map((v) => str(v, 'name')).filter((n) => !!n);
|
|
6211
|
+
const own = perItem.find((p) => p.key === ref.toUpperCase() || p.key === code.toUpperCase() || p.key === String(id));
|
|
6212
|
+
if (own)
|
|
6213
|
+
own.used = true;
|
|
6214
|
+
const asked = own ? own.versions : globalVersions;
|
|
6215
|
+
// Same rule as tc_clone: several versions and none chosen → ask, never default to the latest or v1.
|
|
6216
|
+
if (!asked.length && names.length > 1) {
|
|
6217
|
+
throw new Error(`${code} has ${names.length} versions: ${names.join(', ')}. Ask the user which to copy (do NOT default to the latest or v1) and pass versions:["v2.0"] (or versionsBy:{"${code}":["v2.0"]} for this one), or versions:["all"] for every version. Nothing was copied.`);
|
|
6218
|
+
}
|
|
6219
|
+
// Version names as the user says them: "v2", "2" and "v2.0" are the same version (as in tc_clone).
|
|
6220
|
+
const chosen = [];
|
|
6221
|
+
if (!asked.some((v) => v.toLowerCase() === 'all')) {
|
|
6222
|
+
for (const v of asked) {
|
|
6223
|
+
const hit = names.find((n) => n === v) ?? names.find((n) => n.trim().toLowerCase() === v.toLowerCase()) ?? names.find((n) => norm(n) === norm(v));
|
|
6224
|
+
if (!hit)
|
|
6225
|
+
throw new Error(`${code} has no version "${v}". Versions: ${names.join(', ') || 'none'}.`);
|
|
6226
|
+
if (!chosen.includes(hit))
|
|
6227
|
+
chosen.push(hit);
|
|
6228
|
+
}
|
|
6229
|
+
}
|
|
6230
|
+
if (!moduleOf[kind])
|
|
6231
|
+
moduleOf[kind] = Number.parseInt(str(doc, 'moduleId') ?? '', 10) || 0;
|
|
6232
|
+
const item = { kind, tcId: code, name: str(doc, 'name') ?? '', versions: chosen.length ? chosen : names };
|
|
6233
|
+
items.push(item);
|
|
6234
|
+
entries.push({ kind, id, item });
|
|
6235
|
+
lists[kind].push({ id, ...(chosen.length ? { selversions: chosen } : {}) });
|
|
6236
|
+
}
|
|
6237
|
+
}
|
|
6238
|
+
const stray = perItem.find((p) => !p.used);
|
|
6239
|
+
if (stray)
|
|
6240
|
+
throw new Error(`versionsBy names "${stray.key}", which is not among the items being copied.`);
|
|
6241
|
+
// Environments: the backend reads the source's AND the destination's by name, so a name only one has breaks the copy.
|
|
6242
|
+
const srcEnvs = (await this.environmentsOfProject(sourceProjectId)).map((e) => e.name);
|
|
6243
|
+
const destEnvs = (await this.environmentsOfProject(destProjectId)).map((e) => e.name);
|
|
6244
|
+
const asked = (input.environments ?? []).map((e) => String(e).trim()).filter(Boolean);
|
|
6245
|
+
const bad = asked.filter((e) => !srcEnvs.includes(e) || !destEnvs.includes(e));
|
|
6246
|
+
if (bad.length)
|
|
6247
|
+
throw new Error(`Environment ${bad.map((e) => `"${e}"`).join(', ')} is not in both projects. In both: ${srcEnvs.filter((e) => destEnvs.includes(e)).join(', ') || 'none'}.`);
|
|
6248
|
+
// copyTestData:false → no environment is selected: the backend then copies only the empty structure.
|
|
6249
|
+
const environments = input.copyTestData === false ? [] : asked.length ? asked : srcEnvs.filter((e) => destEnvs.includes(e));
|
|
6250
|
+
// The backend walks the DESTINATION's environments: a source environment with no same-named one there is never
|
|
6251
|
+
// visited (its data is dropped), and a destination environment that is not selected gets rows with EMPTY cells.
|
|
6252
|
+
const missingEnvironments = input.copyTestData === false ? [] : srcEnvs.filter((e) => !destEnvs.includes(e));
|
|
6253
|
+
const emptyEnvironments = destEnvs.filter((e) => !environments.includes(e));
|
|
6254
|
+
// The backend renames an item whose name already exists in the destination PROJECT to `<name>_copyN`.
|
|
6255
|
+
// Best effort: if the names cannot be read the copy is not blocked, it just cannot warn.
|
|
6256
|
+
for (const kind of ['TC', 'FN']) {
|
|
6257
|
+
if (!lists[kind].length)
|
|
6258
|
+
continue;
|
|
6259
|
+
const taken = await this.namesOfProject(kind, destProjectId).catch(() => undefined);
|
|
6260
|
+
if (!taken)
|
|
6261
|
+
continue;
|
|
6262
|
+
for (const e of entries.filter((x) => x.kind === kind)) {
|
|
6263
|
+
if (!taken.has(e.item.name))
|
|
6264
|
+
continue;
|
|
6265
|
+
let n = 1;
|
|
6266
|
+
while (taken.has(`${e.item.name}_copy${n}`))
|
|
6267
|
+
n++;
|
|
6268
|
+
e.item.renamedTo = `${e.item.name}_copy${n}`;
|
|
6269
|
+
}
|
|
6270
|
+
}
|
|
6271
|
+
const result = {
|
|
6272
|
+
preview: !input.confirm,
|
|
6273
|
+
destination: { projectId: dest.id, projectName: dest.name, moduleId: module.id, moduleName: module.name },
|
|
6274
|
+
items, environments, missingEnvironments, emptyEnvironments, copied: [], pending: [],
|
|
6275
|
+
...(input.copyTestData !== undefined ? { copyTestData: input.copyTestData } : {}),
|
|
6276
|
+
};
|
|
6277
|
+
if (!input.confirm)
|
|
6278
|
+
return result;
|
|
6279
|
+
// Snapshot the destination module first, so the copies are told apart from what was already there.
|
|
6280
|
+
const kinds = ['FN', 'TC'].filter((k) => lists[k].length); // functions first, as a test case may call them
|
|
6281
|
+
const before = new Map();
|
|
6282
|
+
for (const k of kinds)
|
|
6283
|
+
before.set(k, new Set((await this.copiesInModule(k, destProjectId, destModuleId)).map((r) => r.id)));
|
|
6284
|
+
for (const k of kinds) {
|
|
6285
|
+
await this.http.postJson('/tm/tcfnCopy/copytc', {
|
|
6286
|
+
type: k, sourceProjId: sourceProjectId, sourceModuleId: moduleOf[k], destinationProjId: destProjectId, destinationModuleId: destModuleId,
|
|
6287
|
+
selectedEnv: environments, tcfnList: lists[k],
|
|
6288
|
+
});
|
|
6289
|
+
}
|
|
6290
|
+
const wait = input.pollMs ?? 2000;
|
|
6291
|
+
const found = new Map();
|
|
6292
|
+
for (let attempt = 0; attempt < 8 && found.size < entries.length; attempt++) {
|
|
6293
|
+
if (attempt && wait > 0)
|
|
6294
|
+
await new Promise((r) => setTimeout(r, wait));
|
|
6295
|
+
for (const k of kinds) {
|
|
6296
|
+
const wanted = new Set(entries.filter((e) => e.kind === k).map((e) => e.id));
|
|
6297
|
+
for (const r of await this.copiesInModule(k, destProjectId, destModuleId)) {
|
|
6298
|
+
const key = `${k}:${r.from}`;
|
|
6299
|
+
if (before.get(k).has(r.id) || !wanted.has(r.from) || found.has(key))
|
|
6300
|
+
continue;
|
|
6301
|
+
found.set(key, { kind: k, fromTcId: String(r.from), id: r.id, ...(r.code ? { code: r.code } : {}), name: r.name });
|
|
6302
|
+
}
|
|
6303
|
+
}
|
|
6304
|
+
}
|
|
6305
|
+
result.copied = [...found.values()];
|
|
6306
|
+
result.pending = entries.filter((e) => !found.has(`${e.kind}:${e.id}`)).map((e) => e.item.tcId);
|
|
6307
|
+
return result;
|
|
6308
|
+
}
|
|
6309
|
+
/** A function's own document, from the active project (the project id is part of the path, so another project's
|
|
6310
|
+
* function reads as not found). */
|
|
6311
|
+
async fetchRawFunctionDoc(ref, projectId) {
|
|
6312
|
+
const raw = await this.http.getJson(`/tm/function/${numericId(ref)}/${projectId}`);
|
|
6313
|
+
let doc = raw?.data ?? raw;
|
|
6314
|
+
if (Array.isArray(doc))
|
|
6315
|
+
doc = doc.length > 0 ? doc[0] : {};
|
|
6316
|
+
return doc && typeof doc === 'object' ? doc : {};
|
|
6317
|
+
}
|
|
6318
|
+
/** Names of the (non-deleted) test cases or functions of a project — what the backend's copy checks a new name against. */
|
|
6319
|
+
async namesOfProject(kind, projectId) {
|
|
6320
|
+
const PAGE = 500;
|
|
6321
|
+
const CAP = 20000;
|
|
6322
|
+
const names = new Set();
|
|
6323
|
+
const path = kind === 'TC' ? '/tm/testcase/search' : '/tm/function/search';
|
|
6324
|
+
for (let offset = 0; offset < CAP; offset += PAGE) {
|
|
6325
|
+
const body = this.searchBody([{ column: 'projectId', value: projectId }], { startIndex: offset, limit: PAGE, rawOffset: true, selectFields: ['name'] });
|
|
6326
|
+
const rows = pickArray(await this.http.postJson(path, body), 'data', 'content', 'testCases', 'functions');
|
|
6327
|
+
for (const r of rows) {
|
|
6328
|
+
const n = str(r, 'name');
|
|
6329
|
+
if (n)
|
|
6330
|
+
names.add(n);
|
|
6331
|
+
}
|
|
6332
|
+
if (rows.length < PAGE)
|
|
6333
|
+
break;
|
|
6334
|
+
}
|
|
6335
|
+
return names;
|
|
6336
|
+
}
|
|
6337
|
+
/** The test cases / functions of a destination module that came from another project's (`from` = the source id). */
|
|
6338
|
+
async copiesInModule(kind, projectId, moduleId) {
|
|
6339
|
+
const body = this.searchBody([{ column: 'projectId', value: projectId }, { column: 'moduleId', value: moduleId }], { limit: 1000, rawOffset: true, selectFields: ['id', 'code', 'name', 'projectLevelcopiedFrom'] });
|
|
6340
|
+
const path = kind === 'TC' ? '/tm/testcase/search' : '/tm/function/search';
|
|
6341
|
+
const rows = pickArray(await this.http.postJson(path, body), 'data', 'content', 'testCases', 'functions');
|
|
6342
|
+
const out = [];
|
|
6343
|
+
for (const r of rows) {
|
|
6344
|
+
const from = Number.parseInt(String(r?.projectLevelcopiedFrom?.id ?? ''), 10);
|
|
6345
|
+
const id = str(r, 'id', '_id');
|
|
6346
|
+
if (!Number.isFinite(from) || !id)
|
|
6347
|
+
continue;
|
|
6348
|
+
const code = str(r, 'code');
|
|
6349
|
+
out.push({ id, ...(code ? { code } : {}), name: str(r, 'name') ?? '', from });
|
|
6350
|
+
}
|
|
6351
|
+
return out;
|
|
6352
|
+
}
|
|
6057
6353
|
// ---------------------------------------------------------------------- Functions (reusable)
|
|
6058
6354
|
// Same tcfnObj collection as testcases — type='FN' instead of 'TC'. Search / getById / delete /
|
|
6059
6355
|
// steps all mirror the testcase endpoints one-to-one.
|
|
@@ -10576,7 +10872,7 @@ export class SimplifyQaAdapter {
|
|
|
10576
10872
|
const reportParentId = Number(tcExecDoc?.executionTypeId) || Number(str(chosen, 'testcaseId')) || parentId;
|
|
10577
10873
|
return {
|
|
10578
10874
|
runId,
|
|
10579
|
-
|
|
10875
|
+
...iterationRollup(runs, chosen),
|
|
10580
10876
|
stepResults,
|
|
10581
10877
|
reportUrl: `${base}/user/reports/reports-page?type=TESTCASE&parentId=${reportParentId}&id=${runIdNum}&projectId=${projectId}`,
|
|
10582
10878
|
};
|
|
@@ -10719,7 +11015,7 @@ export class SimplifyQaAdapter {
|
|
|
10719
11015
|
const stepResults = await this.fetchStepResults(runIdNum, executionRunId, parentId, projectId);
|
|
10720
11016
|
return {
|
|
10721
11017
|
runId: suiteRunId,
|
|
10722
|
-
|
|
11018
|
+
...iterationRollup(runs, chosen),
|
|
10723
11019
|
stepResults,
|
|
10724
11020
|
// A test case inside a SUITE run has no report page of its own here: `parentId` above is an internal item id
|
|
10725
11021
|
// (not a test case id) and `runIdNum` is the SUITE's run id, so a type=TESTCASE link built from them opened
|
|
@@ -11199,7 +11495,38 @@ export class SimplifyQaAdapter {
|
|
|
11199
11495
|
throw new Error(`startRun: could not resolve project name for projectId=${projectId}. ` +
|
|
11200
11496
|
`The token may not have read access to this project.`);
|
|
11201
11497
|
}
|
|
11202
|
-
|
|
11498
|
+
// Re-execution (the report's Re-execute → execution popup 'RE'): only the picked test cases run, as a CHILD of the
|
|
11499
|
+
// earlier run, so their results roll back into it (executions executionItem.service.js updateParentExecutionsItems).
|
|
11500
|
+
let reExec;
|
|
11501
|
+
if (opts.reExecuteOf) {
|
|
11502
|
+
const parentNum = Number.parseInt(numericId(opts.reExecuteOf), 10);
|
|
11503
|
+
const parent = Number.isFinite(parentNum) ? await this.fetchExecDoc(parentNum, projectId) : undefined;
|
|
11504
|
+
if (!parent)
|
|
11505
|
+
throw new Error(`Re-execute: suite run ${opts.reExecuteOf} was not found in this project.`);
|
|
11506
|
+
// A re-execution of a re-execution still belongs to the ORIGINAL run — the report the UI re-executes from.
|
|
11507
|
+
const root = parent.childExecution && parent.parentExecutionId
|
|
11508
|
+
? await this.fetchExecDoc(Number(parent.parentExecutionId), projectId) : parent;
|
|
11509
|
+
if (!root)
|
|
11510
|
+
throw new Error(`Re-execute: the original run of ${opts.reExecuteOf} (${parent.parentExecutionId}) was not found.`);
|
|
11511
|
+
if (String(root.type ?? '').toUpperCase() !== 'SUITE' || Number(root.executionTypeId) !== suiteNum) {
|
|
11512
|
+
throw new Error(`Re-execute: run ${root.id} is not a run of suite ${suiteId}.`);
|
|
11513
|
+
}
|
|
11514
|
+
if (['INPROGRESS', 'QUEUED'].includes(String(root.status ?? '').toUpperCase())) {
|
|
11515
|
+
throw new Error(`Re-execute: run ${root.id} is still in progress — wait until it finishes.`);
|
|
11516
|
+
}
|
|
11517
|
+
if (RE_EXEC_LOCKED.includes(String(root.reviewApproveStatus ?? '').toUpperCase())) {
|
|
11518
|
+
throw new Error(`Re-execute: run ${root.id} is under Review/Approve (${root.reviewApproveStatus}) — re-execution is not allowed until that is reverted.`);
|
|
11519
|
+
}
|
|
11520
|
+
if (mode === 'STACK')
|
|
11521
|
+
throw new Error("Re-execute: a Stack run can't re-execute test cases — use mode local, remote or cloud.");
|
|
11522
|
+
const items = Array.isArray(root.executionItems) ? root.executionItems : [];
|
|
11523
|
+
reExec = {
|
|
11524
|
+
root,
|
|
11525
|
+
keys: selectReExecutionKeys(items, { tcIds: opts.reExecuteTcIds, failedOnly: opts.reExecuteFailedOnly }),
|
|
11526
|
+
items: new Map(items.map((it) => [`${it?.id}|${it?.versionId ?? ''}|${it?.stepId ?? ''}`, it])),
|
|
11527
|
+
};
|
|
11528
|
+
}
|
|
11529
|
+
const env = await this.resolveEnvironment(projectId, opts.environment ?? (reExec ? str(reExec.root, 'environmentType') : undefined));
|
|
11203
11530
|
const suiteType = String(rawSuite.suiteType ?? 'AUTOMATION').toUpperCase();
|
|
11204
11531
|
// Build one executionItems entry per suite row, in suite order. Silently skip rows whose TC no
|
|
11205
11532
|
// longer exists (matches UI :880 `if (!data) return;`). Every item uses the suite row's stored
|
|
@@ -11214,11 +11541,17 @@ export class SimplifyQaAdapter {
|
|
|
11214
11541
|
const executionItems = [];
|
|
11215
11542
|
const cloudNeedsBrowser = [];
|
|
11216
11543
|
let seqCounter = 0;
|
|
11544
|
+
let reExecMatched = 0;
|
|
11217
11545
|
for (const row of members) {
|
|
11218
11546
|
seqCounter++;
|
|
11219
11547
|
const memberTcId = row?.testcaseId;
|
|
11220
11548
|
if (memberTcId === undefined || memberTcId === null)
|
|
11221
11549
|
continue;
|
|
11550
|
+
if (reExec) {
|
|
11551
|
+
if (!reExec.keys.has(`${memberTcId}|${row?.versionId ?? row?.version ?? ''}|${row?.stepId ?? ''}`))
|
|
11552
|
+
continue;
|
|
11553
|
+
reExecMatched++;
|
|
11554
|
+
}
|
|
11222
11555
|
let rawTc;
|
|
11223
11556
|
try {
|
|
11224
11557
|
rawTc = await this.fetchRawTestcase(String(memberTcId));
|
|
@@ -11239,7 +11572,10 @@ export class SimplifyQaAdapter {
|
|
|
11239
11572
|
// Per-mode platform from the suite row. UI reads `data1.executionPlatform[mode]` (:882-965);
|
|
11240
11573
|
// when saved, it's a single object → wrap in `[obj]`; if the row didn't save one for this
|
|
11241
11574
|
// mode, send `[]` and let the backend reject/accept per its own rules.
|
|
11242
|
-
|
|
11575
|
+
// A re-execution runs each test case on the platform it ran on in the earlier run — the UI's onClickRun
|
|
11576
|
+
// OVERWRITES the suite row's platform with the run item's; the suite row is only used if the run has none.
|
|
11577
|
+
const runPlatform = reExec ? reExec.items.get(`${memberTcId}|${row?.versionId ?? row?.version ?? ''}|${row?.stepId ?? ''}`)?.platform?.[0] : undefined;
|
|
11578
|
+
const savedPlatform = runPlatform?.id || runPlatform?.name ? runPlatform : row?.executionPlatform?.[mode];
|
|
11243
11579
|
let platform = [];
|
|
11244
11580
|
if (mode === 'CLOUD' && tcType === 'WEB') {
|
|
11245
11581
|
// the cloud picker is Chrome / Firefox / Edge Headless: a browser the caller names applies to every web test case (as the Run dialog's does)
|
|
@@ -11307,6 +11643,10 @@ export class SimplifyQaAdapter {
|
|
|
11307
11643
|
throw new Error(`ASK the user which browser to run ${rawSuite.code ?? suiteId} in on the cloud — ${CLOUD_BROWSER_NAMES.join(', ')} (cloud runs are headless) — then call again with \`browser\` set. ` +
|
|
11308
11644
|
`It has no saved cloud browser for: ${cloudNeedsBrowser.join(', ')}.`);
|
|
11309
11645
|
}
|
|
11646
|
+
if (reExec && reExecMatched < reExec.keys.size) {
|
|
11647
|
+
throw new Error(`Re-execute: ${reExec.keys.size - reExecMatched} of the picked test case(s) were removed from suite ${suiteId} ` +
|
|
11648
|
+
`(or its version/step changed) since run ${reExec.root.id} — nothing was started.`);
|
|
11649
|
+
}
|
|
11310
11650
|
if (!stackRun && executionItems.length === 0) {
|
|
11311
11651
|
throw new Error(`startRun: suite ${suiteId} has no runnable test cases (all members were deleted, ` +
|
|
11312
11652
|
`unreadable, or filtered out).`);
|
|
@@ -11337,7 +11677,7 @@ export class SimplifyQaAdapter {
|
|
|
11337
11677
|
const body = {
|
|
11338
11678
|
projectId,
|
|
11339
11679
|
environmentType: env,
|
|
11340
|
-
executionStyle: stackRun ? 'SERIAL' : (opts.strategy ?? 'serial').toUpperCase(),
|
|
11680
|
+
executionStyle: stackRun ? 'SERIAL' : (opts.strategy ?? str(reExec?.root, 'executionStyle') ?? 'serial').toUpperCase(),
|
|
11341
11681
|
executionOS: this.detectExecutionOS(),
|
|
11342
11682
|
executionTypeId: suiteNum,
|
|
11343
11683
|
executionTypeName: str(rawSuite, 'name') ?? '',
|
|
@@ -11346,16 +11686,21 @@ export class SimplifyQaAdapter {
|
|
|
11346
11686
|
cloudType,
|
|
11347
11687
|
mode,
|
|
11348
11688
|
executionCategory: 'EXECUTION',
|
|
11349
|
-
|
|
11350
|
-
|
|
11689
|
+
// A re-execution keeps the earlier run's release / sprint unless the caller names others (UI 'RE' defaults).
|
|
11690
|
+
releaseId: reExec && opts.releaseId === undefined ? Number(reExec.root.releaseId) || 0 : this.idOrZero('releaseId', opts.releaseId),
|
|
11691
|
+
iterationId: reExec && opts.sprintId === undefined ? Number(reExec.root.iterationId) || 0 : this.idOrZero('sprintId', opts.sprintId),
|
|
11351
11692
|
executionTime: '',
|
|
11352
11693
|
status: 'INPROGRESS',
|
|
11353
11694
|
iterationsSelected: [],
|
|
11354
11695
|
result: '',
|
|
11355
|
-
globalConfiguration:
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11696
|
+
globalConfiguration: {
|
|
11697
|
+
...suiteRunGlobalConfig(rawSuite, {
|
|
11698
|
+
terminateOnFailure: opts.terminateOnFailure,
|
|
11699
|
+
maxConcurrent: opts.maxConcurrent,
|
|
11700
|
+
}),
|
|
11701
|
+
...(reExec ? { RE_EXECUTION_COUNT: 0 } : {}), // the UI turns auto re-execution off for a manual re-execute
|
|
11702
|
+
},
|
|
11703
|
+
...(reExec ? { childExecution: true, parentExecutionId: Number(reExec.root.id) } : {}),
|
|
11359
11704
|
isRecordingEnabled: false,
|
|
11360
11705
|
offset: -(new Date().getTimezoneOffset()),
|
|
11361
11706
|
type: 'SUITE',
|
|
@@ -11371,7 +11716,8 @@ export class SimplifyQaAdapter {
|
|
|
11371
11716
|
if (!runId)
|
|
11372
11717
|
throw new Error('startRun: backend accepted suite trigger but returned no run id.');
|
|
11373
11718
|
await this.assertRunMode(runId, mode, mode === 'REMOTE' ? agentId : null);
|
|
11374
|
-
|
|
11719
|
+
// A re-execution's results land in the ORIGINAL run's report — link that one.
|
|
11720
|
+
return { runId, reportUrl: this.runReportUrl('SUITE', suiteNum, reExec ? String(reExec.root.id) : runId, projectId) };
|
|
11375
11721
|
}
|
|
11376
11722
|
/** GET the agent /mcp with a 1s timeout. Any HTTP response (incl. 4xx from an MCP server rejecting
|
|
11377
11723
|
* a naked GET) proves the process is up; connect/DNS/timeout errors mean it is down. Replaces
|
|
@@ -11798,7 +12144,10 @@ export class SimplifyQaAdapter {
|
|
|
11798
12144
|
/** Direct REST — same endpoint `resolveEnvironment` uses. Works without an agent hop.
|
|
11799
12145
|
* `key` is what testdata iterations store as `environmentType`; `id` is the uuid used by run dispatch. */
|
|
11800
12146
|
async listEnvironments() {
|
|
11801
|
-
|
|
12147
|
+
return this.environmentsOfProject(this.requireProjectId());
|
|
12148
|
+
}
|
|
12149
|
+
/** The environments of ANY project the caller can read (the active one, or a copy's destination). */
|
|
12150
|
+
async environmentsOfProject(projectId) {
|
|
11802
12151
|
// Let fetch failures propagate rather than reading as "zero environments".
|
|
11803
12152
|
const raw = await this.http.getJson(`/pm/fields/8?projectId=${projectId}&fieldType=environment`);
|
|
11804
12153
|
const arr = Array.isArray(raw) ? raw : Array.isArray(raw?.data) ? raw.data : [];
|