Files
workinf_Blender_Wasm/tools/web/check-wbv2-feature-smoke-plan.mjs
mes123456 f87a72732c
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
test(web): enforce complete one-pass smoke closure
2026-09-07 11:47:42 +08:00

48 lines
2.7 KiB
JavaScript

import assert from "node:assert/strict";
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const abs = (file) => path.join(root, file);
const readJson = (file) => JSON.parse(fs.readFileSync(abs(file), "utf8"));
const sha = (file) => crypto.createHash("sha256").update(fs.readFileSync(abs(file))).digest("hex");
const manifest = readJson("tests/golden/WBV2/feature-smoke-manifest.json");
const plan = readJson(manifest.plan.path);
const report = readJson(manifest.report.path);
const focused = readJson(manifest.focusedFixReport.path);
assert.equal(plan.operation, "ONE_PASS_FEATURE_SMOKE");
assert.equal(plan.policy.oneSmokePerFeature, true);
assert.equal(plan.policy.retryFailedFeature, false);
assert.equal(plan.cases.length, manifest.summary.totalFeatures);
assert.equal(new Set(plan.cases.map((item) => item.featureId)).size, plan.cases.length);
assert.equal(new Set(plan.cases.map((item) => item.smokeId)).size, plan.cases.length);
assert.ok(plan.cases.every((item) => item.runOnce === true && item.maxAttempts === 1));
assert.equal(report.cases.length, plan.cases.length);
assert.ok(report.cases.every((item) => item.attempts === 1), "every feature must have exactly one smoke attempt");
const initialPassed = report.cases.filter((item) => item.status === "PASS");
const initialFailed = report.cases.filter((item) => item.status !== "PASS");
const focusedPassed = focused.fixes.filter((item) => item.status === "PASS");
assert.deepEqual(
focusedPassed.map((item) => item.featureId).sort(),
initialFailed.map((item) => item.featureId).sort(),
"focused fixes must resolve exactly the initial smoke failures",
);
assert.equal(focused.retries, 0);
const resolved = initialPassed.length + focusedPassed.length;
assert.equal(manifest.status, "pass");
assert.deepEqual(manifest.summary, {
totalFeatures: plan.cases.length,
smokeAttempts: plan.cases.length,
initialPassed: initialPassed.length,
focusedFixPassed: focusedPassed.length,
blocked: 0,
retries: 0,
remainingBlocker: null,
});
assert.equal(resolved, plan.cases.length);
for (const artifact of [manifest.plan, manifest.report, manifest.focusedFixReport, manifest.planDocument]) assert.equal(sha(artifact.path), artifact.sha256, `smoke artifact hash mismatch ${artifact.path}`);
process.stdout.write(`wbv2-feature-smoke-plan-ok features=${plan.cases.length} attempts=${manifest.summary.smokeAttempts} initialPassed=${manifest.summary.initialPassed} focusedFixPassed=${manifest.summary.focusedFixPassed} resolved=${resolved}/${plan.cases.length} blocked=${manifest.summary.blocked} retries=${focused.retries}\n`);