Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(e2e): harden auth state parsing and voice mode selector

Steven Enamakeld89849324923
diff --git a/app/test/auth-state.test.ts b/app/test/auth-state.test.ts
index 73a7be83a0..69949b0030 100644
--- a/app/test/auth-state.test.ts
+++ b/app/test/auth-state.test.ts
@@ -20,4 +20,10 @@ describe('authStateValue', () => {
expect(state.isAuthenticated).toBe(true);
expect(state.credential).toBe('session');
});
+
+ it('rejects unrecognized RPC shapes instead of treating missing auth as signed out', () => {
+ expect(() => authStateValue({ result: { logs: ['session state fetched'] } })).toThrow(
+ 'auth_get_state returned no boolean isAuthenticated field'
+ );
+ });
});
diff --git a/app/test/e2e/helpers/auth-state.ts b/app/test/e2e/helpers/auth-state.ts
index 334f589686..05e34a120e 100644
--- a/app/test/e2e/helpers/auth-state.ts
+++ b/app/test/e2e/helpers/auth-state.ts
@@ -7,6 +7,16 @@ export interface AuthStateResponse {
/** Read the auth DTO from the core RPC response. */
export function authStateValue(state: { result?: unknown }): AuthStateResponse {
- const raw = (state.result ?? {}) as { value?: AuthStateResponse } & AuthStateResponse;
- return raw.value ?? raw;
+ const raw = state.result;
+ const envelope = raw && typeof raw === 'object' ? (raw as Record<string, unknown>) : {};
+ const value =
+ envelope.result && typeof envelope.result === 'object'
+ ? (envelope.result as Record<string, unknown>)
+ : envelope;
+
+ if (typeof value.isAuthenticated !== 'boolean') {
+ throw new Error('auth_get_state returned no boolean isAuthenticated field');
+ }
+
+ return value as AuthStateResponse;
}
diff --git a/app/test/e2e/specs/auth-access-control.spec.ts b/app/test/e2e/specs/auth-access-control.spec.ts
index 004064e46e..eefac6029d 100644
--- a/app/test/e2e/specs/auth-access-control.spec.ts
+++ b/app/test/e2e/specs/auth-access-control.spec.ts
@@ -22,9 +22,9 @@
* have been built with VITE_BACKEND_URL pointing there.
*/
import { waitForApp, waitForAppReady, waitForAuthBootstrap } from '../helpers/app-helpers';
+import { type AuthStateResponse, authStateValue } from '../helpers/auth-state';
import { callOpenhumanRpc, expectRpcOk } from '../helpers/core-rpc';
import { triggerAuthDeepLink } from '../helpers/deep-link-helpers';
-import { authStateValue, type AuthStateResponse } from '../helpers/auth-state';
import {
clickButton,
clickText,
diff --git a/app/test/e2e/specs/voice-mode.spec.ts b/app/test/e2e/specs/voice-mode.spec.ts
index 6055613ea6..4c913d4817 100644
--- a/app/test/e2e/specs/voice-mode.spec.ts
+++ b/app/test/e2e/specs/voice-mode.spec.ts
@@ -233,10 +233,9 @@ describe('Voice mode — Human tab capture & error mapping', () => {
expect(await textExists('Voice mode')).toBe(true);
await clickButton('Voice mode');
expect(await textExists('Tap and speak')).toBe(true);
- // The switch is icon-only: "Switch to text" is its accessible name, not
- // visible text. Exercise it through the accessibility helper and verify
- // that the text composer returns.
- await clickButton('Switch to text', 10_000);
+ // The switch is icon-only: its accessible name is not visible DOM text,
+ // so target the button's label instead of the text-search helper.
+ await clickSelector('button[aria-label="Switch to text"]', 10_000);
expect(await waitForAnyText(['How can I help', 'Threads', 'New'], 10_000)).not.toBeNull();
});