mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 22:14:50 +00:00
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import { expect, test } from '../../fixtures'
|
|
import { fileCard } from '../../helpers/files'
|
|
|
|
test.use({ fileOptions: { mediaType: 'video' } })
|
|
|
|
test('selects a transcription language from the video context menu and tracks the job', async ({
|
|
file,
|
|
prisma,
|
|
}) => {
|
|
const { page, projectId, fileId, fileName } = file
|
|
let submitted = false
|
|
await page.route('**/api/signup-info', async (route) => {
|
|
const response = await route.fetch()
|
|
await route.fulfill({ json: { ...(await response.json()), transcriptionEnabled: true } })
|
|
})
|
|
await page.route('**/api/transcription/languages', (route) =>
|
|
route.fulfill({
|
|
json: {
|
|
model: 'whisper-tiny',
|
|
languages: [
|
|
{ code: 'en', name: 'English' },
|
|
{ code: 'zh', name: 'Chinese' },
|
|
],
|
|
},
|
|
}),
|
|
)
|
|
await page.route(`**/api/files/${fileId}/transcription-status`, (route) =>
|
|
route.fulfill({
|
|
body: JSON.stringify(submitted ? { taskId: 'transcript-task', status: 'completed' } : null),
|
|
contentType: 'application/json',
|
|
}),
|
|
)
|
|
await page.route(`**/api/files/${fileId}/transcripts`, async (route) => {
|
|
expect(route.request().postDataJSON()).toEqual({ language: 'zh' })
|
|
submitted = true
|
|
await route.fulfill({ status: 202, json: { kind: 'queued', taskId: 'transcript-task' } })
|
|
})
|
|
|
|
await expect
|
|
.poll(() =>
|
|
prisma.asset.findUnique({
|
|
where: { id: fileId },
|
|
select: { status: true, media: true },
|
|
}),
|
|
)
|
|
.toMatchObject({ status: 'processed', media: { proxyType: 'video' } })
|
|
const [signupInfo] = await Promise.all([
|
|
page.waitForResponse('**/api/signup-info'),
|
|
page.goto(`/projects/${projectId}`),
|
|
])
|
|
expect(await signupInfo.json()).toMatchObject({ transcriptionEnabled: true })
|
|
await fileCard(page, fileName).click({ button: 'right' })
|
|
await page.getByRole('menuitem', { name: 'Generate Transcripts' }).click()
|
|
const dialog = page.getByRole('dialog', { name: 'Generate Transcripts' })
|
|
const language = dialog.getByRole('combobox', { name: 'Language' })
|
|
await expect(language).toHaveValue('Auto')
|
|
await language.fill('Chi')
|
|
await dialog.getByRole('option', { name: 'Chinese' }).click()
|
|
await expect(language).toHaveValue('Chinese')
|
|
await dialog.getByRole('button', { name: 'Generate', exact: true }).click()
|
|
await expect(dialog.getByRole('status')).toHaveText('Transcript generated.')
|
|
})
|