fix(scripts): exempt Storybook stories from coverage:diff gate

Story files are excluded from vitest by design (they run in Storybook
runner, not vitest). Add *.stories.{ts,tsx} to ALLOWED_GLOBS so the
L1 diff gate doesn't flag them as "new untested file".

Also add error-handling test for useOptionalConsent rethrow path
(cookie-consent-banner lines 52-53) achieving 100% statement coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-19 21:24:02 +00:00
parent 1b6f2d1e36
commit cbe7412a58
4 changed files with 94 additions and 16 deletions

View File

@@ -32,6 +32,8 @@ import { execSync } from "node:child_process";
const ALLOWED_GLOBS = [
// Test artifacts
/\.test\.(ts|tsx|js|mjs)$/,
// Storybook story files — excluded from vitest by design; tested in Storybook runner
/\.stories\.(ts|tsx)$/,
/\/__factories__\//,
/\/__contracts__\//,
/\/__fixtures__\//,

View File

@@ -210,6 +210,21 @@ describe("computeDiffCoverage", () => {
assert.equal(result.summary.filesChanged, 3);
});
test("skips Storybook story files (.stories.ts/.stories.tsx — excluded from vitest coverage)", () => {
const lcov = parseLcov(lcovText);
const diff = new Map([
[
"packages/core-ui/src/cookie-consent-banner/cookie-consent-banner.stories.tsx",
new Set([1, 2, 3, 4, 5]),
],
["packages/core-ui/src/atoms/button/button.stories.ts", new Set([1, 2])],
]);
const result = computeDiffCoverage(diff, lcov);
assert.equal(result.status, "pass");
assert.equal(result.summary.filesGated, 0);
assert.equal(result.summary.filesChanged, 2);
});
test("skips packages/core-testing/ (tooling package, no lcov generated)", () => {
const lcov = parseLcov(lcovText);
const diff = new Map([