Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/scripts/verify-bundle-workflows.test.mjs
T

55 lines
1.9 KiB
JavaScript

import fs from "node:fs";
import { describe, expect, it } from "vitest";
const workflowPaths = [
".gitea/workflows/bundle-budget.yml",
".gitea/workflows/bundle-budget-baseline.yml",
];
describe("bundle budget workflows", () => {
it.each(workflowPaths)("runs the hard aggregate gate before writing JSON reports in %s", (workflowPath) => {
const workflow = fs.readFileSync(workflowPath, "utf8");
const hardGateIndex = workflow.indexOf("pnpm run verify:bundle-size");
const jsonReportIndex = workflow.indexOf("node scripts/verify-bundle-size.mjs --json");
expect(hardGateIndex).toBeGreaterThan(-1);
expect(jsonReportIndex).toBeGreaterThan(-1);
expect(hardGateIndex).toBeLessThan(jsonReportIndex);
});
it.each(workflowPaths)("runs when dependency graph inputs change in %s", (workflowPath) => {
const workflow = fs.readFileSync(workflowPath, "utf8");
expect(workflow).toContain('- "package.json"');
expect(workflow).toContain('- "pnpm-lock.yaml"');
});
it.each(workflowPaths)("keeps package triggers scoped to web bundle inputs in %s", (workflowPath) => {
const workflow = fs.readFileSync(workflowPath, "utf8");
expect(workflow).not.toContain('- "packages/**"');
for (const packagePath of [
"packages/brand/**",
"packages/config/**",
"packages/entitlements/**",
"packages/form-widget/**",
"packages/foundation/**",
"packages/i18n/**",
"packages/plugin-runtime/**",
"packages/ui*/**",
"packages/url/**",
"packages/view-models/**",
]) {
expect(workflow).toContain(`- "${packagePath}"`);
}
});
it.each(workflowPaths)("uses the canonical self-hosted Gitea runner in %s", (workflowPath) => {
const workflow = fs.readFileSync(workflowPath, "utf8");
expect(workflow).toContain("runs-on: toolctrl-ci");
expect(workflow).toContain("HIVEGRID_GITEA_HOST_IP");
});
});