From ab4092c0887ac48f48c2e54dfc7c4d9ed72cb934 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Sat, 19 Jul 2025 09:43:39 +0500 Subject: [PATCH] desktop: fix dialog skipping in tests --- apps/desktop/__tests__/auto-updates.test.ts | 30 ++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/desktop/__tests__/auto-updates.test.ts b/apps/desktop/__tests__/auto-updates.test.ts index 6387fdd8c..ef36cbc37 100644 --- a/apps/desktop/__tests__/auto-updates.test.ts +++ b/apps/desktop/__tests__/auto-updates.test.ts @@ -228,19 +228,19 @@ test("downgrade to stable on switching to stable release track", async (t) => { }); async function skipDialog(page: Page) { - await page - .waitForSelector(".ReactModal__Content", { - timeout: 1000 - }) - .catch(() => {}) - .then(async () => { - const positiveButton = page.locator( - "button[data-role='positive-button']" - ); - const negativeButton = page.locator( - "button[data-role='negative-button']" - ); - if (await positiveButton.isVisible()) await positiveButton.click(); - else if (await negativeButton.isVisible()) await negativeButton.click(); - }); + try { + const dialog = page.locator(".ReactModal__Content"); + const positiveButton = dialog.locator( + "button[data-role='positive-button']" + ); + const negativeButton = dialog.locator( + "button[data-role='negative-button']" + ); + if (await positiveButton.isVisible()) + await positiveButton.click({ timeout: 2000 }); + else if (await negativeButton.isVisible()) + await negativeButton.click({ timeout: 2000 }); + } catch (e) { + // ignore error + } }