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
test(app): close read-through gaps the existing suites could not fail
M3gA-Mind122da7157480
diff --git a/app/src/components/oauth/__tests__/OAuthProviderButton.test.tsx b/app/src/components/oauth/__tests__/OAuthProviderButton.test.tsxindex f70d1fc27a..3663f49ff2 100644--- a/app/src/components/oauth/__tests__/OAuthProviderButton.test.tsx+++ b/app/src/components/oauth/__tests__/OAuthProviderButton.test.tsx@@ -13,6 +13,7 @@ import { prepareOAuthLoginLaunch } from '../../../utils/oauthAppVersionGate';import { openUrl } from '../../../utils/openUrl';import { isTauri } from '../../../utils/tauriCommands';import OAuthProviderButton from '../OAuthProviderButton';+import { oauthProviderConfigs } from '../providerConfigs';vi.mock('../../../services/backendHealth', () => ({ checkBackendHealthy: vi.fn() }));@@ -518,3 +519,68 @@ describe('OAuthProviderButton web dev redirect', () => {expect(target.searchParams.get('redirectUri')).toBeNull();});});++// Every case above this point renders `stubProvider` (google) or a google stub+// with the id swapped, so all of them pass even if `github` or `discord` were+// misspelled in the real config. The provider id is the ONLY part of a login+// that is observable client-side: `/auth/me` returns no provider field and the+// session crate models none, so a wrong id here is invisible until the backend+// 404s. Drive the real config, not a stub. (matrix 1.1.1-1.1.4)+// [provider id, accessible button name]. Written out rather than derived, so+// the table below is a claim about what SHOULD ship, not an echo of what does.+const EXPECTED_LOGIN_PROVIDERS = [+ ['google', 'Google'],+ ['github', 'GitHub'],+ ['twitter', 'Twitter'],+ ['discord', 'Discord'],+] as const;++describe('OAuthProviderButton — every configured provider reaches its own backend route', () => {+ beforeEach(() => {+ vi.useFakeTimers();+ vi.mocked(checkBackendHealthy).mockResolvedValue(healthyResult);+ vi.mocked(openUrl).mockResolvedValue(undefined);+ vi.mocked(isTauri).mockReturnValue(true);+ vi.mocked(getDeepLinkAuthState).mockReturnValue({+ isProcessing: false,+ errorMessage: null,+ errorMessageKey: null,+ requiresAppDataReset: false,+ });+ });++ afterEach(() => {+ vi.useRealTimers();+ vi.clearAllMocks();+ });++ // Pins the fixture itself. Without this, the `it.each` below degrades to a+ // no-op the day someone empties the config, and the suite stays green while+ // login is broken for a provider nobody tested by hand.+ it('the shipped config is exactly the four expected providers', () => {+ expect(oauthProviderConfigs.map(config => config.id)).toEqual(+ EXPECTED_LOGIN_PROVIDERS.map(([id]) => id)+ );+ });++ it.each(EXPECTED_LOGIN_PROVIDERS)('provider %s opens /auth/%s/login', async (id, name) => {+ // Looked up by the expected id rather than iterated off the config: a+ // table built by mapping the config would assert `/auth/<whatever the+ // config says>/login` and pass for a typo'd id. This fails instead.+ const config = oauthProviderConfigs.find(candidate => candidate.id === id);+ expect(config, `no provider config with id "${id}"`).toBeDefined();++ render(<OAuthProviderButton provider={config!} />);++ fireEvent.click(screen.getByRole('button', { name }));+ await act(async () => {+ for (let i = 0; i < 6; i++) await Promise.resolve();+ });++ expect(openUrl).toHaveBeenCalledTimes(1);+ const opened = new URL(vi.mocked(openUrl).mock.calls[0][0] as string);+ // Exact pathname, not a `contains`: `/auth/x/login` must not satisfy a+ // check for `/auth/twitter/login`, and vice versa.+ expect(opened.origin + opened.pathname).toBe(`https://backend.test/auth/${id}/login`);+ });+});diff --git a/app/src/components/settings/panels/ToolsPanel.test.tsx b/app/src/components/settings/panels/ToolsPanel.test.tsxindex 5d630eed81..815b9d43f7 100644--- a/app/src/components/settings/panels/ToolsPanel.test.tsx+++ b/app/src/components/settings/panels/ToolsPanel.test.tsx@@ -95,3 +95,67 @@ describe('<ToolsPanel />', () => {expect(screen.getByRole('button', { name: 'Save Changes' })).toBeInTheDocument();});});++/**+ * `setOnboardingTasks` takes the WHOLE `StoredOnboardingTasks` record, so this+ * panel has to re-send every flag it does not own. It does that with+ * `onboardingTasks?.<flag> ?? false` (ToolsPanel.tsx, `handleSave`). Every+ * fixture in the suite above sets all of those flags to `false`/`[]`, so a+ * regression that replaced the read-through with a literal `false` would be+ * invisible there. (matrix 2.2.3)+ *+ * Context worth knowing before reading these as "permissions are covered":+ * `accessibilityPermissionGranted` is, at this commit, never written `true` by+ * anything in `app/src` — both writers (this panel and+ * `pages/onboarding/OnboardingLayout.tsx`) read it and write it straight back.+ * Nothing re-derives it from the core's `detect_permissions()`. These tests do+ * not fix that; they make sure that when it is fixed, saving an unrelated+ * settings panel does not silently wipe it again.+ */+describe('<ToolsPanel /> — saving tools preserves the onboarding flags it does not own', () => {+ const populatedCoreState = {+ snapshot: {+ localState: {+ onboardingTasks: {+ accessibilityPermissionGranted: true,+ localModelConsentGiven: true,+ localModelDownloadStarted: true,+ enabledTools: ['shell'],+ connectedSources: ['gmail'],+ },+ },+ },+ setOnboardingTasks: mocks.setOnboardingTasks,+ };++ beforeEach(() => {+ vi.clearAllMocks();+ mocks.useCoreStateMock.mockReturnValue(populatedCoreState);+ mocks.setOnboardingTasks.mockResolvedValue(undefined);+ });++ it('round-trips accessibilityPermissionGranted, model-consent and sources unchanged', async () => {+ render(<ToolsPanel />);++ const shellToggle = screen.getByRole('switch', { name: /Shell Commands/ });+ await waitFor(() => expect(shellToggle).toHaveAttribute('aria-checked', 'true'));++ fireEvent.click(shellToggle);+ fireEvent.click(screen.getByRole('button', { name: 'Save Changes' }));++ await waitFor(() => expect(mocks.setOnboardingTasks).toHaveBeenCalledTimes(1));+ const saved = mocks.setOnboardingTasks.mock.calls[0][0];++ // The flags this panel does not own must survive its save untouched. A+ // hardcoded `false` here silently revokes a recorded macOS permission and+ // a recorded local-model consent every time someone edits tool settings.+ expect(saved.accessibilityPermissionGranted).toBe(true);+ expect(saved.localModelConsentGiven).toBe(true);+ expect(saved.localModelDownloadStarted).toBe(true);+ expect(saved.connectedSources).toEqual(['gmail']);++ // And the thing it does own still changed, so the assertions above are not+ // passing because the save never happened.+ expect(saved.enabledTools).toEqual([]);+ });+});diff --git a/app/src/pages/onboarding/__tests__/OnboardingLayout.test.tsx b/app/src/pages/onboarding/__tests__/OnboardingLayout.test.tsxindex e2ae4c25fd..2da150fd11 100644--- a/app/src/pages/onboarding/__tests__/OnboardingLayout.test.tsx+++ b/app/src/pages/onboarding/__tests__/OnboardingLayout.test.tsx@@ -290,4 +290,37 @@ describe('OnboardingLayout — Joyride walkthrough integration (#1123)', () => {expect.objectContaining({ enabledTools: existing }));});++ /**+ * Same read-through guard as `ToolsPanel.test.tsx`, for the other writer.+ *+ * `completeAndExit` re-sends the whole `StoredOnboardingTasks` record, so it+ * has to carry `accessibilityPermissionGranted` through with+ * `?? false` (OnboardingLayout.tsx). Every other fixture in this file passes+ * `false` for it, so a regression that hardcoded `false` would be invisible+ * here. (matrix 2.2.3)+ *+ * Worth knowing: at this commit nothing in `app/src` ever writes that flag+ * `true` — both writers read it and write it straight back, and nothing+ * re-derives it from the core's `detect_permissions()`. This test does not+ * fix that; it makes sure the value is not dropped once it can be set.+ */+ it('carries a recorded accessibility permission through onboarding completion', async () => {+ const { mockSetOnboardingTasks } = await setupLayout({+ accessibilityPermissionGranted: true,+ localModelConsentGiven: false,+ localModelDownloadStarted: false,+ enabledTools: ['shell'],+ connectedSources: [],+ updatedAtMs: 1,+ });++ await act(async () => {+ fireEvent.click(screen.getByTestId('complete-btn'));+ });++ expect(mockSetOnboardingTasks).toHaveBeenCalledWith(+ expect.objectContaining({ accessibilityPermissionGranted: true })+ );+ });});