mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 06:43:06 +00:00
Some checks are pending
Deploy / preflight (push) Waiting to run
Deploy / verify (push) Blocked by required conditions
Deploy / deploy staging (teqo-staging) (push) Blocked by required conditions
Deploy / requeue when main advanced (push) Blocked by required conditions
Deploy / deploy production (teqo-1313) (push) Blocked by required conditions
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
import { SpeechExcerptCta } from '@/components/campaign/speech/SpeechExcerptCta'
|
|
import { SPEECH_EXCERPT_REQUEST_EVENT } from '@/lib/speechExcerptSelection'
|
|
|
|
const originalScrollIntoView = Element.prototype.scrollIntoView
|
|
|
|
afterEach(() => {
|
|
cleanup()
|
|
// jsdom has no scrollIntoView; the stub is restored so it cannot leak.
|
|
if (originalScrollIntoView) Element.prototype.scrollIntoView = originalScrollIntoView
|
|
else delete (Element.prototype as { scrollIntoView?: unknown }).scrollIntoView
|
|
})
|
|
|
|
describe('SpeechExcerptCta (C174)', () => {
|
|
it('announces the excerpt intent and scrolls the player into view', () => {
|
|
const scrollIntoView = vi.fn()
|
|
Element.prototype.scrollIntoView = scrollIntoView
|
|
const listened = vi.fn()
|
|
window.addEventListener(SPEECH_EXCERPT_REQUEST_EVENT, listened)
|
|
|
|
render(
|
|
<>
|
|
<div data-slot="speech-player" />
|
|
<SpeechExcerptCta />
|
|
</>,
|
|
)
|
|
|
|
fireEvent.click(screen.getByRole('button', { name: /selecionar trecho/i }))
|
|
|
|
expect(listened).toHaveBeenCalledTimes(1)
|
|
expect(scrollIntoView).toHaveBeenCalledWith({ block: 'start' })
|
|
|
|
window.removeEventListener(SPEECH_EXCERPT_REQUEST_EVENT, listened)
|
|
})
|
|
})
|