63 lines
2.0 KiB
TypeScript
63 lines
2.0 KiB
TypeScript
import { fireEvent, render, screen } from '@testing-library/react'
|
|
import { NextIntlClientProvider } from 'next-intl'
|
|
import { describe, expect, test } from 'vitest'
|
|
import BuilderClientPage from './BuilderClientPage'
|
|
import messages from '../messages/en.json'
|
|
|
|
function Wrapper({ children }: { children: React.ReactNode }) {
|
|
return (
|
|
<NextIntlClientProvider messages={messages} locale="en">
|
|
{children}
|
|
</NextIntlClientProvider>
|
|
)
|
|
}
|
|
|
|
describe('BuilderClientPage - inspector aria-describedby (Hero/CTA/FAQ)', () => {
|
|
test('Hero input references help via aria-describedby', async () => {
|
|
render(
|
|
<Wrapper>
|
|
<BuilderClientPage />
|
|
</Wrapper>
|
|
)
|
|
|
|
fireEvent.click(screen.getByTestId('card-hero'))
|
|
fireEvent.click(await screen.findByLabelText('Select 0'))
|
|
|
|
const hero = await screen.findByLabelText('Hero Heading')
|
|
expect(hero).toHaveAttribute('aria-describedby', 'ins-hero-heading-help')
|
|
})
|
|
|
|
test('CTA inputs reference help via aria-describedby', async () => {
|
|
render(
|
|
<Wrapper>
|
|
<BuilderClientPage />
|
|
</Wrapper>
|
|
)
|
|
|
|
fireEvent.click(screen.getByTestId('card-cta'))
|
|
fireEvent.click(await screen.findByLabelText('Select 0'))
|
|
|
|
const text = await screen.findByLabelText('CTA Text')
|
|
const href = await screen.findByLabelText('CTA Href')
|
|
expect(text).toHaveAttribute('aria-describedby', 'ins-cta-text-help')
|
|
expect(href).toHaveAttribute('aria-describedby', 'ins-cta-href-help')
|
|
})
|
|
|
|
test('FAQ inputs reference help via aria-describedby', async () => {
|
|
render(
|
|
<Wrapper>
|
|
<BuilderClientPage />
|
|
</Wrapper>
|
|
)
|
|
|
|
fireEvent.click(screen.getByTestId('card-faq'))
|
|
fireEvent.click(await screen.findByLabelText('Select 0'))
|
|
fireEvent.click(await screen.findByRole('button', { name: 'Add FAQ Item' }))
|
|
|
|
const q0 = await screen.findByLabelText('FAQ Q 0')
|
|
const a0 = await screen.findByLabelText('FAQ A 0')
|
|
expect(q0).toHaveAttribute('aria-describedby', 'ins-faq-help')
|
|
expect(a0).toHaveAttribute('aria-describedby', 'ins-faq-help')
|
|
})
|
|
})
|