Skip to content

Commit 52ec9de

Browse files
author
Mohammod Al Amin Ashik
committed
refactor: Move desktop-specific E2E tests to WebdriverIO
- Create settings-desktop.wdio.ts for Tauri-specific tests - Remove desktop tests from settings.spec.ts (Playwright web-only) - Desktop tests require Tauri backend (auto-start, system tray) - Web tests remain for UI/layout verification only This fixes E2E test failures in web mode by properly separating desktop integration tests from web-only UI tests.
1 parent a02c654 commit 52ec9de

2 files changed

Lines changed: 227 additions & 260 deletions

File tree

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
/**
2+
* Desktop-only E2E tests for Settings (requires Tauri backend)
3+
* Run with: pnpm test:e2e --spec tests/e2e/specs/settings-desktop.wdio.ts
4+
*/
5+
6+
import { expect, browser } from '@wdio/globals';
7+
8+
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();
14+
15+
const settingsBtn = await $('nav button[data-testid="nav-settings"]');
16+
await settingsBtn.waitForClickable();
17+
await settingsBtn.click();
18+
19+
// Wait for settings page to load
20+
await browser.pause(500);
21+
});
22+
23+
describe('Startup & System Tray Settings', () => {
24+
it('should display startup settings section', async () => {
25+
const heading = await $('h3*=Startup & System Tray');
26+
await expect(heading).toBeDisplayed();
27+
28+
const description = await $('p*=Control how McpMux starts');
29+
await expect(description).toBeDisplayed();
30+
});
31+
32+
it('should display all three startup toggles', async () => {
33+
const autoLaunchLabel = await $('label*=Launch at Startup');
34+
await expect(autoLaunchLabel).toBeDisplayed();
35+
36+
const startMinimizedLabel = await $('label*=Start Minimized');
37+
await expect(startMinimizedLabel).toBeDisplayed();
38+
39+
const closeToTrayLabel = await $('label*=Close to Tray');
40+
await expect(closeToTrayLabel).toBeDisplayed();
41+
});
42+
43+
it('should display descriptive text for each setting', async () => {
44+
const autoLaunchDesc = await $('p*=Start McpMux automatically');
45+
await expect(autoLaunchDesc).toBeDisplayed();
46+
47+
const startMinimizedDesc = await $('p*=Launch in background');
48+
await expect(startMinimizedDesc).toBeDisplayed();
49+
50+
const closeToTrayDesc = await $('p*=Keep running in system tray');
51+
await expect(closeToTrayDesc).toBeDisplayed();
52+
});
53+
54+
it('should have functional toggle switches', async () => {
55+
const autoLaunchSwitch = await $('[data-testid="auto-launch-switch"]');
56+
await expect(autoLaunchSwitch).toBeDisplayed();
57+
await expect(autoLaunchSwitch).toBeEnabled();
58+
59+
const closeToTraySwitch = await $('[data-testid="close-to-tray-switch"]');
60+
await expect(closeToTraySwitch).toBeDisplayed();
61+
await expect(closeToTraySwitch).toBeEnabled();
62+
63+
const startMinimizedSwitch = await $('[data-testid="start-minimized-switch"]');
64+
await expect(startMinimizedSwitch).toBeDisplayed();
65+
});
66+
67+
it('should toggle auto-launch setting', async () => {
68+
const autoLaunchSwitch = await $('[data-testid="auto-launch-switch"]');
69+
70+
const initialState = await autoLaunchSwitch.getAttribute('aria-checked');
71+
72+
await autoLaunchSwitch.click();
73+
await browser.pause(500);
74+
75+
const newState = await autoLaunchSwitch.getAttribute('aria-checked');
76+
expect(newState).not.toBe(initialState);
77+
78+
// Toggle back
79+
await autoLaunchSwitch.click();
80+
await browser.pause(500);
81+
82+
const finalState = await autoLaunchSwitch.getAttribute('aria-checked');
83+
expect(finalState).toBe(initialState);
84+
});
85+
86+
it('should toggle close to tray setting', async () => {
87+
const closeToTraySwitch = await $('[data-testid="close-to-tray-switch"]');
88+
89+
const initialState = await closeToTraySwitch.getAttribute('aria-checked');
90+
91+
await closeToTraySwitch.click();
92+
await browser.pause(500);
93+
94+
const newState = await closeToTraySwitch.getAttribute('aria-checked');
95+
expect(newState).not.toBe(initialState);
96+
97+
// Toggle back
98+
await closeToTraySwitch.click();
99+
await browser.pause(500);
100+
101+
const finalState = await closeToTraySwitch.getAttribute('aria-checked');
102+
expect(finalState).toBe(initialState);
103+
});
104+
105+
it('start minimized should be disabled when auto-launch is off', async () => {
106+
const autoLaunchSwitch = await $('[data-testid="auto-launch-switch"]');
107+
const startMinimizedSwitch = await $('[data-testid="start-minimized-switch"]');
108+
109+
// Ensure auto-launch is off
110+
const autoLaunchState = await autoLaunchSwitch.getAttribute('aria-checked');
111+
if (autoLaunchState === 'true') {
112+
await autoLaunchSwitch.click();
113+
await browser.pause(500);
114+
}
115+
116+
// Start minimized should be disabled
117+
const isDisabled = await startMinimizedSwitch.getAttribute('disabled');
118+
expect(isDisabled).toBe('true');
119+
120+
const ariaChecked = await startMinimizedSwitch.getAttribute('aria-checked');
121+
expect(ariaChecked).toBe('false');
122+
});
123+
124+
it('start minimized should be enabled when auto-launch is on', async () => {
125+
const autoLaunchSwitch = await $('[data-testid="auto-launch-switch"]');
126+
const startMinimizedSwitch = await $('[data-testid="start-minimized-switch"]');
127+
128+
// Ensure auto-launch is on
129+
const autoLaunchState = await autoLaunchSwitch.getAttribute('aria-checked');
130+
if (autoLaunchState === 'false') {
131+
await autoLaunchSwitch.click();
132+
await browser.pause(500);
133+
}
134+
135+
// Start minimized should be enabled
136+
const isDisabled = await startMinimizedSwitch.getAttribute('disabled');
137+
expect(isDisabled).toBeNull();
138+
});
139+
140+
it('should toggle start minimized when enabled', async () => {
141+
const autoLaunchSwitch = await $('[data-testid="auto-launch-switch"]');
142+
const startMinimizedSwitch = await $('[data-testid="start-minimized-switch"]');
143+
144+
// Ensure auto-launch is on first
145+
const autoLaunchState = await autoLaunchSwitch.getAttribute('aria-checked');
146+
if (autoLaunchState === 'false') {
147+
await autoLaunchSwitch.click();
148+
await browser.pause(500);
149+
}
150+
151+
const initialState = await startMinimizedSwitch.getAttribute('aria-checked');
152+
153+
await startMinimizedSwitch.click();
154+
await browser.pause(500);
155+
156+
const newState = await startMinimizedSwitch.getAttribute('aria-checked');
157+
expect(newState).not.toBe(initialState);
158+
159+
// Toggle back
160+
await startMinimizedSwitch.click();
161+
await browser.pause(500);
162+
163+
const finalState = await startMinimizedSwitch.getAttribute('aria-checked');
164+
expect(finalState).toBe(initialState);
165+
});
166+
167+
it('should persist settings across page reloads', async () => {
168+
const closeToTraySwitch = await $('[data-testid="close-to-tray-switch"]');
169+
170+
const initialState = await closeToTraySwitch.getAttribute('aria-checked');
171+
172+
await closeToTraySwitch.click();
173+
await browser.pause(500);
174+
175+
// Reload the page
176+
await browser.refresh();
177+
await browser.pause(1000);
178+
179+
// Navigate to settings again
180+
const settingsBtn = await $('nav button[data-testid="nav-settings"]');
181+
await settingsBtn.waitForClickable();
182+
await settingsBtn.click();
183+
await browser.pause(500);
184+
185+
// Verify state persisted
186+
const persistedState = await closeToTraySwitch.getAttribute('aria-checked');
187+
expect(persistedState).not.toBe(initialState);
188+
189+
// Restore original state
190+
await closeToTraySwitch.click();
191+
await browser.pause(500);
192+
});
193+
194+
it('should show disabled state visually for start minimized', async () => {
195+
const autoLaunchSwitch = await $('[data-testid="auto-launch-switch"]');
196+
const startMinimizedSwitch = await $('[data-testid="start-minimized-switch"]');
197+
198+
// Ensure auto-launch is off
199+
const autoLaunchState = await autoLaunchSwitch.getAttribute('aria-checked');
200+
if (autoLaunchState === 'true') {
201+
await autoLaunchSwitch.click();
202+
await browser.pause(500);
203+
}
204+
205+
// Check that start minimized has disabled styling
206+
const className = await startMinimizedSwitch.getAttribute('class');
207+
expect(className).toContain('opacity-50');
208+
});
209+
210+
it('all settings should work independently', async () => {
211+
const closeToTraySwitch = await $('[data-testid="close-to-tray-switch"]');
212+
213+
// Close to tray should work regardless of auto-launch state
214+
const initialCloseToTray = await closeToTraySwitch.getAttribute('aria-checked');
215+
216+
await closeToTraySwitch.click();
217+
await browser.pause(500);
218+
219+
const newCloseToTray = await closeToTraySwitch.getAttribute('aria-checked');
220+
expect(newCloseToTray).not.toBe(initialCloseToTray);
221+
222+
// Restore
223+
await closeToTraySwitch.click();
224+
await browser.pause(500);
225+
});
226+
});
227+
});

0 commit comments

Comments
 (0)