From a695d0db7bc4819aa848034dc2eac78f3fdd0d95 Mon Sep 17 00:00:00 2001 From: webdevcody Date: Fri, 9 Jan 2026 10:08:38 -0500 Subject: [PATCH] feat: enhance OpenCode provider tests and UI setup - Updated unit tests for OpenCode provider to include new authentication indicators. - Refactored ProvidersSetupStep component by removing unnecessary UI elements for better clarity. - Improved board background persistence tests by utilizing a setup function for initializing app state. - Enhanced settings synchronization tests to ensure proper handling of login and app state. These changes improve the testing framework and user interface for OpenCode integration, ensuring a smoother setup and authentication process. --- .../unit/providers/opencode-provider.test.ts | 19 ++- .../setup-view/steps/providers-setup-step.tsx | 19 --- .../board-background-persistence.spec.ts | 148 +++++++++++------- .../settings-startup-sync-race.spec.ts | 4 +- libs/types/src/provider.ts | 1 + 5 files changed, 111 insertions(+), 80 deletions(-) diff --git a/apps/server/tests/unit/providers/opencode-provider.test.ts b/apps/server/tests/unit/providers/opencode-provider.test.ts index e20e5e67..b33217a8 100644 --- a/apps/server/tests/unit/providers/opencode-provider.test.ts +++ b/apps/server/tests/unit/providers/opencode-provider.test.ts @@ -5,7 +5,7 @@ import { } from '../../../src/providers/opencode-provider.js'; import type { ProviderMessage } from '@automaker/types'; import { collectAsyncGenerator } from '../../utils/helpers.js'; -import { spawnJSONLProcess } from '@automaker/platform'; +import { spawnJSONLProcess, getOpenCodeAuthIndicators } from '@automaker/platform'; vi.mock('@automaker/platform', () => ({ spawnJSONLProcess: vi.fn(), @@ -13,6 +13,11 @@ vi.mock('@automaker/platform', () => ({ findCliInWsl: vi.fn().mockReturnValue(null), createWslCommand: vi.fn(), windowsToWslPath: vi.fn(), + getOpenCodeAuthIndicators: vi.fn().mockResolvedValue({ + hasAuthFile: false, + hasOAuthToken: false, + hasApiKey: false, + }), })); describe('opencode-provider.ts', () => { @@ -25,7 +30,8 @@ describe('opencode-provider.ts', () => { }); afterEach(() => { - vi.restoreAllMocks(); + // Note: Don't use vi.restoreAllMocks() here as it would undo the module-level + // mock implementations (like getOpenCodeAuthIndicators) set up with vi.mock() }); // ========================================================================== @@ -815,6 +821,15 @@ describe('opencode-provider.ts', () => { // ========================================================================== describe('detectInstallation', () => { + beforeEach(() => { + // Ensure the mock implementation is set up for each test + vi.mocked(getOpenCodeAuthIndicators).mockResolvedValue({ + hasAuthFile: false, + hasOAuthToken: false, + hasApiKey: false, + }); + }); + it('should return installed true when CLI is found', async () => { (provider as unknown as { cliPath: string }).cliPath = '/usr/local/bin/opencode'; (provider as unknown as { detectedStrategy: string }).detectedStrategy = 'native'; diff --git a/apps/ui/src/components/views/setup-view/steps/providers-setup-step.tsx b/apps/ui/src/components/views/setup-view/steps/providers-setup-step.tsx index 3b2ab4db..d412444f 100644 --- a/apps/ui/src/components/views/setup-view/steps/providers-setup-step.tsx +++ b/apps/ui/src/components/views/setup-view/steps/providers-setup-step.tsx @@ -1271,25 +1271,6 @@ export function ProvidersSetupStep({ onNext, onBack }: ProvidersSetupStepProps) -
- {providers.map((provider) => ( -
- {provider.configured ? ( - - ) : ( -
- )} - {provider.label} -
- ))} -
-