| import { Page } from '@playwright/test'; |
| import { assertSafeProjectPath } from '../core/safe-paths'; |
|
|
| |
| |
| |
| |
| const STORE_VERSIONS = { |
| APP_STORE: 2, |
| SETUP_STORE: 1, |
| } as const; |
|
|
| |
| |
| |
| export interface TestProject { |
| id: string; |
| name: string; |
| path: string; |
| lastOpened?: string; |
| } |
|
|
| |
| |
| |
| export interface WelcomeViewSetupOptions { |
| |
| workspaceDir?: string; |
| |
| recentProjects?: TestProject[]; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| export async function setupWelcomeView( |
| page: Page, |
| options?: WelcomeViewSetupOptions |
| ): Promise<void> { |
| await page.addInitScript( |
| ({ |
| opts, |
| versions, |
| }: { |
| opts: WelcomeViewSetupOptions | undefined; |
| versions: typeof STORE_VERSIONS; |
| }) => { |
| |
| const appState = { |
| state: { |
| projects: opts?.recentProjects || [], |
| currentProject: null, |
| currentView: 'welcome', |
| theme: 'dark', |
| sidebarOpen: true, |
| skipSandboxWarning: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: 3, |
| }, |
| version: versions.APP_STORE, |
| }; |
| localStorage.setItem('automaker-storage', JSON.stringify(appState)); |
|
|
| |
| const setupState = { |
| state: { |
| isFirstRun: false, |
| setupComplete: true, |
| skipClaudeSetup: false, |
| }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| |
| |
| |
| const settingsCache: Record<string, unknown> = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: opts?.recentProjects || [], |
| |
| |
| currentProjectId: null, |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: 3, |
| }; |
|
|
| |
| |
| if (opts?.workspaceDir) { |
| settingsCache.lastProjectDir = opts.workspaceDir; |
| } |
|
|
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| if (opts?.workspaceDir) { |
| localStorage.setItem('automaker:lastProjectDir', opts.workspaceDir); |
| } |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
|
|
| |
| |
| sessionStorage.setItem('automaker-test-welcome-view', 'true'); |
|
|
| |
| |
| const enforceWelcomeView = () => { |
| const storage = localStorage.getItem('automaker-storage'); |
| if (storage) { |
| try { |
| const state = JSON.parse(storage); |
| if ( |
| state.state && |
| sessionStorage.getItem('automaker-test-welcome-view') === 'true' && |
| state.state.currentProject !== null |
| ) { |
| state.state.currentProject = null; |
| state.state.currentView = 'welcome'; |
| localStorage.setItem('automaker-storage', JSON.stringify(state)); |
| } |
| } catch { |
| |
| } |
| } |
| }; |
|
|
| |
| window.addEventListener('storage', enforceWelcomeView); |
|
|
| |
| const pollInterval = setInterval(enforceWelcomeView, 200); |
| setTimeout(() => { |
| clearInterval(pollInterval); |
| window.removeEventListener('storage', enforceWelcomeView); |
| }, 5000); |
| }, |
| { opts: options, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export async function setupRealProject( |
| page: Page, |
| projectPath: string, |
| projectName: string, |
| options?: { |
| /** Set as current project (opens board view) or just add to recent projects */ |
| setAsCurrent?: boolean; |
| /** Additional recent projects to include */ |
| additionalProjects?: TestProject[]; |
| /** Optional project ID to use (if not provided, generates timestamp-based ID) */ |
| projectId?: string; |
| } |
| ): Promise<void> { |
| assertSafeProjectPath(projectPath); |
| await page.addInitScript( |
| ({ |
| path, |
| name, |
| opts, |
| versions, |
| }: { |
| path: string; |
| name: string; |
| opts: typeof options; |
| versions: typeof STORE_VERSIONS; |
| }) => { |
| const projectId = opts?.projectId || `project-${Date.now()}`; |
| const project: TestProject = { |
| id: projectId, |
| name: name, |
| path: path, |
| lastOpened: new Date().toISOString(), |
| }; |
|
|
| const allProjects = [project, ...(opts?.additionalProjects || [])]; |
| const currentProject = opts?.setAsCurrent !== false ? project : null; |
|
|
| const appState = { |
| state: { |
| projects: allProjects, |
| currentProject: currentProject, |
| currentView: currentProject ? 'board' : 'welcome', |
| theme: 'dark', |
| sidebarOpen: true, |
| skipSandboxWarning: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: 3, |
| }, |
| version: versions.APP_STORE, |
| }; |
| localStorage.setItem('automaker-storage', JSON.stringify(appState)); |
|
|
| |
| const setupState = { |
| state: { |
| isFirstRun: false, |
| setupComplete: true, |
| skipClaudeSetup: false, |
| }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| |
| |
| |
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: allProjects.map((p) => ({ |
| id: p.id, |
| name: p.name, |
| path: p.path, |
| lastOpened: p.lastOpened, |
| })), |
| |
| |
| currentProjectId: currentProject ? currentProject.id : null, |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: 3, |
| skipSandboxWarning: true, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
| }, |
| { path: projectPath, name: projectName, opts: options, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| |
| export async function setupMockProject(page: Page): Promise<void> { |
| await page.addInitScript((versions: typeof STORE_VERSIONS) => { |
| const mockProject = { |
| id: 'test-project-1', |
| name: 'Test Project', |
| path: '/mock/test-project', |
| lastOpened: new Date().toISOString(), |
| }; |
|
|
| const mockState = { |
| state: { |
| projects: [mockProject], |
| currentProject: mockProject, |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: 3, |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| |
| const setupState = { |
| state: { |
| isFirstRun: false, |
| setupComplete: true, |
| skipClaudeSetup: false, |
| }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| |
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: [ |
| { |
| id: mockProject.id, |
| name: mockProject.name, |
| path: mockProject.path, |
| lastOpened: mockProject.lastOpened, |
| }, |
| ], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
| }, STORE_VERSIONS); |
| } |
|
|
| |
| |
| |
| export async function setupMockProjectWithConcurrency( |
| page: Page, |
| concurrency: number |
| ): Promise<void> { |
| await page.addInitScript( |
| ({ maxConcurrency, versions }: { maxConcurrency: number; versions: typeof STORE_VERSIONS }) => { |
| const mockProject = { |
| id: 'test-project-1', |
| name: 'Test Project', |
| path: '/mock/test-project', |
| lastOpened: new Date().toISOString(), |
| }; |
|
|
| const mockState = { |
| state: { |
| projects: [mockProject], |
| currentProject: mockProject, |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: maxConcurrency, |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| |
| const setupState = { |
| state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: [ |
| { |
| id: mockProject.id, |
| name: mockProject.name, |
| path: mockProject.path, |
| lastOpened: mockProject.lastOpened, |
| }, |
| ], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: maxConcurrency, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
| }, |
| { maxConcurrency: concurrency, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| export async function setupMockProjectAtConcurrencyLimit( |
| page: Page, |
| maxConcurrency: number = 1, |
| runningTasks: string[] = ['running-task-1'] |
| ): Promise<void> { |
| await page.addInitScript( |
| ({ |
| maxConcurrency, |
| runningTasks, |
| versions, |
| }: { |
| maxConcurrency: number; |
| runningTasks: string[]; |
| versions: typeof STORE_VERSIONS; |
| }) => { |
| const mockProject = { |
| id: 'test-project-1', |
| name: 'Test Project', |
| path: '/mock/test-project', |
| lastOpened: new Date().toISOString(), |
| }; |
|
|
| const mockState = { |
| state: { |
| projects: [mockProject], |
| currentProject: mockProject, |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: maxConcurrency, |
| isAutoModeRunning: false, |
| runningAutoTasks: runningTasks, |
| autoModeActivityLog: [], |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| const setupState = { |
| state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: [ |
| { |
| id: mockProject.id, |
| name: mockProject.name, |
| path: mockProject.path, |
| lastOpened: mockProject.lastOpened, |
| }, |
| ], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: maxConcurrency, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
| }, |
| { maxConcurrency, runningTasks, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| export async function setupMockProjectWithFeatures( |
| page: Page, |
| options?: { |
| maxConcurrency?: number; |
| runningTasks?: string[]; |
| features?: Array<{ |
| id: string; |
| category: string; |
| description: string; |
| status: 'backlog' | 'in_progress' | 'verified'; |
| steps?: string[]; |
| }>; |
| } |
| ): Promise<void> { |
| await page.addInitScript( |
| ({ opts, versions }: { opts: typeof options; versions: typeof STORE_VERSIONS }) => { |
| const mockProject = { |
| id: 'test-project-1', |
| name: 'Test Project', |
| path: '/mock/test-project', |
| lastOpened: new Date().toISOString(), |
| }; |
|
|
| const mockFeatures = opts?.features || []; |
|
|
| const mockState = { |
| state: { |
| projects: [mockProject], |
| currentProject: mockProject, |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: opts?.maxConcurrency ?? 3, |
| isAutoModeRunning: false, |
| runningAutoTasks: opts?.runningTasks ?? [], |
| autoModeActivityLog: [], |
| features: mockFeatures, |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| const setupState = { |
| state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: [ |
| { |
| id: mockProject.id, |
| name: mockProject.name, |
| path: mockProject.path, |
| lastOpened: mockProject.lastOpened, |
| }, |
| ], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: opts?.maxConcurrency ?? 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| |
| (window as { __mockFeatures?: unknown[] }).__mockFeatures = mockFeatures; |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
| }, |
| { opts: options, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| |
| export async function setupMockProjectWithContextFile( |
| page: Page, |
| featureId: string, |
| contextContent: string = '# Agent Context\n\nPrevious implementation work...' |
| ): Promise<void> { |
| await page.addInitScript( |
| ({ |
| featureId, |
| contextContent, |
| versions, |
| }: { |
| featureId: string; |
| contextContent: string; |
| versions: typeof STORE_VERSIONS; |
| }) => { |
| const mockProject = { |
| id: 'test-project-1', |
| name: 'Test Project', |
| path: '/mock/test-project', |
| lastOpened: new Date().toISOString(), |
| }; |
|
|
| const mockState = { |
| state: { |
| projects: [mockProject], |
| currentProject: mockProject, |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: 3, |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| const setupState = { |
| state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: [ |
| { |
| id: mockProject.id, |
| name: mockProject.name, |
| path: mockProject.path, |
| lastOpened: mockProject.lastOpened, |
| }, |
| ], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
|
|
| |
| |
| |
| ( |
| window as { __mockContextFile?: { featureId: string; path: string; content: string } } |
| ).__mockContextFile = { |
| featureId, |
| path: `/mock/test-project/.automaker/features/${featureId}/agent-output.md`, |
| content: contextContent, |
| }; |
| }, |
| { featureId, contextContent, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| export async function setupMockProjectWithInProgressFeatures( |
| page: Page, |
| options?: { |
| maxConcurrency?: number; |
| runningTasks?: string[]; |
| features?: Array<{ |
| id: string; |
| category: string; |
| description: string; |
| status: 'backlog' | 'in_progress' | 'verified'; |
| steps?: string[]; |
| startedAt?: string; |
| }>; |
| } |
| ): Promise<void> { |
| await page.addInitScript( |
| ({ opts, versions }: { opts: typeof options; versions: typeof STORE_VERSIONS }) => { |
| const mockProject = { |
| id: 'test-project-1', |
| name: 'Test Project', |
| path: '/mock/test-project', |
| lastOpened: new Date().toISOString(), |
| }; |
|
|
| const mockFeatures = opts?.features || []; |
|
|
| const mockState = { |
| state: { |
| projects: [mockProject], |
| currentProject: mockProject, |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: opts?.maxConcurrency ?? 3, |
| isAutoModeRunning: false, |
| runningAutoTasks: opts?.runningTasks ?? [], |
| autoModeActivityLog: [], |
| features: mockFeatures, |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| const setupState = { |
| state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: [ |
| { |
| id: mockProject.id, |
| name: mockProject.name, |
| path: mockProject.path, |
| lastOpened: mockProject.lastOpened, |
| }, |
| ], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: opts?.maxConcurrency ?? 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| |
| (window as { __mockFeatures?: unknown[] }).__mockFeatures = mockFeatures; |
| }, |
| { opts: options, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| export async function setupMockProjectWithView(page: Page, view: string): Promise<void> { |
| await page.addInitScript( |
| ({ currentView, versions }: { currentView: string; versions: typeof STORE_VERSIONS }) => { |
| const mockProject = { |
| id: 'test-project-1', |
| name: 'Test Project', |
| path: '/mock/test-project', |
| lastOpened: new Date().toISOString(), |
| }; |
|
|
| const mockState = { |
| state: { |
| projects: [mockProject], |
| currentProject: mockProject, |
| currentView: currentView, |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: 3, |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| const setupState = { |
| state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: [ |
| { |
| id: mockProject.id, |
| name: mockProject.name, |
| path: mockProject.path, |
| lastOpened: mockProject.lastOpened, |
| }, |
| ], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
| }, |
| { currentView: view, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| export async function setupEmptyLocalStorage(page: Page): Promise<void> { |
| await page.addInitScript((versions: typeof STORE_VERSIONS) => { |
| const mockState = { |
| state: { |
| projects: [], |
| currentProject: null, |
| currentView: 'welcome', |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: 3, |
| }, |
| version: versions.APP_STORE, |
| }; |
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| const setupState = { |
| state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: [], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
| }, STORE_VERSIONS); |
| } |
|
|
| |
| |
| |
| export async function setupMockProjectsWithoutCurrent(page: Page): Promise<void> { |
| await page.addInitScript((versions: typeof STORE_VERSIONS) => { |
| const mockProjects = [ |
| { |
| id: 'test-project-1', |
| name: 'Test Project 1', |
| path: '/mock/test-project-1', |
| lastOpened: new Date().toISOString(), |
| }, |
| { |
| id: 'test-project-2', |
| name: 'Test Project 2', |
| path: '/mock/test-project-2', |
| lastOpened: new Date(Date.now() - 86400000).toISOString(), |
| }, |
| ]; |
|
|
| const mockState = { |
| state: { |
| projects: mockProjects, |
| currentProject: null, |
| currentView: 'welcome', |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: 3, |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| const setupState = { |
| state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: mockProjects.map((p) => ({ |
| id: p.id, |
| name: p.name, |
| path: p.path, |
| lastOpened: p.lastOpened, |
| })), |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
| }, STORE_VERSIONS); |
| } |
|
|
| |
| |
| |
| export async function setupMockProjectWithSkipTestsFeatures( |
| page: Page, |
| options?: { |
| maxConcurrency?: number; |
| runningTasks?: string[]; |
| features?: Array<{ |
| id: string; |
| category: string; |
| description: string; |
| status: 'backlog' | 'in_progress' | 'verified'; |
| steps?: string[]; |
| startedAt?: string; |
| skipTests?: boolean; |
| }>; |
| } |
| ): Promise<void> { |
| await page.addInitScript( |
| ({ opts, versions }: { opts: typeof options; versions: typeof STORE_VERSIONS }) => { |
| const mockProject = { |
| id: 'test-project-1', |
| name: 'Test Project', |
| path: '/mock/test-project', |
| lastOpened: new Date().toISOString(), |
| }; |
|
|
| const mockFeatures = opts?.features || []; |
|
|
| const mockState = { |
| state: { |
| projects: [mockProject], |
| currentProject: mockProject, |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: opts?.maxConcurrency ?? 3, |
| isAutoModeRunning: false, |
| runningAutoTasks: opts?.runningTasks ?? [], |
| autoModeActivityLog: [], |
| features: mockFeatures, |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| const setupState = { |
| state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: [ |
| { |
| id: mockProject.id, |
| name: mockProject.name, |
| path: mockProject.path, |
| lastOpened: mockProject.lastOpened, |
| }, |
| ], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: opts?.maxConcurrency ?? 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
| }, |
| { opts: options, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| export async function setupMockMultipleProjects( |
| page: Page, |
| projectCount: number = 3 |
| ): Promise<void> { |
| await page.addInitScript( |
| ({ count, versions }: { count: number; versions: typeof STORE_VERSIONS }) => { |
| const mockProjects: TestProject[] = []; |
| for (let i = 0; i < count; i++) { |
| mockProjects.push({ |
| id: `test-project-${i + 1}`, |
| name: `Test Project ${i + 1}`, |
| path: `/mock/test-project-${i + 1}`, |
| lastOpened: new Date(Date.now() - i * 86400000).toISOString(), |
| }); |
| } |
|
|
| const mockState = { |
| state: { |
| projects: mockProjects, |
| currentProject: mockProjects[0], |
| currentView: 'board', |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: 3, |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| |
| const setupState = { |
| state: { |
| isFirstRun: false, |
| setupComplete: true, |
| skipClaudeSetup: false, |
| }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| |
| |
| |
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: mockProjects.map((p) => ({ |
| id: p.id, |
| name: p.name, |
| path: p.path, |
| lastOpened: p.lastOpened, |
| })), |
| |
| |
| currentProjectId: mockProjects[0]?.id ?? null, |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
| }, |
| { count: projectCount, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| export async function setupMockProjectWithAgentOutput( |
| page: Page, |
| featureId: string, |
| outputContent: string |
| ): Promise<void> { |
| await page.addInitScript( |
| ({ |
| featureId, |
| outputContent, |
| versions, |
| }: { |
| featureId: string; |
| outputContent: string; |
| versions: typeof STORE_VERSIONS; |
| }) => { |
| const mockProject = { |
| id: 'test-project-1', |
| name: 'Test Project', |
| path: '/mock/test-project', |
| lastOpened: new Date().toISOString(), |
| }; |
|
|
| const mockState = { |
| state: { |
| projects: [mockProject], |
| currentProject: mockProject, |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: 3, |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| const setupState = { |
| state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: [ |
| { |
| id: mockProject.id, |
| name: mockProject.name, |
| path: mockProject.path, |
| lastOpened: mockProject.lastOpened, |
| }, |
| ], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
|
|
| |
| |
| ( |
| window as { __mockContextFile?: { featureId: string; path: string; content: string } } |
| ).__mockContextFile = { |
| featureId, |
| path: `/mock/test-project/.automaker/features/${featureId}/agent-output.md`, |
| content: outputContent, |
| }; |
| }, |
| { featureId, outputContent, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| export async function setupMockProjectWithWaitingApprovalFeatures( |
| page: Page, |
| options?: { |
| maxConcurrency?: number; |
| runningTasks?: string[]; |
| features?: Array<{ |
| id: string; |
| category: string; |
| description: string; |
| status: 'backlog' | 'in_progress' | 'waiting_approval' | 'verified'; |
| steps?: string[]; |
| startedAt?: string; |
| skipTests?: boolean; |
| }>; |
| } |
| ): Promise<void> { |
| await page.addInitScript( |
| ({ opts, versions }: { opts: typeof options; versions: typeof STORE_VERSIONS }) => { |
| const mockProject = { |
| id: 'test-project-1', |
| name: 'Test Project', |
| path: '/mock/test-project', |
| lastOpened: new Date().toISOString(), |
| }; |
|
|
| const mockFeatures = opts?.features || []; |
|
|
| const mockState = { |
| state: { |
| projects: [mockProject], |
| currentProject: mockProject, |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: opts?.maxConcurrency ?? 3, |
| isAutoModeRunning: false, |
| runningAutoTasks: opts?.runningTasks ?? [], |
| autoModeActivityLog: [], |
| features: mockFeatures, |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(mockState)); |
|
|
| const setupState = { |
| state: { isFirstRun: false, setupComplete: true, skipClaudeSetup: false }, |
| version: versions.SETUP_STORE, |
| }; |
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| const settingsCache = { |
| setupComplete: true, |
| isFirstRun: false, |
| projects: [ |
| { |
| id: mockProject.id, |
| name: mockProject.name, |
| path: mockProject.path, |
| lastOpened: mockProject.lastOpened, |
| }, |
| ], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: opts?.maxConcurrency ?? 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| (window as { __mockFeatures?: unknown[] }).__mockFeatures = mockFeatures; |
| }, |
| { opts: options, versions: STORE_VERSIONS } |
| ); |
| } |
|
|
| |
| |
| |
| export async function setupFirstRun(page: Page): Promise<void> { |
| await page.addInitScript((versions: typeof STORE_VERSIONS) => { |
| |
| localStorage.removeItem('automaker-setup'); |
| localStorage.removeItem('automaker-storage'); |
|
|
| |
| const setupState = { |
| state: { |
| isFirstRun: true, |
| setupComplete: false, |
| currentStep: 'welcome', |
| claudeCliStatus: null, |
| claudeAuthStatus: null, |
| claudeInstallProgress: { |
| isInstalling: false, |
| currentStep: '', |
| progress: 0, |
| output: [], |
| }, |
| skipClaudeSetup: false, |
| }, |
| version: versions.SETUP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| |
| const appState = { |
| state: { |
| projects: [], |
| currentProject: null, |
| theme: 'dark', |
| sidebarOpen: true, |
| apiKeys: { anthropic: '', google: '' }, |
| chatSessions: [], |
| chatHistoryOpen: false, |
| maxConcurrency: 3, |
| isAutoModeRunning: false, |
| runningAutoTasks: [], |
| autoModeActivityLog: [], |
| currentView: 'setup', |
| }, |
| version: versions.APP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-storage', JSON.stringify(appState)); |
|
|
| |
| const settingsCache = { |
| setupComplete: false, |
| isFirstRun: true, |
| projects: [], |
| theme: 'dark', |
| sidebarOpen: true, |
| maxConcurrency: 3, |
| }; |
| localStorage.setItem('automaker-settings-cache', JSON.stringify(settingsCache)); |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
| }, STORE_VERSIONS); |
| } |
|
|
| |
| |
| |
| export async function setupComplete(page: Page): Promise<void> { |
| await page.addInitScript((versions: typeof STORE_VERSIONS) => { |
| |
| const setupState = { |
| state: { |
| isFirstRun: false, |
| setupComplete: true, |
| currentStep: 'complete', |
| skipClaudeSetup: false, |
| }, |
| version: versions.SETUP_STORE, |
| }; |
|
|
| localStorage.setItem('automaker-setup', JSON.stringify(setupState)); |
|
|
| |
| localStorage.setItem('automaker-disable-splash', 'true'); |
| }, STORE_VERSIONS); |
| } |
|
|