tts-voice-creator-clone-and.../tests/voice-health.spec.js
mARTin-B78 a0cd7b867f feat(voices): show audio problems in the voice library
Single-voice health endpoint (GET /api/voices/{id}/health), problems stored in
meta on import, shown in the Try-out voice panel; architecture note and docs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 16:35:10 +02:00

41 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// @ts-check
// Audio problems in the routing test result and the library voice panel (mocked routes only).
const { test, expect } = require('@playwright/test');
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');
});