Open History to see the last commit
1import { test, expect } from './fixtures'
2import {
3 clickGenerate,
4 featureUrl,
5 fillPrompt,
6 waitForGenerationComplete,
7} from './helpers'
8import { providersFor } from './test-matrix'
9
10const PROMPT =
11 'A warm, gravelly narrator in his sixties with a slight Irish lilt'
12
13for (const provider of providersFor('voice-design')) {
14 test.describe(`${provider} -- voice-design`, () => {
15 test('designs candidate voices from a description', async ({
16 page,
17 testId,
18 aimockPort,
19 }) => {
20 await page.goto(featureUrl(provider, 'voice-design', testId, aimockPort))
21 await fillPrompt(page, PROMPT)
22 await clickGenerate(page)
23 await waitForGenerationComplete(page)
24
25 const voices = page.getByTestId('designed-voice')
26 await expect(voices).toHaveCount(2)
27 // Unsaved candidates keep the provider's preview ids.
28 await expect(voices.first()).toHaveAttribute(
29 'data-voice-id',
30 'e2e-preview-1',
31 )
32 await expect(voices.first()).toHaveAttribute('data-saved', 'false')
33 await expect(
34 page.getByTestId('voice-preview-audio').first(),
35 ).toBeVisible()
36 await expect(page.getByTestId('voice-preview-text')).toContainText(
37 'quick brown fox',
38 )
39 })
40
41 test('promotes the first candidate into a saved voice', async ({
42 page,
43 testId,
44 aimockPort,
45 }) => {
46 await page.goto(featureUrl(provider, 'voice-design', testId, aimockPort))
47 await fillPrompt(page, PROMPT)
48 await page.getByTestId('save-voice-toggle').check()
49 await page.getByTestId('voice-name-input').fill('Irish Narrator')
50 await clickGenerate(page)
51 await waitForGenerationComplete(page)
52
53 const voices = page.getByTestId('designed-voice')
54 await expect(voices).toHaveCount(2)
55 // The promoted candidate swaps its preview id for a library voice id;
56 // the runner-up stays an unsaved preview.
57 await expect(voices.first()).toHaveAttribute(
58 'data-voice-id',
59 'e2e-saved-voice',
60 )
61 await expect(voices.first()).toHaveAttribute('data-saved', 'true')
62 await expect(voices.nth(1)).toHaveAttribute('data-saved', 'false')
63 })
64 })
65}