// @vitest-environment jsdom
/** What the ListColumn page claims, pinned. Sizes are measured in the browser; these pin the parts. */
import { afterEach, describe, expect, it, vi } from 'vitest'
import { cleanup, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { MenuItem } from './Menu'
import { ListColumn } from './ListColumn'
afterEach(cleanup)
describe('ListColumn', () => {
it('is headed by its title', () => {
render(
Row
, ) const list = screen.getByText('Row').parentElement as HTMLElement expect(list.className.split(' ')).toEqual(expect.arrayContaining(['px-3', 'pt-4', 'pb-3', 'gap-0.5'])) expect(list.contains(screen.getByText('Above'))).toBe(false) }) it('a row that breaks: the column keeps its title, the message is where the list was, the rest stays', () => { const quiet = vi.spyOn(console, 'error').mockImplementation(() => {}) function Broken(): never { throw new Error('boom') } const { container } = render( <>The rest of the page
>, ) expect(screen.getByText('Items')).toBeTruthy() expect(screen.getByText(/Something went wrong in the list panel/)).toBeTruthy() // Only the name comes back: the actions may be what threw. expect(screen.queryByText('Sort')).toBeNull() expect(screen.getByText('The rest of the page')).toBeTruthy() expect((container.firstElementChild as HTMLElement).className.split(' ')).toContain('w-[290px]') quiet.mockRestore() }) })