// @vitest-environment jsdom import { afterEach, describe, expect, it, vi } from 'vitest' import { cleanup, render, screen } from '@testing-library/react' import type { GeneralSectionComponentProps } from '../src/client/GeneralSection.tsx' import { GeneralSection } from '../src/client/GeneralSection.tsx' import { CloseLabel, HeaderContent, TriggerContent } from '../src/client/chrome.tsx' import type { TriggerContentProps } from '../src/client/chrome.tsx' import { en } from '../src/client/locales.ts' afterEach(cleanup) // The seat's key domain is settings ∪ common; the stub answers from the // package dictionary and falls back to the key like the real chain. const t: TriggerContentProps['t'] = key => (en as Record)[key] ?? key // Global standard kit stubs: none of these components consume the hooks. const unusedHook = (() => { throw new Error('unused by settings-general components') }) as never const kit = { useSessions: unusedHook, useWorkspaces: unusedHook } describe('chrome content', () => { it('TriggerContent renders the icon with the label in the wide column', () => { const { container } = render() expect(container.querySelector('svg')).toBeTruthy() expect(screen.getByText('Settings')).toBeTruthy() }) it('TriggerContent drops the label in the rail state', () => { const { container } = render() expect(container.querySelector('svg')).toBeTruthy() expect(screen.queryByText('Settings')).toBeNull() }) it('HeaderContent and CloseLabel render their translated text', () => { render() render() expect(screen.getByText('Settings')).toBeTruthy() expect(screen.getByText('Close')).toBeTruthy() }) }) describe('GeneralSection', () => { function mount() { const renderSlot = vi.fn( ((key: string) =>
) as GeneralSectionComponentProps['renderSlot'], ) const props: GeneralSectionComponentProps = { ...kit, renderSlot } const view = render() return { view, renderSlot } } it('renders the item slot as the section body', () => { const { renderSlot } = mount() expect(renderSlot).toHaveBeenCalledWith('settings.general.item', {}) expect(screen.getByTestId('slot-settings.general.item')).toBeTruthy() }) })