@@ -11,7 +11,7 @@ import {
1111import type { CreateInputs } from "../../src/docker-git/menu-types.js"
1212import type { submitCreateInputs } from "../../src/web/actions-projects.js"
1313import type { GithubAuthStatus } from "../../src/web/api.js"
14- import { submitCreateView } from "../../src/web/app-ready-create.js"
14+ import { handleCreateKey , submitCreateView } from "../../src/web/app-ready-create.js"
1515import { makeBrowserActionContext } from "./browser-action-context-fixture.js"
1616
1717const submitCreateInputsMock = vi . hoisted ( ( ) => vi . fn < typeof submitCreateInputs > ( ) )
@@ -117,6 +117,55 @@ const expectCreateViewReset = (setCreateViewSpy: ReturnType<typeof submitCreateB
117117const expectedOutDirForRepoUrl = ( repoUrl : string ) : string =>
118118 `/home/dev/.docker-git/${ deriveRepoPathParts ( resolveRepoInput ( repoUrl ) . repoUrl ) . pathParts . join ( "/" ) } `
119119
120+ const createKeyEvent = (
121+ key : string ,
122+ shiftKey = false
123+ ) : Parameters < typeof handleCreateKey > [ 0 ] => {
124+ const event = {
125+ key,
126+ shiftKey,
127+ preventDefault : vi . fn ( )
128+ }
129+ return event
130+ }
131+
132+ const createSettingsFlowView = ( ) : CreateFlowView => ( {
133+ step : 1 ,
134+ buffer : "30%" ,
135+ values : {
136+ outDir : "/home/dev/.docker-git/org/repo" ,
137+ repoRef : "feature-x" ,
138+ repoUrl : "https://github.com/org/repo/tree/feature-x"
139+ }
140+ } )
141+
142+ const expectCreateArrowHandling = (
143+ key : "ArrowDown" | "ArrowUp" ,
144+ expectedStep : ( view : CreateFlowView ) => number
145+ ) => {
146+ const { context } = makeBrowserActionContext ( { githubStatus : validGithubStatus } )
147+ const { setCreateView, spy : setCreateViewSpy } = createSetCreateViewSpy ( )
148+ const event = createKeyEvent ( key )
149+ const createView = createSettingsFlowView ( )
150+
151+ const handled = handleCreateKey ( event , {
152+ context,
153+ controllerCwd : "/workspace" ,
154+ createView,
155+ projectsRoot : "/home/dev/.docker-git" ,
156+ setCreateView
157+ } )
158+
159+ expect ( handled ) . toBe ( true )
160+ expect ( event . preventDefault ) . toHaveBeenCalledTimes ( 1 )
161+ expect ( requireCreateViewValue ( setCreateViewSpy . mock . calls [ 0 ] ?. [ 0 ] ) ) . toEqual ( {
162+ ...createView ,
163+ step : expectedStep ( createView ) ,
164+ buffer : ""
165+ } )
166+ expect ( context . setMessage ) . toHaveBeenCalledWith ( null )
167+ }
168+
120169describe ( "app-ready-create" , ( ) => {
121170 beforeEach ( ( ) => {
122171 submitCreateInputsMock . mockReset ( )
@@ -147,6 +196,50 @@ describe("app-ready-create", () => {
147196 expect ( context . setMessage ) . toHaveBeenCalledWith ( null )
148197 } )
149198
199+ it ( "enters the settings wizard when explicitly requested from the repo URL step" , ( ) => {
200+ const { setCreateViewSpy } = submitCreateBuffer (
201+ "https://github.com/org/repo/tree/feature-x" ,
202+ { quickCreate : false }
203+ )
204+
205+ expect ( submitCreateInputsMock ) . not . toHaveBeenCalled ( )
206+ expect ( requireCreateViewValue ( setCreateViewSpy . mock . calls [ 0 ] ?. [ 0 ] ) ) . toMatchObject ( {
207+ step : 1 ,
208+ values : {
209+ outDir : "/home/dev/.docker-git/org/repo" ,
210+ repoRef : "feature-x" ,
211+ repoUrl : "https://github.com/org/repo/tree/feature-x"
212+ }
213+ } )
214+ } )
215+
216+ it ( "moves between settings with arrows and clears the uncommitted buffer" , ( ) => {
217+ expectCreateArrowHandling ( "ArrowDown" , ( view ) => view . step + 1 )
218+ } )
219+
220+ it ( "wraps settings selection upward with ArrowUp and clears the uncommitted buffer" , ( ) => {
221+ expectCreateArrowHandling ( "ArrowUp" , ( view ) => resolveCreateFlowSteps ( view . values ) . length - 1 )
222+ } )
223+
224+ it ( "ignores settings arrows before the Settings flow starts" , ( ) => {
225+ const { context } = makeBrowserActionContext ( { githubStatus : validGithubStatus } )
226+ const { setCreateView, spy : setCreateViewSpy } = createSetCreateViewSpy ( )
227+ const event = createKeyEvent ( "ArrowDown" )
228+
229+ const handled = handleCreateKey ( event , {
230+ context,
231+ controllerCwd : "/workspace" ,
232+ createView : createInitialFlowView ( "https://github.com/org/repo" ) ,
233+ projectsRoot : "/home/dev/.docker-git" ,
234+ setCreateView
235+ } )
236+
237+ expect ( handled ) . toBe ( false )
238+ expect ( event . preventDefault ) . not . toHaveBeenCalled ( )
239+ expect ( setCreateViewSpy ) . not . toHaveBeenCalled ( )
240+ expect ( context . setMessage ) . not . toHaveBeenCalled ( )
241+ } )
242+
150243 it ( "shows a parse error instead of submitting on invalid inline flags" , ( ) => {
151244 const { context, setCreateViewSpy } = submitCreateBuffer ( "https://github.com/org/repo --bogus" )
152245
0 commit comments