The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(test): simplify auth and login flow tests
Steven Enamakelc9d03132ef76
diff --git a/app/test/e2e/specs/auth-access-control.spec.ts b/app/test/e2e/specs/auth-access-control.spec.tsindex 3571c58f89..d75d79dec7 100644--- a/app/test/e2e/specs/auth-access-control.spec.ts+++ b/app/test/e2e/specs/auth-access-control.spec.ts@@ -302,185 +302,7 @@ describe('Auth & Access Control', () => {console.log('[AuthAccess] Multi-device token accepted');});- // -------------------------------------------------------------------------- // 2. Default Plan- // --------------------------------------------------------------------------- it('3.1.1 — billing dashboard handoff is available', async () => {- await navigateViaHash('/settings/account');- // The upstream billing summary now arrives asynchronously. Reuse the- // polling marker assertion so this first navigation has the same contract- // as the later billing checks in this spec.- await expectBillingMarkers(['Open dashboard']);-- console.log('[AuthAccess] 3.1.1 — Billing web handoff verified');- await navigateToHome();- });-- // -------------------------------------------------------------------------- // 3. Upgrade Flow- // --------------------------------------------------------------------------- it('3.2.1 — billing dashboard entry point is stable', async () => {- await navigateViaHash('/settings/account');- clearRequestLog();-- await expectBillingMarkers(['Open dashboard', 'Plan & billing']);-- console.log('[AuthAccess] 3.2.1 — Billing dashboard entry point verified');- await navigateToHome();- });-- // -------------------------------------------------------------------------- // 4. Active Subscription Display- // --------------------------------------------------------------------------- it('3.3.1 — subscription management handoff is displayed correctly', async () => {- // Seed mock state explicitly so this test is self-contained- setMockBehavior('plan', 'BASIC');- setMockBehavior('planActive', 'true');- setMockBehavior('planExpiry', new Date(Date.now() + 30 * 86400000).toISOString());- clearRequestLog();-- await navigateViaHash('/settings/account');-- await expectBillingMarkers([- 'Plan & billing',- 'Manage your subscription, credits, and invoices',- 'Open dashboard',- ]);-- console.log('[AuthAccess] 3.3.1 — Subscription management handoff verified');- });-- it('3.3.3 — manage subscription uses the web dashboard handoff', async () => {- // Seed mock state explicitly so this test is self-contained- setMockBehavior('plan', 'BASIC');- setMockBehavior('planActive', 'true');- setMockBehavior('planExpiry', new Date(Date.now() + 30 * 86400000).toISOString());- clearRequestLog();-- await navigateViaHash('/settings/account');- await browser.pause(3_000);-- await expectBillingMarkers(['Open dashboard']);-- console.log('[AuthAccess] 3.3.3 — Dashboard handoff verified');- resetMockBehavior();- await navigateToHome();- });-- // -------------------------------------------------------------------------- // 5. Logout- // --------------------------------------------------------------------------- it('user can log out via Settings and returns to Welcome', async () => {- // resetApp established a clean authenticated session for this suite.- // A second asynchronous deep-link login here races its post-login redirect- // against the Settings navigation, while adding no logout coverage.- await navigateToHome();-- // Log out + Clear App Data moved out of the main /settings page and- // into the Account section in PR #2550 (LogoutAndClearActions footer- // on /settings/account).- await navigateViaHash('/settings/account');-- // The card also has a noninteractive "Log out" label, so target the- // actual action button by its stable test id rather than matching text.- await clickTestId('settings-nav-logout', 10_000);- console.log('[AuthAccess] Logout action button clicked');-- // Wait for either the optional confirmation dialog or the authoritative- // core logout state. A fixed delay could inspect the core before the- // renderer's async clearSession() has reached auth_logout.- const logoutProgress = await browser.waitUntil(- async () => {- const hasConfirm =- (await textExists('Confirm')) ||- (await textExists('Yes')) ||- (await textExists('Log Out'));- if (hasConfirm) return 'confirmation';- const state = await callOpenhumanRpc<AuthStateResponse>('openhuman.auth_get_state', {});- expectRpcOk('auth_get_state', state);- return authStateValue(state).isAuthenticated === false ? 'signed-out' : false;- },- {- timeout: 15_000,- interval: 250,- timeoutMsg: 'logout neither opened confirmation nor cleared core authentication',- }- );- if (logoutProgress === 'confirmation') {- const confirmed = await browser.execute(() => {- const candidates = document.querySelectorAll('button, [role="button"], a');- for (const el of candidates) {- const text = el.textContent?.trim() || '';- const label = el.getAttribute('aria-label') || '';- if (['Confirm', 'Yes', 'Log Out'].some(t => text === t || label === t)) {- (el as HTMLElement).click();- return true;- }- }- return false;- });- expect(confirmed).toBe(true);- console.log('[AuthAccess] Confirmation dialog: clicked');- }-- // ── Assertion, rewritten ────────────────────────────────────────────- //- // This used to be `expect(onWelcome || !hasToken).toBe(true)`, where- // `hasToken` read `localStorage['persist:auth']`. That key does not- // exist and has not for some time: `app/src/store/index.ts` registers no- // `auth` reducer and no `auth` persist config, and this suite's sibling- // says so in a comment (`login-flow.spec.ts`, bypass case). So `hasToken`- // was always `false`, `!hasToken` was always `true`, and the disjunction- // was a tautology — the test passed whether or not logout did anything.- // Matrix row 1.4.1 was marked green on that.- //- // Two independent mechanisms now, both required:- // 1. the core no longer holds a credential (the half that matters for- // security: a UI that routes to Welcome while the core keeps- // authenticating is exactly the regression worth catching), and- // 2. the shell actually renders the logged-out surface.- await browser.waitUntil(- async () => {- const state = await callOpenhumanRpc<AuthStateResponse>('openhuman.auth_get_state', {});- expectRpcOk('auth_get_state', state);- return authStateValue(state).isAuthenticated === false;- },- {- timeout: 15_000,- interval: 250,- timeoutMsg: 'core still reports authenticated after Settings logout completed',- }- );- const state = await callOpenhumanRpc<AuthStateResponse>('openhuman.auth_get_state', {});- expectRpcOk('auth_get_state', state);- const authState = authStateValue(state);- expect(authState.isAuthenticated).toBe(false);- // `credential` is `skip_serializing_if = "Option::is_none"` on the Rust- // side, so a signed-out state omits it entirely. A stale "session" or- // "local" value here means the credential outlived the logout.- expect(authState.credential).toBeUndefined();- console.log('[AuthAccess] Logout: core reports no credential');-- // `'OpenHuman'` is deliberately NOT in this list. It appears 148 times in- // `app/src/lib/i18n/en.ts` and `textExists` is an unanchored- // `//*[contains(text(), …)]`, so including it would match on most screens- // and re-create the same always-true assertion in a new disguise.- const welcomeCandidates = ['Welcome', 'Sign in', 'Login', 'Get Started'];- let onWelcome = false;- for (const text of welcomeCandidates) {- if (await textExists(text)) {- console.log(`[AuthAccess] Logged-out state confirmed: found "${text}"`);- onWelcome = true;- break;- }- }- expect(onWelcome).toBe(true);- });-+ // Account/billing/logout rendering and auth clearing are browser-owned.it('revoked session auto-logs out the user', async function () {this.timeout(120_000);// Login freshdiff --git a/app/test/e2e/specs/login-flow.spec.ts b/app/test/e2e/specs/login-flow.spec.tsindex af89aee23d..3ad7ddffc7 100644--- a/app/test/e2e/specs/login-flow.spec.ts+++ b/app/test/e2e/specs/login-flow.spec.ts@@ -152,112 +152,7 @@ describe('Login flow — complete with mock data (Linux)', () => {// contract suite, not the browser UI flow.// ------------------------------------------------------------------------ // Phase 2: Onboarding (real step walkthrough)- //- // Onboarding.tsx renders as a portal overlay. On tauri-driver (Linux),- // browser.execute() works, so we can interact with the WebView DOM.- //- // Steps in order:- // 0: WelcomeStep — "Continue" button- // 1: SkillsStep — "Continue" or "Skip for Now"- // 2: ContextGatheringStep — user-driven gate: intro card with "Start when ready" /- // "Continue" / "Skip for now". Step is skipped entirely when SkillsStep- // produced zero connected sources (Onboarding.tsx → handleSkillsNext).- // ------------------------------------------------------------------------- it('onboarding overlay or home page is visible', async () => {- await browser.pause(3_000);-- // Real onboarding step markers- const onboardingCandidates = [- "Hi. I'm OpenHuman.", // WelcomeStep heading- "Let's Start", // WelcomeStep CTA- 'Connect your Gmail', // SkillsStep heading- 'Skip for Now', // SkillsStep CTA when no source is connected- 'Skip', // Onboarding defer button (top-right)- 'Continue', // Later onboarding CTAs- ];- const homeCandidates = ['Home', 'Skills', 'Conversations'];-- const foundOnboarding = await waitForAnyText(onboardingCandidates, 5_000);- if (foundOnboarding) {- console.log(`[LoginFlow] Onboarding visible: "${foundOnboarding}"`);- }-- const foundHome = !foundOnboarding ? await waitForAnyText(homeCandidates, 5_000) : null;- if (foundHome) {- console.log(- `[LoginFlow] Home page visible: "${foundHome}" (onboarding may be deferred/completed)`- );- }-- expect(foundOnboarding || foundHome).toBeTruthy();- });-- it('walk through onboarding steps (if overlay is visible)', async () => {- // Use the shared walkOnboarding helper which drives via- // data-testid="onboarding-next-button" — resilient to CTA label changes.- const beforeHash = await browser.execute(() => window.location.hash);- const alreadyOnHome = String(beforeHash).includes('/home');-- if (alreadyOnHome) {- console.log('[LoginFlow] Already on /home — skipping onboarding walk');- hadOnboardingWalkthrough = false;- return;- }-- hadOnboardingWalkthrough = true;- await walkOnboarding('[LoginFlow]');- });-- // ------------------------------------------------------------------------ // Phase 3: Verify completion- // ------------------------------------------------------------------------- it('mock server received the onboarding-complete call (if onboarding was walked)', async () => {- if (!hadOnboardingWalkthrough) {- console.log(- '[LoginFlow] Onboarding was not walked (overlay not visible) — skipping assertion'- );- return;- }-- const log = getRequestLog();- // The app calls POST /settings/onboarding-complete (via userApi.onboardingComplete)- // The mock may handle it at /telegram/settings/onboarding-complete or /settings/onboarding-complete- const call = log.find(- r =>- r.method === 'POST' &&- (r.url.includes('/settings/onboarding-complete') ||- r.url.includes('/telegram/settings/onboarding-complete'))- );- if (call) {- console.log('[LoginFlow] onboarding-complete call verified');- } else {- // The call may go through the core sidecar RPC relay rather than direct HTTP,- // so it might not appear in the mock request log. Log but don't fail.- console.log(- '[LoginFlow] onboarding-complete call not in mock log (may have gone through core RPC)'- );- console.log('[LoginFlow] Request log:', JSON.stringify(log, null, 2));- }- });-- it('app navigated to Home page after onboarding', async () => {- const foundText = await waitForHomePage(20_000);-- if (foundText) {- console.log(`[LoginFlow] Home page confirmed: found "${foundText}"`);- } else {- const tree = await dumpAccessibilityTree();- console.log('[LoginFlow] Home page text not found. Tree:\n', tree.slice(0, 4000));- }-- expect(foundText).not.toBeNull();- });-- // ------------------------------------------------------------------------ // Phase 4: Error paths — expired and invalid tokens+ // Error paths — expired and invalid tokens// -----------------------------------------------------------------------it('expired token triggers consume call that returns 401', async () => {