Files
pikasTech-HWLAB/web/hwlab-cloud-web/scripts/caserun-native-web-probe.mjs
T
root 2bc5fc653a
Pipelines as Code CI / hwlab-nc01-v03-ci-poll- Success
feat: 完善 CaseRun 原生证据视图
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-18 06:01:58 +02:00

47 lines
2.5 KiB
JavaScript

export default async function caserunNativeSmoke({ page, goto, wait, screenshot, recordStep }) {
await goto("/caserun");
const panel = page.locator("#caserun-panel");
await panel.waitFor({ state: "visible", timeout: 20000 });
const nativeCase = page.locator(".caserun-case-row").filter({ hasText: "native-completed" }).first();
await nativeCase.waitFor({ state: "visible", timeout: 20000 });
await nativeCase.click();
await page.locator("#caserun-start").click();
await page.locator("#caserun-refresh").click();
await wait(300);
const mode = (await page.locator("#caserun-mode").textContent())?.trim() || "";
const runId = (await page.locator("#caserun-run-id").textContent())?.trim() || "";
const events = await page.locator("#caserun-event-text").textContent();
const aggregateStatus = (await page.locator("#caserun-aggregate-status").textContent())?.trim() || "";
const aggregateRunId = (await page.locator("#caserun-aggregate-run-id").textContent())?.trim() || "";
const aggregateSha = (await page.locator("#caserun-aggregate-sha").textContent())?.trim() || "";
const evidenceStatus = (await page.locator("#caserun-evidence-status").textContent())?.trim() || "";
await page.getByRole("tab", { name: "产物" }).click();
const artifactText = (await page.locator(".caserun-artifact-row").textContent()) || "";
await page.getByRole("tab", { name: "编排" }).click();
const workflowId = (await page.locator("#caserun-workflow-id").textContent())?.trim() || "";
await page.getByRole("tab", { name: "结果" }).click();
const conditions = {
mode: mode.includes("native-test"),
aggregateStatus: aggregateStatus === "已完成",
aggregateRunId: aggregateRunId === runId && runId.startsWith("native-completed-"),
aggregateSha: /^[a-f0-9]{64}$/.test(aggregateSha),
evidenceStatus: evidenceStatus === "已完成",
artifact: artifactText.includes("native-result.json") && artifactText.includes("335 B"),
workflow: workflowId === `harnessrl-caserun-${runId}`,
queuedEvent: events?.includes("进入队列") === true,
buildEvent: events?.includes("构建完成") === true,
completedEvent: events?.includes("运行完成") === true
};
const image = await screenshot("caserun-native-completed.png");
recordStep("caserun-native-completed", { ok: Object.values(conditions).every(Boolean), conditions });
return {
ok: Object.values(conditions).every(Boolean),
mode: "native-test",
conditions,
screenshot: image,
finalUrl: page.url(),
valuesRedacted: true
};
}