test(frontend): verify global stylesheet @import graph after vitest

Add scripts/check-css-import-graph.mjs and run it from npm test and
test:coverage so missing relative CSS imports fail CI like Vite/postcss.
Document the step in src/test/README.md; trigger frontend workflow when
the script changes.
This commit is contained in:
Maxim Isaev
2026-05-13 21:09:53 +03:00
parent 2eb23e99b5
commit 94cfb3b58d
4 changed files with 81 additions and 2 deletions
+13
View File
@@ -33,8 +33,21 @@ src/test/
npm test # one-shot run
npm run test:watch # watch mode
npm run test:coverage # with v8 coverage → ./coverage/
npm run check:css-imports # only the global stylesheet @import graph (see below)
```
## CSS `@import` graph
Vitest does not load the full global CSS bundle from `main.tsx`, so a broken
relative `@import` under `src/styles/**` can slip past the suite until Vite
runs (`ENOENT` from postcss-import).
After **`vitest run`**, **`npm test`** and **`npm run test:coverage`** run
**`npm run check:css-imports`**, which executes **`scripts/check-css-import-graph.mjs`**
and walks the same four root stylesheets as **`src/main.tsx`**, resolving
only filesystem-relative imports (`./…`, `../…`). Package imports such as
`@fontsource/...` are ignored.
## Where tests go
- **Co-located with the unit under test**: `Foo.tsx``Foo.test.tsx`,