Skip to content

The agent that grows with you

test(desktop): keep long toast titles readable

xxxigmab6e7b93da55
diff --git a/apps/desktop/src/components/notifications.test.tsx b/apps/desktop/src/components/notifications.test.tsx
new file mode 100644
index 00000000000..5c345ce5ea3
--- /dev/null
+++ b/apps/desktop/src/components/notifications.test.tsx
@@ -0,0 +1,50 @@
+import { cleanup, render, screen } from '@testing-library/react'
+import { afterEach, beforeEach, describe, expect, it } from 'vitest'
+
+import { I18nProvider } from '@/i18n'
+import { clearNotifications, notify } from '@/store/notifications'
+
+import { NotificationStack, toastTitleClassName } from './notifications'
+
+const LONG_TITLE = 'This turn is no longer in server history (it may have been compressed away).'
+const DETAIL = 'target user message is no longer in session history'
+
+describe('toast titles', () => {
+ beforeEach(() => {
+ clearNotifications()
+ })
+
+ afterEach(() => {
+ cleanup()
+ clearNotifications()
+ })
+
+ it('drops the one-line clamp so a long error title can wrap', () => {
+ const className = toastTitleClassName()
+
+ expect(className).toMatch(/\bline-clamp-none\b/)
+ expect(className).not.toMatch(/\bline-clamp-1\b/)
+ expect(className).toMatch(/\bwhitespace-normal\b/)
+ expect(className).toContain('max-h-[4.5em]')
+ expect(className).toMatch(/\boverflow-y-auto\b/)
+ })
+
+ it('renders the full title and body instead of truncating them', () => {
+ notify({ kind: 'error', title: LONG_TITLE, message: DETAIL })
+
+ render(
+ <I18nProvider configClient={null} initialLocale="en">
+ <NotificationStack />
+ </I18nProvider>
+ )
+
+ const title = screen.getByText(LONG_TITLE)
+
+ expect(title.textContent).toBe(LONG_TITLE)
+ expect(title.getAttribute('title')).toBe(LONG_TITLE)
+ expect(title.className).toMatch(/\bline-clamp-none\b/)
+ expect(title.className).not.toMatch(/\bline-clamp-1\b/)
+ expect(title.className).toMatch(/\boverflow-y-auto\b/)
+ expect(screen.getByText(DETAIL)).toBeTruthy()
+ })
+})