Add unit tests for cssVar
What
ui/packages/design-system/src/utils/css.ts has no test yet.
Every chart colour in the UI goes through this helper, including the opacity path that converts a hex token into rgba(...).
What to do
Create ui/packages/design-system/tests/units/utils/css.test.ts covering:
- the raw custom-property value is returned, trimmed, when no opacity is given
- a 6-digit hex with an opacity is converted to
rgba(r, g, b, opacity) - the conversion is correct for known values, for example
#029E73at 0.5 - a missing custom property returns an empty string
- an opacity of 0 is honoured rather than being treated as absent
Set the variables with document.documentElement.style.setProperty in a beforeEach and remove them afterwards.
Reference
ui/packages/design-system/tests/units/utils/lang.test.ts is an existing test of the same shape to copy from.
How to run
Install once, then run the whole suite:
cd ui/packages/design-system && npm install && npm run test:unitWhile writing the test, run just this file so the feedback loop stays fast:
cd ui/packages/design-system && npm run test:unit -- tests/units/utils/css.test.tsProof required in the PR
[!IMPORTANT] The
PRthat closes this issue must include a screenshot of the test passing, pasted into thePRdescription. Pasted text output is not enough.To produce it, run the single-file command above and screenshot the terminal. The capture should show the command, the test file, and the green summary lines (
Test Files 1 passed (1)andTests N passed (N)). Then drag the image straight into thePRdescription field on GitHub, which uploads and embeds it.
Source: kestra-io/kestra