import fs from "node:fs"; import { describe, expect, it } from "vitest"; const workflowPaths = [ ".github/workflows/bundle-budget.yml", ".github/workflows/bundle-budget-baseline.yml", ".gitea/workflows/bundle-budget.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}"`); } }); });