Files
windmill/frontend/src/lib/accentColor.test.ts
T
Ruben FiszelandClaude Opus 5.5 1fd729ac1a feat: add an instance-wide accent color setting with sidebar tint (#11335)
* feat: add an instance-wide accent color setting with sidebar tint

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: paint the cached accent before the license resolves

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat: serve the banner and accent color from one cached endpoint

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: invalidate the instance ui cache and bound it with a ttl

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: keep the instance ui ttl under the client poll period

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* refactor: load the banner and accent color once per page load

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* refactor: read the banner and accent color without a server cache

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: show a cleared accent color as off

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 11:23:30 +02:00

26 lines
955 B
TypeScript

import { describe, it, expect } from 'vitest'
import { accentStylesheet } from './accentColor'
describe('accentStylesheet', () => {
it('refuses anything but #rrggbb, since the value lands in a stylesheet', () => {
for (const bad of ['#000;}body{display:none', '#fff', 'red', '1f9d55', 123, null]) {
expect(accentStylesheet(bad)).toBeUndefined()
}
})
it('overrides every accent token with an in-range r g b triplet in each theme', () => {
// A saturated color exercises the gamut clamp, a grey the zero-chroma path.
for (const color of ['#ff0000', '#808080']) {
const rules = accentStylesheet(color)!.split('\n')
expect(rules).toHaveLength(3)
for (const rule of rules) {
const triplets = [...rule.matchAll(/--color-[a-z-]+: (\d+) (\d+) (\d+);/g)]
expect(triplets).toHaveLength(10)
for (const [, ...channels] of triplets) {
for (const c of channels) expect(Number(c)).toBeLessThanOrEqual(255)
}
}
}
})
})