@posthog/wizard 1.36.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -3
- package/dist/bin.js +200 -24
- package/dist/bin.js.map +1 -1
- package/dist/src/__tests__/cli.test.js +10 -74
- package/dist/src/__tests__/cli.test.js.map +1 -1
- package/dist/src/__tests__/run.test.js +50 -5
- package/dist/src/__tests__/run.test.js.map +1 -1
- package/dist/src/__tests__/wizard-abort.test.js +127 -0
- package/dist/src/__tests__/wizard-abort.test.js.map +1 -0
- package/dist/src/{android → frameworks/android}/android-wizard-agent.d.ts +1 -1
- package/dist/src/{android → frameworks/android}/android-wizard-agent.js +2 -2
- package/dist/src/frameworks/android/android-wizard-agent.js.map +1 -0
- package/dist/src/{android → frameworks/android}/utils.d.ts +1 -1
- package/dist/src/{android → frameworks/android}/utils.js +1 -1
- package/dist/src/frameworks/android/utils.js.map +1 -0
- package/dist/src/{angular → frameworks/angular}/angular-wizard-agent.d.ts +1 -1
- package/dist/src/{angular → frameworks/angular}/angular-wizard-agent.js +9 -7
- package/dist/src/frameworks/angular/angular-wizard-agent.js.map +1 -0
- package/dist/src/{angular → frameworks/angular}/utils.js +1 -1
- package/dist/src/frameworks/angular/utils.js.map +1 -0
- package/dist/src/{astro → frameworks/astro}/astro-wizard-agent.d.ts +1 -1
- package/dist/src/{astro → frameworks/astro}/astro-wizard-agent.js +9 -7
- package/dist/src/frameworks/astro/astro-wizard-agent.js.map +1 -0
- package/dist/src/{astro → frameworks/astro}/utils.d.ts +2 -5
- package/dist/src/{astro → frameworks/astro}/utils.js +3 -52
- package/dist/src/frameworks/astro/utils.js.map +1 -0
- package/dist/src/{django → frameworks/django}/django-wizard-agent.d.ts +1 -1
- package/dist/src/{django → frameworks/django}/django-wizard-agent.js +3 -3
- package/dist/src/frameworks/django/django-wizard-agent.js.map +1 -0
- package/dist/src/{django → frameworks/django}/utils.d.ts +1 -1
- package/dist/src/{django → frameworks/django}/utils.js +6 -6
- package/dist/src/frameworks/django/utils.js.map +1 -0
- package/dist/src/frameworks/fastapi/fastapi-wizard-agent.d.ts +5 -0
- package/dist/src/{fastapi → frameworks/fastapi}/fastapi-wizard-agent.js +3 -32
- package/dist/src/frameworks/fastapi/fastapi-wizard-agent.js.map +1 -0
- package/dist/src/{fastapi → frameworks/fastapi}/utils.d.ts +1 -1
- package/dist/src/{fastapi → frameworks/fastapi}/utils.js +4 -4
- package/dist/src/frameworks/fastapi/utils.js.map +1 -0
- package/dist/src/{flask → frameworks/flask}/flask-wizard-agent.d.ts +1 -1
- package/dist/src/{flask → frameworks/flask}/flask-wizard-agent.js +3 -3
- package/dist/src/frameworks/flask/flask-wizard-agent.js.map +1 -0
- package/dist/src/{flask → frameworks/flask}/utils.d.ts +1 -1
- package/dist/src/{flask → frameworks/flask}/utils.js +7 -7
- package/dist/src/frameworks/flask/utils.js.map +1 -0
- package/dist/src/{javascript-node → frameworks/javascript-node}/javascript-node-wizard-agent.d.ts +1 -1
- package/dist/src/{javascript-node → frameworks/javascript-node}/javascript-node-wizard-agent.js +4 -4
- package/dist/src/frameworks/javascript-node/javascript-node-wizard-agent.js.map +1 -0
- package/dist/src/{javascript-web → frameworks/javascript-web}/javascript-web-wizard-agent.d.ts +1 -1
- package/dist/src/{javascript-web → frameworks/javascript-web}/javascript-web-wizard-agent.js +16 -14
- package/dist/src/frameworks/javascript-web/javascript-web-wizard-agent.js.map +1 -0
- package/dist/src/{javascript-web → frameworks/javascript-web}/utils.d.ts +6 -1
- package/dist/src/{javascript-web → frameworks/javascript-web}/utils.js +49 -1
- package/dist/src/frameworks/javascript-web/utils.js.map +1 -0
- package/dist/src/{laravel → frameworks/laravel}/laravel-wizard-agent.d.ts +1 -1
- package/dist/src/{laravel → frameworks/laravel}/laravel-wizard-agent.js +2 -2
- package/dist/src/frameworks/laravel/laravel-wizard-agent.js.map +1 -0
- package/dist/src/{laravel → frameworks/laravel}/utils.d.ts +1 -1
- package/dist/src/{laravel → frameworks/laravel}/utils.js +5 -5
- package/dist/src/frameworks/laravel/utils.js.map +1 -0
- package/dist/src/{nextjs → frameworks/nextjs}/nextjs-wizard-agent.d.ts +1 -1
- package/dist/src/{nextjs → frameworks/nextjs}/nextjs-wizard-agent.js +30 -8
- package/dist/src/frameworks/nextjs/nextjs-wizard-agent.js.map +1 -0
- package/dist/src/{nextjs → frameworks/nextjs}/utils.d.ts +5 -2
- package/dist/src/{nextjs → frameworks/nextjs}/utils.js +6 -20
- package/dist/src/frameworks/nextjs/utils.js.map +1 -0
- package/dist/src/{nuxt → frameworks/nuxt}/nuxt-wizard-agent.d.ts +1 -1
- package/dist/src/{nuxt → frameworks/nuxt}/nuxt-wizard-agent.js +11 -9
- package/dist/src/frameworks/nuxt/nuxt-wizard-agent.js.map +1 -0
- package/dist/src/{python → frameworks/python}/python-wizard-agent.d.ts +1 -1
- package/dist/src/{python → frameworks/python}/python-wizard-agent.js +3 -3
- package/dist/src/frameworks/python/python-wizard-agent.js.map +1 -0
- package/dist/src/{python → frameworks/python}/utils.d.ts +1 -1
- package/dist/src/frameworks/python/utils.js.map +1 -0
- package/dist/src/{rails → frameworks/rails}/rails-wizard-agent.d.ts +1 -1
- package/dist/src/{rails → frameworks/rails}/rails-wizard-agent.js +2 -2
- package/dist/src/frameworks/rails/rails-wizard-agent.js.map +1 -0
- package/dist/src/{rails → frameworks/rails}/utils.d.ts +1 -1
- package/dist/src/{rails → frameworks/rails}/utils.js +4 -4
- package/dist/src/frameworks/rails/utils.js.map +1 -0
- package/dist/src/{react-native → frameworks/react-native}/react-native-wizard-agent.d.ts +1 -1
- package/dist/src/{react-native → frameworks/react-native}/react-native-wizard-agent.js +9 -7
- package/dist/src/frameworks/react-native/react-native-wizard-agent.js.map +1 -0
- package/dist/src/{react-native → frameworks/react-native}/utils.d.ts +1 -1
- package/dist/src/{react-native → frameworks/react-native}/utils.js +7 -10
- package/dist/src/frameworks/react-native/utils.js.map +1 -0
- package/dist/src/{react-router → frameworks/react-router}/react-router-wizard-agent.d.ts +1 -1
- package/dist/src/{react-router → frameworks/react-router}/react-router-wizard-agent.js +15 -8
- package/dist/src/frameworks/react-router/react-router-wizard-agent.js.map +1 -0
- package/dist/src/frameworks/react-router/utils.d.ts +13 -0
- package/dist/src/{react-router → frameworks/react-router}/utils.js +14 -111
- package/dist/src/frameworks/react-router/utils.js.map +1 -0
- package/dist/src/{ruby → frameworks/ruby}/ruby-wizard-agent.d.ts +1 -1
- package/dist/src/{ruby → frameworks/ruby}/ruby-wizard-agent.js +2 -2
- package/dist/src/frameworks/ruby/ruby-wizard-agent.js.map +1 -0
- package/dist/src/{ruby → frameworks/ruby}/utils.d.ts +1 -1
- package/dist/src/{ruby → frameworks/ruby}/utils.js +1 -1
- package/dist/src/frameworks/ruby/utils.js.map +1 -0
- package/dist/src/{svelte → frameworks/svelte}/svelte-wizard-agent.d.ts +1 -1
- package/dist/src/{svelte → frameworks/svelte}/svelte-wizard-agent.js +5 -5
- package/dist/src/frameworks/svelte/svelte-wizard-agent.js.map +1 -0
- package/dist/src/{swift → frameworks/swift}/swift-wizard-agent.d.ts +1 -1
- package/dist/src/{swift → frameworks/swift}/swift-wizard-agent.js +2 -2
- package/dist/src/frameworks/swift/swift-wizard-agent.js.map +1 -0
- package/dist/src/{swift → frameworks/swift}/utils.d.ts +1 -1
- package/dist/src/frameworks/swift/utils.js.map +1 -0
- package/dist/src/{tanstack-router → frameworks/tanstack-router}/tanstack-router-wizard-agent.d.ts +1 -1
- package/dist/src/{tanstack-router → frameworks/tanstack-router}/tanstack-router-wizard-agent.js +15 -8
- package/dist/src/frameworks/tanstack-router/tanstack-router-wizard-agent.js.map +1 -0
- package/dist/src/frameworks/tanstack-router/utils.d.ts +11 -0
- package/dist/src/{tanstack-router → frameworks/tanstack-router}/utils.js +4 -47
- package/dist/src/frameworks/tanstack-router/utils.js.map +1 -0
- package/dist/src/{tanstack-start → frameworks/tanstack-start}/tanstack-start-wizard-agent.d.ts +1 -1
- package/dist/src/{tanstack-start → frameworks/tanstack-start}/tanstack-start-wizard-agent.js +9 -7
- package/dist/src/frameworks/tanstack-start/tanstack-start-wizard-agent.js.map +1 -0
- package/dist/src/{tanstack-start → frameworks/tanstack-start}/utils.js +1 -1
- package/dist/src/frameworks/tanstack-start/utils.js.map +1 -0
- package/dist/src/{vue → frameworks/vue}/vue-wizard-agent.d.ts +1 -1
- package/dist/src/{vue → frameworks/vue}/vue-wizard-agent.js +8 -8
- package/dist/src/frameworks/vue/vue-wizard-agent.js.map +1 -0
- package/dist/src/lib/__tests__/agent-interface.test.js +91 -19
- package/dist/src/lib/__tests__/agent-interface.test.js.map +1 -1
- package/dist/src/lib/agent-interface.d.ts +49 -2
- package/dist/src/lib/agent-interface.js +254 -40
- package/dist/src/lib/agent-interface.js.map +1 -1
- package/dist/src/lib/agent-runner.d.ts +4 -2
- package/dist/src/lib/agent-runner.js +131 -136
- package/dist/src/lib/agent-runner.js.map +1 -1
- package/dist/src/lib/api.d.ts +4 -4
- package/dist/src/lib/commandments.js +1 -0
- package/dist/src/lib/commandments.js.map +1 -1
- package/dist/src/lib/constants.d.ts +23 -8
- package/dist/src/lib/constants.js +36 -8
- package/dist/src/lib/constants.js.map +1 -1
- package/dist/src/lib/framework-config.d.ts +26 -0
- package/dist/src/lib/framework-config.js.map +1 -1
- package/dist/src/lib/health-checks/__tests__/health-checks.test.d.ts +18 -0
- package/dist/src/lib/health-checks/__tests__/health-checks.test.js +752 -0
- package/dist/src/lib/health-checks/__tests__/health-checks.test.js.map +1 -0
- package/dist/src/lib/health-checks/endpoints.d.ts +3 -0
- package/dist/src/lib/health-checks/endpoints.js +46 -0
- package/dist/src/lib/health-checks/endpoints.js.map +1 -0
- package/dist/src/lib/health-checks/index.d.ts +4 -0
- package/dist/src/lib/health-checks/index.js +23 -0
- package/dist/src/lib/health-checks/index.js.map +1 -0
- package/dist/src/lib/health-checks/readiness.d.ts +24 -0
- package/dist/src/lib/health-checks/readiness.js +119 -0
- package/dist/src/lib/health-checks/readiness.js.map +1 -0
- package/dist/src/lib/health-checks/statuspage.d.ts +9 -0
- package/dist/src/lib/health-checks/statuspage.js +105 -0
- package/dist/src/lib/health-checks/statuspage.js.map +1 -0
- package/dist/src/lib/health-checks/types.d.ts +31 -0
- package/dist/src/lib/health-checks/types.js +10 -0
- package/dist/src/lib/health-checks/types.js.map +1 -0
- package/dist/src/lib/middleware/benchmark.d.ts +2 -2
- package/dist/src/lib/middleware/benchmark.js +3 -3
- package/dist/src/lib/middleware/benchmark.js.map +1 -1
- package/dist/src/lib/middleware/benchmarks/json-writer.js +2 -2
- package/dist/src/lib/middleware/benchmarks/json-writer.js.map +1 -1
- package/dist/src/lib/middleware/benchmarks/summary.d.ts +2 -2
- package/dist/src/lib/middleware/benchmarks/summary.js +9 -9
- package/dist/src/lib/middleware/benchmarks/summary.js.map +1 -1
- package/dist/src/lib/middleware/types.d.ts +2 -2
- package/dist/src/lib/middleware/types.js.map +1 -1
- package/dist/src/lib/package-manager-detection.js +1 -1
- package/dist/src/lib/package-manager-detection.js.map +1 -1
- package/dist/src/lib/registry.js +21 -21
- package/dist/src/lib/registry.js.map +1 -1
- package/dist/src/lib/version.d.ts +1 -1
- package/dist/src/lib/version.js +1 -1
- package/dist/src/lib/version.js.map +1 -1
- package/dist/src/lib/wizard-session.d.ts +115 -0
- package/dist/src/lib/wizard-session.js +104 -0
- package/dist/src/lib/wizard-session.js.map +1 -0
- package/dist/src/lib/wizard-tools.js +13 -0
- package/dist/src/lib/wizard-tools.js.map +1 -1
- package/dist/src/run.d.ts +3 -3
- package/dist/src/run.js +73 -56
- package/dist/src/run.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/MCPClient.d.ts +4 -5
- package/dist/src/steps/add-mcp-server-to-clients/MCPClient.js +6 -6
- package/dist/src/steps/add-mcp-server-to-clients/MCPClient.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/__tests__/defaults.test.js +1 -21
- package/dist/src/steps/add-mcp-server-to-clients/__tests__/defaults.test.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.js +2 -7
- package/dist/src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.js +18 -22
- package/dist/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.d.ts +7 -8
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.js +2 -2
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude.d.ts +6 -6
- package/dist/src/steps/add-mcp-server-to-clients/clients/codex.d.ts +7 -8
- package/dist/src/steps/add-mcp-server-to-clients/clients/codex.js +9 -10
- package/dist/src/steps/add-mcp-server-to-clients/clients/codex.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.d.ts +8 -9
- package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.js +4 -4
- package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.d.ts +8 -9
- package/dist/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.js +4 -4
- package/dist/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/clients/zed.d.ts +8 -9
- package/dist/src/steps/add-mcp-server-to-clients/clients/zed.js +4 -4
- package/dist/src/steps/add-mcp-server-to-clients/clients/zed.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/defaults.d.ts +9 -10
- package/dist/src/steps/add-mcp-server-to-clients/defaults.js +6 -13
- package/dist/src/steps/add-mcp-server-to-clients/defaults.js.map +1 -1
- package/dist/src/steps/add-mcp-server-to-clients/index.d.ts +6 -5
- package/dist/src/steps/add-mcp-server-to-clients/index.js +26 -110
- package/dist/src/steps/add-mcp-server-to-clients/index.js.map +1 -1
- package/dist/src/steps/add-or-update-environment-variables.js +15 -20
- package/dist/src/steps/add-or-update-environment-variables.js.map +1 -1
- package/dist/src/steps/index.d.ts +0 -1
- package/dist/src/steps/index.js +0 -1
- package/dist/src/steps/index.js.map +1 -1
- package/dist/src/steps/run-prettier.js +9 -11
- package/dist/src/steps/run-prettier.js.map +1 -1
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.d.ts +6 -3
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js.map +1 -1
- package/dist/src/steps/upload-environment-variables/index.d.ts +3 -3
- package/dist/src/steps/upload-environment-variables/index.js +7 -35
- package/dist/src/steps/upload-environment-variables/index.js.map +1 -1
- package/dist/src/steps/upload-environment-variables/providers/vercel.d.ts +3 -2
- package/dist/src/steps/upload-environment-variables/providers/vercel.js +2 -2
- package/dist/src/steps/upload-environment-variables/providers/vercel.js.map +1 -1
- package/dist/src/ui/index.d.ts +8 -0
- package/dist/src/ui/index.js +17 -0
- package/dist/src/ui/index.js.map +1 -0
- package/dist/src/ui/logging-ui.d.ts +44 -0
- package/dist/src/ui/logging-ui.js +103 -0
- package/dist/src/ui/logging-ui.js.map +1 -0
- package/dist/src/ui/tui/App.d.ts +6 -0
- package/dist/src/ui/tui/App.js +10 -0
- package/dist/src/ui/tui/App.js.map +1 -0
- package/dist/src/ui/tui/__tests__/layout-helpers.test.js +68 -0
- package/dist/src/ui/tui/__tests__/layout-helpers.test.js.map +1 -0
- package/dist/src/ui/tui/__tests__/store.test.d.ts +1 -0
- package/dist/src/ui/tui/__tests__/store.test.js +723 -0
- package/dist/src/ui/tui/__tests__/store.test.js.map +1 -0
- package/dist/src/ui/tui/components/LearnCard.d.ts +10 -0
- package/dist/src/ui/tui/components/LearnCard.js +217 -0
- package/dist/src/ui/tui/components/LearnCard.js.map +1 -0
- package/dist/src/ui/tui/components/TipsCard.d.ts +9 -0
- package/dist/src/ui/tui/components/TipsCard.js +55 -0
- package/dist/src/ui/tui/components/TipsCard.js.map +1 -0
- package/dist/src/ui/tui/components/TitleBar.d.ts +6 -0
- package/dist/src/ui/tui/components/TitleBar.js +17 -0
- package/dist/src/ui/tui/components/TitleBar.js.map +1 -0
- package/dist/src/ui/tui/flows.d.ts +38 -0
- package/dist/src/ui/tui/flows.js +82 -0
- package/dist/src/ui/tui/flows.js.map +1 -0
- package/dist/src/ui/tui/hooks/useStdoutDimensions.d.ts +9 -0
- package/dist/src/ui/tui/hooks/useStdoutDimensions.js +37 -0
- package/dist/src/ui/tui/hooks/useStdoutDimensions.js.map +1 -0
- package/dist/src/ui/tui/ink-ui.d.ts +50 -0
- package/dist/src/ui/tui/ink-ui.js +108 -0
- package/dist/src/ui/tui/ink-ui.js.map +1 -0
- package/dist/src/ui/tui/package.json +1 -0
- package/dist/src/ui/tui/playground/PlaygroundApp.d.ts +12 -0
- package/dist/src/ui/tui/playground/PlaygroundApp.js +32 -0
- package/dist/src/ui/tui/playground/PlaygroundApp.js.map +1 -0
- package/dist/src/ui/tui/playground/demos/InputDemo.d.ts +4 -0
- package/dist/src/ui/tui/playground/demos/InputDemo.js +53 -0
- package/dist/src/ui/tui/playground/demos/InputDemo.js.map +1 -0
- package/dist/src/ui/tui/playground/demos/LayoutDemo.d.ts +5 -0
- package/dist/src/ui/tui/playground/demos/LayoutDemo.js +25 -0
- package/dist/src/ui/tui/playground/demos/LayoutDemo.js.map +1 -0
- package/dist/src/ui/tui/playground/demos/LogDemo.d.ts +5 -0
- package/dist/src/ui/tui/playground/demos/LogDemo.js +53 -0
- package/dist/src/ui/tui/playground/demos/LogDemo.js.map +1 -0
- package/dist/src/ui/tui/playground/demos/ProgressDemo.d.ts +5 -0
- package/dist/src/ui/tui/playground/demos/ProgressDemo.js +58 -0
- package/dist/src/ui/tui/playground/demos/ProgressDemo.js.map +1 -0
- package/dist/src/ui/tui/playground/demos/RunScreenDemo.d.ts +11 -0
- package/dist/src/ui/tui/playground/demos/RunScreenDemo.js +159 -0
- package/dist/src/ui/tui/playground/demos/RunScreenDemo.js.map +1 -0
- package/dist/src/ui/tui/playground/demos/WelcomeDemo.d.ts +9 -0
- package/dist/src/ui/tui/playground/demos/WelcomeDemo.js +15 -0
- package/dist/src/ui/tui/playground/demos/WelcomeDemo.js.map +1 -0
- package/dist/src/ui/tui/playground/start-playground.d.ts +4 -0
- package/dist/src/ui/tui/playground/start-playground.js +24 -0
- package/dist/src/ui/tui/playground/start-playground.js.map +1 -0
- package/dist/src/ui/tui/primitives/CardLayout.d.ts +12 -0
- package/dist/src/ui/tui/primitives/CardLayout.js +10 -0
- package/dist/src/ui/tui/primitives/CardLayout.js.map +1 -0
- package/dist/src/ui/tui/primitives/ConfirmationInput.d.ts +13 -0
- package/dist/src/ui/tui/primitives/ConfirmationInput.js +35 -0
- package/dist/src/ui/tui/primitives/ConfirmationInput.js.map +1 -0
- package/dist/src/ui/tui/primitives/ContentSequencer.d.ts +42 -0
- package/dist/src/ui/tui/primitives/ContentSequencer.js +137 -0
- package/dist/src/ui/tui/primitives/ContentSequencer.js.map +1 -0
- package/dist/src/ui/tui/primitives/DissolveTransition.d.ts +21 -0
- package/dist/src/ui/tui/primitives/DissolveTransition.js +149 -0
- package/dist/src/ui/tui/primitives/DissolveTransition.js.map +1 -0
- package/dist/src/ui/tui/primitives/EventPlanViewer.d.ts +9 -0
- package/dist/src/ui/tui/primitives/EventPlanViewer.js +9 -0
- package/dist/src/ui/tui/primitives/EventPlanViewer.js.map +1 -0
- package/dist/src/ui/tui/primitives/HNViewer.d.ts +7 -0
- package/dist/src/ui/tui/primitives/HNViewer.js +63 -0
- package/dist/src/ui/tui/primitives/HNViewer.js.map +1 -0
- package/dist/src/ui/tui/primitives/LinesBlock.d.ts +16 -0
- package/dist/src/ui/tui/primitives/LinesBlock.js +37 -0
- package/dist/src/ui/tui/primitives/LinesBlock.js.map +1 -0
- package/dist/src/ui/tui/primitives/LoadingBox.d.ts +8 -0
- package/dist/src/ui/tui/primitives/LoadingBox.js +10 -0
- package/dist/src/ui/tui/primitives/LoadingBox.js.map +1 -0
- package/dist/src/ui/tui/primitives/LogViewer.d.ts +11 -0
- package/dist/src/ui/tui/primitives/LogViewer.js +55 -0
- package/dist/src/ui/tui/primitives/LogViewer.js.map +1 -0
- package/dist/src/ui/tui/primitives/NodeBlock.d.ts +13 -0
- package/dist/src/ui/tui/primitives/NodeBlock.js +17 -0
- package/dist/src/ui/tui/primitives/NodeBlock.js.map +1 -0
- package/dist/src/ui/tui/primitives/PickerMenu.d.ts +20 -0
- package/dist/src/ui/tui/primitives/PickerMenu.js +134 -0
- package/dist/src/ui/tui/primitives/PickerMenu.js.map +1 -0
- package/dist/src/ui/tui/primitives/ProgressList.d.ts +15 -0
- package/dist/src/ui/tui/primitives/ProgressList.js +30 -0
- package/dist/src/ui/tui/primitives/ProgressList.js.map +1 -0
- package/dist/src/ui/tui/primitives/PromptLabel.d.ts +11 -0
- package/dist/src/ui/tui/primitives/PromptLabel.js +13 -0
- package/dist/src/ui/tui/primitives/PromptLabel.js.map +1 -0
- package/dist/src/ui/tui/primitives/ScreenContainer.d.ts +16 -0
- package/dist/src/ui/tui/primitives/ScreenContainer.js +36 -0
- package/dist/src/ui/tui/primitives/ScreenContainer.js.map +1 -0
- package/dist/src/ui/tui/primitives/ScreenErrorBoundary.d.ts +22 -0
- package/dist/src/ui/tui/primitives/ScreenErrorBoundary.js +35 -0
- package/dist/src/ui/tui/primitives/ScreenErrorBoundary.js.map +1 -0
- package/dist/src/ui/tui/primitives/SplitView.d.ts +11 -0
- package/dist/src/ui/tui/primitives/SplitView.js +9 -0
- package/dist/src/ui/tui/primitives/SplitView.js.map +1 -0
- package/dist/src/ui/tui/primitives/TabContainer.d.ts +23 -0
- package/dist/src/ui/tui/primitives/TabContainer.js +45 -0
- package/dist/src/ui/tui/primitives/TabContainer.js.map +1 -0
- package/dist/src/ui/tui/primitives/TextBlock.d.ts +41 -0
- package/dist/src/ui/tui/primitives/TextBlock.js +144 -0
- package/dist/src/ui/tui/primitives/TextBlock.js.map +1 -0
- package/dist/src/ui/tui/primitives/content-types.d.ts +37 -0
- package/dist/src/ui/tui/primitives/content-types.js +19 -0
- package/dist/src/ui/tui/primitives/content-types.js.map +1 -0
- package/dist/src/ui/tui/primitives/index.d.ts +24 -0
- package/dist/src/ui/tui/primitives/index.js +21 -0
- package/dist/src/ui/tui/primitives/index.js.map +1 -0
- package/dist/src/ui/tui/primitives/layout-helpers.d.ts +36 -0
- package/dist/src/ui/tui/primitives/layout-helpers.js +95 -0
- package/dist/src/ui/tui/primitives/layout-helpers.js.map +1 -0
- package/dist/src/ui/tui/primitives/text-helpers.d.ts +10 -0
- package/dist/src/ui/tui/primitives/text-helpers.js +43 -0
- package/dist/src/ui/tui/primitives/text-helpers.js.map +1 -0
- package/dist/src/ui/tui/router.d.ts +56 -0
- package/dist/src/ui/tui/router.js +94 -0
- package/dist/src/ui/tui/router.js.map +1 -0
- package/dist/src/ui/tui/screen-registry.d.ts +19 -0
- package/dist/src/ui/tui/screen-registry.js +34 -0
- package/dist/src/ui/tui/screen-registry.js.map +1 -0
- package/dist/src/ui/tui/screens/AuthScreen.d.ts +13 -0
- package/dist/src/ui/tui/screens/AuthScreen.js +20 -0
- package/dist/src/ui/tui/screens/AuthScreen.js.map +1 -0
- package/dist/src/ui/tui/screens/IntroScreen.d.ts +16 -0
- package/dist/src/ui/tui/screens/IntroScreen.js +63 -0
- package/dist/src/ui/tui/screens/IntroScreen.js.map +1 -0
- package/dist/src/ui/tui/screens/McpScreen.d.ts +24 -0
- package/dist/src/ui/tui/screens/McpScreen.js +112 -0
- package/dist/src/ui/tui/screens/McpScreen.js.map +1 -0
- package/dist/src/ui/tui/screens/OutageScreen.d.ts +10 -0
- package/dist/src/ui/tui/screens/OutageScreen.js +17 -0
- package/dist/src/ui/tui/screens/OutageScreen.js.map +1 -0
- package/dist/src/ui/tui/screens/OutroScreen.d.ts +11 -0
- package/dist/src/ui/tui/screens/OutroScreen.js +22 -0
- package/dist/src/ui/tui/screens/OutroScreen.js.map +1 -0
- package/dist/src/ui/tui/screens/RunScreen.d.ts +16 -0
- package/dist/src/ui/tui/screens/RunScreen.js +73 -0
- package/dist/src/ui/tui/screens/RunScreen.js.map +1 -0
- package/dist/src/ui/tui/screens/SettingsOverrideScreen.d.ts +10 -0
- package/dist/src/ui/tui/screens/SettingsOverrideScreen.js +24 -0
- package/dist/src/ui/tui/screens/SettingsOverrideScreen.js.map +1 -0
- package/dist/src/ui/tui/screens/SetupScreen.d.ts +13 -0
- package/dist/src/ui/tui/screens/SetupScreen.js +74 -0
- package/dist/src/ui/tui/screens/SetupScreen.js.map +1 -0
- package/dist/src/ui/tui/services/mcp-installer.d.ts +21 -0
- package/dist/src/ui/tui/services/mcp-installer.js +58 -0
- package/dist/src/ui/tui/services/mcp-installer.js.map +1 -0
- package/dist/src/ui/tui/start-tui.d.ts +9 -0
- package/dist/src/ui/tui/start-tui.js +41 -0
- package/dist/src/ui/tui/start-tui.js.map +1 -0
- package/dist/src/ui/tui/store.d.ts +132 -0
- package/dist/src/ui/tui/store.js +320 -0
- package/dist/src/ui/tui/store.js.map +1 -0
- package/dist/src/ui/tui/styles.d.ts +31 -0
- package/dist/src/ui/tui/styles.js +34 -0
- package/dist/src/ui/tui/styles.js.map +1 -0
- package/dist/src/ui/wizard-ui.d.ts +64 -0
- package/dist/src/ui/wizard-ui.js +19 -0
- package/dist/src/ui/wizard-ui.js.map +1 -0
- package/dist/src/utils/__tests__/setup-utils.test.d.ts +1 -0
- package/dist/src/utils/__tests__/{clack-utils.test.js → setup-utils.test.js} +31 -22
- package/dist/src/utils/__tests__/setup-utils.test.js.map +1 -0
- package/dist/src/utils/analytics.d.ts +18 -0
- package/dist/src/utils/analytics.js +53 -0
- package/dist/src/utils/analytics.js.map +1 -1
- package/dist/src/utils/anthropic-status.d.ts +1 -12
- package/dist/src/utils/anthropic-status.js +4 -56
- package/dist/src/utils/anthropic-status.js.map +1 -1
- package/dist/src/utils/custom-headers.d.ts +9 -0
- package/dist/src/utils/custom-headers.js +24 -0
- package/dist/src/utils/custom-headers.js.map +1 -0
- package/dist/src/utils/debug.js +2 -2
- package/dist/src/utils/debug.js.map +1 -1
- package/dist/src/utils/environment.js +4 -2
- package/dist/src/utils/environment.js.map +1 -1
- package/dist/src/utils/oauth.d.ts +0 -2
- package/dist/src/utils/oauth.js +18 -21
- package/dist/src/utils/oauth.js.map +1 -1
- package/dist/src/utils/package-manager.js +13 -13
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/src/utils/setup-utils.d.ts +76 -0
- package/dist/src/utils/setup-utils.js +364 -0
- package/dist/src/utils/setup-utils.js.map +1 -0
- package/dist/src/utils/types.d.ts +0 -4
- package/dist/src/utils/types.js.map +1 -1
- package/dist/src/utils/urls.d.ts +1 -1
- package/dist/src/utils/urls.js +22 -9
- package/dist/src/utils/urls.js.map +1 -1
- package/dist/src/utils/wizard-abort.d.ts +13 -0
- package/dist/src/utils/wizard-abort.js +57 -0
- package/dist/src/utils/wizard-abort.js.map +1 -0
- package/package.json +19 -7
- package/dist/src/android/android-wizard-agent.js.map +0 -1
- package/dist/src/android/utils.js.map +0 -1
- package/dist/src/angular/angular-wizard-agent.js.map +0 -1
- package/dist/src/angular/utils.js.map +0 -1
- package/dist/src/astro/astro-wizard-agent.js.map +0 -1
- package/dist/src/astro/utils.js.map +0 -1
- package/dist/src/django/django-wizard-agent.js.map +0 -1
- package/dist/src/django/utils.js.map +0 -1
- package/dist/src/fastapi/fastapi-wizard-agent.d.ts +0 -7
- package/dist/src/fastapi/fastapi-wizard-agent.js.map +0 -1
- package/dist/src/fastapi/utils.js.map +0 -1
- package/dist/src/flask/flask-wizard-agent.js.map +0 -1
- package/dist/src/flask/utils.js.map +0 -1
- package/dist/src/javascript-node/javascript-node-wizard-agent.js.map +0 -1
- package/dist/src/javascript-web/javascript-web-wizard-agent.js.map +0 -1
- package/dist/src/javascript-web/utils.js.map +0 -1
- package/dist/src/laravel/laravel-wizard-agent.js.map +0 -1
- package/dist/src/laravel/utils.js.map +0 -1
- package/dist/src/mcp.d.ts +0 -10
- package/dist/src/mcp.js +0 -45
- package/dist/src/mcp.js.map +0 -1
- package/dist/src/nextjs/nextjs-wizard-agent.js.map +0 -1
- package/dist/src/nextjs/utils.js.map +0 -1
- package/dist/src/nuxt/nuxt-wizard-agent.js.map +0 -1
- package/dist/src/python/python-wizard-agent.js.map +0 -1
- package/dist/src/python/utils.js.map +0 -1
- package/dist/src/rails/rails-wizard-agent.js.map +0 -1
- package/dist/src/rails/utils.js.map +0 -1
- package/dist/src/react-native/react-native-wizard-agent.js.map +0 -1
- package/dist/src/react-native/utils.js.map +0 -1
- package/dist/src/react-router/react-router-wizard-agent.js.map +0 -1
- package/dist/src/react-router/utils.d.ts +0 -19
- package/dist/src/react-router/utils.js.map +0 -1
- package/dist/src/ruby/ruby-wizard-agent.js.map +0 -1
- package/dist/src/ruby/utils.js.map +0 -1
- package/dist/src/steps/__tests__/add-editor-rules.test.js +0 -208
- package/dist/src/steps/__tests__/add-editor-rules.test.js.map +0 -1
- package/dist/src/steps/add-editor-rules.d.ts +0 -8
- package/dist/src/steps/add-editor-rules.js +0 -71
- package/dist/src/steps/add-editor-rules.js.map +0 -1
- package/dist/src/svelte/svelte-wizard-agent.js.map +0 -1
- package/dist/src/swift/swift-wizard-agent.js.map +0 -1
- package/dist/src/swift/utils.js.map +0 -1
- package/dist/src/tanstack-router/tanstack-router-wizard-agent.js.map +0 -1
- package/dist/src/tanstack-router/utils.d.ts +0 -17
- package/dist/src/tanstack-router/utils.js.map +0 -1
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.js.map +0 -1
- package/dist/src/tanstack-start/utils.js.map +0 -1
- package/dist/src/utils/__tests__/clack-utils.test.js.map +0 -1
- package/dist/src/utils/clack-utils.d.ts +0 -190
- package/dist/src/utils/clack-utils.js +0 -728
- package/dist/src/utils/clack-utils.js.map +0 -1
- package/dist/src/utils/clack.d.ts +0 -2
- package/dist/src/utils/clack.js +0 -9
- package/dist/src/utils/clack.js.map +0 -1
- package/dist/src/vue/vue-wizard-agent.js.map +0 -1
- /package/dist/src/{steps/__tests__/add-editor-rules.test.d.ts → __tests__/wizard-abort.test.d.ts} +0 -0
- /package/dist/src/{angular → frameworks/angular}/utils.d.ts +0 -0
- /package/dist/src/{python → frameworks/python}/utils.js +0 -0
- /package/dist/src/{swift → frameworks/swift}/utils.js +0 -0
- /package/dist/src/{tanstack-start → frameworks/tanstack-start}/utils.d.ts +0 -0
- /package/dist/src/{utils/__tests__/clack-utils.test.d.ts → ui/tui/__tests__/layout-helpers.test.d.ts} +0 -0
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
import { WizardStore, TaskStatus, Flow, Screen, Overlay, RunPhase, McpOutcome, } from '../store.js';
|
|
2
|
+
import { OutroKind, AdditionalFeature } from '../../../lib/wizard-session.js';
|
|
3
|
+
import { buildSession } from '../../../lib/wizard-session.js';
|
|
4
|
+
import { Integration } from '../../../lib/constants.js';
|
|
5
|
+
import { analytics } from '../../../utils/analytics.js';
|
|
6
|
+
jest.mock('../../../utils/analytics.js', () => ({
|
|
7
|
+
analytics: {
|
|
8
|
+
capture: jest.fn(),
|
|
9
|
+
wizardCapture: jest.fn(),
|
|
10
|
+
setTag: jest.fn(),
|
|
11
|
+
shutdown: jest.fn().mockResolvedValue(undefined),
|
|
12
|
+
},
|
|
13
|
+
sessionProperties: jest.fn(() => ({})),
|
|
14
|
+
}));
|
|
15
|
+
function createStore(flow) {
|
|
16
|
+
return new WizardStore(flow);
|
|
17
|
+
}
|
|
18
|
+
const wizardCaptureMock = analytics.wizardCapture;
|
|
19
|
+
describe('WizardStore', () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
jest.clearAllMocks();
|
|
22
|
+
});
|
|
23
|
+
// ── Construction ─────────────────────────────────────────────────
|
|
24
|
+
describe('constructor', () => {
|
|
25
|
+
it('initialises with default state', () => {
|
|
26
|
+
const store = createStore();
|
|
27
|
+
expect(store.version).toBe('');
|
|
28
|
+
expect(store.statusMessages).toEqual([]);
|
|
29
|
+
expect(store.tasks).toEqual([]);
|
|
30
|
+
expect(store.session).toEqual(buildSession({}));
|
|
31
|
+
});
|
|
32
|
+
it('defaults to Wizard flow', () => {
|
|
33
|
+
const store = createStore();
|
|
34
|
+
expect(store.router.activeFlow).toBe(Flow.Wizard);
|
|
35
|
+
});
|
|
36
|
+
it('accepts a custom flow', () => {
|
|
37
|
+
const store = createStore(Flow.McpAdd);
|
|
38
|
+
expect(store.router.activeFlow).toBe(Flow.McpAdd);
|
|
39
|
+
});
|
|
40
|
+
it('starts with version 0', () => {
|
|
41
|
+
const store = createStore();
|
|
42
|
+
expect(store.getVersion()).toBe(0);
|
|
43
|
+
expect(store.getSnapshot()).toBe(0);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
// ── Change notification ──────────────────────────────────────────
|
|
47
|
+
describe('change notification', () => {
|
|
48
|
+
it('emitChange increments version and notifies subscribers', () => {
|
|
49
|
+
const store = createStore();
|
|
50
|
+
const listener = jest.fn();
|
|
51
|
+
store.subscribe(listener);
|
|
52
|
+
store.emitChange();
|
|
53
|
+
expect(store.getVersion()).toBe(1);
|
|
54
|
+
expect(listener).toHaveBeenCalledTimes(1);
|
|
55
|
+
});
|
|
56
|
+
it('version increments on each emitChange', () => {
|
|
57
|
+
const store = createStore();
|
|
58
|
+
store.emitChange();
|
|
59
|
+
store.emitChange();
|
|
60
|
+
store.emitChange();
|
|
61
|
+
expect(store.getVersion()).toBe(3);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
// ── React integration (subscribe / getSnapshot) ──────────────────
|
|
65
|
+
describe('subscribe / getSnapshot', () => {
|
|
66
|
+
it('subscribe registers a listener that fires on change', () => {
|
|
67
|
+
const store = createStore();
|
|
68
|
+
const cb = jest.fn();
|
|
69
|
+
store.subscribe(cb);
|
|
70
|
+
store.emitChange();
|
|
71
|
+
expect(cb).toHaveBeenCalledTimes(1);
|
|
72
|
+
});
|
|
73
|
+
it('subscribe returns an unsubscribe function', () => {
|
|
74
|
+
const store = createStore();
|
|
75
|
+
const cb = jest.fn();
|
|
76
|
+
const unsub = store.subscribe(cb);
|
|
77
|
+
unsub();
|
|
78
|
+
store.emitChange();
|
|
79
|
+
expect(cb).not.toHaveBeenCalled();
|
|
80
|
+
});
|
|
81
|
+
it('getSnapshot returns the current version', () => {
|
|
82
|
+
const store = createStore();
|
|
83
|
+
expect(store.getSnapshot()).toBe(0);
|
|
84
|
+
store.emitChange();
|
|
85
|
+
expect(store.getSnapshot()).toBe(1);
|
|
86
|
+
});
|
|
87
|
+
it('is compatible with useSyncExternalStore contract', () => {
|
|
88
|
+
const store = createStore();
|
|
89
|
+
const cb = jest.fn();
|
|
90
|
+
const unsub = store.subscribe(cb);
|
|
91
|
+
const v1 = store.getSnapshot();
|
|
92
|
+
store.completeSetup();
|
|
93
|
+
const v2 = store.getSnapshot();
|
|
94
|
+
expect(v2).toBeGreaterThan(v1);
|
|
95
|
+
expect(cb).toHaveBeenCalled();
|
|
96
|
+
unsub();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
// ── Session setters ──────────────────────────────────────────────
|
|
100
|
+
describe('session setters', () => {
|
|
101
|
+
it('completeSetup sets setupConfirmed and resolves setupComplete promise', async () => {
|
|
102
|
+
const store = createStore();
|
|
103
|
+
const cb = jest.fn();
|
|
104
|
+
store.subscribe(cb);
|
|
105
|
+
store.completeSetup();
|
|
106
|
+
expect(store.session.setupConfirmed).toBe(true);
|
|
107
|
+
await store.setupComplete;
|
|
108
|
+
expect(cb).toHaveBeenCalled();
|
|
109
|
+
});
|
|
110
|
+
it('setRunPhase updates session.runPhase', () => {
|
|
111
|
+
const store = createStore();
|
|
112
|
+
store.setRunPhase(RunPhase.Running);
|
|
113
|
+
expect(store.session.runPhase).toBe(RunPhase.Running);
|
|
114
|
+
});
|
|
115
|
+
it('setCredentials updates session.credentials', () => {
|
|
116
|
+
const store = createStore();
|
|
117
|
+
const creds = {
|
|
118
|
+
accessToken: 'tok',
|
|
119
|
+
projectApiKey: 'pk',
|
|
120
|
+
host: 'https://app.posthog.com',
|
|
121
|
+
projectId: 42,
|
|
122
|
+
};
|
|
123
|
+
store.setCredentials(creds);
|
|
124
|
+
expect(store.session.credentials).toEqual(creds);
|
|
125
|
+
});
|
|
126
|
+
it('setFrameworkConfig updates integration and frameworkConfig', () => {
|
|
127
|
+
const store = createStore();
|
|
128
|
+
const integration = Integration.nextjs;
|
|
129
|
+
const config = {
|
|
130
|
+
metadata: { name: 'Next.js' },
|
|
131
|
+
};
|
|
132
|
+
store.setFrameworkConfig(integration, config);
|
|
133
|
+
expect(store.session.integration).toBe(integration);
|
|
134
|
+
expect(store.session.frameworkConfig).toBe(config);
|
|
135
|
+
});
|
|
136
|
+
it('setDetectionComplete marks detection done', () => {
|
|
137
|
+
const store = createStore();
|
|
138
|
+
expect(store.session.detectionComplete).toBe(false);
|
|
139
|
+
store.setDetectionComplete();
|
|
140
|
+
expect(store.session.detectionComplete).toBe(true);
|
|
141
|
+
});
|
|
142
|
+
it('setDetectedFramework sets the label', () => {
|
|
143
|
+
const store = createStore();
|
|
144
|
+
store.setDetectedFramework('Django');
|
|
145
|
+
expect(store.session.detectedFrameworkLabel).toBe('Django');
|
|
146
|
+
});
|
|
147
|
+
it('setLoginUrl sets and clears the login URL', () => {
|
|
148
|
+
const store = createStore();
|
|
149
|
+
store.setLoginUrl('https://example.com/auth');
|
|
150
|
+
expect(store.session.loginUrl).toBe('https://example.com/auth');
|
|
151
|
+
store.setLoginUrl(null);
|
|
152
|
+
expect(store.session.loginUrl).toBeNull();
|
|
153
|
+
});
|
|
154
|
+
it('setServiceStatus sets status info', () => {
|
|
155
|
+
const store = createStore();
|
|
156
|
+
const status = {
|
|
157
|
+
description: 'Major outage',
|
|
158
|
+
statusPageUrl: 'https://status.posthog.com',
|
|
159
|
+
};
|
|
160
|
+
store.setServiceStatus(status);
|
|
161
|
+
expect(store.session.serviceStatus).toEqual(status);
|
|
162
|
+
store.setServiceStatus(null);
|
|
163
|
+
expect(store.session.serviceStatus).toBeNull();
|
|
164
|
+
});
|
|
165
|
+
it('setMcpComplete marks MCP step done with outcome', () => {
|
|
166
|
+
const store = createStore();
|
|
167
|
+
expect(store.session.mcpComplete).toBe(false);
|
|
168
|
+
store.setMcpComplete(McpOutcome.Installed, ['Cursor']);
|
|
169
|
+
expect(store.session.mcpComplete).toBe(true);
|
|
170
|
+
expect(store.session.mcpOutcome).toBe(McpOutcome.Installed);
|
|
171
|
+
expect(store.session.mcpInstalledClients).toEqual(['Cursor']);
|
|
172
|
+
});
|
|
173
|
+
it('setOutroData sets outro information', () => {
|
|
174
|
+
const store = createStore();
|
|
175
|
+
const data = { kind: OutroKind.Success, message: 'Done!' };
|
|
176
|
+
store.setOutroData(data);
|
|
177
|
+
expect(store.session.outroData).toEqual(data);
|
|
178
|
+
});
|
|
179
|
+
it('setFrameworkContext sets key-value pairs', () => {
|
|
180
|
+
const store = createStore();
|
|
181
|
+
store.setFrameworkContext('packageManager', 'pnpm');
|
|
182
|
+
expect(store.session.frameworkContext['packageManager']).toBe('pnpm');
|
|
183
|
+
store.setFrameworkContext('srcDir', 'src');
|
|
184
|
+
expect(store.session.frameworkContext['srcDir']).toBe('src');
|
|
185
|
+
});
|
|
186
|
+
it('every setter emits exactly one change event', () => {
|
|
187
|
+
const store = createStore();
|
|
188
|
+
const cb = jest.fn();
|
|
189
|
+
store.subscribe(cb);
|
|
190
|
+
store.completeSetup();
|
|
191
|
+
store.setRunPhase(RunPhase.Running);
|
|
192
|
+
store.setCredentials(null);
|
|
193
|
+
store.setDetectionComplete();
|
|
194
|
+
store.setDetectedFramework('React');
|
|
195
|
+
store.setLoginUrl('url');
|
|
196
|
+
store.setServiceStatus(null);
|
|
197
|
+
store.setMcpComplete();
|
|
198
|
+
store.setOutroData({ kind: OutroKind.Success });
|
|
199
|
+
store.setFrameworkContext('k', 'v');
|
|
200
|
+
store.setFrameworkConfig(null, null);
|
|
201
|
+
expect(cb).toHaveBeenCalledTimes(11);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
// ── Setter analytics events ────────────────────────────────────
|
|
205
|
+
describe('setter analytics events', () => {
|
|
206
|
+
it('completeSetup fires setup confirmed event', () => {
|
|
207
|
+
const store = createStore();
|
|
208
|
+
store.completeSetup();
|
|
209
|
+
expect(wizardCaptureMock).toHaveBeenCalledWith('setup confirmed', expect.any(Object));
|
|
210
|
+
});
|
|
211
|
+
it('setCredentials fires auth complete event', () => {
|
|
212
|
+
const store = createStore();
|
|
213
|
+
store.setCredentials({
|
|
214
|
+
accessToken: 'tok',
|
|
215
|
+
projectApiKey: 'pk',
|
|
216
|
+
host: 'h',
|
|
217
|
+
projectId: 42,
|
|
218
|
+
});
|
|
219
|
+
expect(wizardCaptureMock).toHaveBeenCalledWith('auth complete', {
|
|
220
|
+
project_id: 42,
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
it('enableFeature fires feature enabled event', () => {
|
|
224
|
+
const store = createStore();
|
|
225
|
+
store.enableFeature(AdditionalFeature.LLM);
|
|
226
|
+
expect(wizardCaptureMock).toHaveBeenCalledWith('feature enabled', {
|
|
227
|
+
feature: AdditionalFeature.LLM,
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
it('setMcpComplete fires mcp complete event', () => {
|
|
231
|
+
const store = createStore();
|
|
232
|
+
store.setMcpComplete(McpOutcome.Installed, ['Cursor', 'VS Code']);
|
|
233
|
+
expect(wizardCaptureMock).toHaveBeenCalledWith('mcp complete', expect.objectContaining({
|
|
234
|
+
mcp_outcome: McpOutcome.Installed,
|
|
235
|
+
mcp_installed_clients: ['Cursor', 'VS Code'],
|
|
236
|
+
}));
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
// ── Screen resolution (derived state) ────────────────────────────
|
|
240
|
+
describe('currentScreen', () => {
|
|
241
|
+
it('starts at intro for Wizard flow', () => {
|
|
242
|
+
const store = createStore();
|
|
243
|
+
expect(store.currentScreen).toBe(Screen.Intro);
|
|
244
|
+
});
|
|
245
|
+
it('advances to auth after region is set', () => {
|
|
246
|
+
const store = createStore();
|
|
247
|
+
store.completeSetup();
|
|
248
|
+
expect(store.currentScreen).toBe(Screen.Auth);
|
|
249
|
+
});
|
|
250
|
+
it('advances to run after credentials are set', () => {
|
|
251
|
+
const store = createStore();
|
|
252
|
+
store.completeSetup();
|
|
253
|
+
store.setCredentials({
|
|
254
|
+
accessToken: 'tok',
|
|
255
|
+
projectApiKey: 'pk',
|
|
256
|
+
host: 'h',
|
|
257
|
+
projectId: 1,
|
|
258
|
+
});
|
|
259
|
+
expect(store.currentScreen).toBe(Screen.Run);
|
|
260
|
+
});
|
|
261
|
+
it('advances to mcp after run completes', () => {
|
|
262
|
+
const store = createStore();
|
|
263
|
+
store.completeSetup();
|
|
264
|
+
store.setCredentials({
|
|
265
|
+
accessToken: 'tok',
|
|
266
|
+
projectApiKey: 'pk',
|
|
267
|
+
host: 'h',
|
|
268
|
+
projectId: 1,
|
|
269
|
+
});
|
|
270
|
+
store.setRunPhase(RunPhase.Completed);
|
|
271
|
+
expect(store.currentScreen).toBe(Screen.Mcp);
|
|
272
|
+
});
|
|
273
|
+
it('advances to outro after mcp completes', () => {
|
|
274
|
+
const store = createStore();
|
|
275
|
+
store.completeSetup();
|
|
276
|
+
store.setCredentials({
|
|
277
|
+
accessToken: 'tok',
|
|
278
|
+
projectApiKey: 'pk',
|
|
279
|
+
host: 'h',
|
|
280
|
+
projectId: 1,
|
|
281
|
+
});
|
|
282
|
+
store.setRunPhase(RunPhase.Completed);
|
|
283
|
+
store.setMcpComplete();
|
|
284
|
+
expect(store.currentScreen).toBe(Screen.Outro);
|
|
285
|
+
});
|
|
286
|
+
it('starts at McpAdd for McpAdd flow', () => {
|
|
287
|
+
const store = createStore(Flow.McpAdd);
|
|
288
|
+
expect(store.currentScreen).toBe(Screen.McpAdd);
|
|
289
|
+
});
|
|
290
|
+
it('starts at McpRemove for McpRemove flow', () => {
|
|
291
|
+
const store = createStore(Flow.McpRemove);
|
|
292
|
+
expect(store.currentScreen).toBe(Screen.McpRemove);
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
// ── Overlay navigation ───────────────────────────────────────────
|
|
296
|
+
describe('overlay navigation', () => {
|
|
297
|
+
it('pushOverlay shows the overlay over the current screen', () => {
|
|
298
|
+
const store = createStore();
|
|
299
|
+
store.pushOverlay(Overlay.Outage);
|
|
300
|
+
expect(store.currentScreen).toBe(Overlay.Outage);
|
|
301
|
+
});
|
|
302
|
+
it('popOverlay returns to the underlying screen', () => {
|
|
303
|
+
const store = createStore();
|
|
304
|
+
store.pushOverlay(Overlay.Outage);
|
|
305
|
+
store.popOverlay();
|
|
306
|
+
expect(store.currentScreen).toBe(Screen.Intro);
|
|
307
|
+
});
|
|
308
|
+
it('pushOverlay emits change and increments version', () => {
|
|
309
|
+
const store = createStore();
|
|
310
|
+
const cb = jest.fn();
|
|
311
|
+
store.subscribe(cb);
|
|
312
|
+
store.pushOverlay(Overlay.Outage);
|
|
313
|
+
expect(cb).toHaveBeenCalledTimes(1);
|
|
314
|
+
expect(store.getVersion()).toBe(1);
|
|
315
|
+
});
|
|
316
|
+
it('popOverlay emits change and increments version', () => {
|
|
317
|
+
const store = createStore();
|
|
318
|
+
store.pushOverlay(Overlay.Outage);
|
|
319
|
+
const cb = jest.fn();
|
|
320
|
+
store.subscribe(cb);
|
|
321
|
+
store.popOverlay();
|
|
322
|
+
expect(cb).toHaveBeenCalledTimes(1);
|
|
323
|
+
});
|
|
324
|
+
it('pushOverlay sets direction to push', () => {
|
|
325
|
+
const store = createStore();
|
|
326
|
+
store.pushOverlay(Overlay.Outage);
|
|
327
|
+
expect(store.lastNavDirection).toBe('push');
|
|
328
|
+
});
|
|
329
|
+
it('popOverlay sets direction to pop', () => {
|
|
330
|
+
const store = createStore();
|
|
331
|
+
store.pushOverlay(Overlay.Outage);
|
|
332
|
+
store.popOverlay();
|
|
333
|
+
expect(store.lastNavDirection).toBe('pop');
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
// ── Agent observation state ──────────────────────────────────────
|
|
337
|
+
describe('statusMessages', () => {
|
|
338
|
+
it('pushStatus appends messages', () => {
|
|
339
|
+
const store = createStore();
|
|
340
|
+
store.pushStatus('Installing SDK...');
|
|
341
|
+
store.pushStatus('Configuring...');
|
|
342
|
+
expect(store.statusMessages).toEqual([
|
|
343
|
+
'Installing SDK...',
|
|
344
|
+
'Configuring...',
|
|
345
|
+
]);
|
|
346
|
+
});
|
|
347
|
+
it('pushStatus emits change', () => {
|
|
348
|
+
const store = createStore();
|
|
349
|
+
const cb = jest.fn();
|
|
350
|
+
store.subscribe(cb);
|
|
351
|
+
store.pushStatus('msg');
|
|
352
|
+
expect(cb).toHaveBeenCalledTimes(1);
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
describe('tasks', () => {
|
|
356
|
+
it('setTasks replaces the task list', () => {
|
|
357
|
+
const store = createStore();
|
|
358
|
+
const tasks = [
|
|
359
|
+
{ label: 'Install SDK', status: TaskStatus.Pending, done: false },
|
|
360
|
+
{ label: 'Configure', status: TaskStatus.Pending, done: false },
|
|
361
|
+
];
|
|
362
|
+
store.setTasks(tasks);
|
|
363
|
+
expect(store.tasks).toEqual(tasks);
|
|
364
|
+
});
|
|
365
|
+
it('updateTask marks a task as done', () => {
|
|
366
|
+
const store = createStore();
|
|
367
|
+
store.setTasks([
|
|
368
|
+
{ label: 'Install SDK', status: TaskStatus.Pending, done: false },
|
|
369
|
+
]);
|
|
370
|
+
store.updateTask(0, true);
|
|
371
|
+
expect(store.tasks[0].done).toBe(true);
|
|
372
|
+
expect(store.tasks[0].status).toBe(TaskStatus.Completed);
|
|
373
|
+
});
|
|
374
|
+
it('updateTask marks a task as not done', () => {
|
|
375
|
+
const store = createStore();
|
|
376
|
+
store.setTasks([
|
|
377
|
+
{ label: 'Install SDK', status: TaskStatus.Completed, done: true },
|
|
378
|
+
]);
|
|
379
|
+
store.updateTask(0, false);
|
|
380
|
+
expect(store.tasks[0].done).toBe(false);
|
|
381
|
+
expect(store.tasks[0].status).toBe(TaskStatus.Pending);
|
|
382
|
+
});
|
|
383
|
+
it('updateTask is a no-op for out-of-bounds index', () => {
|
|
384
|
+
const store = createStore();
|
|
385
|
+
store.setTasks([
|
|
386
|
+
{ label: 'Install SDK', status: TaskStatus.Pending, done: false },
|
|
387
|
+
]);
|
|
388
|
+
const cb = jest.fn();
|
|
389
|
+
store.subscribe(cb);
|
|
390
|
+
store.updateTask(99, true);
|
|
391
|
+
expect(cb).not.toHaveBeenCalled();
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
describe('syncTodos', () => {
|
|
395
|
+
it('maps incoming todos to TaskItems', () => {
|
|
396
|
+
const store = createStore();
|
|
397
|
+
store.syncTodos([
|
|
398
|
+
{ content: 'Install SDK', status: 'pending' },
|
|
399
|
+
{ content: 'Configure', status: 'completed' },
|
|
400
|
+
]);
|
|
401
|
+
expect(store.tasks).toHaveLength(2);
|
|
402
|
+
expect(store.tasks[0]).toEqual({
|
|
403
|
+
label: 'Install SDK',
|
|
404
|
+
activeForm: undefined,
|
|
405
|
+
status: TaskStatus.Pending,
|
|
406
|
+
done: false,
|
|
407
|
+
});
|
|
408
|
+
expect(store.tasks[1]).toEqual({
|
|
409
|
+
label: 'Configure',
|
|
410
|
+
activeForm: undefined,
|
|
411
|
+
status: TaskStatus.Completed,
|
|
412
|
+
done: true,
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
it('retains completed tasks not in the incoming list', () => {
|
|
416
|
+
const store = createStore();
|
|
417
|
+
store.setTasks([
|
|
418
|
+
{ label: 'Old done task', status: TaskStatus.Completed, done: true },
|
|
419
|
+
{ label: 'Old pending task', status: TaskStatus.Pending, done: false },
|
|
420
|
+
]);
|
|
421
|
+
store.syncTodos([{ content: 'New task', status: 'pending' }]);
|
|
422
|
+
// Old done task is retained, old pending task is dropped
|
|
423
|
+
expect(store.tasks).toHaveLength(2);
|
|
424
|
+
expect(store.tasks[0].label).toBe('Old done task');
|
|
425
|
+
expect(store.tasks[1].label).toBe('New task');
|
|
426
|
+
});
|
|
427
|
+
it('does not duplicate completed tasks that appear in both', () => {
|
|
428
|
+
const store = createStore();
|
|
429
|
+
store.setTasks([
|
|
430
|
+
{ label: 'Shared task', status: TaskStatus.Completed, done: true },
|
|
431
|
+
]);
|
|
432
|
+
store.syncTodos([{ content: 'Shared task', status: 'completed' }]);
|
|
433
|
+
// Should not have duplicates — incomingLabels includes "Shared task",
|
|
434
|
+
// so the retained filter excludes it
|
|
435
|
+
expect(store.tasks).toHaveLength(1);
|
|
436
|
+
expect(store.tasks[0].label).toBe('Shared task');
|
|
437
|
+
});
|
|
438
|
+
it('preserves activeForm from incoming todos', () => {
|
|
439
|
+
const store = createStore();
|
|
440
|
+
store.syncTodos([
|
|
441
|
+
{
|
|
442
|
+
content: 'Installing',
|
|
443
|
+
status: 'in_progress',
|
|
444
|
+
activeForm: 'Installing SDK...',
|
|
445
|
+
},
|
|
446
|
+
]);
|
|
447
|
+
expect(store.tasks[0].activeForm).toBe('Installing SDK...');
|
|
448
|
+
});
|
|
449
|
+
it('emits change', () => {
|
|
450
|
+
const store = createStore();
|
|
451
|
+
const cb = jest.fn();
|
|
452
|
+
store.subscribe(cb);
|
|
453
|
+
store.syncTodos([{ content: 'task', status: 'pending' }]);
|
|
454
|
+
expect(cb).toHaveBeenCalled();
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
// ── Navigation direction ─────────────────────────────────────────
|
|
458
|
+
describe('lastNavDirection', () => {
|
|
459
|
+
it('starts as null', () => {
|
|
460
|
+
const store = createStore();
|
|
461
|
+
expect(store.lastNavDirection).toBeNull();
|
|
462
|
+
});
|
|
463
|
+
it('is set to push on emitChange', () => {
|
|
464
|
+
const store = createStore();
|
|
465
|
+
store.emitChange();
|
|
466
|
+
expect(store.lastNavDirection).toBe('push');
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
// ── Concurrent / rapid-fire mutations ─────────────────────────────
|
|
470
|
+
describe('concurrent mutations', () => {
|
|
471
|
+
it('rapid-fire setters each increment version by 1', () => {
|
|
472
|
+
const store = createStore();
|
|
473
|
+
const cb = jest.fn();
|
|
474
|
+
store.subscribe(cb);
|
|
475
|
+
store.completeSetup();
|
|
476
|
+
store.setRunPhase(RunPhase.Running);
|
|
477
|
+
store.pushStatus('msg1');
|
|
478
|
+
store.pushStatus('msg2');
|
|
479
|
+
store.setDetectedFramework('React');
|
|
480
|
+
expect(store.getVersion()).toBe(5);
|
|
481
|
+
expect(cb).toHaveBeenCalledTimes(5);
|
|
482
|
+
});
|
|
483
|
+
it('subscriber sees consistent state during a setter call', () => {
|
|
484
|
+
const store = createStore();
|
|
485
|
+
const snapshots = [];
|
|
486
|
+
store.subscribe(() => {
|
|
487
|
+
snapshots.push({
|
|
488
|
+
confirmed: store.session.setupConfirmed,
|
|
489
|
+
version: store.getSnapshot(),
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
store.completeSetup();
|
|
493
|
+
expect(snapshots).toEqual([{ confirmed: true, version: 1 }]);
|
|
494
|
+
});
|
|
495
|
+
it('multiple subscribers all see the same state', () => {
|
|
496
|
+
const store = createStore();
|
|
497
|
+
const results = [];
|
|
498
|
+
store.subscribe(() => results.push(store.getSnapshot()));
|
|
499
|
+
store.subscribe(() => results.push(store.getSnapshot()));
|
|
500
|
+
store.subscribe(() => results.push(store.getSnapshot()));
|
|
501
|
+
store.completeSetup();
|
|
502
|
+
// All 3 subscribers should see version 1
|
|
503
|
+
expect(results).toEqual([1, 1, 1]);
|
|
504
|
+
});
|
|
505
|
+
it('subscriber that mutates store during notification triggers additional notifications', () => {
|
|
506
|
+
const store = createStore();
|
|
507
|
+
const versions = [];
|
|
508
|
+
// First subscriber triggers another mutation
|
|
509
|
+
store.subscribe(() => {
|
|
510
|
+
versions.push(store.getSnapshot());
|
|
511
|
+
if (store.session.setupConfirmed &&
|
|
512
|
+
store.session.runPhase === RunPhase.Idle) {
|
|
513
|
+
store.setRunPhase(RunPhase.Running);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
store.completeSetup();
|
|
517
|
+
// Should see version 1 (from completeSetup) and version 2 (from setRunPhase)
|
|
518
|
+
expect(versions).toEqual([1, 2]);
|
|
519
|
+
expect(store.session.runPhase).toBe(RunPhase.Running);
|
|
520
|
+
});
|
|
521
|
+
it('interleaved overlay and session mutations are all visible', () => {
|
|
522
|
+
const store = createStore();
|
|
523
|
+
const screens = [];
|
|
524
|
+
store.subscribe(() => {
|
|
525
|
+
screens.push(store.currentScreen);
|
|
526
|
+
});
|
|
527
|
+
store.completeSetup(); // -> auth
|
|
528
|
+
store.pushOverlay(Overlay.Outage); // -> outage
|
|
529
|
+
store.setCredentials({
|
|
530
|
+
// -> outage (overlay still on top)
|
|
531
|
+
accessToken: 'tok',
|
|
532
|
+
projectApiKey: 'pk',
|
|
533
|
+
host: 'h',
|
|
534
|
+
projectId: 1,
|
|
535
|
+
});
|
|
536
|
+
store.popOverlay(); // -> run
|
|
537
|
+
expect(screens).toEqual([
|
|
538
|
+
Screen.Auth,
|
|
539
|
+
Overlay.Outage,
|
|
540
|
+
Overlay.Outage,
|
|
541
|
+
Screen.Run,
|
|
542
|
+
]);
|
|
543
|
+
});
|
|
544
|
+
it('unsubscribing mid-notification does not affect other subscribers', () => {
|
|
545
|
+
const store = createStore();
|
|
546
|
+
const log = [];
|
|
547
|
+
store.subscribe(() => {
|
|
548
|
+
log.push('sub1');
|
|
549
|
+
});
|
|
550
|
+
const unsub2 = store.subscribe(() => {
|
|
551
|
+
log.push('sub2');
|
|
552
|
+
});
|
|
553
|
+
store.subscribe(() => {
|
|
554
|
+
log.push('sub3');
|
|
555
|
+
});
|
|
556
|
+
store.emitChange();
|
|
557
|
+
expect(log).toEqual(['sub1', 'sub2', 'sub3']);
|
|
558
|
+
// Unsub the second listener
|
|
559
|
+
unsub2();
|
|
560
|
+
log.length = 0;
|
|
561
|
+
store.emitChange();
|
|
562
|
+
expect(log).toEqual(['sub1', 'sub3']);
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
// ── Multiple subscribers ─────────────────────────────────────────
|
|
566
|
+
describe('multiple subscribers', () => {
|
|
567
|
+
it('supports many concurrent subscribers', () => {
|
|
568
|
+
const store = createStore();
|
|
569
|
+
const callbacks = Array.from({ length: 50 }, () => jest.fn());
|
|
570
|
+
const unsubs = callbacks.map((cb) => store.subscribe(cb));
|
|
571
|
+
store.emitChange();
|
|
572
|
+
callbacks.forEach((cb) => expect(cb).toHaveBeenCalledTimes(1));
|
|
573
|
+
// Unsubscribe all
|
|
574
|
+
unsubs.forEach((unsub) => unsub());
|
|
575
|
+
store.emitChange();
|
|
576
|
+
// No more notifications
|
|
577
|
+
callbacks.forEach((cb) => expect(cb).toHaveBeenCalledTimes(1));
|
|
578
|
+
});
|
|
579
|
+
it('double-unsubscribe is safe', () => {
|
|
580
|
+
const store = createStore();
|
|
581
|
+
const cb = jest.fn();
|
|
582
|
+
const unsub = store.subscribe(cb);
|
|
583
|
+
unsub();
|
|
584
|
+
unsub(); // should not throw
|
|
585
|
+
store.emitChange();
|
|
586
|
+
expect(cb).not.toHaveBeenCalled();
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
// ── Edge cases ───────────────────────────────────────────────────
|
|
590
|
+
describe('edge cases', () => {
|
|
591
|
+
it('setFrameworkContext overwrites existing keys', () => {
|
|
592
|
+
const store = createStore();
|
|
593
|
+
store.setFrameworkContext('key', 'value1');
|
|
594
|
+
store.setFrameworkContext('key', 'value2');
|
|
595
|
+
expect(store.session.frameworkContext['key']).toBe('value2');
|
|
596
|
+
});
|
|
597
|
+
it('setFrameworkConfig with null integration and config', () => {
|
|
598
|
+
const store = createStore();
|
|
599
|
+
store.setFrameworkConfig(null, null);
|
|
600
|
+
expect(store.session.integration).toBeNull();
|
|
601
|
+
expect(store.session.frameworkConfig).toBeNull();
|
|
602
|
+
});
|
|
603
|
+
it('pushStatus with empty string', () => {
|
|
604
|
+
const store = createStore();
|
|
605
|
+
store.pushStatus('');
|
|
606
|
+
expect(store.statusMessages).toEqual(['']);
|
|
607
|
+
});
|
|
608
|
+
it('syncTodos with empty array clears non-completed tasks', () => {
|
|
609
|
+
const store = createStore();
|
|
610
|
+
store.setTasks([
|
|
611
|
+
{ label: 'Pending', status: TaskStatus.Pending, done: false },
|
|
612
|
+
{ label: 'Done', status: TaskStatus.Completed, done: true },
|
|
613
|
+
]);
|
|
614
|
+
store.syncTodos([]);
|
|
615
|
+
// Only the completed task is retained
|
|
616
|
+
expect(store.tasks).toEqual([
|
|
617
|
+
{ label: 'Done', status: TaskStatus.Completed, done: true },
|
|
618
|
+
]);
|
|
619
|
+
});
|
|
620
|
+
it('syncTodos with unknown status defaults to Pending', () => {
|
|
621
|
+
const store = createStore();
|
|
622
|
+
store.syncTodos([{ content: 'Task', status: '' }]);
|
|
623
|
+
expect(store.tasks[0].status).toBe(TaskStatus.Pending);
|
|
624
|
+
});
|
|
625
|
+
it('updateTask with negative index is a no-op', () => {
|
|
626
|
+
const store = createStore();
|
|
627
|
+
store.setTasks([
|
|
628
|
+
{ label: 'Task', status: TaskStatus.Pending, done: false },
|
|
629
|
+
]);
|
|
630
|
+
const cb = jest.fn();
|
|
631
|
+
store.subscribe(cb);
|
|
632
|
+
store.updateTask(-1, true);
|
|
633
|
+
expect(cb).not.toHaveBeenCalled();
|
|
634
|
+
});
|
|
635
|
+
it('popOverlay on empty stack does not crash', () => {
|
|
636
|
+
const store = createStore();
|
|
637
|
+
expect(() => store.popOverlay()).not.toThrow();
|
|
638
|
+
expect(store.currentScreen).toBe(Screen.Intro);
|
|
639
|
+
});
|
|
640
|
+
it('screen advances to outro on RunPhase.Error too', () => {
|
|
641
|
+
const store = createStore();
|
|
642
|
+
store.completeSetup();
|
|
643
|
+
store.setCredentials({
|
|
644
|
+
accessToken: 'tok',
|
|
645
|
+
projectApiKey: 'pk',
|
|
646
|
+
host: 'h',
|
|
647
|
+
projectId: 1,
|
|
648
|
+
});
|
|
649
|
+
store.setRunPhase(RunPhase.Error);
|
|
650
|
+
// Run is "complete" (either Completed or Error), so we advance past it
|
|
651
|
+
expect(store.currentScreen).toBe(Screen.Mcp);
|
|
652
|
+
});
|
|
653
|
+
it('completeSetup can only resolve the promise once', async () => {
|
|
654
|
+
const store = createStore();
|
|
655
|
+
store.completeSetup();
|
|
656
|
+
store.completeSetup(); // second call — promise already resolved
|
|
657
|
+
await store.setupComplete;
|
|
658
|
+
expect(store.session.setupConfirmed).toBe(true);
|
|
659
|
+
});
|
|
660
|
+
it('version property (string) is independent from internal _version counter', () => {
|
|
661
|
+
const store = createStore();
|
|
662
|
+
store.version = '1.2.3';
|
|
663
|
+
expect(store.version).toBe('1.2.3');
|
|
664
|
+
expect(store.getVersion()).toBe(0);
|
|
665
|
+
store.emitChange();
|
|
666
|
+
expect(store.version).toBe('1.2.3');
|
|
667
|
+
expect(store.getVersion()).toBe(1);
|
|
668
|
+
});
|
|
669
|
+
});
|
|
670
|
+
// ── Full wizard flow simulation ──────────────────────────────────
|
|
671
|
+
describe('full wizard flow', () => {
|
|
672
|
+
it('walks through the entire wizard flow correctly', () => {
|
|
673
|
+
const store = createStore();
|
|
674
|
+
const screenHistory = [];
|
|
675
|
+
store.subscribe(() => screenHistory.push(store.currentScreen));
|
|
676
|
+
expect(store.currentScreen).toBe(Screen.Intro);
|
|
677
|
+
// Step 1: Confirm setup
|
|
678
|
+
store.completeSetup();
|
|
679
|
+
expect(store.currentScreen).toBe(Screen.Auth);
|
|
680
|
+
// Step 2: Authenticate
|
|
681
|
+
store.setCredentials({
|
|
682
|
+
accessToken: 'tok',
|
|
683
|
+
projectApiKey: 'pk',
|
|
684
|
+
host: 'https://app.posthog.com',
|
|
685
|
+
projectId: 1,
|
|
686
|
+
});
|
|
687
|
+
expect(store.currentScreen).toBe(Screen.Run);
|
|
688
|
+
// Step 3: Start and complete run
|
|
689
|
+
store.setRunPhase(RunPhase.Running);
|
|
690
|
+
expect(store.currentScreen).toBe(Screen.Run);
|
|
691
|
+
store.setRunPhase(RunPhase.Completed);
|
|
692
|
+
expect(store.currentScreen).toBe(Screen.Mcp);
|
|
693
|
+
// Step 4: Complete MCP
|
|
694
|
+
store.setMcpComplete();
|
|
695
|
+
expect(store.currentScreen).toBe(Screen.Outro);
|
|
696
|
+
// Verify version was bumped for each setter call
|
|
697
|
+
expect(store.getVersion()).toBe(5);
|
|
698
|
+
});
|
|
699
|
+
});
|
|
700
|
+
// ── setupComplete promise ────────────────────────────────────────
|
|
701
|
+
describe('setupComplete', () => {
|
|
702
|
+
it('resolves when completeSetup is called', async () => {
|
|
703
|
+
const store = createStore();
|
|
704
|
+
store.completeSetup();
|
|
705
|
+
await store.setupComplete;
|
|
706
|
+
expect(store.session.setupConfirmed).toBe(true);
|
|
707
|
+
});
|
|
708
|
+
it('is a promise that can be awaited before completeSetup is called', async () => {
|
|
709
|
+
const store = createStore();
|
|
710
|
+
let resolved = false;
|
|
711
|
+
void store.setupComplete.then(() => {
|
|
712
|
+
resolved = true;
|
|
713
|
+
});
|
|
714
|
+
// Not yet resolved
|
|
715
|
+
await Promise.resolve(); // flush microtasks
|
|
716
|
+
expect(resolved).toBe(false);
|
|
717
|
+
store.completeSetup();
|
|
718
|
+
await store.setupComplete;
|
|
719
|
+
expect(resolved).toBe(true);
|
|
720
|
+
});
|
|
721
|
+
});
|
|
722
|
+
});
|
|
723
|
+
//# sourceMappingURL=store.test.js.map
|