🧪 Require real Playwright source data

This commit is contained in:
eust-w 2026-06-16 18:53:16 +08:00
parent 71faac3160
commit fb304ef7e4
3 changed files with 38 additions and 17 deletions

View File

@ -567,7 +567,11 @@
</table>
<p class="small">
执行命令:
<code>BASE_URL=<deployed-api-base-url> node scripts/playwright-functional-check.mjs</code>
<code>PLAYWRIGHT_SOURCE_PATH=&lt;path-visible-to-operator-runner&gt; BASE_URL=&lt;deployed-api-base-url&gt; node scripts/playwright-functional-check.mjs</code>
</p>
<p class="small">
<code>PLAYWRIGHT_SOURCE_PATH</code> 必须指向 operator-runner 可读取的真实数据路径;BOS 来源需同时设置
<code>PLAYWRIGHT_SOURCE_DATA_SOURCE=BOS</code> 并准备运行时访问配置。
</p>
</section>

View File

@ -332,9 +332,13 @@ Playwright 实测覆盖了:
执行命令如下:
```bash
BASE_URL=<deployed-api-base-url> node scripts/playwright-functional-check.mjs
PLAYWRIGHT_SOURCE_PATH=<path-visible-to-operator-runner> \
BASE_URL=<deployed-api-base-url> \
node scripts/playwright-functional-check.mjs
```
`PLAYWRIGHT_SOURCE_PATH` 必须指向 operator-runner 可读取的真实数据路径。默认按文件系统路径处理;如果确实要使用 BOS,可同时设置 `PLAYWRIGHT_SOURCE_DATA_SOURCE=BOS` 并确保运行时具备对应 BOS 访问配置。
脚本文件位置:
- [scripts/playwright-functional-check.mjs](../scripts/playwright-functional-check.mjs)

View File

@ -9,6 +9,13 @@ const videoDir = path.join(artifactDir, "video");
const suffix = Date.now().toString(36);
const scanBucket = (process.env.PLAYWRIGHT_SCAN_BUCKET || "").trim();
const scanPrefix = (process.env.PLAYWRIGHT_SCAN_PREFIX || "").trim().replace(/^\/+|\/+$/g, "");
const sourcePath = (process.env.PLAYWRIGHT_SOURCE_PATH || "").trim();
const sourceDataSource = (
process.env.PLAYWRIGHT_SOURCE_DATA_SOURCE ||
(sourcePath.toLowerCase().startsWith("bos://") ? "BOS" : "FILESYSTEM")
)
.trim()
.toUpperCase();
const names = {
admin: `PW Admin ${suffix}`,
adminEmail: `pw-admin-${suffix}@playwright.local`,
@ -34,6 +41,21 @@ function assert(condition, message) {
}
}
function requirePlaywrightSourcePath() {
if (!sourcePath) {
throw new Error(
"PLAYWRIGHT_SOURCE_PATH is required. Point it at a real source path visible to the operator runner, for example a shared PVC dataset path.",
);
}
}
function sourceHyperparams() {
return [
{ key: "DATA_SOURCE", value: sourceDataSource, description: "真实数据来源类型" },
{ key: "SOURCE_PATH", value: sourcePath, description: "真实数据路径" },
];
}
async function api(path, init = {}) {
let lastError;
for (let attempt = 1; attempt <= 6; attempt += 1) {
@ -307,6 +329,7 @@ async function fillLabeledInput(page, labelText, value) {
}
async function main() {
requirePlaywrightSourcePath();
await cleanupTestData();
fs.mkdirSync(videoDir, { recursive: true });
@ -637,7 +660,7 @@ async function main() {
description: "Playwright source node",
inputs: [],
outputs: [{ id: "out-1", name: "manifest", type: "json" }],
hyperparams: [{ key: "SOURCE_TEXT", value: `playwright-${suffix}`, description: "直接注入文本内容" }],
hyperparams: sourceHyperparams(),
},
position: { x: 100, y: 100 },
},
@ -690,8 +713,8 @@ async function main() {
await page.reload({ waitUntil: "networkidle" });
await page.locator(".react-flow__node").filter({ hasText: "真实数据源" }).first().dblclick();
const sourceGroup = page.locator('label:has-text("SOURCE_TEXT")').locator("..").locator("..");
await sourceGroup.locator("input").fill(`playwright-ui-${suffix}`);
const sourceGroup = page.locator('label:has-text("SOURCE_PATH")').locator("..").locator("..");
await sourceGroup.locator("input").fill(sourcePath);
await page.getByRole("button", { name: "保存" }).click();
log("run workflow from editor without redirect");
@ -771,12 +794,7 @@ async function main() {
description: "Edge output running source",
inputs: [],
outputs: [{ id: "out-1", name: "manifest", type: "json" }],
hyperparams: [
{
key: "SOURCE_TEXT",
value: `edge-running-${suffix}`,
},
],
hyperparams: sourceHyperparams(),
},
position: { x: 80, y: 80 },
},
@ -867,12 +885,7 @@ async function main() {
description: "Edge output failed source",
inputs: [],
outputs: [{ id: "out-1", name: "manifest", type: "json" }],
hyperparams: [
{
key: "SOURCE_TEXT",
value: `edge-failed-${suffix}`,
},
],
hyperparams: sourceHyperparams(),
},
position: { x: 80, y: 80 },
},