1- function verifyFiles ( relativePaths : string [ ] ) {
2- cy . withCtx ( async ( ctx , o ) => {
3- for ( const relativePath of o . relativePaths ) {
4- const stats = await ctx . file . checkIfFileExists ( relativePath )
1+ function verifyScaffoldedFiles ( testingType : string ) {
2+ const expectedFileOrder = ( testingType === 'e2e' ) ? [
3+ 'cypress.config.' ,
4+ 'support/e2e.' ,
5+ 'support/commands.' ,
6+ 'fixtures/example.' ,
7+ ] : [
8+ 'cypress.config.' ,
9+ 'support/component.' ,
10+ 'support/commands.' ,
11+ 'support/component-index.' ,
12+ 'fixtures/example.' ,
13+ ]
14+
15+ cy . get ( '[data-cy="collapsible-header"] h2' )
16+ . should ( ( $elements ) => expect ( $elements ) . to . have . length ( expectedFileOrder . length ) ) // assert number of files
17+ . each ( ( $el , i ) => {
18+ const relativePath = $el . text ( )
19+
20+ expect ( relativePath , `file index ${ i } ` ) . to . include ( expectedFileOrder [ i ] ) // assert file order
21+
22+ cy . withCtx ( async ( ctx , o ) => { // assert file exists
23+ const stats = await ctx . file . checkIfFileExists ( o . relativePath )
524
625 expect ( stats ) . to . not . be . null . and . not . be . undefined
7- }
8- } , { relativePaths } )
26+ } , { relativePath } )
27+ } )
928}
1029
1130describe ( 'Launchpad: Setup Project' , ( ) => {
@@ -200,7 +219,7 @@ describe('Launchpad: Setup Project', () => {
200219 cy . findByRole ( 'button' , { name : 'Next Step' } ) . click ( )
201220
202221 cy . contains ( 'h1' , 'Configuration Files' )
203- cy . findByText ( 'We added the following files to your project. ' )
222+ cy . findByText ( 'We added the following files to your project: ' )
204223
205224 cy . get ( '[data-cy=changes]' ) . within ( ( ) => {
206225 cy . contains ( 'cypress.config.js' )
@@ -212,12 +231,7 @@ describe('Launchpad: Setup Project', () => {
212231 cy . containsPath ( 'cypress/fixtures/example.json' )
213232 } )
214233
215- verifyFiles ( [
216- 'cypress.config.js' ,
217- 'cypress/support/e2e.js' ,
218- 'cypress/support/commands.js' ,
219- 'cypress/fixtures/example.json' ,
220- ] )
234+ verifyScaffoldedFiles ( 'e2e' )
221235 } )
222236
223237 it ( 'moves to "Choose a Browser" page after clicking "Continue" button in first step in configuration page' , ( ) => {
@@ -230,7 +244,7 @@ describe('Launchpad: Setup Project', () => {
230244 cy . findByRole ( 'button' , { name : 'Next Step' } ) . click ( )
231245
232246 cy . contains ( 'h1' , 'Configuration Files' )
233- cy . findByText ( 'We added the following files to your project. ' )
247+ cy . findByText ( 'We added the following files to your project: ' )
234248
235249 cy . get ( '[data-cy=valid]' ) . within ( ( ) => {
236250 cy . contains ( 'cypress.config.js' )
@@ -239,12 +253,7 @@ describe('Launchpad: Setup Project', () => {
239253 cy . containsPath ( 'cypress/fixtures/example.json' )
240254 } )
241255
242- verifyFiles ( [
243- 'cypress.config.js' ,
244- 'cypress/support/e2e.js' ,
245- 'cypress/support/commands.js' ,
246- 'cypress/fixtures/example.json' ,
247- ] )
256+ verifyScaffoldedFiles ( 'e2e' )
248257 } )
249258
250259 it ( 'shows the configuration setup page when opened via cli with --component flag' , ( ) => {
@@ -293,7 +302,7 @@ describe('Launchpad: Setup Project', () => {
293302 cy . findByRole ( 'button' , { name : 'Next Step' } ) . click ( )
294303
295304 cy . contains ( 'h1' , 'Configuration Files' )
296- cy . findByText ( 'We added the following files to your project. ' )
305+ cy . findByText ( 'We added the following files to your project: ' )
297306
298307 cy . get ( '[data-cy=valid]' ) . within ( ( ) => {
299308 cy . contains ( 'cypress.config.js' )
@@ -302,12 +311,7 @@ describe('Launchpad: Setup Project', () => {
302311 cy . containsPath ( 'cypress/fixtures/example.json' )
303312 } )
304313
305- verifyFiles ( [
306- 'cypress.config.js' ,
307- 'cypress/support/e2e.js' ,
308- 'cypress/support/commands.js' ,
309- 'cypress/fixtures/example.json' ,
310- ] )
314+ verifyScaffoldedFiles ( 'e2e' )
311315
312316 cy . findByRole ( 'button' , { name : 'Continue' } )
313317 . should ( 'not.have.disabled' )
@@ -334,7 +338,7 @@ describe('Launchpad: Setup Project', () => {
334338 cy . findByRole ( 'button' , { name : 'Next Step' } ) . click ( )
335339
336340 cy . contains ( 'h1' , 'Configuration Files' )
337- cy . findByText ( 'We added the following files to your project. ' )
341+ cy . findByText ( 'We added the following files to your project: ' )
338342
339343 cy . get ( '[data-cy=valid]' ) . within ( ( ) => {
340344 cy . contains ( 'cypress.config.ts' )
@@ -343,12 +347,7 @@ describe('Launchpad: Setup Project', () => {
343347 cy . containsPath ( 'cypress/fixtures/example.json' )
344348 } )
345349
346- verifyFiles ( [
347- 'cypress.config.ts' ,
348- 'cypress/support/e2e.ts' ,
349- 'cypress/support/commands.ts' ,
350- 'cypress/fixtures/example.json' ,
351- ] )
350+ verifyScaffoldedFiles ( 'e2e' )
352351 } )
353352
354353 it ( 'can setup e2e testing for a project selecting TS when CT is configured and config file is JS' , ( ) => {
@@ -368,7 +367,7 @@ describe('Launchpad: Setup Project', () => {
368367 cy . findByRole ( 'button' , { name : 'Next Step' } ) . click ( )
369368
370369 cy . contains ( 'h1' , 'Configuration Files' )
371- cy . findByText ( 'We added the following files to your project. ' )
370+ cy . findByText ( 'We added the following files to your project: ' )
372371
373372 cy . get ( '[data-cy=changes]' ) . within ( ( ) => {
374373 cy . contains ( 'cypress.config.js' )
@@ -380,12 +379,7 @@ describe('Launchpad: Setup Project', () => {
380379 cy . containsPath ( 'cypress/fixtures/example.json' )
381380 } )
382381
383- verifyFiles ( [
384- 'cypress.config.js' ,
385- 'cypress/support/e2e.ts' ,
386- 'cypress/support/commands.ts' ,
387- 'cypress/fixtures/example.json' ,
388- ] )
382+ verifyScaffoldedFiles ( 'e2e' )
389383 } )
390384
391385 it ( 'can setup CT testing for a project selecting TS when E2E is configured and config file is JS' , ( ) => {
@@ -442,12 +436,7 @@ describe('Launchpad: Setup Project', () => {
442436 cy . containsPath ( 'cypress/support/commands.ts' )
443437 } )
444438
445- verifyFiles ( [
446- 'cypress.config.js' ,
447- 'cypress/support/component-index.html' ,
448- 'cypress/support/component.ts' ,
449- 'cypress/support/commands.ts' ,
450- ] )
439+ verifyScaffoldedFiles ( 'component' )
451440
452441 cy . findByRole ( 'button' , { name : 'Continue' } ) . should ( 'have.disabled' )
453442 } )
@@ -501,12 +490,7 @@ describe('Launchpad: Setup Project', () => {
501490 cy . containsPath ( 'cypress/support/commands.ts' )
502491 } )
503492
504- verifyFiles ( [
505- 'cypress.config.js' ,
506- 'cypress/support/component-index.html' ,
507- 'cypress/support/component.ts' ,
508- 'cypress/support/commands.ts' ,
509- ] )
493+ verifyScaffoldedFiles ( 'component' )
510494
511495 cy . findByRole ( 'button' , { name : 'Continue' } ) . should ( 'have.disabled' )
512496 } )
@@ -679,7 +663,7 @@ describe('Launchpad: Setup Project', () => {
679663 cy . containsPath ( 'cypress/fixtures/example.json' )
680664 } )
681665
682- verifyFiles ( [ 'cypress.config.ts' , 'cypress/support/ component-index.html' , 'cypress/support/component.ts' , 'cypress/support/commands.ts' , 'cypress/fixtures/example.json' ] )
666+ verifyScaffoldedFiles ( ' component' )
683667
684668 cy . findByRole ( 'button' , { name : 'Continue' } ) . click ( )
685669
0 commit comments