bpmax-cli 0.2.1-beta.55 → 0.2.1-beta.57
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 +636 -99
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-bug-reporting/SKILL.md +1 -1
- package/skills/bpmax-cli/SKILL.md +1 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/SKILL.md +12 -9
- package/skills/bpmax-e2e-flow-test-operator-v2/references/autonomous-execution.md +40 -0
- package/skills/bpmax-e2e-flow-test-operator-v2/references/browser-action-runner.md +1 -1
- package/skills/bpmax-e2e-flow-test-operator-v2/references/identity-and-failure-routing.md +11 -1
- package/skills/bpmax-e2e-flow-test-operator-v2/references/test-preflight-and-confirmation.md +8 -8
package/dist/bin.js
CHANGED
|
@@ -499,7 +499,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
|
|
|
499
499
|
// package.json
|
|
500
500
|
var package_default = {
|
|
501
501
|
name: "bpmax-cli",
|
|
502
|
-
version: "0.2.1-beta.
|
|
502
|
+
version: "0.2.1-beta.57",
|
|
503
503
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
504
504
|
type: "module",
|
|
505
505
|
bin: {
|
|
@@ -5347,6 +5347,7 @@ var DATASET_SOURCE_TABLE_COLUMNS = /* @__PURE__ */ new Map([
|
|
|
5347
5347
|
"create_time",
|
|
5348
5348
|
"update_time",
|
|
5349
5349
|
"plan_end_time",
|
|
5350
|
+
"real_end_time",
|
|
5350
5351
|
"user_id",
|
|
5351
5352
|
"project_id",
|
|
5352
5353
|
"step_id",
|
|
@@ -18631,6 +18632,7 @@ var SUPPORTED_ACTIONS = {
|
|
|
18631
18632
|
radio: ["form.select_option"],
|
|
18632
18633
|
checkbox: ["form.select_option"],
|
|
18633
18634
|
"bp-date-picker": ["form.set_value", "form.set_date_range"],
|
|
18635
|
+
date_picker: ["form.set_value", "form.set_date_range"],
|
|
18634
18636
|
"bp-upload": ["form.upload_file"],
|
|
18635
18637
|
punishment_item_form_control: ["form.set_punishment"],
|
|
18636
18638
|
signature: ["form.draw_signature"],
|
|
@@ -18639,7 +18641,8 @@ var SUPPORTED_ACTIONS = {
|
|
|
18639
18641
|
flow_selector: ["form.select_option"],
|
|
18640
18642
|
user_select: ["form.select_option", "form.select_user"],
|
|
18641
18643
|
group_select: ["form.select_option"],
|
|
18642
|
-
ecology_browser_review: ["form.select_option"]
|
|
18644
|
+
ecology_browser_review: ["form.select_option"],
|
|
18645
|
+
sub_form: ["detail.add_row", "detail.set_value"]
|
|
18643
18646
|
};
|
|
18644
18647
|
var SELECTOR_CONTROLS = /* @__PURE__ */ new Set([
|
|
18645
18648
|
"selector",
|
|
@@ -18660,7 +18663,6 @@ var UNSUPPORTED_REQUIRED_CONTROLS = /* @__PURE__ */ new Set([
|
|
|
18660
18663
|
"group_selector",
|
|
18661
18664
|
"project_selector",
|
|
18662
18665
|
"relation_selector",
|
|
18663
|
-
"sub_form",
|
|
18664
18666
|
"subform"
|
|
18665
18667
|
]);
|
|
18666
18668
|
function controlActionsFor(controlType) {
|
|
@@ -18982,7 +18984,7 @@ import axios7 from "axios";
|
|
|
18982
18984
|
|
|
18983
18985
|
// src/core/e2e-scenario-orchestrator.ts
|
|
18984
18986
|
import { createHash as createHash11 } from "crypto";
|
|
18985
|
-
import { chmod as
|
|
18987
|
+
import { chmod as chmod3, mkdir as mkdir12, readFile as readFile16, realpath as realpath6, rename as rename4, rm as rm6, stat as stat11, writeFile as writeFile12 } from "fs/promises";
|
|
18986
18988
|
import path17 from "path";
|
|
18987
18989
|
|
|
18988
18990
|
// src/core/e2e-automation-schema.ts
|
|
@@ -19012,6 +19014,7 @@ var BROWSER_ACTION_TYPES = [
|
|
|
19012
19014
|
"context.extract",
|
|
19013
19015
|
"page.assert_step",
|
|
19014
19016
|
"list.assert_record",
|
|
19017
|
+
"list.assert_cell",
|
|
19015
19018
|
"message.open",
|
|
19016
19019
|
"message.assert_delivery",
|
|
19017
19020
|
"file.download",
|
|
@@ -19058,6 +19061,7 @@ var CHECK_TYPES = /* @__PURE__ */ new Set([
|
|
|
19058
19061
|
"wait.route",
|
|
19059
19062
|
"page.assert_step",
|
|
19060
19063
|
"list.assert_record",
|
|
19064
|
+
"list.assert_cell",
|
|
19061
19065
|
"message.assert_delivery"
|
|
19062
19066
|
]);
|
|
19063
19067
|
var MUTATION_READBACK_CHECK_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -19151,7 +19155,10 @@ function actionTargetMatchesField(action, field, label) {
|
|
|
19151
19155
|
const actionLabels = [
|
|
19152
19156
|
stringValue2(target.label),
|
|
19153
19157
|
stringValue2(target.name),
|
|
19154
|
-
stringValue2(target.text)
|
|
19158
|
+
stringValue2(target.text),
|
|
19159
|
+
stringValue2(target.table_label),
|
|
19160
|
+
stringValue2(target.column_label),
|
|
19161
|
+
stringValue2(action.table)
|
|
19155
19162
|
].filter(Boolean);
|
|
19156
19163
|
return actionFields.includes(field) || actionLabels.includes(label);
|
|
19157
19164
|
}
|
|
@@ -19357,7 +19364,7 @@ function formContractIssues(rawStep, stepKey, required) {
|
|
|
19357
19364
|
const hasWrite = actions.some((action) => isRecord8(action) && allowedWrites.has(stringValue2(action.type)) && actionTargetMatchesField(action, field, label));
|
|
19358
19365
|
const hasAssertion = checks.some((check) => isRecord8(check) && stringValue2(check.type) === "form.assert_value" && actionTargetMatchesField(check, field, label)) || // Upload execution validates selected file metadata and server response;
|
|
19359
19366
|
// a text-value assertion cannot represent a browser File object.
|
|
19360
|
-
controlType === "bp-upload" && actions.some((action) => isRecord8(action) && stringValue2(action.type) === "form.upload_file" && actionTargetMatchesField(action, field, label));
|
|
19367
|
+
controlType === "bp-upload" && actions.some((action) => isRecord8(action) && stringValue2(action.type) === "form.upload_file" && actionTargetMatchesField(action, field, label)) || controlType === "sub_form" && checks.some((check) => isRecord8(check) && stringValue2(check.type) === "detail.assert_rows" && [field, label].includes(stringValue2(check.table)) && Number(check.count) > 0);
|
|
19361
19368
|
if (!hasWrite || !hasAssertion) {
|
|
19362
19369
|
issues.push({
|
|
19363
19370
|
rule_id: "test_suite.automation.required_field_uncovered",
|
|
@@ -19611,11 +19618,40 @@ function actionIssues(action, stepKey, index, check, resolutionOutcome) {
|
|
|
19611
19618
|
message: `${stepKey} action[${index}] form.assert_value match must be exact, contains, or non_empty`
|
|
19612
19619
|
});
|
|
19613
19620
|
}
|
|
19614
|
-
if (
|
|
19621
|
+
if (type === "form.assert_value" && action.count !== void 0 && (!Number.isInteger(action.count) || Number(action.count) < 0)) {
|
|
19622
|
+
issues.push({
|
|
19623
|
+
rule_id: "test_suite.automation.form_value_count_invalid",
|
|
19624
|
+
step_key: stepKey,
|
|
19625
|
+
message: `${stepKey} action[${index}] form.assert_value count must be a non-negative integer`
|
|
19626
|
+
});
|
|
19627
|
+
}
|
|
19628
|
+
if (type === "form.assert_value" && action.tag_name !== void 0 && !["input", "textarea", "select"].includes(stringValue2(action.tag_name))) {
|
|
19629
|
+
issues.push({
|
|
19630
|
+
rule_id: "test_suite.automation.form_value_tag_invalid",
|
|
19631
|
+
step_key: stepKey,
|
|
19632
|
+
message: `${stepKey} action[${index}] form.assert_value tag_name must be input, textarea, or select`
|
|
19633
|
+
});
|
|
19634
|
+
}
|
|
19635
|
+
if (type === "form.assert_value" && action.input_type !== void 0 && !stringValue2(action.input_type)) {
|
|
19636
|
+
issues.push({
|
|
19637
|
+
rule_id: "test_suite.automation.form_value_input_type_invalid",
|
|
19638
|
+
step_key: stepKey,
|
|
19639
|
+
message: `${stepKey} action[${index}] form.assert_value input_type must be a non-empty string`
|
|
19640
|
+
});
|
|
19641
|
+
}
|
|
19642
|
+
if (type === "form.assert_value" && action.disabled !== void 0 && typeof action.disabled !== "boolean") {
|
|
19643
|
+
issues.push({
|
|
19644
|
+
rule_id: "test_suite.automation.form_value_disabled_invalid",
|
|
19645
|
+
step_key: stepKey,
|
|
19646
|
+
message: `${stepKey} action[${index}] form.assert_value disabled must be boolean`
|
|
19647
|
+
});
|
|
19648
|
+
}
|
|
19649
|
+
const semanticDetailTarget = isRecord8(action.target) && Boolean(stringValue2(action.target.table_label)) && Boolean(stringValue2(action.target.column_label));
|
|
19650
|
+
if (["detail.add_row", "detail.assert_rows"].includes(type) && !stringValue2(action.table)) {
|
|
19615
19651
|
issues.push({ rule_id: "test_suite.automation.target_missing", step_key: stepKey, message: `${stepKey} action[${index}] requires table` });
|
|
19616
19652
|
}
|
|
19617
|
-
if (type === "detail.set_value" && (!stringValue2(action.field) || !Number.isInteger(action.row) || Number(action.row) < 0)) {
|
|
19618
|
-
issues.push({ rule_id: "test_suite.automation.detail_target_invalid", step_key: stepKey, message: `${stepKey} action[${index}] requires field and a zero-based row` });
|
|
19653
|
+
if (type === "detail.set_value" && !semanticDetailTarget && (!stringValue2(action.table) || !stringValue2(action.field) || !Number.isInteger(action.row) || Number(action.row) < 0)) {
|
|
19654
|
+
issues.push({ rule_id: "test_suite.automation.detail_target_invalid", step_key: stepKey, message: `${stepKey} action[${index}] requires a semantic table/column target or table, field, and a zero-based row` });
|
|
19619
19655
|
}
|
|
19620
19656
|
if (type === "navigation.open" && !stringValue2(action.route)) {
|
|
19621
19657
|
issues.push({ rule_id: "test_suite.automation.route_missing", step_key: stepKey, message: `${stepKey} action[${index}] requires route` });
|
|
@@ -19638,6 +19674,21 @@ function actionIssues(action, stepKey, index, check, resolutionOutcome) {
|
|
|
19638
19674
|
if (type === "list.assert_record" && !stringValue2(action.text) && !stringValue2(action.value)) {
|
|
19639
19675
|
issues.push({ rule_id: "test_suite.automation.expected_check_invalid", step_key: stepKey, message: `${stepKey} action[${index}] list.assert_record requires text or value` });
|
|
19640
19676
|
}
|
|
19677
|
+
if (type === "list.assert_cell") {
|
|
19678
|
+
const listCellTarget = isRecord8(action.target) ? action.target : {};
|
|
19679
|
+
if (!stringValue2(action.source)) {
|
|
19680
|
+
issues.push({ rule_id: "test_suite.automation.list_cell_anchor_missing", step_key: stepKey, message: `${stepKey} action[${index}] list.assert_cell requires source with the unique row anchor` });
|
|
19681
|
+
}
|
|
19682
|
+
if (!stringValue2(listCellTarget.column_label)) {
|
|
19683
|
+
issues.push({ rule_id: "test_suite.automation.list_cell_column_missing", step_key: stepKey, message: `${stepKey} action[${index}] list.assert_cell requires target.column_label` });
|
|
19684
|
+
}
|
|
19685
|
+
if (action.value === void 0) {
|
|
19686
|
+
issues.push({ rule_id: "test_suite.automation.list_cell_value_missing", step_key: stepKey, message: `${stepKey} action[${index}] list.assert_cell requires value; use an empty string to assert an empty cell` });
|
|
19687
|
+
}
|
|
19688
|
+
if (action.match !== void 0 && !["exact", "contains", "non_empty"].includes(stringValue2(action.match))) {
|
|
19689
|
+
issues.push({ rule_id: "test_suite.automation.value_match_invalid", step_key: stepKey, message: `${stepKey} action[${index}] list.assert_cell match must be exact, contains, or non_empty` });
|
|
19690
|
+
}
|
|
19691
|
+
}
|
|
19641
19692
|
if (type === "message.open") {
|
|
19642
19693
|
if (action.collateral_mutation !== "message.read") {
|
|
19643
19694
|
issues.push({
|
|
@@ -20007,7 +20058,7 @@ function validateBrowserAutomationDataProfile(step, data, stepKey) {
|
|
|
20007
20058
|
|
|
20008
20059
|
// src/core/e2e-browser-runner.ts
|
|
20009
20060
|
import { createHash as createHash10 } from "crypto";
|
|
20010
|
-
import { lstat as lstat3, mkdir as mkdir11, readFile as readFile15, realpath as realpath5, rename as rename3, stat as stat10, writeFile as writeFile11 } from "fs/promises";
|
|
20061
|
+
import { chmod as chmod2, lstat as lstat3, mkdir as mkdir11, readFile as readFile15, realpath as realpath5, rename as rename3, stat as stat10, writeFile as writeFile11 } from "fs/promises";
|
|
20011
20062
|
import path16 from "path";
|
|
20012
20063
|
import {
|
|
20013
20064
|
chromium
|
|
@@ -20447,7 +20498,7 @@ function identityStepOperation(step) {
|
|
|
20447
20498
|
if (/(mock|模拟用户|(?:确保|切换).{0,8}(?:身份|用户))/i.test(text5)) return "mock";
|
|
20448
20499
|
return null;
|
|
20449
20500
|
}
|
|
20450
|
-
var BROWSER_TOOL_RE = /(Chrome Control|chrome:control-chrome|Chrome DevTools|DevTools|Playwright|AppleScript|app_in_browser|App in Browser)/i;
|
|
20501
|
+
var BROWSER_TOOL_RE = /(Chrome plugin|Chrome Control|chrome:control-chrome|Chrome DevTools|DevTools|Playwright|AppleScript|app_in_browser|App in Browser)/i;
|
|
20451
20502
|
var REPORT_EVIDENCE_PLACEHOLDER_RE = /^(?:n\/?a|none|null|todo|tbd|xxx|unknown|pending|待补|暂无|无|未执行|跳过|-+)$/i;
|
|
20452
20503
|
var LIVE_DRAFT_RE = /(live|draft|已发布|草稿|发布态|live_draft=)/i;
|
|
20453
20504
|
var MULTI_ROLE_VALUE_RE = /[,、/]\s*[^,、/\s]+|多角色|跨角色/;
|
|
@@ -20476,6 +20527,19 @@ var TestSuiteError = class extends Error {
|
|
|
20476
20527
|
this.suggestion = options.suggestion;
|
|
20477
20528
|
}
|
|
20478
20529
|
};
|
|
20530
|
+
var IDENTITY_PHASE_CONTRACT_FIELDS = [
|
|
20531
|
+
"identity_id",
|
|
20532
|
+
"case_id",
|
|
20533
|
+
"phase",
|
|
20534
|
+
"actor",
|
|
20535
|
+
"required_exact_id",
|
|
20536
|
+
"required_exact_name",
|
|
20537
|
+
"authorization_rule",
|
|
20538
|
+
"binding_source",
|
|
20539
|
+
"status",
|
|
20540
|
+
"pre_action_readback",
|
|
20541
|
+
"cleanup_policy"
|
|
20542
|
+
];
|
|
20479
20543
|
function runtimeRoute(runtimeUrl) {
|
|
20480
20544
|
const url = new URL(runtimeUrl);
|
|
20481
20545
|
const hashRoute = url.hash.startsWith("#/") ? new URL(url.hash.slice(1), url.origin) : null;
|
|
@@ -20677,6 +20741,93 @@ async function readCaseSteps(filePath) {
|
|
|
20677
20741
|
return row;
|
|
20678
20742
|
});
|
|
20679
20743
|
}
|
|
20744
|
+
function identityContractIncludesCase(expression, caseId) {
|
|
20745
|
+
return expression.split("|").map((value) => value.trim()).filter(Boolean).some((token) => {
|
|
20746
|
+
if (token === caseId) return true;
|
|
20747
|
+
const range = token.match(/^([A-Za-z_-]*?)(\d+)-([A-Za-z_-]*?)(\d+)$/);
|
|
20748
|
+
const candidate = caseId.match(/^([A-Za-z_-]*?)(\d+)$/);
|
|
20749
|
+
if (!range || !candidate) return false;
|
|
20750
|
+
const startPrefix = range[1];
|
|
20751
|
+
const endPrefix = range[3] || startPrefix;
|
|
20752
|
+
return candidate[1] === startPrefix && startPrefix === endPrefix && Number(candidate[2]) >= Number(range[2]) && Number(candidate[2]) <= Number(range[4]);
|
|
20753
|
+
});
|
|
20754
|
+
}
|
|
20755
|
+
async function readIdentityPhaseContracts(scenarioDir) {
|
|
20756
|
+
const filePath = path15.join(scenarioDir, "contracts", "identity-phase-contracts.csv");
|
|
20757
|
+
if (!await exists3(filePath)) return [];
|
|
20758
|
+
const text5 = (await readText(filePath)).replace(/^\uFEFF/, "");
|
|
20759
|
+
const lines = text5.split(/\r?\n/).filter((line) => line.length > 0);
|
|
20760
|
+
const fields = lines.length ? splitCsvLine(lines[0]) : [];
|
|
20761
|
+
if (JSON.stringify(fields) !== JSON.stringify(IDENTITY_PHASE_CONTRACT_FIELDS)) {
|
|
20762
|
+
fail(`${filePath}: CSV fields must be exactly ${JSON.stringify(IDENTITY_PHASE_CONTRACT_FIELDS)}`, {
|
|
20763
|
+
rule_id: "test_suite.identity_phase.header",
|
|
20764
|
+
path: filePath
|
|
20765
|
+
});
|
|
20766
|
+
}
|
|
20767
|
+
return lines.slice(1).map((line) => {
|
|
20768
|
+
const values = splitCsvLine(line);
|
|
20769
|
+
const row = {};
|
|
20770
|
+
IDENTITY_PHASE_CONTRACT_FIELDS.forEach((field, index) => {
|
|
20771
|
+
row[field] = values[index] ?? "";
|
|
20772
|
+
});
|
|
20773
|
+
return row;
|
|
20774
|
+
});
|
|
20775
|
+
}
|
|
20776
|
+
async function validateIdentityPhaseContracts(scenarioDir, stepsByCase, selectedCaseIds) {
|
|
20777
|
+
const contracts = await readIdentityPhaseContracts(scenarioDir);
|
|
20778
|
+
if (contracts.length === 0) return;
|
|
20779
|
+
const contractPath = path15.join(scenarioDir, "contracts", "identity-phase-contracts.csv");
|
|
20780
|
+
for (const contract of contracts) {
|
|
20781
|
+
const exactUserId = Number(contract.required_exact_id);
|
|
20782
|
+
if (contract.status !== "exact_identity_verified" || !Number.isSafeInteger(exactUserId) || exactUserId <= 0) continue;
|
|
20783
|
+
for (const [caseId, caseSteps] of stepsByCase) {
|
|
20784
|
+
if (selectedCaseIds && !selectedCaseIds.has(caseId)) continue;
|
|
20785
|
+
if (!identityContractIncludesCase(contract.case_id, caseId)) continue;
|
|
20786
|
+
const ordered = [...caseSteps].sort((left, right) => Number(left.step_no) - Number(right.step_no));
|
|
20787
|
+
const businessSteps = ordered.filter((step) => step.actor === contract.actor && step.runner !== "identity");
|
|
20788
|
+
if (businessSteps.length === 0) continue;
|
|
20789
|
+
const firstBusinessStepNo = Number(businessSteps[0].step_no);
|
|
20790
|
+
const lastBusinessStepNo = Number(businessSteps.at(-1).step_no);
|
|
20791
|
+
const mockSteps = ordered.filter((step) => step.runner === "identity" && identityStepOperation(step) === "mock" && step.actor === contract.actor && Number(step.step_no) < firstBusinessStepNo);
|
|
20792
|
+
if (mockSteps.length !== 1) {
|
|
20793
|
+
fail(`${contractPath}:${contract.identity_id}:${caseId}: actor=${contract.actor} \u7684\u9996\u4E2A\u4E1A\u52A1\u6B65\u9AA4\u524D\u5FC5\u987B\u6709\u4E14\u53EA\u6709\u4E00\u4E2A\u5DF2\u5BA1\u6838 runner=identity mock \u6B65\u9AA4`, {
|
|
20794
|
+
rule_id: "test_suite.identity_phase.mock_missing",
|
|
20795
|
+
path: contractPath,
|
|
20796
|
+
suggestion: `Add a phase_bound identity step before ${caseId}/${businessSteps[0].step_id} with user_id=${exactUserId}; actor alone never switches the Playwright session.`
|
|
20797
|
+
});
|
|
20798
|
+
}
|
|
20799
|
+
const declaredUserId = mockSteps[0].input_data.match(/(?:user_id|用户ID|用户 id)\s*[=::]\s*(\d+)/i)?.[1];
|
|
20800
|
+
if (Number(declaredUserId) !== exactUserId) {
|
|
20801
|
+
fail(`${contractPath}:${contract.identity_id}:${caseId}: identity mock user_id \u5FC5\u987B\u4E0E required_exact_id=${exactUserId} \u5B8C\u5168\u4E00\u81F4`, {
|
|
20802
|
+
rule_id: "test_suite.identity_phase.mock_target_mismatch",
|
|
20803
|
+
path: contractPath
|
|
20804
|
+
});
|
|
20805
|
+
}
|
|
20806
|
+
if (/unmock|restore|恢复/i.test(contract.cleanup_policy)) {
|
|
20807
|
+
const unmockSteps = ordered.filter((step) => step.runner === "identity" && identityStepOperation(step) === "unmock" && Number(step.step_no) > lastBusinessStepNo);
|
|
20808
|
+
if (unmockSteps.length !== 1) {
|
|
20809
|
+
fail(`${contractPath}:${contract.identity_id}:${caseId}: cleanup_policy=${contract.cleanup_policy} \u8981\u6C42\u4E1A\u52A1\u9636\u6BB5\u540E\u6709\u4E14\u53EA\u6709\u4E00\u4E2A runner=identity unmock \u6B65\u9AA4`, {
|
|
20810
|
+
rule_id: "test_suite.identity_phase.unmock_missing",
|
|
20811
|
+
path: contractPath,
|
|
20812
|
+
suggestion: `Add a phase_bound unmock step after ${caseId}/${businessSteps.at(-1).step_id}.`
|
|
20813
|
+
});
|
|
20814
|
+
}
|
|
20815
|
+
}
|
|
20816
|
+
}
|
|
20817
|
+
}
|
|
20818
|
+
}
|
|
20819
|
+
async function validateExecutionManifestIdentityContracts(manifest) {
|
|
20820
|
+
const stepsByCase = /* @__PURE__ */ new Map();
|
|
20821
|
+
for (const step of manifest.steps) {
|
|
20822
|
+
const values = stepsByCase.get(step.case_id) ?? [];
|
|
20823
|
+
values.push(step);
|
|
20824
|
+
stepsByCase.set(step.case_id, values);
|
|
20825
|
+
}
|
|
20826
|
+
const selectedCaseIds = new Set(
|
|
20827
|
+
manifest.selected_case_ids?.length ? manifest.selected_case_ids : [manifest.case_id]
|
|
20828
|
+
);
|
|
20829
|
+
await validateIdentityPhaseContracts(manifest.source_suite, stepsByCase, selectedCaseIds);
|
|
20830
|
+
}
|
|
20680
20831
|
async function writeAtomicText(filePath, content) {
|
|
20681
20832
|
const resolved = path15.resolve(filePath);
|
|
20682
20833
|
const tempPath = `${resolved}.tmp-${process.pid}-${Date.now()}`;
|
|
@@ -21204,7 +21355,7 @@ function validatePreflightEvidence(filePath, caseId, row, steps, prepTokens) {
|
|
|
21204
21355
|
fail(`${filePath}:${caseId}: \`prep_data\` \u5FC5\u987B\u5305\u542B \`precondition_check=\`\uFF0C\u5426\u5219\u53EA\u80FD\u8FDB\u5165\u51C6\u5907\u9636\u6BB5\uFF0C\u4E0D\u80FD\u5F00\u59CB\u6B63\u5F0F E2E \u6267\u884C`, { rule_id: "test_suite.case.precondition_check" });
|
|
21205
21356
|
}
|
|
21206
21357
|
if (!prepTokens.browser_tool || !BROWSER_TOOL_RE.test(prepTokens.browser_tool)) {
|
|
21207
|
-
fail(`${filePath}:${caseId}: E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E\u6D4F\u89C8\u5668\u5DE5\u5177\u8BC1\u636E\
|
|
21358
|
+
fail(`${filePath}:${caseId}: E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E\u6D4F\u89C8\u5668\u5DE5\u5177\u8BC1\u636E\uFF1BV2 \u5F55\u5236\u4F7F\u7528 \`browser_tool=Chrome plugin\`\uFF0C\u7A33\u5B9A\u590D\u8DD1\u4F7F\u7528 Playwright`, { rule_id: "test_suite.case.browser_tool" });
|
|
21208
21359
|
}
|
|
21209
21360
|
if (!prepTokens.live_draft || !LIVE_DRAFT_RE.test(prepTokens.live_draft)) {
|
|
21210
21361
|
fail(`${filePath}:${caseId}: E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E\u672C\u8F6E\u76EE\u6807\u662F live \u53D1\u5E03\u6001\u8FD8\u662F draft \u8349\u7A3F\u6001`, { rule_id: "test_suite.case.live_draft" });
|
|
@@ -21587,6 +21738,7 @@ async function validateScenario(scenarioDir) {
|
|
|
21587
21738
|
const caseStepsPath = path15.join(scenarioDir, "case_steps.csv");
|
|
21588
21739
|
const caseSteps = await readCaseSteps(caseStepsPath);
|
|
21589
21740
|
const stepsByCase = validateCaseSteps(caseStepsPath, rows2, caseSteps);
|
|
21741
|
+
await validateIdentityPhaseContracts(scenarioDir, stepsByCase);
|
|
21590
21742
|
await validateScenarioAutomation(scenarioDir, caseSteps);
|
|
21591
21743
|
if (rows2.length === 0) fail(`${casesPath}: at least one case is required`);
|
|
21592
21744
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -22658,6 +22810,8 @@ async function prepareV2TestSuiteConfirmation(options) {
|
|
|
22658
22810
|
digest: request.digest,
|
|
22659
22811
|
confirmation_required: true,
|
|
22660
22812
|
exact_confirmation_text_required: false,
|
|
22813
|
+
autonomous_accept_supported: true,
|
|
22814
|
+
acceptance_modes: ["explicit_user_confirmation", "explicit_test_request"],
|
|
22661
22815
|
confirmation_summary: {
|
|
22662
22816
|
scope: request.scope,
|
|
22663
22817
|
scenario_ids: request.scenario_ids,
|
|
@@ -22679,25 +22833,46 @@ async function acceptV2TestSuiteConfirmation(options) {
|
|
|
22679
22833
|
const base = { ...request };
|
|
22680
22834
|
delete base.digest;
|
|
22681
22835
|
if (request.version !== 1 || request.kind !== "bpmax_e2e_v2_confirmation_request" || request.state !== "pending" || request.digest !== v2ConfirmationDigest(base)) fail(`invalid V2 confirmation request: ${requestPath}`, { rule_id: "test_suite.v2_confirmation.request_invalid", path: requestPath });
|
|
22682
|
-
if (options.confirmed
|
|
22836
|
+
if (options.confirmed === true && options.autonomous === true) {
|
|
22837
|
+
fail("V2 confirmation acceptance must use either explicit confirmation or autonomous test-request authorization, not both", {
|
|
22838
|
+
rule_id: "test_suite.v2_confirmation.mode_conflict",
|
|
22839
|
+
path: requestPath
|
|
22840
|
+
});
|
|
22841
|
+
}
|
|
22842
|
+
if (options.autonomous === true && request.scope === "shared_scenario_replace") {
|
|
22843
|
+
fail("Replacing a shared V2 scenario cannot use autonomous test-request authorization", {
|
|
22844
|
+
rule_id: "test_suite.v2_confirmation.autonomous_shared_replace_forbidden",
|
|
22845
|
+
path: requestPath,
|
|
22846
|
+
suggestion: "Keep the isolated draft, or obtain explicit confirmation before replacing the shared scenario."
|
|
22847
|
+
});
|
|
22848
|
+
}
|
|
22849
|
+
if (options.confirmed !== true && options.autonomous !== true) {
|
|
22683
22850
|
fail("V2 confirmation request has not been explicitly confirmed by the user", {
|
|
22684
22851
|
rule_id: "test_suite.v2_confirmation.explicit_confirmation_required",
|
|
22685
22852
|
path: requestPath,
|
|
22686
|
-
suggestion: "
|
|
22853
|
+
suggestion: "Use --confirmed after a separate confirmation, or --autonomous when the current explicit test request already authorizes automatic execution of the displayed scope."
|
|
22687
22854
|
});
|
|
22688
22855
|
}
|
|
22856
|
+
const confirmationMode = options.autonomous === true ? "explicit_test_request" : "explicit_user_confirmation";
|
|
22689
22857
|
const receipt = {
|
|
22690
22858
|
...request,
|
|
22691
22859
|
kind: "bpmax_e2e_v2_confirmation_receipt",
|
|
22692
22860
|
state: "accepted",
|
|
22693
|
-
confirmation_mode:
|
|
22861
|
+
confirmation_mode: confirmationMode,
|
|
22694
22862
|
request: requestPath,
|
|
22695
22863
|
request_sha256: await sha256(requestPath),
|
|
22696
22864
|
accepted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
22697
22865
|
};
|
|
22698
22866
|
const receiptPath = path15.resolve(options.receipt ?? path15.join(path15.dirname(requestPath), V2_CONFIRMATION_RECEIPT));
|
|
22699
22867
|
await writeAtomicJson(receiptPath, receipt);
|
|
22700
|
-
return {
|
|
22868
|
+
return {
|
|
22869
|
+
ok: true,
|
|
22870
|
+
receipt: receiptPath,
|
|
22871
|
+
digest: receipt.digest,
|
|
22872
|
+
scope: receipt.scope,
|
|
22873
|
+
confirmation_mode: receipt.confirmation_mode,
|
|
22874
|
+
continue_without_second_confirmation: receipt.confirmation_mode === "explicit_test_request"
|
|
22875
|
+
};
|
|
22701
22876
|
}
|
|
22702
22877
|
async function validateV2Confirmation(options) {
|
|
22703
22878
|
if (!options.required) return void 0;
|
|
@@ -22733,7 +22908,7 @@ async function validateV2Confirmation(options) {
|
|
|
22733
22908
|
const expectedScopes = Array.isArray(options.scope) ? options.scope : [options.scope];
|
|
22734
22909
|
const receiptScenarios = [...receipt.scenario_ids ?? []].sort();
|
|
22735
22910
|
const receiptCases = normalizedCaseIds(receipt.selected_case_ids ?? []);
|
|
22736
|
-
if (receipt.version !== 1 || receipt.kind !== "bpmax_e2e_v2_confirmation_receipt" || receipt.state !== "accepted" || !expectedScopes.includes(receipt.scope) || JSON.stringify(receiptScenarios) !== JSON.stringify(scenarioIds) || (options.validateCaseIds ?? true) && JSON.stringify(receiptCases) !== JSON.stringify(expectedCaseIds) || receipt.confirmation_mode
|
|
22911
|
+
if (receipt.version !== 1 || receipt.kind !== "bpmax_e2e_v2_confirmation_receipt" || receipt.state !== "accepted" || !expectedScopes.includes(receipt.scope) || JSON.stringify(receiptScenarios) !== JSON.stringify(scenarioIds) || (options.validateCaseIds ?? true) && JSON.stringify(receiptCases) !== JSON.stringify(expectedCaseIds) || !["explicit_user_confirmation", "explicit_test_request"].includes(receipt.confirmation_mode) || !receipt.accepted_at || Number.isNaN(Date.parse(receipt.accepted_at))) fail("V2 confirmation receipt does not match this scenario, selected cases, or operation scope", {
|
|
22737
22912
|
rule_id: "test_suite.v2_confirmation.scope_mismatch",
|
|
22738
22913
|
path: receiptPath
|
|
22739
22914
|
});
|
|
@@ -23215,12 +23390,8 @@ async function assertExecutionManifestFresh(manifest, manifestPath) {
|
|
|
23215
23390
|
path: manifestPath
|
|
23216
23391
|
});
|
|
23217
23392
|
}
|
|
23218
|
-
if (
|
|
23219
|
-
|
|
23220
|
-
rule_id: stale.rule_id,
|
|
23221
|
-
path: stale.path,
|
|
23222
|
-
suggestion: "Do not continue this manifest with changed Agent instructions. Start a new run after reviewing and syncing the Skill bundle."
|
|
23223
|
-
});
|
|
23393
|
+
if (manifest.result === "running" || manifest.mutation_attempt_guard) {
|
|
23394
|
+
await validateExecutionManifestIdentityContracts(manifest);
|
|
23224
23395
|
}
|
|
23225
23396
|
if (manifest.mutation_attempt_guard && !manifest.active_run_lease) {
|
|
23226
23397
|
fail("execution manifest has an unresolved mutation attempt without its active-run lease", {
|
|
@@ -23258,20 +23429,27 @@ async function executionManifestStaleReason(manifest) {
|
|
|
23258
23429
|
if (currentHash !== manifest.suite_hash) {
|
|
23259
23430
|
return { rule_id: "test_suite.run.suite_stale", path: manifest.source_suite };
|
|
23260
23431
|
}
|
|
23261
|
-
|
|
23262
|
-
|
|
23263
|
-
|
|
23264
|
-
|
|
23265
|
-
|
|
23266
|
-
|
|
23267
|
-
|
|
23268
|
-
|
|
23269
|
-
|
|
23270
|
-
|
|
23271
|
-
|
|
23432
|
+
return null;
|
|
23433
|
+
}
|
|
23434
|
+
async function executionManifestSkillWarnings(manifest) {
|
|
23435
|
+
if (!manifest.skill_sources?.length || !manifest.skill_bundle_sha256) return [];
|
|
23436
|
+
const warnings = [];
|
|
23437
|
+
for (const source of manifest.skill_sources) {
|
|
23438
|
+
let currentSkillHash = "";
|
|
23439
|
+
try {
|
|
23440
|
+
currentSkillHash = await skillBundleSha256(source);
|
|
23441
|
+
} catch {
|
|
23442
|
+
currentSkillHash = "";
|
|
23443
|
+
}
|
|
23444
|
+
if (currentSkillHash !== manifest.skill_bundle_sha256) {
|
|
23445
|
+
warnings.push({
|
|
23446
|
+
rule_id: "test_suite.run.skill_content_changed",
|
|
23447
|
+
path: source,
|
|
23448
|
+
message: "E2E Skill content changed after run start; the pinned suite, automation and runner contract remain authoritative for this run."
|
|
23449
|
+
});
|
|
23272
23450
|
}
|
|
23273
23451
|
}
|
|
23274
|
-
return
|
|
23452
|
+
return warnings;
|
|
23275
23453
|
}
|
|
23276
23454
|
async function evidenceContainsDiagnostic(evidencePath) {
|
|
23277
23455
|
const info = await stat9(evidencePath);
|
|
@@ -24336,6 +24514,7 @@ async function startTestSuiteRunUnlocked(options) {
|
|
|
24336
24514
|
if (missingCaseId) fail(`${scenarioDir}: active case not found: ${missingCaseId}`, { rule_id: "test_suite.run.case_not_found" });
|
|
24337
24515
|
const allSteps = await readCaseSteps(path15.join(scenarioDir, "case_steps.csv"));
|
|
24338
24516
|
const grouped = validateCaseSteps(path15.join(scenarioDir, "case_steps.csv"), rows2, allSteps);
|
|
24517
|
+
await validateIdentityPhaseContracts(scenarioDir, grouped, new Set(selectedCaseIds));
|
|
24339
24518
|
const selectedSteps = selectedCaseIds.flatMap((caseId) => grouped.get(caseId) ?? []);
|
|
24340
24519
|
const selectedSeen = /* @__PURE__ */ new Set();
|
|
24341
24520
|
for (const row of selectedRows) await validateCase(path15.join(scenarioDir, "cases.csv"), row, grouped.get(row.case_id) ?? [], selectedSeen);
|
|
@@ -25028,7 +25207,8 @@ async function testSuiteRunStatus(manifestPath, profile) {
|
|
|
25028
25207
|
const manifest = await readExecutionManifest(manifestPath);
|
|
25029
25208
|
await assertExecutionManifestFresh(manifest, path15.resolve(manifestPath));
|
|
25030
25209
|
if (profile && manifest.profile !== profile) fail(`execution manifest profile is ${manifest.profile}, not ${profile}`, { rule_id: "test_suite.run.profile_mismatch", path: manifestPath });
|
|
25031
|
-
|
|
25210
|
+
const warnings = await executionManifestSkillWarnings(manifest);
|
|
25211
|
+
return { ok: true, execution: manifest, ...warnings.length > 0 ? { warnings } : {} };
|
|
25032
25212
|
}
|
|
25033
25213
|
async function indexSuite(root = DEFAULT_SUITE_ROOT, includeInactive = false, options = {}) {
|
|
25034
25214
|
const items = await lintSuite(root, options);
|
|
@@ -26593,6 +26773,26 @@ function browserFormValueMatches(actual, expected, match = "exact") {
|
|
|
26593
26773
|
const expectedText = expected !== null && typeof expected === "object" ? comparableBrowserFormValue(expected) : String(expected ?? "");
|
|
26594
26774
|
return match === "contains" ? actualText.includes(expectedText) : actualText === expectedText;
|
|
26595
26775
|
}
|
|
26776
|
+
async function waitForBrowserAssertion(options) {
|
|
26777
|
+
const deadline = Date.now() + options.timeout;
|
|
26778
|
+
const interval = Math.max(10, options.interval ?? 100);
|
|
26779
|
+
const sleep = options.sleep ?? ((milliseconds) => new Promise((resolve) => {
|
|
26780
|
+
setTimeout(resolve, milliseconds);
|
|
26781
|
+
}));
|
|
26782
|
+
let lastError = "browser assertion did not pass";
|
|
26783
|
+
do {
|
|
26784
|
+
try {
|
|
26785
|
+
const result = await options.evaluate();
|
|
26786
|
+
if (result.passed) return result.value;
|
|
26787
|
+
lastError = result.error;
|
|
26788
|
+
} catch (error) {
|
|
26789
|
+
lastError = error instanceof Error ? error.message : String(error);
|
|
26790
|
+
}
|
|
26791
|
+
if (Date.now() >= deadline) break;
|
|
26792
|
+
await sleep(Math.min(interval, Math.max(0, deadline - Date.now())));
|
|
26793
|
+
} while (Date.now() <= deadline);
|
|
26794
|
+
throw new Error(lastError);
|
|
26795
|
+
}
|
|
26596
26796
|
function browserListRecordCountMatches(actualCount, expectedCount) {
|
|
26597
26797
|
return expectedCount === void 0 ? actualCount > 0 : actualCount === expectedCount;
|
|
26598
26798
|
}
|
|
@@ -26746,6 +26946,12 @@ function browserNetworkResponseAfterCursor(responses, urlPattern, cursor) {
|
|
|
26746
26946
|
function browserActionNetworkCursor(actionType, currentActionCursor, previousActionCursor) {
|
|
26747
26947
|
return actionType === "form.upload_file" ? currentActionCursor : previousActionCursor;
|
|
26748
26948
|
}
|
|
26949
|
+
function browserExpectedCheckPhase(check, hasMutationAction) {
|
|
26950
|
+
if (hasMutationAction && ["form.assert_value", "detail.assert_rows"].includes(check.type)) {
|
|
26951
|
+
return "pre_mutation";
|
|
26952
|
+
}
|
|
26953
|
+
return "post_action";
|
|
26954
|
+
}
|
|
26749
26955
|
function browserMutationUrlPatterns(action) {
|
|
26750
26956
|
const patterns = [String(action.url_pattern ?? "").trim()];
|
|
26751
26957
|
if (action.collateral_mutation === "project.share") {
|
|
@@ -26963,6 +27169,17 @@ async function locatorForTarget(page, target) {
|
|
|
26963
27169
|
}
|
|
26964
27170
|
throw new Error("browser action target is empty");
|
|
26965
27171
|
}
|
|
27172
|
+
async function detailValueLocator(page, action) {
|
|
27173
|
+
if (action.target?.table_label && action.target.column_label) {
|
|
27174
|
+
return editableLocator(await locatorForTarget(page, action.target));
|
|
27175
|
+
}
|
|
27176
|
+
const table = await tableLocator(page, String(action.table));
|
|
27177
|
+
const row = table.locator(".el-table__body tr, tbody tr").nth(Number(action.row));
|
|
27178
|
+
const field = String(action.field);
|
|
27179
|
+
const escaped = field.replace(/["\\]/g, "\\$&");
|
|
27180
|
+
const target = row.locator(`[data-field-key="${escaped}"], [field="${escaped}"], [name="${escaped}"]`).first();
|
|
27181
|
+
return editableLocator(target);
|
|
27182
|
+
}
|
|
26966
27183
|
async function editableLocator(locator) {
|
|
26967
27184
|
const tagName = await locator.evaluate((element) => element.tagName.toLowerCase()).catch(() => "");
|
|
26968
27185
|
if (["input", "textarea", "select"].includes(tagName)) return locator;
|
|
@@ -26979,6 +27196,23 @@ async function editableLocator(locator) {
|
|
|
26979
27196
|
const groupedEditable = semanticGroup.locator("input:not([type=hidden]), textarea, [contenteditable=true], select");
|
|
26980
27197
|
return await groupedEditable.count() ? groupedEditable.first() : locator;
|
|
26981
27198
|
}
|
|
27199
|
+
async function setBrowserEditableValue(locator, value) {
|
|
27200
|
+
const text5 = String(value ?? "");
|
|
27201
|
+
const control = await locator.evaluate((element) => ({
|
|
27202
|
+
inputNumber: Boolean(element.closest(".el-input-number")),
|
|
27203
|
+
dateEditor: Boolean(element.closest(".el-date-editor"))
|
|
27204
|
+
})).catch(() => ({ inputNumber: false, dateEditor: false }));
|
|
27205
|
+
if (control.inputNumber) {
|
|
27206
|
+
await locator.click();
|
|
27207
|
+
await locator.press("ArrowUp");
|
|
27208
|
+
await locator.press("ControlOrMeta+A");
|
|
27209
|
+
await locator.type(text5);
|
|
27210
|
+
await locator.press("Tab");
|
|
27211
|
+
return;
|
|
27212
|
+
}
|
|
27213
|
+
await locator.fill(text5);
|
|
27214
|
+
if (control.dateEditor) await locator.press("Tab");
|
|
27215
|
+
}
|
|
26982
27216
|
function targetLocatorByIndex(locator, target) {
|
|
26983
27217
|
return Number.isInteger(target?.nth) ? locator.nth(Number(target?.nth)) : locator.first();
|
|
26984
27218
|
}
|
|
@@ -27181,18 +27415,60 @@ async function readBrowserFormValue(page, target) {
|
|
|
27181
27415
|
const locator = await editableLocator(semanticTarget);
|
|
27182
27416
|
return locator.inputValue().catch(() => locator.textContent());
|
|
27183
27417
|
}
|
|
27184
|
-
async function
|
|
27185
|
-
const
|
|
27186
|
-
await
|
|
27187
|
-
|
|
27188
|
-
|
|
27189
|
-
|
|
27418
|
+
async function readBrowserFormControlMetadata(page, target) {
|
|
27419
|
+
const semanticTarget = await visibleTargetLocator(page, target);
|
|
27420
|
+
const locator = await editableLocator(semanticTarget);
|
|
27421
|
+
return {
|
|
27422
|
+
tag_name: String(await locator.evaluate((element) => element.tagName.toLowerCase())).trim(),
|
|
27423
|
+
input_type: String(await locator.getAttribute("type") ?? "").trim().toLowerCase(),
|
|
27424
|
+
disabled: await locator.isDisabled().catch(() => false)
|
|
27425
|
+
};
|
|
27426
|
+
}
|
|
27427
|
+
function browserFormControlMetadataMatches(metadata, action) {
|
|
27428
|
+
if (action.tag_name !== void 0 && metadata.tag_name !== action.tag_name) return false;
|
|
27429
|
+
if (action.input_type !== void 0 && metadata.input_type !== String(action.input_type).toLowerCase()) return false;
|
|
27430
|
+
if (action.disabled !== void 0 && metadata.disabled !== action.disabled) return false;
|
|
27431
|
+
return true;
|
|
27432
|
+
}
|
|
27433
|
+
async function selectBrowserUser(page, target, userName, expectedUserId, timeout) {
|
|
27434
|
+
const semanticTarget = await visibleTargetLocator(page, target);
|
|
27435
|
+
const formItem = nearestFormItem(semanticTarget);
|
|
27436
|
+
const pickerButton = await firstVisibleLocator(
|
|
27437
|
+
formItem.getByRole("button", { name: /添加|编辑|选择/ }),
|
|
27438
|
+
Math.min(timeout, 1e3)
|
|
27439
|
+
);
|
|
27440
|
+
await (pickerButton ?? semanticTarget).click({ timeout });
|
|
27190
27441
|
const picker = await lastVisibleLocator(page.getByRole("dialog"), timeout);
|
|
27191
27442
|
if (!picker) throw new Error("user picker dialog not visible");
|
|
27443
|
+
const search = picker.getByPlaceholder(/姓名|手机号|拼音|工号/).first();
|
|
27444
|
+
if (await search.isVisible().catch(() => false)) {
|
|
27445
|
+
await search.fill(userName);
|
|
27446
|
+
}
|
|
27447
|
+
if (expectedUserId) {
|
|
27448
|
+
const candidateRows = picker.locator(".checkbox-item-list").filter({ hasText: userName });
|
|
27449
|
+
const exactCandidates = [];
|
|
27450
|
+
const candidateCount = await candidateRows.count();
|
|
27451
|
+
for (let index = 0; index < candidateCount; index += 1) {
|
|
27452
|
+
const candidate = candidateRows.nth(index);
|
|
27453
|
+
const name = String(await candidate.locator(".item-user-name").textContent().catch(() => "") ?? "").trim();
|
|
27454
|
+
const userId = String(await candidate.locator(".item-user-id").textContent().catch(() => "") ?? "").trim();
|
|
27455
|
+
if (name === userName && userId === expectedUserId && await candidate.isVisible().catch(() => false)) {
|
|
27456
|
+
exactCandidates.push(candidate);
|
|
27457
|
+
}
|
|
27458
|
+
}
|
|
27459
|
+
if (exactCandidates.length !== 1) {
|
|
27460
|
+
throw new Error(`user picker exact candidate mismatch for ${userName}/${expectedUserId}: expected 1, got ${exactCandidates.length}`);
|
|
27461
|
+
}
|
|
27462
|
+
await exactCandidates[0].click({ timeout });
|
|
27463
|
+
} else {
|
|
27464
|
+
const option = await firstVisibleLocator(picker.getByText(userName, { exact: true }), timeout);
|
|
27465
|
+
if (!option) throw new Error(`user picker option not visible: ${userName}`);
|
|
27466
|
+
await option.click({ timeout });
|
|
27467
|
+
}
|
|
27192
27468
|
const confirm3 = picker.getByRole("button", { name: /确认|确定/ }).first();
|
|
27193
27469
|
await confirm3.waitFor({ state: "visible", timeout });
|
|
27194
27470
|
await confirm3.click({ timeout });
|
|
27195
|
-
const selected = await firstVisibleLocator(
|
|
27471
|
+
const selected = await firstVisibleLocator(formItem.getByText(userName, { exact: true }), timeout);
|
|
27196
27472
|
if (!selected) throw new Error(`selected user readback not visible: ${userName}`);
|
|
27197
27473
|
}
|
|
27198
27474
|
function browserDateRangeValues(value) {
|
|
@@ -27341,7 +27617,7 @@ async function executeAction(page, action, variables, runtime) {
|
|
|
27341
27617
|
case "form.set_value": {
|
|
27342
27618
|
const target = next.target ?? { field: next.field };
|
|
27343
27619
|
const locator = await editableLocator(await visibleTargetLocator(page, target));
|
|
27344
|
-
await locator
|
|
27620
|
+
await setBrowserEditableValue(locator, next.value);
|
|
27345
27621
|
return {};
|
|
27346
27622
|
}
|
|
27347
27623
|
case "form.set_date_range": {
|
|
@@ -27371,6 +27647,7 @@ async function executeAction(page, action, variables, runtime) {
|
|
|
27371
27647
|
page,
|
|
27372
27648
|
next.target ?? { field: next.field },
|
|
27373
27649
|
String(next.option ?? next.value ?? ""),
|
|
27650
|
+
next.source ? String(next.source) : void 0,
|
|
27374
27651
|
timeout
|
|
27375
27652
|
);
|
|
27376
27653
|
return {};
|
|
@@ -27445,19 +27722,61 @@ async function executeAction(page, action, variables, runtime) {
|
|
|
27445
27722
|
}
|
|
27446
27723
|
case "form.assert_value": {
|
|
27447
27724
|
const target = next.target ?? { field: next.field };
|
|
27448
|
-
|
|
27449
|
-
|
|
27450
|
-
|
|
27451
|
-
|
|
27452
|
-
|
|
27453
|
-
|
|
27454
|
-
|
|
27455
|
-
|
|
27456
|
-
|
|
27457
|
-
|
|
27458
|
-
|
|
27725
|
+
if (next.count !== void 0) {
|
|
27726
|
+
return waitForBrowserAssertion({
|
|
27727
|
+
timeout,
|
|
27728
|
+
evaluate: async () => {
|
|
27729
|
+
const locator = await locatorForTarget(page, target);
|
|
27730
|
+
const matchingValues = [];
|
|
27731
|
+
const locatorCount = await locator.count();
|
|
27732
|
+
for (let index = 0; index < locatorCount; index += 1) {
|
|
27733
|
+
const candidate = locator.nth(index);
|
|
27734
|
+
if (!await candidate.isVisible().catch(() => false)) continue;
|
|
27735
|
+
const actual = await readBrowserFormValue(page, { ...target, nth: index });
|
|
27736
|
+
const metadata = await readBrowserFormControlMetadata(page, { ...target, nth: index });
|
|
27737
|
+
if (browserFormValueMatches(actual, next.value, next.match ?? "exact") && browserFormControlMetadataMatches(metadata, next)) matchingValues.push(actual);
|
|
27738
|
+
}
|
|
27739
|
+
const passed = matchingValues.length === Number(next.count);
|
|
27740
|
+
return {
|
|
27741
|
+
passed,
|
|
27742
|
+
error: `form value count mismatch: expected ${next.count}, got ${matchingValues.length}`,
|
|
27743
|
+
value: {
|
|
27744
|
+
assertion: {
|
|
27745
|
+
type: next.type,
|
|
27746
|
+
passed,
|
|
27747
|
+
match: next.match ?? "exact",
|
|
27748
|
+
target,
|
|
27749
|
+
count: matchingValues.length,
|
|
27750
|
+
expected_count: next.count
|
|
27751
|
+
}
|
|
27752
|
+
}
|
|
27753
|
+
};
|
|
27754
|
+
}
|
|
27755
|
+
});
|
|
27756
|
+
}
|
|
27757
|
+
return waitForBrowserAssertion({
|
|
27758
|
+
timeout,
|
|
27759
|
+
evaluate: async () => {
|
|
27760
|
+
const actual = await readBrowserFormValue(page, target);
|
|
27761
|
+
const metadata = await readBrowserFormControlMetadata(page, target);
|
|
27762
|
+
const match = next.match ?? "exact";
|
|
27763
|
+
const passed = browserFormValueMatches(actual, next.value, match) && browserFormControlMetadataMatches(metadata, next);
|
|
27764
|
+
return {
|
|
27765
|
+
passed,
|
|
27766
|
+
error: `form value/control mismatch (${match}): expected ${String(next.value ?? "")}, got ${String(actual ?? "")}/${JSON.stringify(metadata)}`,
|
|
27767
|
+
value: {
|
|
27768
|
+
assertion: {
|
|
27769
|
+
type: next.type,
|
|
27770
|
+
passed,
|
|
27771
|
+
match,
|
|
27772
|
+
target,
|
|
27773
|
+
actual: match === "non_empty" ? "non_empty" : actual,
|
|
27774
|
+
...metadata
|
|
27775
|
+
}
|
|
27776
|
+
}
|
|
27777
|
+
};
|
|
27459
27778
|
}
|
|
27460
|
-
};
|
|
27779
|
+
});
|
|
27461
27780
|
}
|
|
27462
27781
|
case "detail.add_row": {
|
|
27463
27782
|
const table = await tableLocator(page, String(next.table));
|
|
@@ -27465,12 +27784,7 @@ async function executeAction(page, action, variables, runtime) {
|
|
|
27465
27784
|
return {};
|
|
27466
27785
|
}
|
|
27467
27786
|
case "detail.set_value": {
|
|
27468
|
-
|
|
27469
|
-
const row = table.locator(".el-table__body tr, tbody tr").nth(Number(next.row));
|
|
27470
|
-
const field = String(next.field);
|
|
27471
|
-
const escaped = field.replace(/["\\]/g, "\\$&");
|
|
27472
|
-
const target = row.locator(`[data-field-key="${escaped}"], [field="${escaped}"], [name="${escaped}"]`).first();
|
|
27473
|
-
await (await editableLocator(target)).fill(String(next.value ?? ""));
|
|
27787
|
+
await setBrowserEditableValue(await detailValueLocator(page, next), next.value);
|
|
27474
27788
|
return {};
|
|
27475
27789
|
}
|
|
27476
27790
|
case "detail.assert_rows": {
|
|
@@ -27595,6 +27909,29 @@ async function executeAction(page, action, variables, runtime) {
|
|
|
27595
27909
|
}
|
|
27596
27910
|
return { assertion: { type: next.type, passed, expected, count: visibleCount, expected_count: expectedCount } };
|
|
27597
27911
|
}
|
|
27912
|
+
case "list.assert_cell": {
|
|
27913
|
+
const rowAnchor = String(next.source ?? "");
|
|
27914
|
+
const columnLabel = String(next.target?.column_label ?? "");
|
|
27915
|
+
const headerCells = page.locator(".el-table__header-wrapper").first().locator("th .cell");
|
|
27916
|
+
const headerTexts = (await headerCells.allTextContents()).map((value) => value.replace(/\s+/g, " ").trim());
|
|
27917
|
+
const columnIndex = headerTexts.findIndex((value) => value === columnLabel || value.includes(columnLabel));
|
|
27918
|
+
if (columnIndex < 0) throw new Error(`list column not found: ${columnLabel}`);
|
|
27919
|
+
const rows2 = page.locator(".el-table__body-wrapper").first().locator("tbody tr").filter({ hasText: rowAnchor });
|
|
27920
|
+
const visibleRows = [];
|
|
27921
|
+
const rowCount = await rows2.count();
|
|
27922
|
+
for (let index = 0; index < rowCount; index += 1) {
|
|
27923
|
+
const row = rows2.nth(index);
|
|
27924
|
+
if (await row.isVisible().catch(() => false)) visibleRows.push(row);
|
|
27925
|
+
}
|
|
27926
|
+
if (visibleRows.length !== 1) {
|
|
27927
|
+
throw new Error(`list row anchor mismatch for ${rowAnchor}: expected 1, got ${visibleRows.length}`);
|
|
27928
|
+
}
|
|
27929
|
+
const actual = String(await visibleRows[0].locator("td").nth(columnIndex).innerText().catch(() => "")).replace(/\s+/g, " ").trim();
|
|
27930
|
+
const match = next.match ?? "exact";
|
|
27931
|
+
const passed = browserFormValueMatches(actual, next.value, match);
|
|
27932
|
+
if (!passed) throw new Error(`list cell mismatch for ${rowAnchor}/${columnLabel} (${match}): expected ${String(next.value ?? "")}, got ${actual}`);
|
|
27933
|
+
return { assertion: { type: next.type, passed, row_anchor: rowAnchor, column: columnLabel, match, actual } };
|
|
27934
|
+
}
|
|
27598
27935
|
case "message.open": {
|
|
27599
27936
|
const listUrlPattern = String(next.list_url_pattern ?? "");
|
|
27600
27937
|
const readUrlPattern = String(next.url_pattern ?? "");
|
|
@@ -27709,6 +28046,7 @@ async function waitForInteractiveLogin(context2, options) {
|
|
|
27709
28046
|
workspace,
|
|
27710
28047
|
preferredRoute: targetRoute,
|
|
27711
28048
|
fingerprint: options.fingerprint,
|
|
28049
|
+
fingerprintPolicy: "preferred",
|
|
27712
28050
|
requireExistingCandidate: false,
|
|
27713
28051
|
keepProbePage: true
|
|
27714
28052
|
}).catch(() => void 0);
|
|
@@ -27731,12 +28069,21 @@ async function openInteractiveLoginSession(options) {
|
|
|
27731
28069
|
});
|
|
27732
28070
|
try {
|
|
27733
28071
|
await waitForInteractiveLogin(context2, options);
|
|
28072
|
+
await persistInteractiveLoginStorageState(context2, options.storageState);
|
|
27734
28073
|
return { context: context2, owned: true };
|
|
27735
28074
|
} catch (error) {
|
|
27736
28075
|
await context2.close().catch(() => void 0);
|
|
27737
28076
|
throw error;
|
|
27738
28077
|
}
|
|
27739
28078
|
}
|
|
28079
|
+
async function persistInteractiveLoginStorageState(context2, storageStatePath) {
|
|
28080
|
+
if (!storageStatePath) return void 0;
|
|
28081
|
+
const target = path16.resolve(storageStatePath);
|
|
28082
|
+
const state = await context2.storageState();
|
|
28083
|
+
await writeAtomicJson2(target, state);
|
|
28084
|
+
await chmod2(target, 384);
|
|
28085
|
+
return target;
|
|
28086
|
+
}
|
|
27740
28087
|
function workspacePathPrefix(workspace) {
|
|
27741
28088
|
return `/w:${workspace.trim().replace(/^w:/, "")}`;
|
|
27742
28089
|
}
|
|
@@ -27848,12 +28195,14 @@ async function probeAuthenticatedContext(options) {
|
|
|
27848
28195
|
await page.waitForLoadState("networkidle", { timeout: 8e3 }).catch(() => void 0);
|
|
27849
28196
|
const finalUrl = new URL(page.url());
|
|
27850
28197
|
if (finalUrl.origin !== profileOrigin || /(?:^|\/)login(?:\/|$)/i.test(finalUrl.pathname) || !finalUrl.pathname.startsWith(workspacePrefix)) return void 0;
|
|
28198
|
+
let fingerprintMatched = false;
|
|
27851
28199
|
if (options.fingerprint) {
|
|
27852
28200
|
const failures = await assertFingerprint(page, options.fingerprint, { data: {}, context: {}, base_url: options.profileOrigin });
|
|
27853
|
-
|
|
28201
|
+
fingerprintMatched = failures.length === 0;
|
|
28202
|
+
if (!fingerprintMatched && options.fingerprintPolicy !== "preferred") return void 0;
|
|
27854
28203
|
}
|
|
27855
28204
|
passed = true;
|
|
27856
|
-
return { page, score: preferred?.score ?? 0 };
|
|
28205
|
+
return { page, score: (preferred?.score ?? 0) + (fingerprintMatched ? 4 : 0) };
|
|
27857
28206
|
} finally {
|
|
27858
28207
|
if (!passed || options.keepProbePage !== true) {
|
|
27859
28208
|
await page.close().catch(() => void 0);
|
|
@@ -27864,12 +28213,14 @@ async function openContext(options) {
|
|
|
27864
28213
|
const cookieEnv = options.cookieEnv?.trim();
|
|
27865
28214
|
const cookieHeader = !options.storageState && cookieEnv ? process.env[cookieEnv]?.trim() : void 0;
|
|
27866
28215
|
if (options.storageState || cookieHeader) {
|
|
27867
|
-
|
|
27868
|
-
|
|
28216
|
+
let browser2 = await chromium.launch({
|
|
28217
|
+
// Invalid imported authentication must not flash a disposable window before
|
|
28218
|
+
// the persistent interactive-login surface is opened.
|
|
28219
|
+
headless: true,
|
|
27869
28220
|
executablePath: options.executablePath,
|
|
27870
28221
|
channel: options.executablePath ? void 0 : "chrome"
|
|
27871
28222
|
});
|
|
27872
|
-
|
|
28223
|
+
let context3 = await browser2.newContext(options.storageState ? { storageState: path16.resolve(options.storageState) } : void 0);
|
|
27873
28224
|
if (cookieHeader) {
|
|
27874
28225
|
await installCookieLoginBootstrap(context3, options.baseUrl || "");
|
|
27875
28226
|
await context3.addCookies(browserCookiesFromHeader(cookieHeader, options.baseUrl || ""));
|
|
@@ -27880,6 +28231,7 @@ async function openContext(options) {
|
|
|
27880
28231
|
workspace: options.workspace || "new_oa",
|
|
27881
28232
|
preferredRoute: options.preferredRoute || "",
|
|
27882
28233
|
fingerprint: options.fingerprint,
|
|
28234
|
+
fingerprintPolicy: "preferred",
|
|
27883
28235
|
requireExistingCandidate: false,
|
|
27884
28236
|
keepProbePage: true
|
|
27885
28237
|
}).catch(() => void 0);
|
|
@@ -27891,6 +28243,32 @@ async function openContext(options) {
|
|
|
27891
28243
|
throw new Error(`${prefix}: supplied authentication did not pass the target-route probe and interactive recovery failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
27892
28244
|
});
|
|
27893
28245
|
}
|
|
28246
|
+
if (options.headed) {
|
|
28247
|
+
const importedState = await context3.storageState();
|
|
28248
|
+
await context3.close().catch(() => void 0);
|
|
28249
|
+
await browser2.close().catch(() => void 0);
|
|
28250
|
+
browser2 = await chromium.launch({
|
|
28251
|
+
headless: false,
|
|
28252
|
+
executablePath: options.executablePath,
|
|
28253
|
+
channel: options.executablePath ? void 0 : "chrome"
|
|
28254
|
+
});
|
|
28255
|
+
context3 = await browser2.newContext({ storageState: importedState });
|
|
28256
|
+
const headedProbe = await probeAuthenticatedContext({
|
|
28257
|
+
context: context3,
|
|
28258
|
+
profileOrigin: options.baseUrl || "",
|
|
28259
|
+
workspace: options.workspace || "new_oa",
|
|
28260
|
+
preferredRoute: options.preferredRoute || "",
|
|
28261
|
+
fingerprint: options.fingerprint,
|
|
28262
|
+
fingerprintPolicy: "preferred",
|
|
28263
|
+
requireExistingCandidate: false,
|
|
28264
|
+
keepProbePage: true
|
|
28265
|
+
}).catch(() => void 0);
|
|
28266
|
+
if (!headedProbe) {
|
|
28267
|
+
await context3.close().catch(() => void 0);
|
|
28268
|
+
await browser2.close().catch(() => void 0);
|
|
28269
|
+
return openInteractiveLoginSession(options);
|
|
28270
|
+
}
|
|
28271
|
+
}
|
|
27894
28272
|
return { context: context3, browser: browser2, owned: true };
|
|
27895
28273
|
}
|
|
27896
28274
|
if (options.cdpEndpoint) {
|
|
@@ -27909,6 +28287,7 @@ async function openContext(options) {
|
|
|
27909
28287
|
workspace,
|
|
27910
28288
|
preferredRoute,
|
|
27911
28289
|
fingerprint: options.fingerprint,
|
|
28290
|
+
fingerprintPolicy: "preferred",
|
|
27912
28291
|
requireExistingCandidate: true
|
|
27913
28292
|
}).catch(() => void 0);
|
|
27914
28293
|
if (result) probes.push({ context: candidate, ...result });
|
|
@@ -27926,6 +28305,7 @@ async function openContext(options) {
|
|
|
27926
28305
|
workspace,
|
|
27927
28306
|
preferredRoute,
|
|
27928
28307
|
fingerprint: options.fingerprint,
|
|
28308
|
+
fingerprintPolicy: "preferred",
|
|
27929
28309
|
requireExistingCandidate: false,
|
|
27930
28310
|
keepProbePage: true
|
|
27931
28311
|
}).catch(() => void 0);
|
|
@@ -27953,6 +28333,7 @@ async function openContext(options) {
|
|
|
27953
28333
|
workspace: options.workspace || "new_oa",
|
|
27954
28334
|
preferredRoute: options.preferredRoute || "",
|
|
27955
28335
|
fingerprint: options.fingerprint,
|
|
28336
|
+
fingerprintPolicy: "preferred",
|
|
27956
28337
|
requireExistingCandidate: false,
|
|
27957
28338
|
keepProbePage: true
|
|
27958
28339
|
}).catch(() => void 0);
|
|
@@ -27968,6 +28349,7 @@ async function openContext(options) {
|
|
|
27968
28349
|
});
|
|
27969
28350
|
try {
|
|
27970
28351
|
await waitForInteractiveLogin(context3, options);
|
|
28352
|
+
await persistInteractiveLoginStorageState(context3, options.storageState);
|
|
27971
28353
|
} catch (error) {
|
|
27972
28354
|
await context3.close().catch(() => void 0);
|
|
27973
28355
|
throw error;
|
|
@@ -27987,6 +28369,7 @@ async function openContext(options) {
|
|
|
27987
28369
|
workspace: options.workspace || "new_oa",
|
|
27988
28370
|
preferredRoute: options.preferredRoute || "",
|
|
27989
28371
|
fingerprint: options.fingerprint,
|
|
28372
|
+
fingerprintPolicy: "preferred",
|
|
27990
28373
|
requireExistingCandidate: false,
|
|
27991
28374
|
keepProbePage: true
|
|
27992
28375
|
}).catch(() => void 0);
|
|
@@ -28607,11 +28990,19 @@ async function runOneBrowserStep(options, session) {
|
|
|
28607
28990
|
try {
|
|
28608
28991
|
currentActionIndex = -1;
|
|
28609
28992
|
await restoreStepStartPage(page, definition, variables, actionTrace);
|
|
28993
|
+
const hasMutationAction = definition.actions.some((action) => action.mutation === true);
|
|
28994
|
+
const preMutationChecks = definition.expected_checks.filter(
|
|
28995
|
+
(check) => browserExpectedCheckPhase(check, hasMutationAction) === "pre_mutation"
|
|
28996
|
+
);
|
|
28997
|
+
const postActionChecks = definition.expected_checks.filter(
|
|
28998
|
+
(check) => browserExpectedCheckPhase(check, hasMutationAction) === "post_action"
|
|
28999
|
+
);
|
|
29000
|
+
let preMutationChecksExecuted = false;
|
|
28610
29001
|
for (let index = 0; index < definition.actions.length; index += 1) {
|
|
28611
29002
|
currentActionIndex = index;
|
|
28612
29003
|
const action = definition.actions[index];
|
|
28613
29004
|
const actionResponseCursor = responseSequence;
|
|
28614
|
-
if (!fingerprintChecked &&
|
|
29005
|
+
if (!fingerprintChecked && action.type !== "navigation.open") {
|
|
28615
29006
|
const failures = await assertFingerprint(page, definition.page_fingerprint, variables);
|
|
28616
29007
|
if (failures.length > 0) {
|
|
28617
29008
|
const evidence2 = await writeRunnerEvidence({
|
|
@@ -28651,6 +29042,20 @@ async function runOneBrowserStep(options, session) {
|
|
|
28651
29042
|
}
|
|
28652
29043
|
fingerprintChecked = true;
|
|
28653
29044
|
}
|
|
29045
|
+
if (action.mutation === true && !preMutationChecksExecuted) {
|
|
29046
|
+
for (const check of preMutationChecks) {
|
|
29047
|
+
const result2 = await executeAction(page, check, variables, {
|
|
29048
|
+
responses,
|
|
29049
|
+
responseCursor: previousActionResponseCursor,
|
|
29050
|
+
recordResponse,
|
|
29051
|
+
onMutationAttempt: async () => {
|
|
29052
|
+
throw new Error("pre-mutation expected checks cannot attempt a remote mutation");
|
|
29053
|
+
}
|
|
29054
|
+
});
|
|
29055
|
+
assertions.push(result2.assertion ?? { type: check.type, passed: true });
|
|
29056
|
+
}
|
|
29057
|
+
preMutationChecksExecuted = true;
|
|
29058
|
+
}
|
|
28654
29059
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
28655
29060
|
const result = await executeAction(page, action, variables, {
|
|
28656
29061
|
responses,
|
|
@@ -28679,6 +29084,46 @@ async function runOneBrowserStep(options, session) {
|
|
|
28679
29084
|
if (result.extracted) variables.context[result.extracted[0]] = result.extracted[1];
|
|
28680
29085
|
if (result.assertion) assertions.push(result.assertion);
|
|
28681
29086
|
actionTrace.push({ index, type: action.type, started_at: startedAt, finished_at: (/* @__PURE__ */ new Date()).toISOString(), ok: true });
|
|
29087
|
+
if (!fingerprintChecked && index === 0 && action.type === "navigation.open") {
|
|
29088
|
+
const failures = await assertFingerprint(page, definition.page_fingerprint, variables);
|
|
29089
|
+
if (failures.length > 0) {
|
|
29090
|
+
const evidence2 = await writeRunnerEvidence({
|
|
29091
|
+
dir: evidenceDir,
|
|
29092
|
+
page,
|
|
29093
|
+
caseId: requestedCase,
|
|
29094
|
+
stepId: requestedStep,
|
|
29095
|
+
runId: validated.manifest.run_id,
|
|
29096
|
+
evidenceNonce: validated.manifest.evidence_nonce,
|
|
29097
|
+
status: "cache_stale",
|
|
29098
|
+
assertions: failures.map((message) => ({ name: "page_fingerprint", passed: false, message })),
|
|
29099
|
+
actionTrace,
|
|
29100
|
+
automationStep: definition,
|
|
29101
|
+
consoleErrors,
|
|
29102
|
+
networkErrors,
|
|
29103
|
+
networkResponses: responses,
|
|
29104
|
+
remoteSubmitted: false,
|
|
29105
|
+
readbackConfirmed: false,
|
|
29106
|
+
error: failures.join("; ")
|
|
29107
|
+
});
|
|
29108
|
+
return {
|
|
29109
|
+
ok: false,
|
|
29110
|
+
status: "cache_stale",
|
|
29111
|
+
remote_submitted: false,
|
|
29112
|
+
readback_confirmed: false,
|
|
29113
|
+
llm_intervention_required: true,
|
|
29114
|
+
manifest: validated.manifestPath,
|
|
29115
|
+
case_id: requestedCase,
|
|
29116
|
+
case_step_id: requestedStep,
|
|
29117
|
+
evidence: evidence2,
|
|
29118
|
+
current_url: page.url(),
|
|
29119
|
+
error: failures.join("; "),
|
|
29120
|
+
repairable: true,
|
|
29121
|
+
failure_kind: "page_drift",
|
|
29122
|
+
failure_action_index: index
|
|
29123
|
+
};
|
|
29124
|
+
}
|
|
29125
|
+
fingerprintChecked = true;
|
|
29126
|
+
}
|
|
28682
29127
|
previousActionResponseCursor = actionResponseCursor;
|
|
28683
29128
|
}
|
|
28684
29129
|
if (!fingerprintChecked) {
|
|
@@ -28720,7 +29165,7 @@ async function runOneBrowserStep(options, session) {
|
|
|
28720
29165
|
};
|
|
28721
29166
|
}
|
|
28722
29167
|
}
|
|
28723
|
-
for (const check of
|
|
29168
|
+
for (const check of postActionChecks) {
|
|
28724
29169
|
const checkResponseCursor = responseSequence;
|
|
28725
29170
|
const result = await executeAction(page, check, variables, {
|
|
28726
29171
|
responses,
|
|
@@ -29513,6 +29958,28 @@ function repairRequiresAutomationChange(result) {
|
|
|
29513
29958
|
"assertion_failed"
|
|
29514
29959
|
].includes(String(result.failure_kind || ""));
|
|
29515
29960
|
}
|
|
29961
|
+
function isBrowserAuthenticationErrorMessage(message) {
|
|
29962
|
+
return /e2e\.browser\.(?:interactive_login_timeout|login_bootstrap_required|auth_(?:cookie|import)_probe_failed|auth_context_missing)/i.test(message);
|
|
29963
|
+
}
|
|
29964
|
+
function isBrowserAuthenticationFailure(result) {
|
|
29965
|
+
return isBrowserAuthenticationErrorMessage(String(result.error || ""));
|
|
29966
|
+
}
|
|
29967
|
+
function interactiveLoginRecoveryAction() {
|
|
29968
|
+
return {
|
|
29969
|
+
kind: "playwright_authentication_recovery",
|
|
29970
|
+
user_action_required: true,
|
|
29971
|
+
instruction: "Complete or repair authentication for the run-scoped Playwright profile. A normal --resume will stay blocked and will not reopen Chrome.",
|
|
29972
|
+
next_command: `Re-run the same e2e scenario execute command with --resume --retry-interactive-login only when the user is ready to complete one visible login attempt.`
|
|
29973
|
+
};
|
|
29974
|
+
}
|
|
29975
|
+
function orphanedRunRecoveryAction() {
|
|
29976
|
+
return {
|
|
29977
|
+
kind: "playwright_orphaned_run_recovery",
|
|
29978
|
+
user_action_required: true,
|
|
29979
|
+
instruction: "The previous scenario process ended while its checkpoint was running. Confirm that no browser process remains and that no mutation was attempted.",
|
|
29980
|
+
next_command: "Re-run the same e2e scenario execute command with --resume --recover-orphaned-run only after the stale browser process is gone."
|
|
29981
|
+
};
|
|
29982
|
+
}
|
|
29516
29983
|
function completedBrowserStepHashes(execution, automation) {
|
|
29517
29984
|
const hashes = {};
|
|
29518
29985
|
for (const step of executionSteps(execution)) {
|
|
@@ -29665,6 +30132,7 @@ async function saveOperationState(file, state) {
|
|
|
29665
30132
|
await writeAtomicJson3(file, state);
|
|
29666
30133
|
}
|
|
29667
30134
|
function pausedResult(state, checkpoint) {
|
|
30135
|
+
const userActionRequired = state.status === "paused_external_action" && ["playwright_authentication_required", "orphaned_execution_recovery_required"].includes(state.pause?.kind || "");
|
|
29668
30136
|
return {
|
|
29669
30137
|
ok: false,
|
|
29670
30138
|
status: state.status,
|
|
@@ -29674,7 +30142,8 @@ function pausedResult(state, checkpoint) {
|
|
|
29674
30142
|
current_step: state.current_step,
|
|
29675
30143
|
current_action_index: state.current_action_index,
|
|
29676
30144
|
mutation_state: state.mutation_state,
|
|
29677
|
-
resume_allowed: state.status !== "paused_write_state_unknown",
|
|
30145
|
+
resume_allowed: state.status !== "paused_write_state_unknown" && !userActionRequired,
|
|
30146
|
+
...userActionRequired ? { user_action_required: true } : {},
|
|
29678
30147
|
llm_intervention_required: state.status === "paused_repairable",
|
|
29679
30148
|
...state.pause ? { pause: state.pause } : {}
|
|
29680
30149
|
};
|
|
@@ -29709,7 +30178,7 @@ async function executeE2eScenarioUnlocked(options, dependencies = DEFAULT_DEPEND
|
|
|
29709
30178
|
const generatedUserDataDir = !options.userDataDir ? path17.join(path17.dirname(manifest), ".playwright-session") : void 0;
|
|
29710
30179
|
if (generatedUserDataDir) {
|
|
29711
30180
|
await mkdir12(generatedUserDataDir, { recursive: true, mode: 448 });
|
|
29712
|
-
await
|
|
30181
|
+
await chmod3(generatedUserDataDir, 448);
|
|
29713
30182
|
options.userDataDir = generatedUserDataDir;
|
|
29714
30183
|
}
|
|
29715
30184
|
options.interactiveLogin ??= true;
|
|
@@ -29767,6 +30236,21 @@ async function executeE2eScenarioUnlocked(options, dependencies = DEFAULT_DEPEND
|
|
|
29767
30236
|
if (operation.manifest !== manifest || operation.scenario !== scenario || operation.plan_file !== planFile || operation.automation_file !== automationFile) {
|
|
29768
30237
|
throw new Error("e2e.scenario.checkpoint_binding_mismatch: checkpoint is bound to a different manifest, scenario, plan, or automation file");
|
|
29769
30238
|
}
|
|
30239
|
+
if (hasCheckpoint && options.resume && operation.status === "running" && options.recoverOrphanedRun !== true) {
|
|
30240
|
+
if (operation.mutation_state !== "not_attempted") {
|
|
30241
|
+
throw new Error("e2e.scenario.orphaned_mutation_state_unknown: a crashed running checkpoint may have attempted a mutation; resolve current-run write state before recovery");
|
|
30242
|
+
}
|
|
30243
|
+
operation.status = "paused_external_action";
|
|
30244
|
+
operation.pause = {
|
|
30245
|
+
kind: "orphaned_execution_recovery_required",
|
|
30246
|
+
message: "The previous scenario process ended while the checkpoint was running. Automatic resume is blocked to prevent repeated browser launches.",
|
|
30247
|
+
...operation.current_step ? { repair_scope: operation.current_step } : {},
|
|
30248
|
+
script_change_required: false,
|
|
30249
|
+
external_action: orphanedRunRecoveryAction()
|
|
30250
|
+
};
|
|
30251
|
+
await saveOperationState(checkpoint, operation);
|
|
30252
|
+
return pausedResult(operation, checkpoint);
|
|
30253
|
+
}
|
|
29770
30254
|
const mutationGuard = initialMutationGuard;
|
|
29771
30255
|
let recoveredMutationGuard = false;
|
|
29772
30256
|
if (mutationGuard) {
|
|
@@ -29856,6 +30340,18 @@ async function executeE2eScenarioUnlocked(options, dependencies = DEFAULT_DEPEND
|
|
|
29856
30340
|
throw new Error(`e2e.scenario.mutation_guard_mismatch: guarded step is already ${String(guardedStep.status)}`);
|
|
29857
30341
|
}
|
|
29858
30342
|
}
|
|
30343
|
+
if (operation.status === "paused_repairable" && isBrowserAuthenticationErrorMessage(operation.pause?.message || "")) {
|
|
30344
|
+
operation.status = "paused_external_action";
|
|
30345
|
+
operation.pause = {
|
|
30346
|
+
...operation.pause,
|
|
30347
|
+
kind: "playwright_authentication_required",
|
|
30348
|
+
message: operation.pause?.message || "Playwright authentication must be restored before this run can continue.",
|
|
30349
|
+
repair_request: void 0,
|
|
30350
|
+
script_change_required: false,
|
|
30351
|
+
external_action: interactiveLoginRecoveryAction()
|
|
30352
|
+
};
|
|
30353
|
+
await saveOperationState(checkpoint, operation);
|
|
30354
|
+
}
|
|
29859
30355
|
if (recoveredMutationGuard && operation.status === "complete") {
|
|
29860
30356
|
return {
|
|
29861
30357
|
ok: true,
|
|
@@ -29912,6 +30408,12 @@ async function executeE2eScenarioUnlocked(options, dependencies = DEFAULT_DEPEND
|
|
|
29912
30408
|
if (operation.status === "complete") {
|
|
29913
30409
|
throw new Error("test_suite.run.completed_manifest: completed cases are never resumed or reused; start a new full_rerun manifest");
|
|
29914
30410
|
}
|
|
30411
|
+
if (options.resume && operation.status === "paused_external_action" && operation.pause?.kind === "playwright_authentication_required" && options.retryInteractiveLogin !== true) {
|
|
30412
|
+
return pausedResult(operation, checkpoint);
|
|
30413
|
+
}
|
|
30414
|
+
if (options.resume && operation.status === "paused_external_action" && operation.pause?.kind === "orphaned_execution_recovery_required" && options.recoverOrphanedRun !== true) {
|
|
30415
|
+
return pausedResult(operation, checkpoint);
|
|
30416
|
+
}
|
|
29915
30417
|
if (options.resume && operation.status === "paused_external_action" && operation.pause?.kind === "report_sync_failed") {
|
|
29916
30418
|
try {
|
|
29917
30419
|
const reportSync = await dependencies.syncTestSuiteRunReport(manifest);
|
|
@@ -30301,6 +30803,21 @@ async function executeE2eScenarioUnlocked(options, dependencies = DEFAULT_DEPEND
|
|
|
30301
30803
|
await saveOperationState(checkpoint, operation);
|
|
30302
30804
|
return pausedResult(operation, checkpoint);
|
|
30303
30805
|
}
|
|
30806
|
+
if (isBrowserAuthenticationFailure(result)) {
|
|
30807
|
+
operation.status = "paused_external_action";
|
|
30808
|
+
operation.mutation_state = "not_attempted";
|
|
30809
|
+
operation.pause = {
|
|
30810
|
+
kind: "playwright_authentication_required",
|
|
30811
|
+
message: result.error || result.status,
|
|
30812
|
+
repair_scope: failedStepKey,
|
|
30813
|
+
failed_action_index: result.failure_action_index,
|
|
30814
|
+
script_change_required: false,
|
|
30815
|
+
evidence: result.evidence,
|
|
30816
|
+
external_action: interactiveLoginRecoveryAction()
|
|
30817
|
+
};
|
|
30818
|
+
await saveOperationState(checkpoint, operation);
|
|
30819
|
+
return pausedResult(operation, checkpoint);
|
|
30820
|
+
}
|
|
30304
30821
|
if (result.repairable || ["cache_stale", "execution_failed"].includes(result.status)) {
|
|
30305
30822
|
const failedStepHash = browserAutomationStepSha256(requiredAutomationStep(automation, failedStepKey));
|
|
30306
30823
|
const scriptChangeRequired = repairRequiresAutomationChange(result);
|
|
@@ -30541,7 +31058,7 @@ async function resolveE2eScenarioWriteState(options, dependencies = DEFAULT_DEPE
|
|
|
30541
31058
|
|
|
30542
31059
|
// src/core/e2e-identity-bridge.ts
|
|
30543
31060
|
import { createHash as createHash12, randomUUID as randomUUID4 } from "crypto";
|
|
30544
|
-
import { chmod as
|
|
31061
|
+
import { chmod as chmod4, lstat as lstat4, mkdir as mkdir13, readFile as readFile17, realpath as realpath7, rename as rename5, stat as stat12, unlink as unlink2, writeFile as writeFile13 } from "fs/promises";
|
|
30545
31062
|
import path18 from "path";
|
|
30546
31063
|
var REQUEST_TTL_SECONDS = 180;
|
|
30547
31064
|
var RESULT_MAX_DURATION_MS = 15 * 60 * 1e3;
|
|
@@ -30639,6 +31156,17 @@ function recoveredOriginalIdentity(lease) {
|
|
|
30639
31156
|
}
|
|
30640
31157
|
return null;
|
|
30641
31158
|
}
|
|
31159
|
+
function recoveredExpiredCorruptRecordingIdentity(lease, binding) {
|
|
31160
|
+
if (!binding.recording_session || binding.execution_manifest || !lease.binding.recording_session || lease.binding.execution_manifest || path18.resolve(binding.recording_session) !== path18.resolve(lease.binding.recording_session) || binding.profile !== lease.binding.profile || !lease.expires_at || Date.parse(lease.expires_at) > Date.now()) {
|
|
31161
|
+
return null;
|
|
31162
|
+
}
|
|
31163
|
+
const original = safeIdentity(lease.original_user);
|
|
31164
|
+
const target = safeIdentity(lease.target_user);
|
|
31165
|
+
if (!original?.id || !original.mock || !target?.id || !target.mock || original.id !== target.id) {
|
|
31166
|
+
return null;
|
|
31167
|
+
}
|
|
31168
|
+
return { identity: original, source: "lease_original" };
|
|
31169
|
+
}
|
|
30642
31170
|
async function readJson(file) {
|
|
30643
31171
|
return JSON.parse(await readFile17(file, "utf8"));
|
|
30644
31172
|
}
|
|
@@ -30683,13 +31211,13 @@ async function atomicJson(file, value, exclusive = false) {
|
|
|
30683
31211
|
if (exclusive) {
|
|
30684
31212
|
await writeFile13(file, `${JSON.stringify(value, null, 2)}
|
|
30685
31213
|
`, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
30686
|
-
await
|
|
31214
|
+
await chmod4(file, 384);
|
|
30687
31215
|
return;
|
|
30688
31216
|
}
|
|
30689
31217
|
const temp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
30690
31218
|
await writeFile13(temp, `${JSON.stringify(value, null, 2)}
|
|
30691
31219
|
`, { encoding: "utf8", mode: 384 });
|
|
30692
|
-
await
|
|
31220
|
+
await chmod4(temp, 384);
|
|
30693
31221
|
await rename5(temp, file);
|
|
30694
31222
|
}
|
|
30695
31223
|
async function withLeaseLock(leaseFile, action) {
|
|
@@ -30813,7 +31341,7 @@ async function prepareIdentityBrowserBridge(options) {
|
|
|
30813
31341
|
if (options.operation === "unmock" && (!activeLease || !["active", "uncertain"].includes(activeLease.state))) {
|
|
30814
31342
|
throw new Error("e2e.identity.browser.unmock_without_lease: unmock \u5FC5\u987B\u5BF9\u5E94\u540C\u4E00\u6B63\u5F0F run \u6216 recording session \u7684 active/uncertain identity lease\u3002");
|
|
30815
31343
|
}
|
|
30816
|
-
const originalRecovery = options.operation === "unmock" && activeLease ? recoveredOriginalIdentity(activeLease) : null;
|
|
31344
|
+
const originalRecovery = options.operation === "unmock" && activeLease ? recoveredOriginalIdentity(activeLease) ?? recoveredExpiredCorruptRecordingIdentity(activeLease, options.binding) : null;
|
|
30817
31345
|
if (options.operation === "unmock" && !originalRecovery) {
|
|
30818
31346
|
throw new Error("e2e.identity.browser.original_identity_unrecoverable: lease \u65E0\u6CD5\u8BC1\u660E\u7CBE\u786E\u539F\u59CB\u8EAB\u4EFD\uFF0C\u7981\u6B62\u5C1D\u8BD5 unmock \u6216\u91CA\u653E\u79DF\u7EA6\u3002");
|
|
30819
31347
|
}
|
|
@@ -32911,7 +33439,8 @@ async function updateAutomationFromRecordedTrace(options) {
|
|
|
32911
33439
|
runner: "browser_action",
|
|
32912
33440
|
page_fingerprint: trace.page_fingerprint,
|
|
32913
33441
|
actions: trace.actions,
|
|
32914
|
-
expected_checks: trace.expected_checks
|
|
33442
|
+
expected_checks: trace.expected_checks,
|
|
33443
|
+
...isRecord15(trace.resolution_checks) ? { resolution_checks: trace.resolution_checks } : {}
|
|
32915
33444
|
}
|
|
32916
33445
|
};
|
|
32917
33446
|
const candidateStep = document2.steps[automationStepKey(options.caseId, options.caseStepId)].automation;
|
|
@@ -33754,7 +34283,7 @@ function registerE2eCommands(program2) {
|
|
|
33754
34283
|
});
|
|
33755
34284
|
});
|
|
33756
34285
|
const scenario = e2e.command("scenario").description("Run resumable BPMAX E2E scenario plans");
|
|
33757
|
-
scenario.command("execute").description("Execute the formal deterministic operation flow until complete or a controlled pause").requiredOption("--plan <file>", "Scenario plan JSON file").requiredOption("--automation <file>", "Scenario automation.json").requiredOption("--execution-manifest <file>", "Current formal test-suite execution manifest").option("--data-profile <json>", "Current-run JSON variables or @file").option("--base-url <url>", "Browser base URL; defaults to the manifest profile origin").option("--profile <profile>", "Profile name; must match the execution manifest").option("--cdp-endpoint <url>", "Connect to an existing authenticated Chrome CDP endpoint").option("--cookie-env <name>", "Environment variable containing a current browser Cookie header", "BPMAX_COOKIE_HEADER").option("--storage-state <file>", "Playwright storage state JSON").option("--user-data-dir <dir>", "Persistent Chrome user data directory").option("--executable-path <file>", "Chrome/Chromium executable path").option("--headed", "Run a visible browser window").option("--no-interactive-login", "Fail instead of opening a visible Playwright login window when authentication is missing").option("--login-timeout <seconds>", "Maximum time to wait for interactive Playwright login", "300").option("--checkpoint <file>", "Operation-flow checkpoint; defaults to the current report run directory").option("--resume", "Resume the same unfinished operation flow after a controlled repair or external action").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
34286
|
+
scenario.command("execute").description("Execute the formal deterministic operation flow until complete or a controlled pause").requiredOption("--plan <file>", "Scenario plan JSON file").requiredOption("--automation <file>", "Scenario automation.json").requiredOption("--execution-manifest <file>", "Current formal test-suite execution manifest").option("--data-profile <json>", "Current-run JSON variables or @file").option("--base-url <url>", "Browser base URL; defaults to the manifest profile origin").option("--profile <profile>", "Profile name; must match the execution manifest").option("--cdp-endpoint <url>", "Connect to an existing authenticated Chrome CDP endpoint").option("--cookie-env <name>", "Environment variable containing a current browser Cookie header", "BPMAX_COOKIE_HEADER").option("--storage-state <file>", "Playwright storage state JSON").option("--user-data-dir <dir>", "Persistent Chrome user data directory").option("--executable-path <file>", "Chrome/Chromium executable path").option("--headed", "Run a visible browser window").option("--no-interactive-login", "Fail instead of opening a visible Playwright login window when authentication is missing").option("--retry-interactive-login", "Explicitly allow one new visible login attempt after an authentication pause").option("--recover-orphaned-run", "Explicitly recover a stale running checkpoint after confirming no browser process or mutation remains").option("--login-timeout <seconds>", "Maximum time to wait for interactive Playwright login", "300").option("--checkpoint <file>", "Operation-flow checkpoint; defaults to the current report run directory").option("--resume", "Resume the same unfinished operation flow after a controlled repair or external action").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
33758
34287
|
const loginTimeoutMs = Number(options.loginTimeout) * 1e3;
|
|
33759
34288
|
if (!Number.isFinite(loginTimeoutMs) || loginTimeoutMs <= 0) {
|
|
33760
34289
|
throw new Error("e2e.browser.login_timeout_invalid: --login-timeout must be a positive number of seconds");
|
|
@@ -34317,11 +34846,7 @@ function buildGitLabIssuePayload(input) {
|
|
|
34317
34846
|
function resolveGitLabToken(options) {
|
|
34318
34847
|
const env = options.env || process.env;
|
|
34319
34848
|
if (options.tokenEnv) {
|
|
34320
|
-
|
|
34321
|
-
if (!explicitToken) {
|
|
34322
|
-
throw new Error(`GitLab token is required. Set ${options.tokenEnv}.`);
|
|
34323
|
-
}
|
|
34324
|
-
return explicitToken;
|
|
34849
|
+
return env[options.tokenEnv]?.trim() || void 0;
|
|
34325
34850
|
}
|
|
34326
34851
|
const candidates = [
|
|
34327
34852
|
env.GITLAB_TOKEN,
|
|
@@ -34330,28 +34855,40 @@ function resolveGitLabToken(options) {
|
|
|
34330
34855
|
"-1pFevGtvjq4fXSxzZJQ"
|
|
34331
34856
|
];
|
|
34332
34857
|
const token = candidates.find((candidate) => candidate?.trim());
|
|
34333
|
-
|
|
34334
|
-
|
|
34335
|
-
|
|
34336
|
-
return
|
|
34858
|
+
return token?.trim() || void 0;
|
|
34859
|
+
}
|
|
34860
|
+
function gitLabIssueAuthError(status, tokenConfigured) {
|
|
34861
|
+
return new Error(
|
|
34862
|
+
`GitLab issue submission failed with HTTP ${status}. ` + (tokenConfigured ? "The configured GitLab token was rejected. Replace GITLAB_TOKEN, GL_TOKEN, PRIVATE_TOKEN, or --token-env, then retry." : "No GitLab token was configured. Set GITLAB_TOKEN, GL_TOKEN, PRIVATE_TOKEN, or --token-env, then retry.") + " Browser login is not used for issue submission."
|
|
34863
|
+
);
|
|
34337
34864
|
}
|
|
34338
34865
|
async function createGitLabIssue(input, options) {
|
|
34339
|
-
const token = options.token.trim();
|
|
34340
|
-
if (!token) {
|
|
34341
|
-
throw new Error("GitLab token is required.");
|
|
34342
|
-
}
|
|
34343
34866
|
const baseUrl = normalizeBaseUrl2(options.baseUrl);
|
|
34344
34867
|
const projectPath = gitLabProjectApiPath(options.project);
|
|
34345
34868
|
const client = options.client || axios8.create({ baseURL: baseUrl });
|
|
34346
34869
|
const headers = AxiosHeaders3.from();
|
|
34347
|
-
|
|
34348
|
-
|
|
34349
|
-
|
|
34350
|
-
|
|
34351
|
-
|
|
34352
|
-
|
|
34353
|
-
|
|
34354
|
-
|
|
34870
|
+
const token = options.token?.trim();
|
|
34871
|
+
if (token) {
|
|
34872
|
+
headers.set("PRIVATE-TOKEN", token);
|
|
34873
|
+
}
|
|
34874
|
+
try {
|
|
34875
|
+
const response = await client.request({
|
|
34876
|
+
method: "POST",
|
|
34877
|
+
url: `/api/v4/projects/${projectPath}/issues`,
|
|
34878
|
+
headers,
|
|
34879
|
+
data: buildGitLabIssuePayload(input)
|
|
34880
|
+
});
|
|
34881
|
+
return response.data;
|
|
34882
|
+
} catch (error) {
|
|
34883
|
+
const status = error && typeof error === "object" && "response" in error && error.response && typeof error.response === "object" && "status" in error.response && typeof error.response.status === "number" ? error.response.status : void 0;
|
|
34884
|
+
if (!token && (status === 401 || status === 403 || status === 404)) {
|
|
34885
|
+
throw gitLabIssueAuthError(status, false);
|
|
34886
|
+
}
|
|
34887
|
+
if (token && status === 401) {
|
|
34888
|
+
throw gitLabIssueAuthError(status, true);
|
|
34889
|
+
}
|
|
34890
|
+
throw error;
|
|
34891
|
+
}
|
|
34355
34892
|
}
|
|
34356
34893
|
function lintIssueReportDraft(input) {
|
|
34357
34894
|
const findings = [];
|
|
@@ -39237,7 +39774,7 @@ function registerTestSuiteCommands(program2) {
|
|
|
39237
39774
|
output: options.output
|
|
39238
39775
|
}));
|
|
39239
39776
|
});
|
|
39240
|
-
confirmation.command("accept").description("Accept a prepared V2 E2E confirmation
|
|
39777
|
+
confirmation.command("accept").description("Accept a prepared V2 E2E scope after explicit confirmation or an explicit autonomous test request").requiredOption("--request <file>", "Prepared V2 confirmation request").option("--confirmed", "The user explicitly confirmed the displayed scenario, case scope, and operation").option("--autonomous", "The current explicit test request authorizes automatic execution of the bound scope without a second confirmation").option("--receipt <file>", "Accepted confirmation receipt output path").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
39241
39778
|
printResult(options.format, await acceptV2TestSuiteConfirmation(options));
|
|
39242
39779
|
});
|
|
39243
39780
|
suite.command("draft-update").description("Copy one formal suite scenario to the draft suite for editing").requiredOption("--scenario <id>", "Scenario id").option("--suite-root <path>", "Formal suite root directory", DEFAULT_SUITE_ROOT).option("--draft-root <path>", "Draft suite root directory", DEFAULT_DRAFT_ROOT).option("--replace", "Allow replacing an existing draft scenario").option("--diff-reviewed", "Confirm the copy diff preview was reviewed").requiredOption("--latest-proof <path>", "latest-* proof JSON written after syncing the sysconfig repo").option("--format <format>", "Output format", "json").action(async (options) => {
|