- add PageTitle and apply it on /download, /themes, /configs, /showcase, /link, 404 - reset range-slider thumbs in the theme editor; fold color picker into the swatch - hide horizontal scrollbars in the ClickGui mock; clip html to kill 100vw pan - pin the footer under short pages via flex AppShell; split 404 art from caption - one landing CTA geometry (lv-cta-lg / quiet); CLOUD eyebrow; auth caption scrim - showcase error hides sort/pager; query retry limited to 1
45 lines
1.9 KiB
TypeScript
45 lines
1.9 KiB
TypeScript
import { render, screen } from '@testing-library/react'
|
||
import userEvent from '@testing-library/user-event'
|
||
import { expect, test, vi } from 'vitest'
|
||
import { Button } from '../Button'
|
||
import { PageTitle } from '../PageTitle'
|
||
import { TextField } from '../TextField'
|
||
import { ShareCode } from '../ShareCode'
|
||
import { Notice } from '../Notice'
|
||
|
||
test('busy button is disabled and announces busy', () => {
|
||
render(<Button busy>Сохранить</Button>)
|
||
const b = screen.getByRole('button', { name: 'Сохранить' })
|
||
expect(b).toBeDisabled()
|
||
expect(b).toHaveAttribute('aria-busy', 'true')
|
||
})
|
||
|
||
test('text field links label and error', () => {
|
||
render(<TextField label="Почта" error="Введи почту" />)
|
||
const input = screen.getByLabelText('Почта')
|
||
expect(input).toHaveAttribute('aria-invalid', 'true')
|
||
expect(input).toHaveAccessibleDescription('Введи почту')
|
||
})
|
||
|
||
test('share code copies to clipboard and confirms', async () => {
|
||
const user = userEvent.setup()
|
||
const writeText = vi.spyOn(navigator.clipboard, 'writeText').mockResolvedValue()
|
||
render(<ShareCode code="7KQ3M9XA" />)
|
||
expect(screen.getByText('7KQ3M9XA')).toBeInTheDocument()
|
||
await user.click(screen.getByRole('button', { name: 'Скопировать' }))
|
||
expect(writeText).toHaveBeenCalledWith('7KQ3M9XA')
|
||
expect(await screen.findByText('Скопировано')).toBeInTheDocument()
|
||
})
|
||
|
||
test('error notice is an alert', () => {
|
||
render(<Notice tone="error">Неверный код</Notice>)
|
||
expect(screen.getByRole('alert')).toHaveTextContent('Неверный код')
|
||
})
|
||
|
||
test('page title renders one h1 with an optional lead', () => {
|
||
render(
|
||
<PageTitle lead="Короткое описание">Мои конфиги</PageTitle>,
|
||
)
|
||
expect(screen.getByRole('heading', { level: 1, name: 'Мои конфиги' })).toBeInTheDocument()
|
||
expect(screen.getByText('Короткое описание')).toBeInTheDocument()
|
||
})
|