|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | import { expect, browser } from '@wdio/globals'; |
| 7 | +import { byTestId, TIMEOUT } from '../helpers/selectors'; |
7 | 8 |
|
8 | 9 | describe('Settings - Desktop Features', () => { |
9 | | - beforeEach(async () => { |
10 | | - // Navigate to settings page |
11 | | - const dashboardBtn = await $('nav button[data-testid="nav-dashboard"]'); |
12 | | - await dashboardBtn.waitForClickable(); |
13 | | - await dashboardBtn.click(); |
| 10 | + before(async () => { |
| 11 | + // Let the app and WebView load (spec may run in isolation so no prior tests have warmed the UI) |
| 12 | + await browser.pause(5000); |
| 13 | + // Ensure app shell is ready before any test |
| 14 | + const sidebar = await byTestId('sidebar'); |
| 15 | + await sidebar.waitForDisplayed({ timeout: TIMEOUT.veryLong }); |
| 16 | + const navSettings = await byTestId('nav-settings'); |
| 17 | + await navSettings.waitForClickable({ timeout: TIMEOUT.medium }); |
| 18 | + }); |
14 | 19 |
|
15 | | - const settingsBtn = await $('nav button[data-testid="nav-settings"]'); |
16 | | - await settingsBtn.waitForClickable(); |
| 20 | + beforeEach(async () => { |
| 21 | + // Go to Settings (same pattern as settings.wdio.ts) |
| 22 | + const settingsBtn = await byTestId('nav-settings'); |
17 | 23 | await settingsBtn.click(); |
18 | | - |
19 | | - // Wait for settings page to load |
20 | | - await browser.pause(500); |
| 24 | + // Wait for desktop Startup section to be present (section is always rendered; toggles may still be loading) |
| 25 | + const startupSection = await byTestId('settings-startup-section'); |
| 26 | + await startupSection.waitForDisplayed({ timeout: TIMEOUT.medium }); |
| 27 | + // Wait for toggles to be interactive (get_startup_settings has resolved) |
| 28 | + const autoLaunchSwitch = await byTestId('auto-launch-switch'); |
| 29 | + await autoLaunchSwitch.waitForDisplayed({ timeout: TIMEOUT.medium }); |
21 | 30 | }); |
22 | 31 |
|
23 | 32 | describe('Startup & System Tray Settings', () => { |
@@ -175,20 +184,20 @@ describe('Settings - Desktop Features', () => { |
175 | 184 |
|
176 | 185 | // Reload the page |
177 | 186 | await browser.refresh(); |
178 | | - await browser.pause(1000); |
179 | 187 |
|
180 | | - // Navigate to settings again |
| 188 | + // Navigate to settings again and wait for section to load |
181 | 189 | const settingsBtn = await $('nav button[data-testid="nav-settings"]'); |
182 | 190 | await settingsBtn.waitForClickable(); |
183 | 191 | await settingsBtn.click(); |
184 | | - await browser.pause(500); |
| 192 | + const switchAfterReload = await $('[data-testid="close-to-tray-switch"]'); |
| 193 | + await switchAfterReload.waitForDisplayed({ timeout: TIMEOUT.medium }); |
185 | 194 |
|
186 | 195 | // Verify state persisted |
187 | | - const persistedState = await closeToTraySwitch.getAttribute('aria-checked'); |
| 196 | + const persistedState = await switchAfterReload.getAttribute('aria-checked'); |
188 | 197 | expect(persistedState).not.toBe(initialState); |
189 | 198 |
|
190 | 199 | // Restore original state |
191 | | - await closeToTraySwitch.click(); |
| 200 | + await switchAfterReload.click(); |
192 | 201 | await browser.pause(500); |
193 | 202 | }); |
194 | 203 |
|
|
0 commit comments