From 0a85df41afbdcef62346def942c3795102a9d7b6 Mon Sep 17 00:00:00 2001 From: 4gray Date: Sat, 4 Jul 2026 12:04:10 +0200 Subject: [PATCH] test(e2e): wait for DB readiness before opening the downloads page On slow CI runners (macOS) the renderer can query SQLite while the DB worker is still creating tables, leaving the downloads page on its skeleton state forever. Poll a playlist read until it succeeds before navigating on a cold profile. Co-Authored-By: Claude Fable 5 --- .../electron-backend-e2e/src/downloads.e2e.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/apps/electron-backend-e2e/src/downloads.e2e.ts b/apps/electron-backend-e2e/src/downloads.e2e.ts index 498b5e4bf..6810cc3c1 100644 --- a/apps/electron-backend-e2e/src/downloads.e2e.ts +++ b/apps/electron-backend-e2e/src/downloads.e2e.ts @@ -17,6 +17,34 @@ async function openDownloadsPage(page: Page): Promise { await page.waitForURL(/\/workspace\/downloads(?:\?.*)?$/); } +/** + * On a cold profile the renderer can query SQLite while the DB worker is + * still creating tables ("database is locked" / "no such table" on slow CI + * runners), which leaves the downloads page on its skeleton forever. Wait + * until a playlist read succeeds before navigating. + */ +async function waitForDatabaseReady(page: Page): Promise { + await expect + .poll( + () => + page.evaluate(async () => { + const electron = window.electron; + if (!electron) { + return false; + } + try { + await (electron.dbGetAppPlaylistMetas?.() ?? + electron.dbGetAppPlaylists?.()); + return true; + } catch { + return false; + } + }), + { timeout: 30000 } + ) + .toBe(true); +} + test.describe('Electron Downloads', () => { test('@downloads @electron shows the add-a-playlist empty state when no sources exist', async ({ dataDir, @@ -24,6 +52,7 @@ test.describe('Electron Downloads', () => { const app = await launchElectronApp(dataDir); try { + await waitForDatabaseReady(app.mainWindow); await openDownloadsPage(app.mainWindow); await expect(