feat(transcript): add a popup language search

This commit is contained in:
yiling
2026-12-05 12:57:15 +08:00
parent 70e4c63323
commit 0ba3349335
7 changed files with 92 additions and 31 deletions
@@ -93,23 +93,43 @@ test('starts a transcript for an archived video and tracks it in the file metada
}
await openDialog()
const dialog = page.getByRole('dialog', { name: 'Generate Transcripts' })
const language = dialog.getByRole('combobox', { name: 'Language' })
const language = dialog.getByRole('combobox', { name: 'Language', exact: true })
const generate = dialog.getByRole('button', { name: 'Generate', exact: true })
const metadata = fileCard(page, fileName).getByTestId('file-card-metadata')
const searchBox = dialog.getByRole('combobox', { name: 'Search languages' })
const dialogHeight = () => dialog.evaluate((element) => element.clientHeight)
await expect(language).toBeEnabled()
const closedHeight = await dialogHeight()
await language.press('ArrowDown')
await expect(dialog.getByRole('option', { name: 'English' })).toBeVisible()
expect(await dialogHeight()).toBe(closedHeight)
await expect(searchBox).toBeFocused()
await searchBox.fill('unmatched query')
await expect(dialog.getByText('No matching languages.')).toBeVisible()
expect(await dialogHeight()).toBe(closedHeight)
await searchBox.press('Escape')
await expect(searchBox).toBeHidden()
await expect(language).toBeFocused()
await expect(language).toHaveText('Auto')
const selectLanguage = async (search: string, name: string) => {
await language.fill(search)
await language.click()
await expect(searchBox).toHaveValue('')
await searchBox.fill(search)
await expect(dialog.getByRole('option')).toHaveCount(1)
await expect(dialog.getByRole('option', { name })).toBeVisible()
await language.press('ArrowDown')
await expect(language).toHaveAttribute('aria-activedescendant', /.+/)
await language.press('Enter')
await expect(language).toHaveValue(name)
await searchBox.press('ArrowDown')
await expect(searchBox).toHaveAttribute('aria-activedescendant', /.+/)
await searchBox.press('Enter')
await expect(searchBox).toBeHidden()
await expect(language).toHaveText(name)
}
await expect(language).toHaveValue('Auto')
await selectLanguage('Simplified', 'Chinese (Simplified)')
await generate.click()
await expect(dialog.getByRole('alert')).toBeVisible()
await expect(language).toHaveValue('Chinese (Simplified)')
await expect(language).toHaveText('Chinese (Simplified)')
await generate.click()
await expect(dialog).toBeHidden()
await expect(metadata).toHaveText('Transcribing…')