#19980·kestra

Add unit tests for cssVar

Author: MilosPaunovicCreated Sep 30, 2026Updated Sep 30, 2026
Labelsarea/frontendkind/cooldowngood first issue

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 #029E73 at 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:

bash
cd ui/packages/design-system && npm install && npm run test:unit

While writing the test, run just this file so the feedback loop stays fast:

bash
cd ui/packages/design-system && npm run test:unit -- tests/units/utils/css.test.ts

Proof required in the PR

[!IMPORTANT] The PR that closes this issue must include a screenshot of the test passing, pasted into the PR description. 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) and Tests N passed (N)). Then drag the image straight into the PR description field on GitHub, which uploads and embeds it.