bpmax-cli 0.2.1-beta.62 → 0.2.1-beta.65
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/dist/bin.js
CHANGED
|
@@ -501,7 +501,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
|
|
|
501
501
|
// package.json
|
|
502
502
|
var package_default = {
|
|
503
503
|
name: "bpmax-cli",
|
|
504
|
-
version: "0.2.1-beta.
|
|
504
|
+
version: "0.2.1-beta.65",
|
|
505
505
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
506
506
|
type: "module",
|
|
507
507
|
bin: {
|
|
@@ -8665,6 +8665,9 @@ function lintConsoleTemplateModule(module, index, errors, warnings) {
|
|
|
8665
8665
|
if (name === "\u56FE\u8868" && configScript.includes("ctx.config") && !consoleTemplateHasCtxConfigFallback(configScript)) {
|
|
8666
8666
|
errors.push(`${moduleLabel} config \u811A\u672C\u5F15\u7528 ctx.config \u65F6\u5FC5\u987B\u63D0\u4F9B\u7A7A\u5BF9\u8C61 fallback\u3002`);
|
|
8667
8667
|
}
|
|
8668
|
+
if (name === "\u56FE\u8868" && /^(?:const|let|var)\b/.test(configScript.trim()) && !/\n/.test(configScript)) {
|
|
8669
|
+
errors.push(`${moduleLabel} config \u811A\u672C\u4E0D\u80FD\u4F7F\u7528\u5355\u884C const/let/var \u8BED\u53E5\uFF1B\u8BF7\u6539\u4E3A\u591A\u884C\u51FD\u6570\u4F53\u6216 return \u8868\u8FBE\u5F0F\u4EE5\u517C\u5BB9\u8FD0\u884C\u65F6\u89E3\u6790\u5668\u3002`);
|
|
8670
|
+
}
|
|
8668
8671
|
if (name === "\u4E00\u822C\u8868\u683C") {
|
|
8669
8672
|
if (/\$\{\s*(page_size|offset)\s*\}/.test(configScript)) {
|
|
8670
8673
|
errors.push(`${moduleLabel} config \u811A\u672C\u4E0D\u80FD\u5305\u542B\u524D\u7AEF\u5206\u9875\u5360\u4F4D\u7B26 \${page_size}/\${offset}\uFF1B\u8BF7\u4F7F\u7528 typed \u53C2\u6570\u6216 ctx.pageInfo\u3002`);
|
|
@@ -10288,6 +10291,29 @@ function normalizeStructuredFormTemplateValue(value, ruleType) {
|
|
|
10288
10291
|
const resolvedType = fieldType || typeAlias || (typeof ruleType === "string" ? ruleType : "");
|
|
10289
10292
|
return resolvedType ? { ...value, field_type: resolvedType } : { ...value };
|
|
10290
10293
|
}
|
|
10294
|
+
var FORM_SELECTION_CONTROL_TYPES = /* @__PURE__ */ new Set(["i_select", "checkbox"]);
|
|
10295
|
+
function normalizeSelectionRuleOptions(rule) {
|
|
10296
|
+
const type = typeof rule.type === "string" ? rule.type : "";
|
|
10297
|
+
if (!FORM_SELECTION_CONTROL_TYPES.has(type)) return rule;
|
|
10298
|
+
const normalizeOptions = (options) => {
|
|
10299
|
+
if (!Array.isArray(options)) return options;
|
|
10300
|
+
return options.map((option) => {
|
|
10301
|
+
if (!isRecord4(option)) return option;
|
|
10302
|
+
const label = option.label ?? option.title;
|
|
10303
|
+
const businessValue = option._original ?? option.value;
|
|
10304
|
+
if (label === void 0 || businessValue === void 0 || String(label) === String(option.value)) {
|
|
10305
|
+
return option;
|
|
10306
|
+
}
|
|
10307
|
+
return { ...option, label: String(label), value: String(label), _original: businessValue };
|
|
10308
|
+
});
|
|
10309
|
+
};
|
|
10310
|
+
const next = { ...rule };
|
|
10311
|
+
if (Array.isArray(next.options)) next.options = normalizeOptions(next.options);
|
|
10312
|
+
if (isRecord4(next.props) && Array.isArray(next.props.options)) {
|
|
10313
|
+
next.props = { ...next.props, options: normalizeOptions(next.props.options) };
|
|
10314
|
+
}
|
|
10315
|
+
return next;
|
|
10316
|
+
}
|
|
10291
10317
|
function buildStructuredFormTemplatePayload(work) {
|
|
10292
10318
|
const mode = work.mode;
|
|
10293
10319
|
if (mode !== "edit" && mode !== "create") {
|
|
@@ -10333,7 +10359,7 @@ function buildStructuredFormTemplatePayload(work) {
|
|
|
10333
10359
|
if (formTemplateValueFieldType(normalizedValue) !== bundle.rule.type) {
|
|
10334
10360
|
throw new Error(`form-template field_type mismatch for ${ref}.`);
|
|
10335
10361
|
}
|
|
10336
|
-
const rule = mode === "create" ? stripKeys(bundle.rule, FORM_RULE_ID_KEYS) : { ...bundle.rule };
|
|
10362
|
+
const rule = normalizeSelectionRuleOptions(mode === "create" ? stripKeys(bundle.rule, FORM_RULE_ID_KEYS) : { ...bundle.rule });
|
|
10337
10363
|
const value = normalizeFormTemplateValueValidateMap(
|
|
10338
10364
|
mode === "create" ? stripKeys(normalizedValue, FORM_VALUE_ID_KEYS) : normalizedValue
|
|
10339
10365
|
);
|
|
@@ -12782,6 +12808,9 @@ function buildDomainSubmitPayload(domain, work, options = {}, raw) {
|
|
|
12782
12808
|
return payload2;
|
|
12783
12809
|
}
|
|
12784
12810
|
const payload = pickDefined(work, ["name", "desc", "category", "option", "rule", "value"]);
|
|
12811
|
+
if (Array.isArray(payload.rule)) {
|
|
12812
|
+
payload.rule = payload.rule.map((row) => Array.isArray(row) ? row.map((rule) => isRecord4(rule) ? normalizeSelectionRuleOptions(rule) : rule) : row);
|
|
12813
|
+
}
|
|
12785
12814
|
if (work.mode === "create") {
|
|
12786
12815
|
const createPayload = stripFormTemplateCreateIds(payload);
|
|
12787
12816
|
validateNonEmptyFormCreatePayload(createPayload);
|
|
@@ -21103,6 +21132,17 @@ function validateBrowserAutomationDocument(value, options = {}) {
|
|
|
21103
21132
|
}
|
|
21104
21133
|
actions.forEach((action, index) => issues.push(...actionIssues(action, stepKey, index, false)));
|
|
21105
21134
|
checks.forEach((action, index) => issues.push(...actionIssues(action, stepKey, index, true)));
|
|
21135
|
+
const localContextNames = new Set(actions.flatMap((action) => isRecord8(action) && action.type === "context.extract" && stringValue2(action.name) ? [stringValue2(action.name)] : []));
|
|
21136
|
+
const contextReferences = JSON.stringify({ actions, checks }).matchAll(/\{\{context\.([A-Za-z0-9_-]+)\}\}/g);
|
|
21137
|
+
for (const match of contextReferences) {
|
|
21138
|
+
if (!localContextNames.has(match[1])) {
|
|
21139
|
+
issues.push({
|
|
21140
|
+
rule_id: "test_suite.automation.context_cross_step",
|
|
21141
|
+
step_key: stepKey,
|
|
21142
|
+
message: `${stepKey} references context.${match[1]} without extracting it in the same reconstructable step`
|
|
21143
|
+
});
|
|
21144
|
+
}
|
|
21145
|
+
}
|
|
21106
21146
|
const formContractValidation = formContractIssues(
|
|
21107
21147
|
rawStep,
|
|
21108
21148
|
stepKey,
|
|
@@ -21180,6 +21220,14 @@ function validateBrowserAutomationDocument(value, options = {}) {
|
|
|
21180
21220
|
message: `${stepKey} resolution_checks.${outcome} requires wait.route, page.assert_step, or list.assert_record; visibility-only checks cannot resolve an uncertain write`
|
|
21181
21221
|
});
|
|
21182
21222
|
}
|
|
21223
|
+
const committedTypes = outcomeChecks.map((check) => isRecord8(check) ? stringValue2(check.type) : "");
|
|
21224
|
+
if (outcome === "committed" && committedTypes.length > 1 && committedTypes.includes("navigation.open") && committedTypes.includes("wait.route") && committedTypes.every((type) => ["navigation.open", "wait.route"].includes(type))) {
|
|
21225
|
+
issues.push({
|
|
21226
|
+
rule_id: "test_suite.automation.mutation_resolution_committed_weak",
|
|
21227
|
+
step_key: stepKey,
|
|
21228
|
+
message: `${stepKey} resolution_checks.committed must include a business-state readback (page.assert_step, list.assert_record, or equivalent); navigation.open/wait.route alone cannot prove the mutation committed`
|
|
21229
|
+
});
|
|
21230
|
+
}
|
|
21183
21231
|
}
|
|
21184
21232
|
if (normalizedResolutionBranches.committed && normalizedResolutionBranches.committed === normalizedResolutionBranches.not_committed) {
|
|
21185
21233
|
issues.push({
|
|
@@ -21207,6 +21255,30 @@ function validateBrowserAutomationDocument(value, options = {}) {
|
|
|
21207
21255
|
}
|
|
21208
21256
|
}
|
|
21209
21257
|
}
|
|
21258
|
+
const extractedByName = /* @__PURE__ */ new Map();
|
|
21259
|
+
for (const [stepKey, rawStep] of Object.entries(value.steps)) {
|
|
21260
|
+
if (!isRecord8(rawStep)) continue;
|
|
21261
|
+
for (const action of Array.isArray(rawStep.actions) ? rawStep.actions : []) {
|
|
21262
|
+
if (!isRecord8(action) || action.type !== "context.extract") continue;
|
|
21263
|
+
const name = stringValue2(action.name);
|
|
21264
|
+
if (!name) continue;
|
|
21265
|
+
const owners = extractedByName.get(name) ?? /* @__PURE__ */ new Set();
|
|
21266
|
+
owners.add(stepKey);
|
|
21267
|
+
extractedByName.set(name, owners);
|
|
21268
|
+
}
|
|
21269
|
+
}
|
|
21270
|
+
for (const [stepKey, rawStep] of Object.entries(value.steps)) {
|
|
21271
|
+
for (const match of JSON.stringify(rawStep).matchAll(/\{\{data\.([A-Za-z0-9_-]+)\}\}/g)) {
|
|
21272
|
+
const owners = extractedByName.get(match[1]);
|
|
21273
|
+
if (owners && !owners.has(stepKey)) {
|
|
21274
|
+
issues.push({
|
|
21275
|
+
rule_id: "test_suite.automation.context_cross_step",
|
|
21276
|
+
step_key: stepKey,
|
|
21277
|
+
message: `${stepKey} references data.${match[1]}, but that name is produced only by context.extract in another step; step context is not persistent`
|
|
21278
|
+
});
|
|
21279
|
+
}
|
|
21280
|
+
}
|
|
21281
|
+
}
|
|
21210
21282
|
return { document: value, issues, warnings };
|
|
21211
21283
|
}
|
|
21212
21284
|
function validateBrowserAutomationCompileMetadataDetailed(document2) {
|
|
@@ -24453,7 +24525,7 @@ async function applyReviewedAutomationRepairUnlocked(options) {
|
|
|
24453
24525
|
const [caseId, caseStepId] = currentKey.split("/");
|
|
24454
24526
|
const attemptedStepSha256 = browserAutomationStepSha256(currentStep);
|
|
24455
24527
|
const mutationGuardCheckpoint = mutationGuard ? await realpath6(mutationGuard.checkpoint).catch(() => path17.resolve(mutationGuard.checkpoint)) : "";
|
|
24456
|
-
if (!mutationGuard || mutationGuard.state !== "attempted_unconfirmed" || mutationGuardCheckpoint !== checkpointPath || mutationGuard.case_id !== caseId || mutationGuard.case_step_id !== caseStepId || mutationGuard.automation_step_sha256 !== attemptedStepSha256 || mutationGuard.automation_step_sha256 !== String(pause2.failed_step_hash || "") || mutationGuard.checkpoint_revision !== Number(
|
|
24528
|
+
if (!mutationGuard || mutationGuard.state !== "attempted_unconfirmed" || mutationGuardCheckpoint !== checkpointPath || mutationGuard.case_id !== caseId || mutationGuard.case_step_id !== caseStepId || mutationGuard.automation_step_sha256 !== attemptedStepSha256 || mutationGuard.automation_step_sha256 !== String(pause2.failed_step_hash || "") || mutationGuard.checkpoint_revision !== Number(pause2.checkpoint_revision) || mutationGuard.mutation_attempt_id !== String(pause2.mutation_attempt_id || "")) {
|
|
24457
24529
|
fail("paused_write_state_unknown resolution repair is not bound to the active mutation attempt", {
|
|
24458
24530
|
rule_id: "test_suite.automation.resolution_repair_guard_mismatch",
|
|
24459
24531
|
path: checkpointPath
|
|
@@ -26498,7 +26570,7 @@ async function acquireActiveRunLease(options) {
|
|
|
26498
26570
|
}
|
|
26499
26571
|
if (existing.manifest && await exists3(existing.manifest)) {
|
|
26500
26572
|
const manifest = await readExecutionManifest(existing.manifest);
|
|
26501
|
-
if (manifest.mutation_attempt_guard) {
|
|
26573
|
+
if (manifest.mutation_attempt_guard && !manifest.abandoned_mutation) {
|
|
26502
26574
|
fail(`previous run ${manifest.run_id} still has an unresolved mutation attempt; starting another run could replay the same business write`, {
|
|
26503
26575
|
rule_id: "test_suite.run.mutation_resolution_required",
|
|
26504
26576
|
path: existing.manifest,
|
|
@@ -26562,7 +26634,7 @@ async function assertNoUnresolvedMutationInReportRoot(reportRoot, scenarioId, ca
|
|
|
26562
26634
|
}
|
|
26563
26635
|
if (candidate.scenario_id !== scenarioId || candidate.profile !== profile || !manifestSelectedCaseIds(candidate).some((caseId) => caseIds.includes(caseId))) continue;
|
|
26564
26636
|
const manifest = await readExecutionManifest(manifestPath);
|
|
26565
|
-
if (manifest.scenario_id !== scenarioId || manifest.profile !== profile || !manifest.mutation_attempt_guard || !caseIds.includes(manifest.mutation_attempt_guard.case_id)) continue;
|
|
26637
|
+
if (manifest.scenario_id !== scenarioId || manifest.profile !== profile || !manifest.mutation_attempt_guard || Boolean(manifest.abandoned_mutation) || !caseIds.includes(manifest.mutation_attempt_guard.case_id)) continue;
|
|
26566
26638
|
fail(`previous run ${manifest.run_id} still has an unresolved mutation attempt; starting another run could replay the same business write`, {
|
|
26567
26639
|
rule_id: "test_suite.run.mutation_resolution_required",
|
|
26568
26640
|
path: manifestPath,
|
|
@@ -27313,6 +27385,84 @@ async function testSuiteRunStatus(manifestPath, profile) {
|
|
|
27313
27385
|
const warnings = await executionManifestSkillWarnings(manifest);
|
|
27314
27386
|
return { ok: true, execution: manifest, ...warnings.length > 0 ? { warnings } : {} };
|
|
27315
27387
|
}
|
|
27388
|
+
async function abandonTestSuiteRun(options) {
|
|
27389
|
+
return withExecutionManifestLock(options.manifest, async () => {
|
|
27390
|
+
const manifestPath = path17.resolve(options.manifest);
|
|
27391
|
+
const manifest = await readExecutionManifest(manifestPath, true);
|
|
27392
|
+
const reason = String(options.reason || "").trim();
|
|
27393
|
+
if (!reason) fail("abandon requires a non-empty reason", { rule_id: "test_suite.run.abandon_reason_required", path: manifestPath });
|
|
27394
|
+
if (manifest.result !== "running" || !manifest.mutation_attempt_guard) {
|
|
27395
|
+
fail("only a running manifest with an unresolved mutation attempt can be abandoned", {
|
|
27396
|
+
rule_id: "test_suite.run.abandon_not_allowed",
|
|
27397
|
+
path: manifestPath
|
|
27398
|
+
});
|
|
27399
|
+
}
|
|
27400
|
+
const expectedConfirm = `abandon e2e run ${manifest.run_id}`;
|
|
27401
|
+
if (options.confirm !== expectedConfirm) {
|
|
27402
|
+
fail(`abandon requires exact --confirm "${expectedConfirm}"`, {
|
|
27403
|
+
rule_id: "test_suite.run.abandon_confirmation_required",
|
|
27404
|
+
path: manifestPath,
|
|
27405
|
+
suggestion: `Re-run with --confirm "${expectedConfirm}" after reviewing the run and reason.`
|
|
27406
|
+
});
|
|
27407
|
+
}
|
|
27408
|
+
const operator = String(options.operator || process.env.USER || "unknown").trim() || "unknown";
|
|
27409
|
+
const abandonedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
27410
|
+
const receipt = path17.join(path17.dirname(manifestPath), "abandonment-receipt.json");
|
|
27411
|
+
const guard = manifest.mutation_attempt_guard;
|
|
27412
|
+
const receiptValue = {
|
|
27413
|
+
schema_version: 1,
|
|
27414
|
+
kind: "bpmax_e2e_run_abandonment_receipt",
|
|
27415
|
+
run_id: manifest.run_id,
|
|
27416
|
+
scenario_id: manifest.scenario_id,
|
|
27417
|
+
case_id: guard.case_id,
|
|
27418
|
+
case_step_id: guard.case_step_id,
|
|
27419
|
+
mutation_attempt_id: guard.mutation_attempt_id,
|
|
27420
|
+
mutation_state: "abandoned_unknown",
|
|
27421
|
+
reason,
|
|
27422
|
+
operator,
|
|
27423
|
+
original_mutation_guard: guard,
|
|
27424
|
+
abandoned_at: abandonedAt
|
|
27425
|
+
};
|
|
27426
|
+
const receiptText = `${JSON.stringify(receiptValue, null, 2)}
|
|
27427
|
+
`;
|
|
27428
|
+
await writeAtomicText(receipt, receiptText);
|
|
27429
|
+
const receiptSha256 = createHash11("sha256").update(receiptText).digest("hex");
|
|
27430
|
+
manifest.abandoned_mutation = {
|
|
27431
|
+
state: "abandoned_unknown",
|
|
27432
|
+
reason,
|
|
27433
|
+
operator,
|
|
27434
|
+
receipt,
|
|
27435
|
+
receipt_sha256: receiptSha256,
|
|
27436
|
+
mutation_attempt_id: guard.mutation_attempt_id,
|
|
27437
|
+
abandoned_at: abandonedAt
|
|
27438
|
+
};
|
|
27439
|
+
manifest.mutation_attempt_guard = void 0;
|
|
27440
|
+
manifest.result = "blocked";
|
|
27441
|
+
manifest.current_case_id = void 0;
|
|
27442
|
+
manifest.current_step_id = null;
|
|
27443
|
+
manifest.finished_at = abandonedAt;
|
|
27444
|
+
await writeExecutionManifest(manifestPath, manifest, true);
|
|
27445
|
+
const released = manifest.active_run_lease ? await releaseActiveRunLease(manifest.active_run_lease) : false;
|
|
27446
|
+
let reportSync;
|
|
27447
|
+
try {
|
|
27448
|
+
reportSync = await syncTestSuiteRunReportUnlocked(manifestPath);
|
|
27449
|
+
} catch (error) {
|
|
27450
|
+
reportSync = { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
27451
|
+
}
|
|
27452
|
+
return {
|
|
27453
|
+
ok: true,
|
|
27454
|
+
status: "abandoned",
|
|
27455
|
+
mutation_state: "abandoned_unknown",
|
|
27456
|
+
manifest: manifestPath,
|
|
27457
|
+
receipt,
|
|
27458
|
+
receipt_sha256: receiptSha256,
|
|
27459
|
+
active_run_lease_released: released,
|
|
27460
|
+
report_sync: reportSync,
|
|
27461
|
+
execution: manifest,
|
|
27462
|
+
next_action: "Start a fresh full_rerun run. The abandoned run remains blocked and its mutation outcome must not be interpreted as not committed."
|
|
27463
|
+
};
|
|
27464
|
+
});
|
|
27465
|
+
}
|
|
27316
27466
|
async function indexSuite(root = DEFAULT_SUITE_ROOT, includeInactive = false, options = {}) {
|
|
27317
27467
|
const items = await lintSuite(root, options);
|
|
27318
27468
|
return includeInactive ? items : items.filter((item) => item.status === "active");
|
|
@@ -28546,7 +28696,11 @@ async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
|
28546
28696
|
const missingExecuted = plannedCases.filter((caseId) => !executedCases.includes(caseId));
|
|
28547
28697
|
const unexpectedExecuted = executedCases.filter((caseId) => !plannedCases.includes(caseId));
|
|
28548
28698
|
if (plannedCases.length > 0 && missingExecuted.length > 0) {
|
|
28549
|
-
|
|
28699
|
+
const notRunEvidence = reportKeyValue(text5, "not_run_cases:");
|
|
28700
|
+
const hasStructuredNotRun = missingExecuted.every((caseId) => new RegExp(`(?:^|,)\\s*${caseId.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")}\\s*[:=]`).test(notRunEvidence));
|
|
28701
|
+
if (!hasStructuredNotRun) {
|
|
28702
|
+
errors.push(`[test_suite.report.case_reconciliation] ${reportPath}: planned_cases \u4E2D\u5B58\u5728\u672A\u6267\u884C\u7528\u4F8B: ${missingExecuted.join(", ")}\uFF1B\u62A5\u544A\u5FC5\u987B\u5199\u660E blocked/not run \u539F\u56E0\u5E76\u964D\u7EA7\u7ED3\u8BBA`);
|
|
28703
|
+
}
|
|
28550
28704
|
}
|
|
28551
28705
|
if (unexpectedExecuted.length > 0) {
|
|
28552
28706
|
errors.push(`[test_suite.report.case_reconciliation] ${reportPath}: executed_cases \u5305\u542B\u4E0D\u5728 planned_cases \u4E2D\u7684\u7528\u4F8B: ${unexpectedExecuted.join(", ")}`);
|
|
@@ -29234,10 +29388,6 @@ function browserStepHasMutation(step) {
|
|
|
29234
29388
|
function matchingMutationRequest(request, patterns) {
|
|
29235
29389
|
return ["POST", "PUT", "PATCH", "DELETE"].includes(request.method().toUpperCase()) && [...patterns].some((pattern) => request.url().includes(pattern));
|
|
29236
29390
|
}
|
|
29237
|
-
function matchingMutationRecord(value, urlPattern) {
|
|
29238
|
-
if (!isRecord11(value)) return false;
|
|
29239
|
-
return ["POST", "PUT", "PATCH", "DELETE"].includes(String(value.method || "").toUpperCase()) && String(value.url || "").includes(urlPattern);
|
|
29240
|
-
}
|
|
29241
29391
|
async function waitForMutationNetworkClosure(options) {
|
|
29242
29392
|
const timeoutMs = options.timeoutMs ?? 1e4;
|
|
29243
29393
|
const quietWindowMs = 1e3;
|
|
@@ -29805,6 +29955,7 @@ async function selectBrowserUser(page, target, userName, expectedUserId, timeout
|
|
|
29805
29955
|
}
|
|
29806
29956
|
if (expectedUserId) {
|
|
29807
29957
|
const candidateRows = picker.locator(".checkbox-item-list").filter({ hasText: userName });
|
|
29958
|
+
await firstVisibleLocator(candidateRows, timeout);
|
|
29808
29959
|
const exactCandidates = [];
|
|
29809
29960
|
const candidateCount = await candidateRows.count();
|
|
29810
29961
|
for (let index = 0; index < candidateCount; index += 1) {
|
|
@@ -29937,6 +30088,11 @@ async function tableLocator(page, table) {
|
|
|
29937
30088
|
const direct = page.locator(`[data-table-key="${escaped}"], [table-key="${escaped}"], [data-key="${escaped}"]`);
|
|
29938
30089
|
if (await direct.count()) return direct.first();
|
|
29939
30090
|
const heading = page.getByText(table, { exact: false }).first();
|
|
30091
|
+
const formItem = heading.locator('xpath=ancestor::*[contains(concat(" ", normalize-space(@class), " "), " el-form-item ")][1]');
|
|
30092
|
+
if (await formItem.count()) {
|
|
30093
|
+
const elTable = formItem.locator(".el-table").first();
|
|
30094
|
+
if (await elTable.count()) return elTable;
|
|
30095
|
+
}
|
|
29940
30096
|
return heading.locator('xpath=ancestor::*[contains(@class,"table") or contains(@class,"sub-form")][1]');
|
|
29941
30097
|
}
|
|
29942
30098
|
async function assertFingerprint(page, fingerprint, variables) {
|
|
@@ -30283,7 +30439,7 @@ async function executeAction(page, action, variables, runtime) {
|
|
|
30283
30439
|
}
|
|
30284
30440
|
case "detail.assert_rows": {
|
|
30285
30441
|
const table = await tableLocator(page, String(next.table));
|
|
30286
|
-
const count = await table.locator(".el-table__body tr, tbody tr").count();
|
|
30442
|
+
const count = await table.locator(".el-table__body-wrapper tbody tr, .el-table__body tr, tbody tr").count();
|
|
30287
30443
|
const passed = count === Number(next.count);
|
|
30288
30444
|
if (!passed) throw new Error(`detail row count mismatch: expected ${next.count}, got ${count}`);
|
|
30289
30445
|
return { assertion: { type: next.type, passed, table: next.table, count } };
|
|
@@ -30680,15 +30836,27 @@ async function contextHasAuthenticatedIdentity(context2, profileOrigin) {
|
|
|
30680
30836
|
failOnStatusCode: false,
|
|
30681
30837
|
timeout: 15e3
|
|
30682
30838
|
});
|
|
30683
|
-
if (
|
|
30684
|
-
|
|
30685
|
-
|
|
30686
|
-
|
|
30687
|
-
|
|
30688
|
-
|
|
30839
|
+
if (response.ok()) {
|
|
30840
|
+
const payload = await response.json();
|
|
30841
|
+
if (isRecord11(payload)) {
|
|
30842
|
+
const data = isRecord11(payload.data) ? payload.data : payload;
|
|
30843
|
+
const id = Number(data.id);
|
|
30844
|
+
if (Number.isSafeInteger(id) && id > 0 && data.role !== void 0 && data.role !== null) return true;
|
|
30845
|
+
}
|
|
30846
|
+
}
|
|
30689
30847
|
} catch {
|
|
30690
|
-
return false;
|
|
30691
30848
|
}
|
|
30849
|
+
for (const page of context2.pages()) {
|
|
30850
|
+
try {
|
|
30851
|
+
const url = new URL(page.url());
|
|
30852
|
+
if (url.origin !== new URL(profileOrigin).origin || /(?:^|\/)login(?:\/|$)/i.test(url.pathname)) continue;
|
|
30853
|
+
const authenticatedMarker = page.locator('[data-user-id], [data-testid*="logout" i], [aria-label*="\u9000\u51FA" i]').first();
|
|
30854
|
+
if (await authenticatedMarker.isVisible({ timeout: 500 }).catch(() => false)) return true;
|
|
30855
|
+
if (await page.getByText(/退出登录|登出|Logout/i).first().isVisible({ timeout: 500 }).catch(() => false)) return true;
|
|
30856
|
+
} catch {
|
|
30857
|
+
}
|
|
30858
|
+
}
|
|
30859
|
+
return false;
|
|
30692
30860
|
}
|
|
30693
30861
|
async function probeAuthenticatedContext(options) {
|
|
30694
30862
|
let profileOrigin;
|
|
@@ -31219,6 +31387,15 @@ async function runPlaywrightIdentityOperation(options) {
|
|
|
31219
31387
|
await page.screenshot({ path: screenshotPath, fullPage: false });
|
|
31220
31388
|
const assertions = options.operation === "mock" ? [{ name: "Playwright context switched to exact target user", passed: after.mock === true && Number(after.id) === Number(options.userId) }] : options.operation === "unmock" ? [{ name: "Playwright context restored original user", passed: after.mock === false }] : [{ name: "Playwright context current identity read back", passed: Number(after.id) > 0 }];
|
|
31221
31389
|
const evidence = path18.join(evidenceDir, `identity-playwright-${options.operation}.json`);
|
|
31390
|
+
const redactIdentity = (value) => ({
|
|
31391
|
+
id: Number.isSafeInteger(Number(value.id)) ? Number(value.id) : void 0,
|
|
31392
|
+
name: typeof value.name === "string" ? value.name : void 0,
|
|
31393
|
+
organization_id: Number.isSafeInteger(Number(value.organization_id)) ? Number(value.organization_id) : void 0,
|
|
31394
|
+
mock: value.mock === true,
|
|
31395
|
+
mock_by_user: Number.isSafeInteger(Number(value.mock_by_user)) ? Number(value.mock_by_user) : void 0,
|
|
31396
|
+
can_mock: value.can_mock === true,
|
|
31397
|
+
source: typeof value.source === "string" ? value.source : void 0
|
|
31398
|
+
});
|
|
31222
31399
|
await writeFile12(evidence, `${JSON.stringify({
|
|
31223
31400
|
schema_version: 2,
|
|
31224
31401
|
run_id: options.runId,
|
|
@@ -31236,10 +31413,10 @@ async function runPlaywrightIdentityOperation(options) {
|
|
|
31236
31413
|
remote_submitted: options.operation !== "status",
|
|
31237
31414
|
resolved_from_readback: resolvedFromReadback,
|
|
31238
31415
|
readback_confirmed: true,
|
|
31239
|
-
current_user: after,
|
|
31240
|
-
before,
|
|
31241
|
-
after,
|
|
31242
|
-
...target ? { target_user: target } : {},
|
|
31416
|
+
current_user: redactIdentity(after),
|
|
31417
|
+
before: redactIdentity(before),
|
|
31418
|
+
after: redactIdentity(after),
|
|
31419
|
+
...target ? { target_user: redactIdentity(target) } : {},
|
|
31243
31420
|
runtime_scope: "page",
|
|
31244
31421
|
runtime_environment: "profile",
|
|
31245
31422
|
runtime_url: page.url(),
|
|
@@ -32053,7 +32230,20 @@ function mutationResolutionNoRequestEvidenceMatches(options) {
|
|
|
32053
32230
|
if (!patterns.includes(options.urlPattern)) return false;
|
|
32054
32231
|
const requests = Array.isArray(evidence.mutation_requests) ? evidence.mutation_requests : [];
|
|
32055
32232
|
const responses = Array.isArray(evidence.network_responses) ? evidence.network_responses : [];
|
|
32056
|
-
|
|
32233
|
+
const matchesEndpoint = (value) => {
|
|
32234
|
+
if (!isRecord11(value) || !["POST", "PUT", "PATCH", "DELETE"].includes(String(value.method || "").toUpperCase())) return false;
|
|
32235
|
+
const raw = String(value.url || "");
|
|
32236
|
+
try {
|
|
32237
|
+
const actual = new URL(raw).pathname.replace(/\/+$/, "");
|
|
32238
|
+
const expected = new URL(options.urlPattern, raw).pathname.replace(/\/+$/, "");
|
|
32239
|
+
return actual === expected || actual.startsWith(`${expected}/`);
|
|
32240
|
+
} catch {
|
|
32241
|
+
const actual = raw.split(/[?#]/, 1)[0].replace(/\/+$/, "");
|
|
32242
|
+
const expected = options.urlPattern.split(/[?#]/, 1)[0].replace(/\/+$/, "");
|
|
32243
|
+
return actual === expected || actual.startsWith(`${expected}/`);
|
|
32244
|
+
}
|
|
32245
|
+
};
|
|
32246
|
+
return !requests.some(matchesEndpoint) && !responses.some(matchesEndpoint);
|
|
32057
32247
|
}
|
|
32058
32248
|
function mutationResolutionNoRequestFingerprintIsStrong(step) {
|
|
32059
32249
|
return Boolean(String(step.page_fingerprint.route || "").trim()) && Array.isArray(step.page_fingerprint.buttons) && step.page_fingerprint.buttons.some((value) => String(value || "").trim());
|
|
@@ -32619,7 +32809,8 @@ function externalActionForStep(manifest, step) {
|
|
|
32619
32809
|
const evidenceDir = path19.join(runDir, "evidence", `${caseId}-${stepId}`);
|
|
32620
32810
|
if (step.runner === "identity") {
|
|
32621
32811
|
const source = `${String(step.action || "")} ${String(step.input_data || "")}`;
|
|
32622
|
-
const
|
|
32812
|
+
const structuredOperation = isRecord12(step.input_data) ? String(step.input_data.operation || "").trim().toLowerCase() : "";
|
|
32813
|
+
const operation = ["mock", "unmock", "status"].includes(structuredOperation) ? structuredOperation : /unmock|恢复.*身份|还原.*身份/i.test(source) ? "unmock" : /status|当前.*身份|确认.*身份/i.test(source) ? "status" : "mock";
|
|
32623
32814
|
const userId = source.match(/(?:user_id|用户ID|用户 id)\s*[=::]\s*(\d+)/i)?.[1];
|
|
32624
32815
|
if (operation === "mock" && !userId) {
|
|
32625
32816
|
return {
|
|
@@ -42178,6 +42369,9 @@ function registerTestSuiteCommands(program2) {
|
|
|
42178
42369
|
run.command("status").description("Show execution manifest status").requiredOption("--manifest <file>", "Execution manifest file").option("--profile <profile>", "Profile name; must match the execution manifest").option("--format <format>", "Output format", "json").action(async (options, command) => {
|
|
42179
42370
|
printResult(options.format, await testSuiteRunStatus(options.manifest, effectiveProfileOption(options, command)));
|
|
42180
42371
|
});
|
|
42372
|
+
run.command("abandon").description("Abandon a running E2E manifest with an unresolved mutation and release its active-run lease").requiredOption("--manifest <file>", "Execution manifest file").requiredOption("--reason <reason>", "Audited reason for abandoning the unresolved run").requiredOption("--confirm <confirmation>", "Exact confirmation: abandon e2e run <run_id>").option("--operator <name>", "Operator identity recorded in the abandonment receipt").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
42373
|
+
printResult(options.format, await abandonTestSuiteRun(options));
|
|
42374
|
+
});
|
|
42181
42375
|
review.command("repair").description("Repair missing schema fields in an existing draft review.json").requiredOption("--scenario <id>", "Scenario id").option("--draft-root <path>", "Draft suite root directory", DEFAULT_DRAFT_ROOT).requiredOption("--latest-proof <path>", "latest-* proof JSON written after syncing the sysconfig repo").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
42182
42376
|
printResult(options.format, await initOrRepairReview({ ...options, repair: true }));
|
|
42183
42377
|
});
|