Load the whole song into the browser for the lyrics editor so audio no longer stops

This commit is contained in:
Jonathan Sykes
2026-10-11 03:57:02 +08:00
parent f84ecb5ae9
commit 785e903e1e
2 changed files with 82 additions and 4 deletions

View File

@@ -150,3 +150,18 @@ test('player lyric editor groups Shift+Enter words and stamps their shared cue',
const document = await text.inputValue(); expect(document).toContain('[0:00.00] Because You are God\n| You can do anything');
expect(document).not.toContain('[0:00.00] |');
});
test('editor loads the whole audio into the browser once and reuses it', async ({ page }) => {
const wav = Buffer.alloc(44 + 16000); // 1 s of silence, 8 kHz 16-bit mono
wav.write('RIFF', 0); wav.writeUInt32LE(36 + 16000, 4); wav.write('WAVEfmt ', 8); wav.writeUInt32LE(16, 16);
wav.writeUInt16LE(1, 20); wav.writeUInt16LE(1, 22); wav.writeUInt32LE(8000, 24); wav.writeUInt32LE(16000, 28);
wav.writeUInt16LE(2, 32); wav.writeUInt16LE(16, 34); wav.write('data', 36); wav.writeUInt32LE(16000, 40);
let hits = 0;
await fixture(page);
await page.route('**/api/media/' + id + '?a=1', route => { hits++; route.fulfill({ contentType: 'audio/wav', body: wav }); });
await page.locator('[data-open="' + id + '"]').first().click();
await expect(page.locator('#dur')).toHaveText('0:01');
expect(hits).toBe(1);
await page.reload(); await page.locator('[data-open="' + id + '"]').first().click();
await expect(page.locator('#dur')).toHaveText('0:01');
expect(hits).toBe(1);
});