Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(desktop): r1-l7 drift-guard CHAT_DRAWER_DEFAULT_WIDTH against the CSS pre-mount clamp

Diego Zacarias59b01f602945
diff --git a/desktop-app/ui/src/hooks/__tests__/useChatDrawerResize.test.ts b/desktop-app/ui/src/hooks/__tests__/useChatDrawerResize.test.ts
index f4a85c65a..cf83fe9a3 100644
--- a/desktop-app/ui/src/hooks/__tests__/useChatDrawerResize.test.ts
+++ b/desktop-app/ui/src/hooks/__tests__/useChatDrawerResize.test.ts
@@ -1,5 +1,11 @@
import { describe, expect, it } from 'vitest'
-import { CHAT_DRAWER_MIN_WIDTH, clampWidth } from '../useChatDrawerResize'
+import { readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import {
+ CHAT_DRAWER_DEFAULT_WIDTH,
+ CHAT_DRAWER_MIN_WIDTH,
+ clampWidth,
+} from '../useChatDrawerResize'
// R2-M1: the drawer resize hook's pure logic (clamp, drag mapping) had no direct
// coverage — an inverted min/max or a reversed drag direction would leave every
@@ -63,3 +69,16 @@ describe('clampWidth embed floor (docked sizing)', () => {
expect(clampWidth(300, 700)).toBe(CHAT_DRAWER_MIN_WIDTH) // 340
})
})
+
+describe('CHAT_DRAWER_DEFAULT_WIDTH CSS pre-mount clamp drift guard', () => {
+ // The CSS `--chat-drawer-width` clamp is the pre-mount / closed-state fallback
+ // React never gets to set inline. Its floor is CHAT_DRAWER_MIN_WIDTH and its
+ // ceiling is CHAT_DRAWER_DEFAULT_WIDTH; nothing else couples the two, so a
+ // default-width edit that skips styles.css would silently diverge. Read the
+ // real stylesheet and pin the exact clamp so that edit turns this red.
+ it('matches clamp(MIN, 32vw, DEFAULT) in styles.css', () => {
+ expect(CHAT_DRAWER_DEFAULT_WIDTH).toBe(525)
+ const css = readFileSync(fileURLToPath(new URL('../../styles.css', import.meta.url)), 'utf8')
+ expect(css).toContain(`clamp(${CHAT_DRAWER_MIN_WIDTH}px, 32vw, ${CHAT_DRAWER_DEFAULT_WIDTH}px)`)
+ })
+})