@@ -12,6 +12,7 @@ import {
1212 askCreateInitialBrowserCheck ,
1313 askInstallDependencies ,
1414 askInitializeGit ,
15+ askPlaywrightConfigPath ,
1516} from '../prompts'
1617import * as directoryUtils from '../../utils/directory'
1718
@@ -69,4 +70,49 @@ describe('prompts', () => {
6970 }
7071 expect ( onCancel ) . toBeCalledTimes ( availableTemplates . length )
7172 } )
73+
74+ it ( 'should ask to select a playwright config path' , async ( ) => {
75+ const projectDir = path . resolve ( __dirname , './fixtures/playwright-multi' )
76+ const candidates = [
77+ path . join ( projectDir , 'playwright.config.ts' ) ,
78+ path . join ( projectDir , 'staging/playwright.config.ts' ) ,
79+ ]
80+
81+ // Select first candidate
82+ prompts . inject ( [ candidates [ 0 ] ] )
83+ const { playwrightConfigPath } = await askPlaywrightConfigPath ( candidates , projectDir , onCancel )
84+ expect ( playwrightConfigPath ) . toBe ( candidates [ 0 ] )
85+ } )
86+
87+ it ( 'should ask to select custom when choosing custom option' , async ( ) => {
88+ const projectDir = path . resolve ( __dirname , './fixtures/playwright-multi' )
89+ const candidates = [
90+ path . join ( projectDir , 'playwright.config.ts' ) ,
91+ ]
92+
93+ // Select custom (index 1 = last item), then provide a valid path
94+ prompts . inject ( [ '__custom__' , 'playwright.config.ts' ] )
95+ const { playwrightConfigPath } = await askPlaywrightConfigPath ( candidates , projectDir , onCancel )
96+ expect ( playwrightConfigPath ) . toBe ( path . resolve ( projectDir , 'playwright.config.ts' ) )
97+ } )
98+
99+ it ( 'should skip playwright config when user selects Skip' , async ( ) => {
100+ const projectDir = path . resolve ( __dirname , './fixtures/playwright-multi' )
101+ const candidates = [
102+ path . join ( projectDir , 'playwright.config.ts' ) ,
103+ path . join ( projectDir , 'staging/playwright.config.ts' ) ,
104+ ]
105+
106+ prompts . inject ( [ '__skip__' ] )
107+ const { playwrightConfigPath } = await askPlaywrightConfigPath ( candidates , projectDir , onCancel )
108+ expect ( playwrightConfigPath ) . toBeUndefined ( )
109+ } )
110+
111+ it ( 'should fall back to custom input when no candidates' , async ( ) => {
112+ const projectDir = path . resolve ( __dirname , './fixtures/playwright-multi' )
113+
114+ prompts . inject ( [ 'staging/playwright.config.ts' ] )
115+ const { playwrightConfigPath } = await askPlaywrightConfigPath ( [ ] , projectDir , onCancel )
116+ expect ( playwrightConfigPath ) . toBe ( path . resolve ( projectDir , 'staging/playwright.config.ts' ) )
117+ } )
72118} )
0 commit comments