mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-12 03:56:15 -08:00
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
f8fb03ef1e
commit
0a85df41af
1 file changed
+29
@@ -17,6 +17,34 @@ async function openDownloadsPage(page: Page): Promise<void> {
|
||||
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<void> {
|
||||
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(
|
||||
|
||||
Reference in new issue
Block a user