Explain save failures and keep download diagnostics available

This commit is contained in:
Jonathan Sykes
2026-10-03 19:23:07 +08:00
parent f341b0c76e
commit 5e78374efb
10 changed files with 209 additions and 4 deletions

View File

@@ -44,3 +44,29 @@ test('normal resumptions do not force the server to restart a cache job', async
expect(retries).toBe(0);
expect(await page.evaluate(id => cachedIds.has(id), id)).toBe(true);
});
for (const layout of ['classic', 'glass-stage']) for (const width of [390, 1440]) for (const screen of ['downloads', 'settings']) {
test(`${layout} ${width} ${screen}: friendly failure retains safe technical details`, async ({ page }) => {
await page.setViewportSize({ width, height: 844 });
await openClassic(page, { settings: { autoPreload: false } });
const raw = `ERROR: [youtube] ${id}: Video unavailable\nYouTube clients tried: default, web_embedded, web_safari\n<script>window.unsafeDetail=true</script>`;
await page.evaluate(({ layout, screen, id, raw }) => {
data.settings.layout = layout; applyAppearance();
SaveQueue.add({ id, title: 'Rock Medley', channel: 'Petra - Topic' });
SaveQueue.state(id, 'failed', raw);
view = { type: screen }; render();
}, { layout, screen, id, raw });
if (screen === 'settings') await page.locator('[data-section="downloads-storage"]').click();
const row = page.locator(screen === 'settings' ? '.download-job' : '.dl-failed').first();
await expect(row).toContainText('YouTube isn’t letting the server save this video.');
await expect(row.locator('pre')).toBeHidden();
const summary = row.locator('summary');
expect((await summary.boundingBox()).height).toBeGreaterThanOrEqual(44);
await summary.click();
await expect(row.locator('pre')).toHaveText(raw);
expect(await page.evaluate(() => window.unsafeDetail)).toBeUndefined();
const bounds = await row.evaluate(el => ({ width: el.clientWidth, content: el.scrollWidth, children: [...el.querySelectorAll('*')].filter(child => child.scrollWidth > child.clientWidth + 1).map(child => [child.tagName, child.className, child.clientWidth, child.scrollWidth]) }));
expect(bounds.content <= bounds.width + 1, JSON.stringify(bounds)).toBe(true);
await expect(row.getByRole('button', { name: 'Retry Rock Medley', exact: true })).toBeVisible();
});
}