@cobre-npm/ds-v3 0.144.2 → 0.145.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -27,6 +27,14 @@ pnpm approve-builds
|
|
|
27
27
|
|
|
28
28
|
Then re-run `pnpm install` if needed.
|
|
29
29
|
|
|
30
|
+
`postinstall` downloads the headless Chromium the render lane tests against (~95 MB, once per
|
|
31
|
+
machine, idempotent). It lives in `postinstall` rather than in the test script because the browser is
|
|
32
|
+
a dependency of the suite, and because more than one command runs that suite — putting it in `test`
|
|
33
|
+
left every other entry point without a browser. `SKIP_TEST_BROWSER=1` skips it, for any image that installs dependencies and never runs the suite —
|
|
34
|
+
the Dockerfile that builds the Storybook showcase sets it. On Alpine it skips itself, because
|
|
35
|
+
Playwright publishes glibc builds only. `--ignore-scripts` skips it too, and `pnpm test:browsers`
|
|
36
|
+
gets it back.
|
|
37
|
+
|
|
30
38
|
## Develop with Storybook (primary workflow)
|
|
31
39
|
|
|
32
40
|
This is a component library — day-to-day development happens in Storybook, which renders every component with its variants and docs:
|
|
@@ -48,10 +56,45 @@ Opens at [http://localhost:6006](http://localhost:6006).
|
|
|
48
56
|
| `pnpm dev` | Bare Vite dev harness (`src/main.ts`) — rarely needed |
|
|
49
57
|
| `pnpm build` | Type-check + build the publishable library into `dist/` |
|
|
50
58
|
| `pnpm build-storybook` | Build the static Storybook site |
|
|
51
|
-
| `pnpm test
|
|
52
|
-
| `pnpm test` |
|
|
59
|
+
| `pnpm test` | The whole gate: story render lane, logic lane with coverage, invariants |
|
|
60
|
+
| `pnpm test:stories` | Render lane only — mounts all 81 stories in headless Chromium |
|
|
61
|
+
| `pnpm test:unit` | Logic lane only, with coverage enforced against `coverage-floor.json` |
|
|
62
|
+
| `pnpm test:browsers` | Re-download the Chromium build the render lane needs — normally unnecessary, `pnpm install` does it |
|
|
53
63
|
| `pnpm lint` | Lint & auto-fix with [ESLint](https://eslint.org/) |
|
|
54
64
|
|
|
65
|
+
## Testing
|
|
66
|
+
|
|
67
|
+
The suite is split in two lanes because the two numbers would not mean the same thing
|
|
68
|
+
([ADR-0008](https://github.com/Cobre-Colombia/portal/blob/trunk/docs/adr/0008-the-quality-gate-splits-by-subject-and-only-ratchets-up.md)):
|
|
69
|
+
|
|
70
|
+
- **Render lane** (`test:stories`) — every story mounts without error, in headless Chromium via
|
|
71
|
+
`@storybook/addon-vitest`. It is **binary**: no percentage is attached to it. Storybook marks a
|
|
72
|
+
line covered when a story renders it while asserting nothing, so a percentage built that way
|
|
73
|
+
measures *exercised*, not *verified*.
|
|
74
|
+
- **Logic lane** (`test:unit`) — the non-component sources (`src/**/*.ts` minus stories, tests,
|
|
75
|
+
type-only modules, barrels and the dev entry), with coverage thresholds enforced.
|
|
76
|
+
|
|
77
|
+
### The coverage floor ratchets
|
|
78
|
+
|
|
79
|
+
`coverage-floor.json` holds the thresholds, and it is **a floor, not a target**. It was set to what
|
|
80
|
+
the repo measured the day the gate was switched on — there is no retroactive 95% and no backfill of
|
|
81
|
+
the existing components as a precondition. It may only rise:
|
|
82
|
+
|
|
83
|
+
- `scripts/check-invariants.mjs` fails the build when any number in the file drops below the base
|
|
84
|
+
ref. It is a change-level check, so it runs in CI, or locally with
|
|
85
|
+
`pnpm test:invariants -- --base origin/trunk`.
|
|
86
|
+
- `src/utils/repo-invariants.test.ts` fails when `vitest.config.mts` stops reading its thresholds
|
|
87
|
+
from that file, which would otherwise be a silent way to lower the gate to nothing.
|
|
88
|
+
|
|
89
|
+
To raise the floor: improve coverage, run `pnpm test:unit`, and copy the reported totals into
|
|
90
|
+
`coverage-floor.json`.
|
|
91
|
+
|
|
92
|
+
### Adding tests
|
|
93
|
+
|
|
94
|
+
Component behaviour belongs in a story — it is the lane that already exists and the one consuming
|
|
95
|
+
apps read as documentation. Reach for the logic lane when the subject is a composable, a pure
|
|
96
|
+
function or shared state.
|
|
97
|
+
|
|
55
98
|
## Recommended IDE Setup
|
|
56
99
|
|
|
57
100
|
[VSCode](https://code.visualstudio.com/) + [Vue - Official (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (disable Vetur).
|