27 lines
1.7 KiB
JavaScript
27 lines
1.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.equal(focused.retries, 0);
|
|
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} blocked=${manifest.summary.blocked} retries=${focused.retries}\n`);
|