41 lines
2.1 KiB
JavaScript
41 lines
2.1 KiB
JavaScript
// @ts-check
|
||
// Audio problems in the routing test result and the library voice panel (mocked routes only).
|
||
const { test, expect } = require('./_guard');
|
||
|
||
const PROBLEMS = [
|
||
{ kind: 'silence', start_s: 2.0, end_s: 4.0, detail: '2.0s of silence' },
|
||
{ kind: 'level_jump', start_s: 6.5, end_s: 6.5, detail: '+25 dB level change' },
|
||
];
|
||
|
||
async function setup(page) {
|
||
await page.route('**/api/voices/*/health', route => route.fulfill({ json: { warnings: [], problems: PROBLEMS } }));
|
||
await page.route('**/api/voices*', route => route.fulfill({ json: [] }));
|
||
await page.route('**/api/settings*', route => route.fulfill({ json: {} }));
|
||
await page.goto('/', { waitUntil: 'domcontentloaded' });
|
||
await page.waitForFunction(() => typeof window.navTo === 'function' && typeof window.fmtAudioProblems === 'function', null, { timeout: 15_000 });
|
||
}
|
||
|
||
test('fmtAudioProblems gives timestamped text', async ({ page }) => {
|
||
await setup(page);
|
||
const text = await page.evaluate(p => window.fmtAudioProblems(p), PROBLEMS);
|
||
expect(text).toBe('silence at 2s–4s (2.0s of silence); level jump at 6.5s (+25 dB level change)');
|
||
});
|
||
|
||
test('routing test result lists audio problems as text', async ({ page }) => {
|
||
await setup(page);
|
||
await page.evaluate(() => {
|
||
window.renderRouteTestResult({ requested_voice: 'a', routed_voice: 'b', voice_health: { warnings: ['Long silence in reference audio'], problems: [{ kind: 'silence', start_s: 2, end_s: 4, detail: '2.0s of silence' }] }, sounds: {} });
|
||
});
|
||
await expect(page.locator('#routing-test-result')).toContainText('Audio problems: silence at 2s–4s (2.0s of silence)');
|
||
});
|
||
|
||
test('library panel shows problems from the single-voice health endpoint', async ({ page }) => {
|
||
await setup(page);
|
||
await page.evaluate(() => {
|
||
const sel = document.getElementById('tts-voice-select');
|
||
sel.innerHTML = '<option value="EN_F_x">EN_F_x</option>'; sel.value = 'EN_F_x';
|
||
});
|
||
await page.evaluate(() => window.showVoiceProblems('EN_F_x'));
|
||
await expect(page.locator('#preview-match-problems')).toContainText('Audio problems: silence at 2s');
|
||
});
|