From 0bb1518279a481de35dcaa0abcb724ceae8c280e Mon Sep 17 00:00:00 2001 From: Cyrus Gray <144336577+graycyrus@users.noreply.github.com> Date: Fri, 3 Apr 2026 17:30:05 +0530 Subject: [PATCH] =?UTF-8?q?Revert=20"fix(e2e):=20rewrite=20performFullLogi?= =?UTF-8?q?n=20and=20extend=20walkOnboarding=20for=206-st=E2=80=A6"=20(#30?= =?UTF-8?q?6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 11b708a98062baa88288aeda25e73fe77f859fe5. --- app/test/e2e/helpers/shared-flows.ts | 77 +++--------------- .../e2e/specs/auth-access-control.spec.ts | 81 ++++++++++++------- 2 files changed, 63 insertions(+), 95 deletions(-) diff --git a/app/test/e2e/helpers/shared-flows.ts b/app/test/e2e/helpers/shared-flows.ts index 0575e4417..2b54b840b 100644 --- a/app/test/e2e/helpers/shared-flows.ts +++ b/app/test/e2e/helpers/shared-flows.ts @@ -260,10 +260,6 @@ export const ONBOARDING_OVERLAY_TEXTS = [ 'Screen & Accessibility', 'Enable Tools', 'Install Skills', - 'Lastly, your Recovery Phrase', - 'Your Recovery Phrase', - 'Import Recovery Phrase', - 'Finish Setup', ] as const; /** True when the full-screen onboarding overlay is likely visible. */ @@ -274,45 +270,10 @@ async function onboardingOverlayLikelyVisible(): Promise { return false; } -async function completeMnemonicStep(logPrefix: string): Promise { - const mnemonicVisible = - (await textExists('Lastly, your Recovery Phrase')) || - (await textExists('Your Recovery Phrase')) || - (await textExists('Import Recovery Phrase')); - - if (!mnemonicVisible) { - return false; - } - - console.log(`${logPrefix} MnemonicStep visible`); - - try { - const checked = await browser.execute(() => { - const checkbox = document.querySelector('input[type="checkbox"]') as HTMLInputElement | null; - if (!checkbox) return false; - if (!checkbox.checked) { - checkbox.click(); - } - return checkbox.checked; - }); - console.log(`${logPrefix} MnemonicStep checkbox checked=${checked}`); - } catch (err) { - console.log(`${logPrefix} MnemonicStep checkbox interaction failed:`, err); - } - - const clicked = await clickFirstMatch(['Finish Setup', 'Continue'], 12_000); - if (clicked) { - console.log(`${logPrefix} MnemonicStep: clicked ${clicked}`); - await browser.pause(4_000); - return true; - } - - return false; -} - /** - * Walk through onboarding. Supports both the legacy 5-step flow and the - * newer 6-step variant that ends with a recovery phrase confirmation. + * Walk through onboarding: Welcome → Local AI → Screen & Accessibility → Tools → Skills. + * Each step uses the shared primary button label "Continue" (see OnboardingNextButton). + * Completing the last step dismisses the overlay. */ export async function walkOnboarding(logPrefix = '[E2E]') { let visible = false; @@ -330,41 +291,29 @@ export async function walkOnboarding(logPrefix = '[E2E]') { return; } - // Up to 7 passes covers the 6-step flow plus one retry while async content settles. - for (let step = 0; step < 7; step++) { + // Up to 6 "Continue" clicks — covers 5 steps plus one retry if the list is still loading. + for (let step = 0; step < 6; step++) { if (!(await onboardingOverlayLikelyVisible())) { console.log(`${logPrefix} Onboarding dismissed after step ${step}`); return; } - if (await completeMnemonicStep(logPrefix)) { - continue; - } - - const clicked = await clickFirstMatch(['Continue', 'Finish Setup'], 12_000); + const clicked = await clickFirstMatch(['Continue'], 12_000); if (clicked) { - console.log(`${logPrefix} Onboarding step ${step}: clicked ${clicked}`); - await browser.pause(clicked === 'Finish Setup' || step >= 4 ? 4_000 : 2_000); + console.log(`${logPrefix} Onboarding step ${step}: clicked Continue`); + await browser.pause(step >= 4 ? 4_000 : 2_000); } else { const installSkillsLabel = ONBOARDING_OVERLAY_TEXTS[ONBOARDING_OVERLAY_TEXTS.length - 1]!; - if ( - (await textExists('Install Skills')) || - (await textExists('Finish Setup')) || - (await textExists(installSkillsLabel)) - ) { + if (await textExists(installSkillsLabel)) { await browser.pause(2_500); - if (await completeMnemonicStep(logPrefix)) { - continue; - } - const retry = await clickFirstMatch(['Continue', 'Finish Setup'], 10_000); + const retry = await clickFirstMatch(['Continue'], 10_000); if (retry) { - console.log(`${logPrefix} Onboarding step ${step}: retry ${retry}`); + console.log( + `${logPrefix} Onboarding step ${step}: retry Continue on ${installSkillsLabel}` + ); await browser.pause(4_000); - continue; } } - const tree = await dumpAccessibilityTree(); - console.log(`${logPrefix} Onboarding stalled at step ${step}. Tree:\n`, tree.slice(0, 4000)); break; } } diff --git a/app/test/e2e/specs/auth-access-control.spec.ts b/app/test/e2e/specs/auth-access-control.spec.ts index 07fe8685f..ba528542a 100644 --- a/app/test/e2e/specs/auth-access-control.spec.ts +++ b/app/test/e2e/specs/auth-access-control.spec.ts @@ -14,9 +14,9 @@ * 1.3 Logout via Settings menu * 1.3.1 Revoked session auto-logout * - * Onboarding steps: - * Shared helper walks the current onboarding overlay and supports both the - * legacy 5-step flow and the newer 6-step flow with recovery phrase setup. + * Onboarding steps (Onboarding.tsx — 5 steps, indices 0–4): + * Welcome → Local AI → Screen & Accessibility → Enable Tools → Install Skills + * (each step: primary "Continue"; final step completes onboarding) * * The mock server runs on http://127.0.0.1:18473 and the .app bundle must * have been built with VITE_BACKEND_URL pointing there. @@ -37,9 +37,8 @@ import { navigateToBilling, navigateToHome, navigateToSettings, - performFullLogin, waitForHomePage, - waitForRequest as waitForSharedRequest, + walkOnboarding, } from '../helpers/shared-flows'; import { clearRequestLog, @@ -76,6 +75,51 @@ async function waitForRequest(method, urlFragment, timeout = 15_000) { return undefined; } +// walkOnboarding, waitForHomePage imported from shared-flows + +/** + * Perform full login via deep link. Walks onboarding. Leaves app on Home page. + */ +async function performFullLogin(token = 'e2e-test-token') { + await triggerAuthDeepLink(token); + + await waitForWindowVisible(25_000); + await waitForWebView(15_000); + await waitForAppReady(15_000); + await waitForAuthBootstrap(15_000); + + const consumeCall = await waitForRequest('POST', '/telegram/login-tokens/', 20_000); + if (!consumeCall) { + console.log( + '[AuthAccess] Missing consume call. Request log:', + JSON.stringify(getRequestLog(), null, 2) + ); + throw new Error('Auth consume call missing in performFullLogin'); + } + // The app may call /telegram/me or /settings for user profile + const meCall = + (await waitForRequest('GET', '/telegram/me', 10_000)) || + (await waitForRequest('GET', '/settings', 10_000)); + if (!meCall) { + console.log( + '[AuthAccess] Missing user profile call. Request log:', + JSON.stringify(getRequestLog(), null, 2) + ); + console.log('[AuthAccess] Continuing without user profile call confirmation'); + } + + // Walk real onboarding steps + await walkOnboarding('[AuthAccess]'); + + const homeText = await waitForHomePage(15_000); + if (!homeText) { + const tree = await dumpAccessibilityTree(); + console.log('[AuthAccess] Home page not reached after login. Tree:\n', tree.slice(0, 4000)); + throw new Error('Full login did not reach Home page'); + } + console.log(`[AuthAccess] Home page confirmed: found "${homeText}"`); +} + // =========================================================================== // Test suite // =========================================================================== @@ -97,32 +141,7 @@ describe('Auth & Access Control', () => { // ------------------------------------------------------------------------- it('new user registers via deep link and reaches home', async () => { - await performFullLogin('e2e-auth-token', '[AuthAccess]', async () => { - const consumeCall = await waitForSharedRequest( - getRequestLog, - 'POST', - '/telegram/login-tokens/', - 20_000 - ); - if (!consumeCall) { - console.log( - '[AuthAccess] Missing consume call. Request log:', - JSON.stringify(getRequestLog(), null, 2) - ); - throw new Error('Auth consume call missing in performFullLogin'); - } - - const meCall = - (await waitForSharedRequest(getRequestLog, 'GET', '/telegram/me', 10_000)) || - (await waitForSharedRequest(getRequestLog, 'GET', '/settings', 10_000)); - if (!meCall) { - console.log( - '[AuthAccess] Missing user profile call. Request log:', - JSON.stringify(getRequestLog(), null, 2) - ); - console.log('[AuthAccess] Continuing without user profile call confirmation'); - } - }); + await performFullLogin('e2e-auth-token'); }); it('re-authenticating with a new token for the same user returns to home', async () => {