Skip to content

Commit 9b981f3

Browse files
CodeGhost21claude
andcommitted
fix(e2e): fix prettier formatting and login-flow syntax error
- Rewrite login-flow.spec.ts (was mangled by external edits) - Run prettier on all E2E files to pass CI formatting check - Keep waitForAuthBootstrap from app-helpers.ts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f92ec4c commit 9b981f3

11 files changed

Lines changed: 197 additions & 202 deletions

app/test/e2e/helpers/app-helpers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* DOM via W3C WebDriver. Readiness is detected by checking document state
1212
* and the presence of the React root element.
1313
*/
14-
1514
import { isTauriDriver } from './platform';
1615

1716
/**

app/test/e2e/helpers/deep-link-helpers.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ function resolveBuiltAppPath(): string | null {
133133
*/
134134
export async function triggerDeepLink(url: string): Promise<void> {
135135
const appPath = resolveBuiltAppPath();
136-
deepLinkDebug('triggerDeepLink', { url, appPath: appPath ?? '(none)', platform: process.platform });
136+
deepLinkDebug('triggerDeepLink', {
137+
url,
138+
appPath: appPath ?? '(none)',
139+
platform: process.platform,
140+
});
137141

138142
if (typeof browser !== 'undefined') {
139143
// Strategy 1: WebView simulate (works on tauri-driver, skipped on Mac2)
@@ -180,9 +184,7 @@ export async function triggerDeepLink(url: string): Promise<void> {
180184
return;
181185
} catch (err) {
182186
deepLinkDebug('xdg-open failed', err instanceof Error ? err.message : err);
183-
throw new Error(
184-
`Failed to trigger deep link: ${err instanceof Error ? err.message : err}`
185-
);
187+
throw new Error(`Failed to trigger deep link: ${err instanceof Error ? err.message : err}`);
186188
}
187189
}
188190

app/test/e2e/helpers/element-helpers.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ export async function waitForWindowVisible(
218218
* - Mac2: Wait for XCUIElementTypeWebView in accessibility tree
219219
* - tauri-driver: Wait for document.readyState === 'complete'
220220
*/
221-
export async function waitForWebView(timeout: number = 20_000): Promise<ChainablePromiseElement | null> {
221+
export async function waitForWebView(
222+
timeout: number = 20_000
223+
): Promise<ChainablePromiseElement | null> {
222224
if (isTauriDriver()) {
223225
const start = Date.now();
224226
while (Date.now() - start < timeout) {
@@ -272,10 +274,7 @@ export async function clickButton(
272274
* - Mac2: XCUIElementTypeButton XPath + W3C pointer click
273275
* - tauri-driver: CSS button selector + standard click
274276
*/
275-
export async function clickNativeButton(
276-
text: string,
277-
timeout: number = 15_000
278-
): Promise<void> {
277+
export async function clickNativeButton(text: string, timeout: number = 15_000): Promise<void> {
279278
const el = await waitForButton(text, timeout);
280279
await clickAtElement(el);
281280
}

app/test/e2e/helpers/platform.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ export function isTauriDriver(): boolean {
3030
// Appium Mac2 always sets automationName to 'mac2'
3131
if (automation === 'mac2' || automation.includes('mac2')) return false;
3232

33-
const platform = String(
34-
caps.platformName ?? caps['appium:platformName'] ?? ''
35-
).toLowerCase();
33+
const platform = String(caps.platformName ?? caps['appium:platformName'] ?? '').toLowerCase();
3634

3735
// If platformName is 'mac' it's Appium on macOS even without automationName
3836
if (platform === 'mac') return false;

app/test/e2e/specs/auth-access-control.spec.ts

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ async function navigateToHome() {
9090
await browser.pause(2_000);
9191
const homeText = await waitForHomePage(15_000);
9292
if (!homeText) {
93-
try { await clickNativeButton('Home', 5_000); } catch { /* ignore */ }
93+
try {
94+
await clickNativeButton('Home', 5_000);
95+
} catch {
96+
/* ignore */
97+
}
9498
await browser.pause(2_000);
9599
await waitForHomePage(10_000);
96100
}
@@ -108,12 +112,14 @@ async function navigateToBilling() {
108112
// Wait for Settings page content.
109113
// Note: "Billing & Usage" contains "&" which breaks XPath — use "Billing" only.
110114
const settingsLoaded =
111-
(await textExists('Billing')) ||
112-
(await textExists('Profile')) ||
113-
(await textExists('Privacy'));
115+
(await textExists('Billing')) || (await textExists('Profile')) || (await textExists('Privacy'));
114116
if (!settingsLoaded) {
115117
console.log('[AuthAccess] Settings page not loaded, retrying click...');
116-
try { await clickNativeButton('Settings', 5_000); } catch { /* ignore */ }
118+
try {
119+
await clickNativeButton('Settings', 5_000);
120+
} catch {
121+
/* ignore */
122+
}
117123
await browser.pause(3_000);
118124
}
119125

@@ -165,21 +171,32 @@ async function performFullLogin(token = 'e2e-test-token') {
165171
await browser.pause(2_000);
166172

167173
for (const text of ['Looks Amazing', 'Bring It On']) {
168-
if (await textExists(text)) { await clickText(text, 5_000); break; }
174+
if (await textExists(text)) {
175+
await clickText(text, 5_000);
176+
break;
177+
}
169178
}
170179
await browser.pause(2_000);
171180

172181
for (const text of ['Got it', 'Continue']) {
173-
if (await textExists(text)) { await clickText(text, 5_000); break; }
182+
if (await textExists(text)) {
183+
await clickText(text, 5_000);
184+
break;
185+
}
174186
}
175187
await browser.pause(2_000);
176188

177189
for (const text of ["Let's Go", "I'm Ready"]) {
178-
if (await textExists(text)) { await clickText(text, 5_000); break; }
190+
if (await textExists(text)) {
191+
await clickText(text, 5_000);
192+
break;
193+
}
179194
}
180195
await browser.pause(3_000);
181196
} else {
182-
console.log('[AuthAccess] Onboarding overlay not visible — skipping (WKWebView portal limitation)');
197+
console.log(
198+
'[AuthAccess] Onboarding overlay not visible — skipping (WKWebView portal limitation)'
199+
);
183200
await browser.pause(3_000);
184201
}
185202

@@ -223,7 +240,11 @@ describe('Auth & Access Control', () => {
223240

224241
const homeText = await waitForHomePage(15_000);
225242
if (!homeText) {
226-
try { await clickNativeButton('Home', 5_000); } catch { /* ignore */ }
243+
try {
244+
await clickNativeButton('Home', 5_000);
245+
} catch {
246+
/* ignore */
247+
}
227248
await browser.pause(2_000);
228249
}
229250
const finalHome = homeText || (await waitForHomePage(10_000));
@@ -238,7 +259,11 @@ describe('Auth & Access Control', () => {
238259

239260
const homeText = await waitForHomePage(15_000);
240261
if (!homeText) {
241-
try { await clickNativeButton('Home', 5_000); } catch { /* ignore */ }
262+
try {
263+
await clickNativeButton('Home', 5_000);
264+
} catch {
265+
/* ignore */
266+
}
242267
await browser.pause(2_000);
243268
}
244269
const finalHome = homeText || (await waitForHomePage(10_000));
@@ -259,8 +284,7 @@ describe('Auth & Access Control', () => {
259284
await navigateToBilling();
260285

261286
// BillingPanel heading: "Current Plan — FREE"
262-
const hasPlan =
263-
(await textExists('Current Plan')) || (await textExists('FREE'));
287+
const hasPlan = (await textExists('Current Plan')) || (await textExists('FREE'));
264288
if (!hasPlan) {
265289
const tree = await dumpAccessibilityTree();
266290
console.log('[AuthAccess] Billing page tree:\n', tree.slice(0, 6000));
@@ -295,8 +319,7 @@ describe('Auth & Access Control', () => {
295319
}
296320

297321
// Verify purchasing state appears
298-
const hasWaiting =
299-
(await textExists('Waiting')) || (await textExists('Waiting for payment'));
322+
const hasWaiting = (await textExists('Waiting')) || (await textExists('Waiting for payment'));
300323
console.log(`[AuthAccess] Purchasing state visible: ${hasWaiting}`);
301324

302325
// Switch mock to BASIC plan so polling clears the waiting state
@@ -334,7 +357,9 @@ describe('Auth & Access Control', () => {
334357

335358
// Check that plan info is displayed (Current Plan heading or tier name)
336359
const hasPlanInfo =
337-
(await textExists('Current Plan')) || (await textExists('BASIC')) || (await textExists('Basic'));
360+
(await textExists('Current Plan')) ||
361+
(await textExists('BASIC')) ||
362+
(await textExists('Basic'));
338363
expect(hasPlanInfo).toBe(true);
339364

340365
// "Manage" button appears when hasActiveSubscription is true in currentPlan response.
@@ -352,7 +377,9 @@ describe('Auth & Access Control', () => {
352377
// If "Manage" is visible, click it and verify portal API call.
353378
const hasManage = await textExists('Manage');
354379
if (!hasManage) {
355-
console.log('[AuthAccess] 3.3.3 — Manage button not visible (team subscription stale). Skipping portal click.');
380+
console.log(
381+
'[AuthAccess] 3.3.3 — Manage button not visible (team subscription stale). Skipping portal click.'
382+
);
356383
// Verify the portal endpoint works by calling it programmatically
357384
// (the mock server handles POST /payments/stripe/portal)
358385
resetMockBehavior();
@@ -388,7 +415,11 @@ describe('Auth & Access Control', () => {
388415

389416
const homeCheck = await waitForHomePage(10_000);
390417
if (!homeCheck) {
391-
try { await clickNativeButton('Home', 5_000); } catch { /* ignore */ }
418+
try {
419+
await clickNativeButton('Home', 5_000);
420+
} catch {
421+
/* ignore */
422+
}
392423
await browser.pause(2_000);
393424
}
394425

app/test/e2e/specs/card-payment-flow.spec.ts

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ const LOG_PREFIX = '[PaymentFlow]';
3737
// ---------------------------------------------------------------------------
3838

3939
async function waitForHomePage(timeout = 15_000) {
40-
const candidates = ['Test', 'Good morning', 'Good afternoon', 'Good evening', 'Message OpenHuman'];
40+
const candidates = [
41+
'Test',
42+
'Good morning',
43+
'Good afternoon',
44+
'Good evening',
45+
'Message OpenHuman',
46+
];
4147
const deadline = Date.now() + timeout;
4248
while (Date.now() < deadline) {
4349
for (const text of candidates) {
@@ -69,11 +75,19 @@ async function waitForRequest(method, urlFragment, timeout = 15_000) {
6975
}
7076

7177
async function navigateToHome() {
72-
try { await clickNativeButton('Home', 10_000); } catch { /* ignore */ }
78+
try {
79+
await clickNativeButton('Home', 10_000);
80+
} catch {
81+
/* ignore */
82+
}
7383
await browser.pause(2_000);
7484
let homeText = await waitForHomePage(15_000);
7585
if (!homeText) {
76-
try { await clickNativeButton('Home', 5_000); } catch { /* ignore */ }
86+
try {
87+
await clickNativeButton('Home', 5_000);
88+
} catch {
89+
/* ignore */
90+
}
7791
await browser.pause(2_000);
7892
homeText = await waitForHomePage(10_000);
7993
}
@@ -85,7 +99,11 @@ async function navigateToBilling() {
8599
await browser.pause(3_000);
86100

87101
if (!(await textExists('Billing'))) {
88-
try { await clickNativeButton('Settings', 5_000); } catch { /* ignore */ }
102+
try {
103+
await clickNativeButton('Settings', 5_000);
104+
} catch {
105+
/* ignore */
106+
}
89107
await browser.pause(3_000);
90108
}
91109

@@ -109,15 +127,24 @@ async function performFullLogin(token = 'e2e-payment-token') {
109127
await clickText('Skip for now', 10_000);
110128
await browser.pause(2_000);
111129
for (const t of ['Looks Amazing', 'Bring It On']) {
112-
if (await textExists(t)) { await clickText(t, 5_000); break; }
130+
if (await textExists(t)) {
131+
await clickText(t, 5_000);
132+
break;
133+
}
113134
}
114135
await browser.pause(2_000);
115136
for (const t of ['Got it', 'Continue']) {
116-
if (await textExists(t)) { await clickText(t, 5_000); break; }
137+
if (await textExists(t)) {
138+
await clickText(t, 5_000);
139+
break;
140+
}
117141
}
118142
await browser.pause(2_000);
119143
for (const t of ["Let's Go", "I'm Ready"]) {
120-
if (await textExists(t)) { await clickText(t, 5_000); break; }
144+
if (await textExists(t)) {
145+
await clickText(t, 5_000);
146+
break;
147+
}
121148
}
122149
await browser.pause(3_000);
123150
} else {
@@ -205,7 +232,9 @@ describe('Card Payment Flow', () => {
205232
await navigateToBilling();
206233

207234
const hasBillingContent =
208-
(await textExists('Current Plan')) || (await textExists('FREE')) || (await textExists('Upgrade'));
235+
(await textExists('Current Plan')) ||
236+
(await textExists('FREE')) ||
237+
(await textExists('Upgrade'));
209238
expect(hasBillingContent).toBe(true);
210239

211240
console.log(`${LOG_PREFIX} 5.2.2 — Billing loads correctly with default plan`);
@@ -239,7 +268,9 @@ describe('Card Payment Flow', () => {
239268

240269
const hasManage = await textExists('Manage');
241270
if (!hasManage) {
242-
console.log(`${LOG_PREFIX} 5.3.2 — Manage not visible (stale team data). Verifying API only.`);
271+
console.log(
272+
`${LOG_PREFIX} 5.3.2 — Manage not visible (stale team data). Verifying API only.`
273+
);
243274
resetMockBehavior();
244275
await navigateToHome();
245276
return;

0 commit comments

Comments
 (0)