simplify3x-connect 0.31.9 → 0.31.11
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/assets/tessdata/eng.traineddata +0 -0
- package/dist/adapters/remoteMcp/adapter.d.ts +1 -1
- package/dist/adapters/remoteMcp/adapter.d.ts.map +1 -1
- package/dist/adapters/remoteMcp/adapter.js +6 -5
- package/dist/adapters/remoteMcp/adapter.js.map +1 -1
- package/dist/adapters/simplifyqa/adapter.d.ts +46 -2
- package/dist/adapters/simplifyqa/adapter.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/adapter.js +434 -23
- package/dist/adapters/simplifyqa/adapter.js.map +1 -1
- package/dist/adapters/simplifyqa/appProfile.d.ts +25 -0
- package/dist/adapters/simplifyqa/appProfile.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/appProfile.js +137 -0
- package/dist/adapters/simplifyqa/appProfile.js.map +1 -0
- package/dist/adapters/simplifyqa/executionFailures.d.ts +53 -11
- package/dist/adapters/simplifyqa/executionFailures.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/executionFailures.js +289 -46
- package/dist/adapters/simplifyqa/executionFailures.js.map +1 -1
- package/dist/adapters/simplifyqa/executionSources.d.ts +64 -0
- package/dist/adapters/simplifyqa/executionSources.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/executionSources.js +138 -0
- package/dist/adapters/simplifyqa/executionSources.js.map +1 -0
- package/dist/adapters/simplifyqa/failureAnalysis.d.ts +18 -1
- package/dist/adapters/simplifyqa/failureAnalysis.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failureAnalysis.js +182 -10
- package/dist/adapters/simplifyqa/failureAnalysis.js.map +1 -1
- package/dist/adapters/simplifyqa/failureAnalysisCard.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failureAnalysisCard.js +45 -19
- package/dist/adapters/simplifyqa/failureAnalysisCard.js.map +1 -1
- package/dist/adapters/simplifyqa/failureAnalysisRun.d.ts +8 -1
- package/dist/adapters/simplifyqa/failureAnalysisRun.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failureAnalysisRun.js +108 -4
- package/dist/adapters/simplifyqa/failureAnalysisRun.js.map +1 -1
- package/dist/adapters/simplifyqa/failureAnalysisTypes.d.ts +65 -1
- package/dist/adapters/simplifyqa/failureAnalysisTypes.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failureAnalysisTypes.js +12 -1
- package/dist/adapters/simplifyqa/failureAnalysisTypes.js.map +1 -1
- package/dist/adapters/simplifyqa/failureHistory.d.ts +64 -20
- package/dist/adapters/simplifyqa/failureHistory.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failureHistory.js +88 -30
- package/dist/adapters/simplifyqa/failureHistory.js.map +1 -1
- package/dist/adapters/simplifyqa/failurePatterns.d.ts +11 -0
- package/dist/adapters/simplifyqa/failurePatterns.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failurePatterns.js +4 -3
- package/dist/adapters/simplifyqa/failurePatterns.js.map +1 -1
- package/dist/adapters/simplifyqa/failureReport.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failureReport.js +8 -0
- package/dist/adapters/simplifyqa/failureReport.js.map +1 -1
- package/dist/adapters/simplifyqa/failureReportModel.d.ts +125 -1
- package/dist/adapters/simplifyqa/failureReportModel.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failureReportModel.js +324 -4
- package/dist/adapters/simplifyqa/failureReportModel.js.map +1 -1
- package/dist/adapters/simplifyqa/failureReview.d.ts +1 -1
- package/dist/adapters/simplifyqa/failureReview.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failureReview.js +44 -8
- package/dist/adapters/simplifyqa/failureReview.js.map +1 -1
- package/dist/adapters/simplifyqa/failureSuggest.d.ts +4 -2
- package/dist/adapters/simplifyqa/failureSuggest.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/failureSuggest.js +44 -14
- package/dist/adapters/simplifyqa/failureSuggest.js.map +1 -1
- package/dist/adapters/simplifyqa/failureTypes.d.ts +19 -0
- package/dist/adapters/simplifyqa/failureTypes.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/heal/apply.d.ts +3 -1
- package/dist/adapters/simplifyqa/heal/apply.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/heal/apply.js +5 -1
- package/dist/adapters/simplifyqa/heal/apply.js.map +1 -1
- package/dist/adapters/simplifyqa/heal/diagnose.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/heal/diagnose.js +14 -0
- package/dist/adapters/simplifyqa/heal/diagnose.js.map +1 -1
- package/dist/adapters/simplifyqa/heal/plan.d.ts +2 -0
- package/dist/adapters/simplifyqa/heal/plan.d.ts.map +1 -1
- package/dist/adapters/simplifyqa/heal/plan.js +43 -0
- package/dist/adapters/simplifyqa/heal/plan.js.map +1 -1
- package/dist/adapters/simplifyqa/networkErrors.d.ts +11 -0
- package/dist/adapters/simplifyqa/networkErrors.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/networkErrors.js +108 -0
- package/dist/adapters/simplifyqa/networkErrors.js.map +1 -0
- package/dist/adapters/simplifyqa/outage.d.ts +41 -0
- package/dist/adapters/simplifyqa/outage.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/outage.js +108 -0
- package/dist/adapters/simplifyqa/outage.js.map +1 -0
- package/dist/adapters/simplifyqa/patternSplit.d.ts +32 -0
- package/dist/adapters/simplifyqa/patternSplit.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/patternSplit.js +79 -0
- package/dist/adapters/simplifyqa/patternSplit.js.map +1 -0
- package/dist/adapters/simplifyqa/screenText.d.ts +84 -0
- package/dist/adapters/simplifyqa/screenText.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/screenText.js +497 -0
- package/dist/adapters/simplifyqa/screenText.js.map +1 -0
- 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 +4 -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/heal.d.ts +10 -0
- package/dist/domain/heal.d.ts.map +1 -1
- package/dist/domain/heal.js.map +1 -1
- package/dist/domain/types.d.ts +56 -0
- package/dist/domain/types.d.ts.map +1 -1
- package/dist/export/html.d.ts +26 -0
- package/dist/export/html.d.ts.map +1 -0
- package/dist/export/html.js +842 -0
- package/dist/export/html.js.map +1 -0
- package/dist/export/labelCompare.d.ts +36 -0
- package/dist/export/labelCompare.d.ts.map +1 -0
- package/dist/export/labelCompare.js +96 -0
- package/dist/export/labelCompare.js.map +1 -0
- package/dist/export/layout.d.ts +19 -10
- package/dist/export/layout.d.ts.map +1 -1
- package/dist/export/layout.js +40 -9
- package/dist/export/layout.js.map +1 -1
- package/dist/export/pdf.d.ts +31 -1
- package/dist/export/pdf.d.ts.map +1 -1
- package/dist/export/pdf.js +170 -34
- package/dist/export/pdf.js.map +1 -1
- package/dist/export/xlsx.d.ts +1 -1
- package/dist/export/xlsx.js +2 -2
- package/dist/export/xlsx.js.map +1 -1
- package/dist/initAgents.d.ts.map +1 -1
- package/dist/initAgents.js +28 -8
- 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 +15 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/desktopRecordingMode.d.ts +27 -0
- package/dist/tools/desktopRecordingMode.d.ts.map +1 -0
- package/dist/tools/desktopRecordingMode.js +40 -0
- package/dist/tools/desktopRecordingMode.js.map +1 -0
- package/dist/tools/discovery.tools.d.ts.map +1 -1
- package/dist/tools/discovery.tools.js +159 -16
- package/dist/tools/discovery.tools.js.map +1 -1
- package/dist/tools/executionPlan.tools.d.ts.map +1 -1
- package/dist/tools/executionPlan.tools.js +9 -6
- package/dist/tools/executionPlan.tools.js.map +1 -1
- package/dist/tools/failure.tools.d.ts +10 -0
- package/dist/tools/failure.tools.d.ts.map +1 -1
- package/dist/tools/failure.tools.js +140 -18
- package/dist/tools/failure.tools.js.map +1 -1
- package/dist/tools/failureExport.tools.d.ts +1 -1
- package/dist/tools/failureExport.tools.d.ts.map +1 -1
- package/dist/tools/failureExport.tools.js +69 -26
- package/dist/tools/failureExport.tools.js.map +1 -1
- package/dist/tools/heal.tools.js +1 -1
- package/dist/tools/heal.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/recording.tools.d.ts.map +1 -1
- package/dist/tools/recording.tools.js +12 -4
- package/dist/tools/recording.tools.js.map +1 -1
- package/dist/tools/recordingNames.d.ts +16 -0
- package/dist/tools/recordingNames.d.ts.map +1 -1
- package/dist/tools/recordingNames.js +31 -0
- package/dist/tools/recordingNames.js.map +1 -1
- package/dist/tools/storySync.tools.d.ts.map +1 -1
- package/dist/tools/storySync.tools.js +2 -1
- package/dist/tools/storySync.tools.js.map +1 -1
- package/dist/tools/testcase.tools.d.ts +13 -1
- package/dist/tools/testcase.tools.d.ts.map +1 -1
- package/dist/tools/testcase.tools.js +80 -13
- package/dist/tools/testcase.tools.js.map +1 -1
- package/dist/tools/verdictMemory.d.ts +55 -0
- package/dist/tools/verdictMemory.d.ts.map +1 -0
- package/dist/tools/verdictMemory.js +117 -0
- package/dist/tools/verdictMemory.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +6 -2
|
@@ -553,6 +553,20 @@ const PLAN_RUN_DROP_KEYS = [
|
|
|
553
553
|
'_id', 'id', 'customerId', 'deleted', 'createdAt', 'createdBy', 'authkey', 'code', 'childExecutions', 'exception',
|
|
554
554
|
'agentStartTime', 'agentEndTime', 'executionDuration', 'executionFlow', 'updatedAt', 'updatedBy', 'childExecution',
|
|
555
555
|
];
|
|
556
|
+
/** The NEWEST version row of a test case: the highest `vMAJOR.MINOR`. Names that are not plain `vN.M` (a hand-named "Baseline")
|
|
557
|
+
* never win over one that is; with none parseable there is no "latest" to speak of. */
|
|
558
|
+
export function latestVersionRow(versions) {
|
|
559
|
+
let best;
|
|
560
|
+
for (const v of versions) {
|
|
561
|
+
const m = /^v(\d+)\.(\d+)$/i.exec((str(v, 'name', 'versionName') ?? '').trim());
|
|
562
|
+
if (!m)
|
|
563
|
+
continue;
|
|
564
|
+
const [major, minor] = [Number(m[1]), Number(m[2])];
|
|
565
|
+
if (!best || major > best.major || (major === best.major && minor > best.minor))
|
|
566
|
+
best = { major, minor, row: v };
|
|
567
|
+
}
|
|
568
|
+
return best?.row;
|
|
569
|
+
}
|
|
556
570
|
/** A test case's version for a plan entry. The entry validator requires a real `tcVersionId`, so a
|
|
557
571
|
* missing one is refused, never guessed (unlike suite entries, which tolerate a default). With
|
|
558
572
|
* `optional`, return what exists and let the caller decide. */
|
|
@@ -570,20 +584,44 @@ function testcaseVersion(raw, optional = false) {
|
|
|
570
584
|
/** Reject a planned end date that is before the planned start date. The SQA web form blocks this, but
|
|
571
585
|
* the backend happily saves it (US-2564 saved 2026-12-10 → 2026-12-01), so the MCP must enforce it on
|
|
572
586
|
* every backlog write that takes planned dates. Only checks when both are present in the same call. */
|
|
573
|
-
export function assertPlannedDates(start, end) {
|
|
574
|
-
const
|
|
575
|
-
const
|
|
576
|
-
|
|
587
|
+
export function assertPlannedDates(start, end, stored) {
|
|
588
|
+
const clean = (v) => (v == null ? '' : String(v).trim());
|
|
589
|
+
const wellFormed = (v) => /^\d{4}-\d{2}-\d{2}/.test(v);
|
|
590
|
+
// an impossible day (2026-02-30) is refused for every date that is SENT, even when the other one is not; a malformed one is
|
|
591
|
+
// left to the calling module's own wording unless both dates have to be compared
|
|
592
|
+
const real = (v, label) => {
|
|
593
|
+
if (wellFormed(v) && !isRealDay(v))
|
|
594
|
+
throw new Error(`${label} "${v.slice(0, 10)}" is not a real calendar day.`);
|
|
595
|
+
};
|
|
596
|
+
const s = clean(start);
|
|
597
|
+
const e = clean(end);
|
|
598
|
+
if (s)
|
|
599
|
+
real(s, 'Planned start date');
|
|
600
|
+
if (e)
|
|
601
|
+
real(e, 'Planned end date');
|
|
602
|
+
// A date that is not being changed still counts: when only one is sent, the other is the one already stored on the item.
|
|
603
|
+
const effStart = start === undefined && stored ? clean(stored.start) : s;
|
|
604
|
+
const effEnd = end === undefined && stored ? clean(stored.end) : e;
|
|
605
|
+
if (!effStart || !effEnd)
|
|
577
606
|
return;
|
|
578
|
-
const
|
|
579
|
-
if (
|
|
607
|
+
for (const v of [effStart, effEnd])
|
|
608
|
+
if (!wellFormed(v))
|
|
580
609
|
throw new Error(`Planned dates must look like 2026-12-10 (got "${v}").`);
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
610
|
+
const [ds, de] = [effStart.slice(0, 10), effEnd.slice(0, 10)];
|
|
611
|
+
if (de <= ds) {
|
|
612
|
+
const kept = start === undefined && stored ? ` — the item's start date is already ${ds}` : end === undefined && stored ? ` — the item's end date is already ${de}` : '';
|
|
613
|
+
throw new Error(`Planned end date (${de}) must be after the planned start date (${ds})${kept}.`);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
/** `2026-02-30` is not a day: `new Date()` quietly rolls it to 2 March, which is how an impossible date was saved as another one. */
|
|
617
|
+
export function isRealDay(v) {
|
|
618
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(v);
|
|
619
|
+
if (!m)
|
|
620
|
+
return false;
|
|
621
|
+
const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
622
|
+
if (mo < 1 || mo > 12 || d < 1)
|
|
623
|
+
return false;
|
|
624
|
+
return d <= new Date(Date.UTC(y, mo, 0)).getUTCDate();
|
|
587
625
|
}
|
|
588
626
|
/** Version for a plan/suite entry: the requested one (id or name), else the test case's current one.
|
|
589
627
|
* A requested version that does not exist FAILS — silently falling back to v1.0 turned a request for
|
|
@@ -594,6 +632,12 @@ export function pickTestcaseVersion(raw, wantId, wantName) {
|
|
|
594
632
|
if (!id && !name)
|
|
595
633
|
return testcaseVersion(raw);
|
|
596
634
|
const versions = Array.isArray(raw?.versions) ? raw.versions : [];
|
|
635
|
+
if (!id && name.toLowerCase() === 'latest') {
|
|
636
|
+
const row = latestVersionRow(versions);
|
|
637
|
+
if (!row)
|
|
638
|
+
throw new Error(`${str(raw, 'code') ?? `TC-${raw?.id}`} has no vMAJOR.MINOR version to pick the latest from. Name the version instead (version:"v2.0").`);
|
|
639
|
+
return { versionId: str(row, 'id', '_id', 'versionId') ?? '', versionName: str(row, 'name', 'versionName') ?? '' };
|
|
640
|
+
}
|
|
597
641
|
const hit = versions.find((v) => {
|
|
598
642
|
const vid = str(v, 'id', '_id', 'versionId') ?? '';
|
|
599
643
|
const vname = str(v, 'name', 'versionName') ?? '';
|
|
@@ -883,6 +927,9 @@ export class SimplifyQaAdapter {
|
|
|
883
927
|
/** Gather every identifier this process can claim: bare hostname, non-loopback MAC addresses,
|
|
884
928
|
* non-loopback IPs. Cached per-adapter — network interfaces do not change mid-session. */
|
|
885
929
|
this.localIdsCache = null;
|
|
930
|
+
/** DESKTOP heal verify: how often the run is read, and how long it may wait for the agent to pick it up. */
|
|
931
|
+
this.desktopHealPollMs = 5000;
|
|
932
|
+
this.desktopHealPickupMs = 5 * 60000;
|
|
886
933
|
if (!cfg.baseUrl) {
|
|
887
934
|
throw new Error('SimplifyQaAdapter requires a baseUrl — set QA_BASE_URL or use a JWT with a `url` claim.');
|
|
888
935
|
}
|
|
@@ -2120,6 +2167,8 @@ export class SimplifyQaAdapter {
|
|
|
2120
2167
|
continue;
|
|
2121
2168
|
if (!/^\d{4}-\d{2}-\d{2}/.test(want) || Number.isNaN(new Date(want).getTime()))
|
|
2122
2169
|
throw new Error(`${key} must be a date like 2026-11-17 (got "${want}").`);
|
|
2170
|
+
if (!isRealDay(want))
|
|
2171
|
+
throw new Error(`${key} "${want.slice(0, 10)}" is not a real calendar day.`);
|
|
2123
2172
|
if (day(doc[key]) !== day(want))
|
|
2124
2173
|
change(field, key, want, day(doc[key]), day(want));
|
|
2125
2174
|
}
|
|
@@ -2282,6 +2331,8 @@ export class SimplifyQaAdapter {
|
|
|
2282
2331
|
for (const [k, v] of [['plannedStartDate', start], ['plannedEndDate', end]]) {
|
|
2283
2332
|
if (!/^\d{4}-\d{2}-\d{2}/.test(v) || Number.isNaN(new Date(v).getTime()))
|
|
2284
2333
|
throw new Error(`${k} must be a date like 2026-11-17 (got "${v}").`);
|
|
2334
|
+
if (!isRealDay(v))
|
|
2335
|
+
throw new Error(`${k} "${v.slice(0, 10)}" is not a real calendar day.`);
|
|
2285
2336
|
}
|
|
2286
2337
|
if (new Date(end) < new Date(start))
|
|
2287
2338
|
throw new Error(`plannedEndDate (${dayOf(end)}) must be on or after plannedStartDate (${dayOf(start)}).`);
|
|
@@ -2498,6 +2549,8 @@ export class SimplifyQaAdapter {
|
|
|
2498
2549
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(day) || Number.isNaN(new Date(`${day}T00:00:00Z`).getTime())) {
|
|
2499
2550
|
throw new Error(`${label} must be a date like 2026-11-20 (got "${v}").`);
|
|
2500
2551
|
}
|
|
2552
|
+
if (!isRealDay(day))
|
|
2553
|
+
throw new Error(`${label} "${day}" is not a real calendar day.`);
|
|
2501
2554
|
return `${day}T00:00:00.000Z`;
|
|
2502
2555
|
}
|
|
2503
2556
|
/** The form's Feature field: a feature of THIS project, by id, business key (FT-248) or exact name. */
|
|
@@ -3328,9 +3381,29 @@ export class SimplifyQaAdapter {
|
|
|
3328
3381
|
const raw = await this.http.postJson('/pm/userstory', body);
|
|
3329
3382
|
return toSavedRef(raw, true);
|
|
3330
3383
|
}
|
|
3384
|
+
/** Date check for an EDIT of a story / epic / feature. Sending only one date used to skip the check (the other one is not in
|
|
3385
|
+
* the patch), so a story could be left ending before it started. When exactly one is sent, the stored other one is read and
|
|
3386
|
+
* compared; a stored item that cannot be read refuses the edit instead of letting it through unchecked. */
|
|
3387
|
+
async assertEditedDates(entity, numericId, patch) {
|
|
3388
|
+
assertPlannedDates(patch.plannedStartDate, patch.plannedEndDate);
|
|
3389
|
+
const oneSent = (patch.plannedStartDate === undefined) !== (patch.plannedEndDate === undefined);
|
|
3390
|
+
if (!oneSent)
|
|
3391
|
+
return;
|
|
3392
|
+
let doc;
|
|
3393
|
+
try {
|
|
3394
|
+
const raw = await this.http.getJson(`${BACKLOG_ATTACHMENT_SPECS[entity].path}/${numericId}`);
|
|
3395
|
+
doc = Array.isArray(raw) ? raw[0] : (raw?.data && typeof raw.data === 'object' && !Array.isArray(raw.data) ? raw.data : raw);
|
|
3396
|
+
}
|
|
3397
|
+
catch (e) {
|
|
3398
|
+
throw new Error(`Could not read the ${entity === 'userstory' ? 'story' : entity}'s current dates to check the new one against them (${e instanceof Error ? e.message : String(e)}), so nothing was changed.`);
|
|
3399
|
+
}
|
|
3400
|
+
if (!doc || typeof doc !== 'object')
|
|
3401
|
+
throw new Error(`The ${entity === 'userstory' ? 'story' : entity} was not found, so its dates could not be checked.`);
|
|
3402
|
+
assertPlannedDates(patch.plannedStartDate, patch.plannedEndDate, { start: doc.plannedStartDate, end: doc.plannedEndDate });
|
|
3403
|
+
}
|
|
3331
3404
|
async updateStory(id, patch) {
|
|
3332
3405
|
const resolvedId = await this.resolveStoryNumericId(id);
|
|
3333
|
-
|
|
3406
|
+
await this.assertEditedDates('userstory', resolvedId, patch);
|
|
3334
3407
|
// The backend's update controller runs its privilege check with `req.body.projectId`; a partial
|
|
3335
3408
|
// patch that omits it makes that call throw (HTTP 500), which is why a story edit has to carry the
|
|
3336
3409
|
// project. Default to the connected project — the story being edited belongs to it.
|
|
@@ -3625,8 +3698,8 @@ export class SimplifyQaAdapter {
|
|
|
3625
3698
|
return toSavedRef(raw, true);
|
|
3626
3699
|
}
|
|
3627
3700
|
async updateEpic(id, patch) {
|
|
3628
|
-
assertPlannedDates(patch.plannedStartDate, patch.plannedEndDate);
|
|
3629
3701
|
const resolvedId = await this.resolveEpicNumericId(id);
|
|
3702
|
+
await this.assertEditedDates('epic', resolvedId, patch);
|
|
3630
3703
|
const raw = await this.http.putJson(`/pm/epic/${resolvedId}`, patch);
|
|
3631
3704
|
return toSavedRef(raw ?? { id: resolvedId }, false);
|
|
3632
3705
|
}
|
|
@@ -3697,8 +3770,8 @@ export class SimplifyQaAdapter {
|
|
|
3697
3770
|
return toSavedRef(raw, true);
|
|
3698
3771
|
}
|
|
3699
3772
|
async updateFeature(id, patch) {
|
|
3700
|
-
assertPlannedDates(patch.plannedStartDate, patch.plannedEndDate);
|
|
3701
3773
|
const resolvedId = await this.resolveFeatureNumericId(id);
|
|
3774
|
+
await this.assertEditedDates('feature', resolvedId, patch);
|
|
3702
3775
|
const raw = await this.http.putJson(`/pm/feature/${resolvedId}`, patch);
|
|
3703
3776
|
return toSavedRef(raw ?? { id: resolvedId }, false);
|
|
3704
3777
|
}
|
|
@@ -3720,7 +3793,11 @@ export class SimplifyQaAdapter {
|
|
|
3720
3793
|
* has no limit/offset of its own and always wants the WHOLE project tree; `searchBody`'s default
|
|
3721
3794
|
* page size (100) previously truncated any project with more modules than that silently. */
|
|
3722
3795
|
async listModules() {
|
|
3723
|
-
|
|
3796
|
+
return this.modulesOfProject(this.requireProjectId());
|
|
3797
|
+
}
|
|
3798
|
+
/** Every module of ANY project the caller can read — `listModules` for the active project, and the
|
|
3799
|
+
* destination lookup of a cross-project copy. */
|
|
3800
|
+
async modulesOfProject(projectId) {
|
|
3724
3801
|
const PAGE = 100;
|
|
3725
3802
|
const SAFETY_CAP = 5000;
|
|
3726
3803
|
const rows = [];
|
|
@@ -4194,6 +4271,12 @@ export class SimplifyQaAdapter {
|
|
|
4194
4271
|
delete body[k];
|
|
4195
4272
|
body['updateVersion'] = typeof row.updateVersion === 'number' ? row.updateVersion : 0;
|
|
4196
4273
|
const changes = [];
|
|
4274
|
+
// an impossible day is refused for every date that is sent (Date quietly rolls 2026-02-30 to 2 March)
|
|
4275
|
+
for (const k of ['plannedStartDate', 'plannedEndDate', 'actualStartDate', 'actualEndDate']) {
|
|
4276
|
+
const v = patch[k];
|
|
4277
|
+
if (typeof v === 'string' && v.trim() && /^\d{4}-\d{2}-\d{2}/.test(v) && !isRealDay(v))
|
|
4278
|
+
throw new Error(`${k} "${v.slice(0, 10)}" is not a real calendar day.`);
|
|
4279
|
+
}
|
|
4197
4280
|
const set = (k, v) => { if (v !== undefined && JSON.stringify(body[k]) !== JSON.stringify(v)) {
|
|
4198
4281
|
body[k] = v;
|
|
4199
4282
|
changes.push(k);
|
|
@@ -4215,6 +4298,9 @@ export class SimplifyQaAdapter {
|
|
|
4215
4298
|
if (body['plannedStartDate'] && body['plannedEndDate'] && new Date(String(body['plannedEndDate'])) < new Date(String(body['plannedStartDate']))) {
|
|
4216
4299
|
throw new Error('plannedEndDate must be on or after plannedStartDate.');
|
|
4217
4300
|
}
|
|
4301
|
+
if (body['actualStartDate'] && body['actualEndDate'] && new Date(String(body['actualEndDate'])) < new Date(String(body['actualStartDate']))) {
|
|
4302
|
+
throw new Error(`actualEndDate (${String(body['actualEndDate']).slice(0, 10)}) must be on or after actualStartDate (${String(body['actualStartDate']).slice(0, 10)}).`);
|
|
4303
|
+
}
|
|
4218
4304
|
const stateBefore = String(row.state ?? '');
|
|
4219
4305
|
const id = String(row.id);
|
|
4220
4306
|
const code = String(row.code ?? `#${id}`);
|
|
@@ -4322,6 +4408,8 @@ export class SimplifyQaAdapter {
|
|
|
4322
4408
|
throw new Error(`${kind}_create needs ${k} (YYYY-MM-DD).`);
|
|
4323
4409
|
if (!/^\d{4}-\d{2}-\d{2}/.test(v) || Number.isNaN(new Date(v).getTime()))
|
|
4324
4410
|
throw new Error(`${k} must be a date like 2026-11-16 (got "${v}").`);
|
|
4411
|
+
if (!isRealDay(v))
|
|
4412
|
+
throw new Error(`${k} "${v.slice(0, 10)}" is not a real calendar day.`);
|
|
4325
4413
|
}
|
|
4326
4414
|
if (new Date(input.plannedEndDate) < new Date(input.plannedStartDate))
|
|
4327
4415
|
throw new Error('plannedEndDate must be on or after plannedStartDate.');
|
|
@@ -5970,6 +6058,247 @@ export class SimplifyQaAdapter {
|
|
|
5970
6058
|
productUrl: this.productUrlFor({ kind: 'testcase', id: newId }),
|
|
5971
6059
|
};
|
|
5972
6060
|
}
|
|
6061
|
+
/** Copy test cases and/or functions from the active project into ANOTHER project — the UI's "Copy to project"
|
|
6062
|
+
* popup: `POST /tm/tcfnCopy/copytc` (one request per kind: `type` is TC or FN). The backend copies the chosen
|
|
6063
|
+
* versions with their steps, objects, parameters, nested functions and test data (for the chosen environments),
|
|
6064
|
+
* renames a duplicate name to `<name>_copyN`, and answers BEFORE it has finished — so after the call this looks
|
|
6065
|
+
* for the copies in the destination (rows carrying `projectLevelcopiedFrom`) and reports what it found. */
|
|
6066
|
+
async copyTestCasesToProject(input) {
|
|
6067
|
+
const sourceProjectId = this.requireProjectId();
|
|
6068
|
+
const uniq = (xs) => [...new Set((xs ?? []).map((t) => String(t).trim()).filter(Boolean))];
|
|
6069
|
+
const tcIds = uniq(input.tcIds);
|
|
6070
|
+
const fnIds = uniq(input.functionIds);
|
|
6071
|
+
if (!tcIds.length && !fnIds.length)
|
|
6072
|
+
throw new Error('tcIds or functionIds is required — what to copy.');
|
|
6073
|
+
tcIds.forEach((t) => assertBusinessKeyKind(t, 'TC'));
|
|
6074
|
+
fnIds.forEach((t) => assertBusinessKeyKind(t, 'FN'));
|
|
6075
|
+
// Same rule as tc_clone's tdCopy: the user decides about test data, the tool never assumes it.
|
|
6076
|
+
if (input.confirm && input.copyTestData === undefined) {
|
|
6077
|
+
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.');
|
|
6078
|
+
}
|
|
6079
|
+
if (input.copyTestData === false && (input.environments ?? []).length) {
|
|
6080
|
+
throw new Error('environments and copyTestData:false contradict each other — with no test data there is no environment to choose.');
|
|
6081
|
+
}
|
|
6082
|
+
// Destination project: id, code or exact name, among the projects this user can see.
|
|
6083
|
+
const wantProject = String(input.destinationProject ?? '').trim();
|
|
6084
|
+
if (!wantProject)
|
|
6085
|
+
throw new Error('destinationProject is required (project id, code or name).');
|
|
6086
|
+
const projects = await this.listProjects();
|
|
6087
|
+
const pw = wantProject.toLowerCase();
|
|
6088
|
+
const pHits = projects.filter((p) => p.id === wantProject || (p.code ?? '').toLowerCase() === pw || p.name.trim().toLowerCase() === pw);
|
|
6089
|
+
if (pHits.length !== 1) {
|
|
6090
|
+
throw new Error(pHits.length
|
|
6091
|
+
? `Project "${wantProject}" matches ${pHits.length} projects (${pHits.map((p) => `${p.name} [id ${p.id}]`).join(', ')}). Pass the project id.`
|
|
6092
|
+
: `Project "${wantProject}" was not found among your projects (${projects.map((p) => `${p.name} [id ${p.id}]`).join(', ') || 'none'}).`);
|
|
6093
|
+
}
|
|
6094
|
+
const dest = pHits[0];
|
|
6095
|
+
const destProjectId = Number.parseInt(dest.id, 10);
|
|
6096
|
+
if (destProjectId === sourceProjectId)
|
|
6097
|
+
throw new Error('The destination is the active project — use tc_clone / fn_clone to copy within a project.');
|
|
6098
|
+
// Only into a project the caller may copy into — the privileges the backend itself checks on the destination
|
|
6099
|
+
// (one per kind). Checked before anything of that project is read, and on a preview too.
|
|
6100
|
+
const access = await this.getProjectPrivileges(dest.id);
|
|
6101
|
+
if (!access.tokenValid)
|
|
6102
|
+
throw new Error('Your SimplifyQA token is not valid, so access to the destination project cannot be checked. Reconnect and try again.');
|
|
6103
|
+
if (!access.hasRole)
|
|
6104
|
+
throw new Error(`You have no access to project "${dest.name}" — you can only copy into projects you are a member of.`);
|
|
6105
|
+
const needs = [];
|
|
6106
|
+
if (tcIds.length)
|
|
6107
|
+
needs.push(['copy_testcase_across_project', 'test cases']);
|
|
6108
|
+
if (fnIds.length)
|
|
6109
|
+
needs.push(['copy_function_across_projects', 'functions']);
|
|
6110
|
+
for (const [privilege, what] of needs) {
|
|
6111
|
+
if (!access.privileges.includes(privilege)) {
|
|
6112
|
+
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.`);
|
|
6113
|
+
}
|
|
6114
|
+
}
|
|
6115
|
+
// Destination module.
|
|
6116
|
+
const modules = await this.modulesOfProject(destProjectId);
|
|
6117
|
+
const wantModule = String(input.destinationModule ?? '').trim();
|
|
6118
|
+
let module;
|
|
6119
|
+
if (wantModule) {
|
|
6120
|
+
const mw = wantModule.toLowerCase();
|
|
6121
|
+
const mHits = modules.filter((m) => m.id === wantModule || m.name.trim().toLowerCase() === mw);
|
|
6122
|
+
if (mHits.length !== 1) {
|
|
6123
|
+
throw new Error(mHits.length
|
|
6124
|
+
? `Module "${wantModule}" matches ${mHits.length} modules in ${dest.name} (${mHits.map((m) => `${m.name} [id ${m.id}]`).join(', ')}). Pass the module id.`
|
|
6125
|
+
: `Module "${wantModule}" was not found in ${dest.name}. Modules: ${modules.map((m) => `${m.name} [id ${m.id}]`).join(', ') || 'none'}.`);
|
|
6126
|
+
}
|
|
6127
|
+
module = mHits[0];
|
|
6128
|
+
}
|
|
6129
|
+
else {
|
|
6130
|
+
module = modules.find((m) => m.isRoot) ?? modules.find((m) => m.name.trim().toLowerCase() === 'default module');
|
|
6131
|
+
if (!module)
|
|
6132
|
+
throw new Error(`${dest.name} has no root module to default to — pass destinationModule.`);
|
|
6133
|
+
}
|
|
6134
|
+
const destModuleId = Number.parseInt(module.id, 10);
|
|
6135
|
+
// Sources and their versions. `versionsBy` (per item) beats `versions` (for all).
|
|
6136
|
+
const clean = (xs) => (xs ?? []).map((v) => String(v).trim()).filter(Boolean);
|
|
6137
|
+
const globalVersions = clean(input.versions);
|
|
6138
|
+
const perItem = Object.entries(input.versionsBy ?? {}).map(([k, v]) => ({ key: k.trim().toUpperCase(), versions: clean(v), used: false }));
|
|
6139
|
+
const items = [];
|
|
6140
|
+
const entries = [];
|
|
6141
|
+
const lists = { TC: [], FN: [] };
|
|
6142
|
+
const moduleOf = { TC: 0, FN: 0 };
|
|
6143
|
+
const norm = (n) => n.trim().toLowerCase().replace(/^v/, '').replace(/\.0+$/, '');
|
|
6144
|
+
for (const kind of ['TC', 'FN']) {
|
|
6145
|
+
for (const ref of kind === 'TC' ? tcIds : fnIds) {
|
|
6146
|
+
const id = Number.parseInt(numericId(ref), 10);
|
|
6147
|
+
const doc = kind === 'TC'
|
|
6148
|
+
? await this.fetchRawTestcase(ref)
|
|
6149
|
+
: await this.fetchRawFunctionDoc(ref, sourceProjectId);
|
|
6150
|
+
if (!doc || Object.keys(doc).length === 0 || doc.deleted === true)
|
|
6151
|
+
throw new Error(`${kind === 'TC' ? 'test case' : 'function'} ${ref} not found`);
|
|
6152
|
+
// Only the active project's own items: a lookup by id must not read another project's.
|
|
6153
|
+
const owner = Number.parseInt(str(doc, 'projectId') ?? '', 10);
|
|
6154
|
+
if (Number.isFinite(owner) && owner !== sourceProjectId) {
|
|
6155
|
+
throw new Error(`${ref} belongs to project ${owner}, not the active project (${sourceProjectId}). Switch to its project first.`);
|
|
6156
|
+
}
|
|
6157
|
+
const code = str(doc, 'code') ?? ref;
|
|
6158
|
+
const versionRows = kind === 'TC' ? (Array.isArray(doc.versions) ? doc.versions : []) : await this.fetchFunctionVersionRows(String(id));
|
|
6159
|
+
const names = versionRows.map((v) => str(v, 'name')).filter((n) => !!n);
|
|
6160
|
+
const own = perItem.find((p) => p.key === ref.toUpperCase() || p.key === code.toUpperCase() || p.key === String(id));
|
|
6161
|
+
if (own)
|
|
6162
|
+
own.used = true;
|
|
6163
|
+
const asked = own ? own.versions : globalVersions;
|
|
6164
|
+
// Same rule as tc_clone: several versions and none chosen → ask, never default to the latest or v1.
|
|
6165
|
+
if (!asked.length && names.length > 1) {
|
|
6166
|
+
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.`);
|
|
6167
|
+
}
|
|
6168
|
+
// Version names as the user says them: "v2", "2" and "v2.0" are the same version (as in tc_clone).
|
|
6169
|
+
const chosen = [];
|
|
6170
|
+
if (!asked.some((v) => v.toLowerCase() === 'all')) {
|
|
6171
|
+
for (const v of asked) {
|
|
6172
|
+
const hit = names.find((n) => n === v) ?? names.find((n) => n.trim().toLowerCase() === v.toLowerCase()) ?? names.find((n) => norm(n) === norm(v));
|
|
6173
|
+
if (!hit)
|
|
6174
|
+
throw new Error(`${code} has no version "${v}". Versions: ${names.join(', ') || 'none'}.`);
|
|
6175
|
+
if (!chosen.includes(hit))
|
|
6176
|
+
chosen.push(hit);
|
|
6177
|
+
}
|
|
6178
|
+
}
|
|
6179
|
+
if (!moduleOf[kind])
|
|
6180
|
+
moduleOf[kind] = Number.parseInt(str(doc, 'moduleId') ?? '', 10) || 0;
|
|
6181
|
+
const item = { kind, tcId: code, name: str(doc, 'name') ?? '', versions: chosen.length ? chosen : names };
|
|
6182
|
+
items.push(item);
|
|
6183
|
+
entries.push({ kind, id, item });
|
|
6184
|
+
lists[kind].push({ id, ...(chosen.length ? { selversions: chosen } : {}) });
|
|
6185
|
+
}
|
|
6186
|
+
}
|
|
6187
|
+
const stray = perItem.find((p) => !p.used);
|
|
6188
|
+
if (stray)
|
|
6189
|
+
throw new Error(`versionsBy names "${stray.key}", which is not among the items being copied.`);
|
|
6190
|
+
// Environments: the backend reads the source's AND the destination's by name, so a name only one has breaks the copy.
|
|
6191
|
+
const srcEnvs = (await this.environmentsOfProject(sourceProjectId)).map((e) => e.name);
|
|
6192
|
+
const destEnvs = (await this.environmentsOfProject(destProjectId)).map((e) => e.name);
|
|
6193
|
+
const asked = (input.environments ?? []).map((e) => String(e).trim()).filter(Boolean);
|
|
6194
|
+
const bad = asked.filter((e) => !srcEnvs.includes(e) || !destEnvs.includes(e));
|
|
6195
|
+
if (bad.length)
|
|
6196
|
+
throw new Error(`Environment ${bad.map((e) => `"${e}"`).join(', ')} is not in both projects. In both: ${srcEnvs.filter((e) => destEnvs.includes(e)).join(', ') || 'none'}.`);
|
|
6197
|
+
// copyTestData:false → no environment is selected: the backend then copies only the empty structure.
|
|
6198
|
+
const environments = input.copyTestData === false ? [] : asked.length ? asked : srcEnvs.filter((e) => destEnvs.includes(e));
|
|
6199
|
+
// The backend walks the DESTINATION's environments: a source environment with no same-named one there is never
|
|
6200
|
+
// visited (its data is dropped), and a destination environment that is not selected gets rows with EMPTY cells.
|
|
6201
|
+
const missingEnvironments = input.copyTestData === false ? [] : srcEnvs.filter((e) => !destEnvs.includes(e));
|
|
6202
|
+
const emptyEnvironments = destEnvs.filter((e) => !environments.includes(e));
|
|
6203
|
+
// The backend renames an item whose name already exists in the destination PROJECT to `<name>_copyN`.
|
|
6204
|
+
// Best effort: if the names cannot be read the copy is not blocked, it just cannot warn.
|
|
6205
|
+
for (const kind of ['TC', 'FN']) {
|
|
6206
|
+
if (!lists[kind].length)
|
|
6207
|
+
continue;
|
|
6208
|
+
const taken = await this.namesOfProject(kind, destProjectId).catch(() => undefined);
|
|
6209
|
+
if (!taken)
|
|
6210
|
+
continue;
|
|
6211
|
+
for (const e of entries.filter((x) => x.kind === kind)) {
|
|
6212
|
+
if (!taken.has(e.item.name))
|
|
6213
|
+
continue;
|
|
6214
|
+
let n = 1;
|
|
6215
|
+
while (taken.has(`${e.item.name}_copy${n}`))
|
|
6216
|
+
n++;
|
|
6217
|
+
e.item.renamedTo = `${e.item.name}_copy${n}`;
|
|
6218
|
+
}
|
|
6219
|
+
}
|
|
6220
|
+
const result = {
|
|
6221
|
+
preview: !input.confirm,
|
|
6222
|
+
destination: { projectId: dest.id, projectName: dest.name, moduleId: module.id, moduleName: module.name },
|
|
6223
|
+
items, environments, missingEnvironments, emptyEnvironments, copied: [], pending: [],
|
|
6224
|
+
...(input.copyTestData !== undefined ? { copyTestData: input.copyTestData } : {}),
|
|
6225
|
+
};
|
|
6226
|
+
if (!input.confirm)
|
|
6227
|
+
return result;
|
|
6228
|
+
// Snapshot the destination module first, so the copies are told apart from what was already there.
|
|
6229
|
+
const kinds = ['FN', 'TC'].filter((k) => lists[k].length); // functions first, as a test case may call them
|
|
6230
|
+
const before = new Map();
|
|
6231
|
+
for (const k of kinds)
|
|
6232
|
+
before.set(k, new Set((await this.copiesInModule(k, destProjectId, destModuleId)).map((r) => r.id)));
|
|
6233
|
+
for (const k of kinds) {
|
|
6234
|
+
await this.http.postJson('/tm/tcfnCopy/copytc', {
|
|
6235
|
+
type: k, sourceProjId: sourceProjectId, sourceModuleId: moduleOf[k], destinationProjId: destProjectId, destinationModuleId: destModuleId,
|
|
6236
|
+
selectedEnv: environments, tcfnList: lists[k],
|
|
6237
|
+
});
|
|
6238
|
+
}
|
|
6239
|
+
const wait = input.pollMs ?? 2000;
|
|
6240
|
+
const found = new Map();
|
|
6241
|
+
for (let attempt = 0; attempt < 8 && found.size < entries.length; attempt++) {
|
|
6242
|
+
if (attempt && wait > 0)
|
|
6243
|
+
await new Promise((r) => setTimeout(r, wait));
|
|
6244
|
+
for (const k of kinds) {
|
|
6245
|
+
const wanted = new Set(entries.filter((e) => e.kind === k).map((e) => e.id));
|
|
6246
|
+
for (const r of await this.copiesInModule(k, destProjectId, destModuleId)) {
|
|
6247
|
+
const key = `${k}:${r.from}`;
|
|
6248
|
+
if (before.get(k).has(r.id) || !wanted.has(r.from) || found.has(key))
|
|
6249
|
+
continue;
|
|
6250
|
+
found.set(key, { kind: k, fromTcId: String(r.from), id: r.id, ...(r.code ? { code: r.code } : {}), name: r.name });
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
}
|
|
6254
|
+
result.copied = [...found.values()];
|
|
6255
|
+
result.pending = entries.filter((e) => !found.has(`${e.kind}:${e.id}`)).map((e) => e.item.tcId);
|
|
6256
|
+
return result;
|
|
6257
|
+
}
|
|
6258
|
+
/** A function's own document, from the active project (the project id is part of the path, so another project's
|
|
6259
|
+
* function reads as not found). */
|
|
6260
|
+
async fetchRawFunctionDoc(ref, projectId) {
|
|
6261
|
+
const raw = await this.http.getJson(`/tm/function/${numericId(ref)}/${projectId}`);
|
|
6262
|
+
let doc = raw?.data ?? raw;
|
|
6263
|
+
if (Array.isArray(doc))
|
|
6264
|
+
doc = doc.length > 0 ? doc[0] : {};
|
|
6265
|
+
return doc && typeof doc === 'object' ? doc : {};
|
|
6266
|
+
}
|
|
6267
|
+
/** Names of the (non-deleted) test cases or functions of a project — what the backend's copy checks a new name against. */
|
|
6268
|
+
async namesOfProject(kind, projectId) {
|
|
6269
|
+
const PAGE = 500;
|
|
6270
|
+
const CAP = 20000;
|
|
6271
|
+
const names = new Set();
|
|
6272
|
+
const path = kind === 'TC' ? '/tm/testcase/search' : '/tm/function/search';
|
|
6273
|
+
for (let offset = 0; offset < CAP; offset += PAGE) {
|
|
6274
|
+
const body = this.searchBody([{ column: 'projectId', value: projectId }], { startIndex: offset, limit: PAGE, rawOffset: true, selectFields: ['name'] });
|
|
6275
|
+
const rows = pickArray(await this.http.postJson(path, body), 'data', 'content', 'testCases', 'functions');
|
|
6276
|
+
for (const r of rows) {
|
|
6277
|
+
const n = str(r, 'name');
|
|
6278
|
+
if (n)
|
|
6279
|
+
names.add(n);
|
|
6280
|
+
}
|
|
6281
|
+
if (rows.length < PAGE)
|
|
6282
|
+
break;
|
|
6283
|
+
}
|
|
6284
|
+
return names;
|
|
6285
|
+
}
|
|
6286
|
+
/** The test cases / functions of a destination module that came from another project's (`from` = the source id). */
|
|
6287
|
+
async copiesInModule(kind, projectId, moduleId) {
|
|
6288
|
+
const body = this.searchBody([{ column: 'projectId', value: projectId }, { column: 'moduleId', value: moduleId }], { limit: 1000, rawOffset: true, selectFields: ['id', 'code', 'name', 'projectLevelcopiedFrom'] });
|
|
6289
|
+
const path = kind === 'TC' ? '/tm/testcase/search' : '/tm/function/search';
|
|
6290
|
+
const rows = pickArray(await this.http.postJson(path, body), 'data', 'content', 'testCases', 'functions');
|
|
6291
|
+
const out = [];
|
|
6292
|
+
for (const r of rows) {
|
|
6293
|
+
const from = Number.parseInt(String(r?.projectLevelcopiedFrom?.id ?? ''), 10);
|
|
6294
|
+
const id = str(r, 'id', '_id');
|
|
6295
|
+
if (!Number.isFinite(from) || !id)
|
|
6296
|
+
continue;
|
|
6297
|
+
const code = str(r, 'code');
|
|
6298
|
+
out.push({ id, ...(code ? { code } : {}), name: str(r, 'name') ?? '', from });
|
|
6299
|
+
}
|
|
6300
|
+
return out;
|
|
6301
|
+
}
|
|
5973
6302
|
// ---------------------------------------------------------------------- Functions (reusable)
|
|
5974
6303
|
// Same tcfnObj collection as testcases — type='FN' instead of 'TC'. Search / getById / delete /
|
|
5975
6304
|
// steps all mirror the testcase endpoints one-to-one.
|
|
@@ -7673,16 +8002,17 @@ export class SimplifyQaAdapter {
|
|
|
7673
8002
|
throw new Error(`assignTo "${input.assignTo}" is not a user id.`);
|
|
7674
8003
|
}
|
|
7675
8004
|
}
|
|
8005
|
+
// `defaulted`: no version was asked for, so the test case's current one was taken (the caller is told if a newer one exists)
|
|
7676
8006
|
const candidates = [];
|
|
7677
8007
|
for (const tcId of input.tcIds ?? []) {
|
|
7678
8008
|
const raw = await this.readOwnTestcase(tcId);
|
|
7679
8009
|
const v = pickTestcaseVersion(raw, input.versionId, input.version);
|
|
7680
|
-
candidates.push({ raw, ...v, platform: entryPlatform(raw.executionPlatform), source: { sourceType: 'testcase', sourceId: 0 } });
|
|
8010
|
+
candidates.push({ raw, ...v, platform: entryPlatform(raw.executionPlatform), source: { sourceType: 'testcase', sourceId: 0 }, defaulted: !input.versionId && !input.version });
|
|
7681
8011
|
}
|
|
7682
8012
|
for (const spec of input.testCases ?? []) {
|
|
7683
8013
|
const raw = await this.readOwnTestcase(spec.tcId);
|
|
7684
8014
|
const v = pickTestcaseVersion(raw, spec.versionId, spec.version);
|
|
7685
|
-
candidates.push({ raw, ...v, platform: entryPlatform(raw.executionPlatform), source: { sourceType: 'testcase', sourceId: 0 } });
|
|
8015
|
+
candidates.push({ raw, ...v, platform: entryPlatform(raw.executionPlatform), source: { sourceType: 'testcase', sourceId: 0 }, defaulted: !spec.versionId && !spec.version });
|
|
7686
8016
|
}
|
|
7687
8017
|
for (const suiteId of input.suiteIds ?? []) {
|
|
7688
8018
|
const suite = await this.readOwnSuite(suiteId);
|
|
@@ -7714,6 +8044,8 @@ export class SimplifyQaAdapter {
|
|
|
7714
8044
|
const added = [];
|
|
7715
8045
|
const skipped = [];
|
|
7716
8046
|
const rows = [];
|
|
8047
|
+
const addedVersions = [];
|
|
8048
|
+
const notes = [];
|
|
7717
8049
|
for (const c of candidates) {
|
|
7718
8050
|
const code = str(c.raw, 'code') ?? `TC-${c.raw.id}`;
|
|
7719
8051
|
const key = `${Number(c.raw.id)}|${String(c.versionId ?? '')}|${assignee}`;
|
|
@@ -7722,7 +8054,15 @@ export class SimplifyQaAdapter {
|
|
|
7722
8054
|
continue;
|
|
7723
8055
|
}
|
|
7724
8056
|
if (seenExact.has(key)) {
|
|
7725
|
-
|
|
8057
|
+
// Tell the caller HOW to add the other version — a plain "already in the plan" reads like the plan can only ever hold one.
|
|
8058
|
+
const tcNum = Number(c.raw.id);
|
|
8059
|
+
const others = (Array.isArray(c.raw.versions) ? c.raw.versions : [])
|
|
8060
|
+
.map((v) => ({ id: str(v, 'id', '_id'), name: str(v, 'name', 'versionName') }))
|
|
8061
|
+
.filter((v) => v.id && v.name && v.id !== c.versionId && !seenExact.has(`${tcNum}|${v.id}|${assignee}`));
|
|
8062
|
+
const hint = others.length
|
|
8063
|
+
? ` — other version${others.length > 1 ? 's' : ''} you can add: ${others.map((v) => v.name).join(', ')}; pass version:"${others[0].name}" (or testCases:[{ tcId, version }])`
|
|
8064
|
+
: '';
|
|
8065
|
+
skipped.push({ code, reason: `already in the plan (${c.versionName || c.versionId})${hint}` });
|
|
7726
8066
|
continue;
|
|
7727
8067
|
}
|
|
7728
8068
|
seenExact.add(key);
|
|
@@ -7739,10 +8079,19 @@ export class SimplifyQaAdapter {
|
|
|
7739
8079
|
...(input.assignDate ? { expAssignedDate: input.assignDate } : {}),
|
|
7740
8080
|
});
|
|
7741
8081
|
added.push(code);
|
|
8082
|
+
addedVersions.push(`${code} (${c.versionName || c.versionId})`);
|
|
8083
|
+
// No version was asked for and a NEWER one exists: the plan got the older one — say so instead of staying silent.
|
|
8084
|
+
if (c.defaulted) {
|
|
8085
|
+
const latest = latestVersionRow(Array.isArray(c.raw.versions) ? c.raw.versions : []);
|
|
8086
|
+
const latestId = latest ? str(latest, 'id', '_id', 'versionId') : undefined;
|
|
8087
|
+
if (latest && latestId && latestId !== c.versionId) {
|
|
8088
|
+
notes.push(`${code}: added ${c.versionName || c.versionId}, but ${str(latest, 'name', 'versionName')} is newer — pass version:"latest" (or version:"${str(latest, 'name', 'versionName')}") to add that one.`);
|
|
8089
|
+
}
|
|
8090
|
+
}
|
|
7742
8091
|
}
|
|
7743
8092
|
if (rows.length)
|
|
7744
8093
|
await this.http.postJson('/tm/execplantestcases', rows);
|
|
7745
|
-
return { added, skipped };
|
|
8094
|
+
return { added, skipped, addedVersions, notes };
|
|
7746
8095
|
}
|
|
7747
8096
|
/** The plan's entries for these test cases — what removing them would delete. No write. */
|
|
7748
8097
|
async planEntriesRemovePreview(planId, tcIds) {
|
|
@@ -8917,11 +9266,15 @@ export class SimplifyQaAdapter {
|
|
|
8917
9266
|
const wantId = (requested?.versionId ?? '').trim();
|
|
8918
9267
|
const wantName = (requested?.version ?? '').trim();
|
|
8919
9268
|
if (wantId || wantName) {
|
|
8920
|
-
const
|
|
9269
|
+
const wantsLatest = !wantId && wantName.toLowerCase() === 'latest';
|
|
9270
|
+
const hit = wantsLatest ? latestVersionRow(versions) : versions.find((v) => {
|
|
8921
9271
|
const id = str(v, 'id', '_id', 'versionId') ?? '';
|
|
8922
9272
|
const name = str(v, 'name', 'versionName') ?? '';
|
|
8923
9273
|
return (wantId && id === wantId) || (wantName && name.trim().toLowerCase() === wantName.toLowerCase());
|
|
8924
9274
|
});
|
|
9275
|
+
if (wantsLatest && !hit) {
|
|
9276
|
+
throw new Error(`${code} has no vMAJOR.MINOR version to pick the latest from. Name the version instead (version:"v2.0").`);
|
|
9277
|
+
}
|
|
8925
9278
|
if (!hit) {
|
|
8926
9279
|
const available = versions.map((v) => `${str(v, 'name') ?? '?'} (${str(v, 'id', '_id', 'versionId') ?? '?'})`).join(', ');
|
|
8927
9280
|
throw new Error(`${code} has no version ${wantId ? `"${wantId}"` : `"${wantName}"`}. ` +
|
|
@@ -9210,6 +9563,13 @@ export class SimplifyQaAdapter {
|
|
|
9210
9563
|
else
|
|
9211
9564
|
attributes.push(merged);
|
|
9212
9565
|
}
|
|
9566
|
+
// DESKTOP heal (plan.md P13): drop the stale XPaths the plan names; only heal_apply passes them, for DESKTOP objects.
|
|
9567
|
+
if (changes.removeLocators?.length) {
|
|
9568
|
+
const drop = new Set(changes.removeLocators);
|
|
9569
|
+
for (let i = attributes.length - 1; i >= 0; i--)
|
|
9570
|
+
if (drop.has(attributes[i].name))
|
|
9571
|
+
attributes.splice(i, 1);
|
|
9572
|
+
}
|
|
9213
9573
|
// The UI treats `unique` (the default locator) as exclusive — setting one clears it on the rest.
|
|
9214
9574
|
const defaultLoc = (changes.locators ?? []).filter((l) => l.unique === true).pop();
|
|
9215
9575
|
if (defaultLoc) {
|
|
@@ -11683,7 +12043,10 @@ export class SimplifyQaAdapter {
|
|
|
11683
12043
|
/** Direct REST — same endpoint `resolveEnvironment` uses. Works without an agent hop.
|
|
11684
12044
|
* `key` is what testdata iterations store as `environmentType`; `id` is the uuid used by run dispatch. */
|
|
11685
12045
|
async listEnvironments() {
|
|
11686
|
-
|
|
12046
|
+
return this.environmentsOfProject(this.requireProjectId());
|
|
12047
|
+
}
|
|
12048
|
+
/** The environments of ANY project the caller can read (the active one, or a copy's destination). */
|
|
12049
|
+
async environmentsOfProject(projectId) {
|
|
11687
12050
|
// Let fetch failures propagate rather than reading as "zero environments".
|
|
11688
12051
|
const raw = await this.http.getJson(`/pm/fields/8?projectId=${projectId}&fieldType=environment`);
|
|
11689
12052
|
const arr = Array.isArray(raw) ? raw : Array.isArray(raw?.data) ? raw.data : [];
|
|
@@ -12046,10 +12409,19 @@ export class SimplifyQaAdapter {
|
|
|
12046
12409
|
if (!h) {
|
|
12047
12410
|
throw new Error("Healing needs a local SimplifyQA agent — set QA_MCP_URL to the agent's /mcp endpoint, then retry.");
|
|
12048
12411
|
}
|
|
12049
|
-
|
|
12412
|
+
// DESKTOP (plan.md P13): a DESKTOP test case is proposed by the recorder's DESKTOP healer; every other test case asks
|
|
12413
|
+
// heal_propose, exactly as before (after this one read of the test case).
|
|
12414
|
+
let desktopHeal = false;
|
|
12415
|
+
try {
|
|
12416
|
+
desktopHeal = (await this.getTestCase(input.tcId)).technologyType?.toUpperCase() === 'DESKTOP';
|
|
12417
|
+
}
|
|
12418
|
+
catch { /* as before */ }
|
|
12419
|
+
const res = (await h.callRaw(desktopHeal ? 'desktop_heal_propose' : 'heal_propose', input, desktopHeal ? 10 * 60000 : undefined));
|
|
12050
12420
|
if (res?.structuredContent && typeof res.structuredContent === 'object')
|
|
12051
12421
|
return res.structuredContent;
|
|
12052
12422
|
const text = res?.content?.find((c) => c?.type === 'text')?.text ?? '';
|
|
12423
|
+
if (desktopHeal && res?.isError)
|
|
12424
|
+
throw new Error(text.trim() || 'desktop_heal_propose failed');
|
|
12053
12425
|
if (!text.trim())
|
|
12054
12426
|
throw new Error('heal_propose returned an empty response');
|
|
12055
12427
|
try {
|
|
@@ -12182,6 +12554,7 @@ export class SimplifyQaAdapter {
|
|
|
12182
12554
|
}
|
|
12183
12555
|
return {
|
|
12184
12556
|
tcId,
|
|
12557
|
+
...(tc.technologyType ? { technologyType: tc.technologyType } : {}), // DESKTOP object rules (plan.md P13)
|
|
12185
12558
|
...(tc.currentVersionId ? { currentVersionId: tc.currentVersionId } : {}),
|
|
12186
12559
|
steps: stepFacts,
|
|
12187
12560
|
objects,
|
|
@@ -12193,15 +12566,53 @@ export class SimplifyQaAdapter {
|
|
|
12193
12566
|
};
|
|
12194
12567
|
}
|
|
12195
12568
|
async applyHealPlan(plan, opts) {
|
|
12569
|
+
// DESKTOP (plan.md P13): apply_and_verify runs the healed version for a DESKTOP test case; every other technology
|
|
12570
|
+
// keeps "verification is not available" (in that mode only, one read of the test case decides).
|
|
12571
|
+
let desktopVerify = false;
|
|
12572
|
+
if (opts?.mode === 'apply_and_verify') {
|
|
12573
|
+
try {
|
|
12574
|
+
desktopVerify = (await this.getTestCase(plan.tcId)).technologyType?.toUpperCase() === 'DESKTOP';
|
|
12575
|
+
}
|
|
12576
|
+
catch { /* as before */ }
|
|
12577
|
+
}
|
|
12196
12578
|
const deps = {
|
|
12197
12579
|
getTestCase: (id) => this.getTestCase(id),
|
|
12198
12580
|
getObject: (id) => this.getObject(id),
|
|
12199
12581
|
updateObject: (id, changes) => this.updateObject(id, changes),
|
|
12200
12582
|
saveAsNewVersion: (id, o) => this.saveAsNewVersion(id, o),
|
|
12201
12583
|
patchTestDataCells: (input) => this.patchHealTestData(input),
|
|
12584
|
+
...(desktopVerify ? { verify: (tcId, p, versionId) => this.verifyDesktopHeal(tcId, p, versionId) } : {}),
|
|
12202
12585
|
};
|
|
12203
12586
|
return applyHealPlanCore(deps, plan, opts ?? {});
|
|
12204
12587
|
}
|
|
12588
|
+
/** DESKTOP heal (plan.md P13): runs the version heal_apply just saved ("healed-<plan>") on this machine's agent and
|
|
12589
|
+
* waits for it, as any DESKTOP run (the real application, mouse and keyboard). Verified when the run passes. A run
|
|
12590
|
+
* reads "notExecuted" until the agent picks it up, so that state means "waiting" here; a run no agent picks up
|
|
12591
|
+
* within 5 minutes (for example an agent whose token the backend refuses) ends the wait with that reason. The run
|
|
12592
|
+
* names the saved version by its id when the save returned one: applying the same plan again saves another version
|
|
12593
|
+
* with the same name, and a run by name would take the first of them. */
|
|
12594
|
+
async verifyDesktopHeal(tcId, plan, savedVersionId) {
|
|
12595
|
+
const versionName = `healed-${plan.planId.slice(0, 8)}`;
|
|
12596
|
+
const ref = await this.startRun({ tcId }, { mode: 'local', versionId: savedVersionId || versionName });
|
|
12597
|
+
const start = Date.now();
|
|
12598
|
+
const deadline = start + 15 * 60000;
|
|
12599
|
+
for (;;) {
|
|
12600
|
+
await new Promise((r) => setTimeout(r, this.desktopHealPollMs));
|
|
12601
|
+
const st = await this.getRun(ref.runId);
|
|
12602
|
+
if (st.state === 'passed')
|
|
12603
|
+
return { verified: true, runId: ref.runId };
|
|
12604
|
+
if (['failed', 'error', 'stopped', 'skipped'].includes(st.state)) {
|
|
12605
|
+
return { verified: false, runId: ref.runId, reason: `the run of ${versionName} ended ${st.state}` };
|
|
12606
|
+
}
|
|
12607
|
+
const waiting = st.state === 'notExecuted' || st.state === 'queued';
|
|
12608
|
+
if (waiting && Date.now() - start > this.desktopHealPickupMs) {
|
|
12609
|
+
return { verified: false, runId: ref.runId, reason: `no agent picked up the run of ${versionName} within ${Math.round(this.desktopHealPickupMs / 60000)} minutes (it is still ${st.state}); check that the agent is online, then run that version` };
|
|
12610
|
+
}
|
|
12611
|
+
if (Date.now() > deadline) {
|
|
12612
|
+
return { verified: false, runId: ref.runId, reason: `the run of ${versionName} did not finish within 15 minutes` };
|
|
12613
|
+
}
|
|
12614
|
+
}
|
|
12615
|
+
}
|
|
12205
12616
|
/** Patch cells of the FAILING iterations only, via the existing test-data endpoints:
|
|
12206
12617
|
* POST /tm/testdata/searchItr (read) → POST /tm/testdata/updateItr (write that one row). */
|
|
12207
12618
|
async patchHealTestData(input) {
|