@@ -2,13 +2,13 @@ import defaultMessages from '@packages/frontend-shared/src/locales/en-US.json'
22import type { SinonStub } from 'sinon'
33
44describe ( 'App: Runs' , { viewportWidth : 1200 } , ( ) => {
5- beforeEach ( ( ) => {
6- cy . scaffoldProject ( 'component-tests' )
7- cy . openProject ( 'component-tests' )
8- cy . startAppServer ( 'component' )
9- } )
10-
115 context ( 'Runs Page' , ( ) => {
6+ beforeEach ( ( ) => {
7+ cy . scaffoldProject ( 'component-tests' )
8+ cy . openProject ( 'component-tests' )
9+ cy . startAppServer ( 'component' )
10+ } )
11+
1212 it ( 'resolves the runs page' , ( ) => {
1313 cy . loginUser ( )
1414 cy . visitApp ( )
@@ -33,6 +33,12 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
3333 } )
3434
3535 context ( 'Runs - Login' , ( ) => {
36+ beforeEach ( ( ) => {
37+ cy . scaffoldProject ( 'component-tests' )
38+ cy . openProject ( 'component-tests' )
39+ cy . startAppServer ( 'component' )
40+ } )
41+
3642 it ( 'when logged out, shows call to action' , ( ) => {
3743 cy . visitApp ( )
3844 cy . get ( '[href="#/runs"]' ) . click ( )
@@ -131,9 +137,9 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
131137
132138 context ( 'Runs - Connect Project' , ( ) => {
133139 it ( 'opens Connect Project modal after clicking Connect Project button' , ( ) => {
134- cy . withCtx ( async ( ctx ) => {
135- await ctx . actions . file . writeFileInProject ( 'cypress. config.js ', 'module.exports = {}' )
136- } )
140+ cy . scaffoldProject ( 'component-tests' )
141+ cy . openProject ( 'component-tests' , [ '-- config-file ', 'cypressWithoutProjectId.config.js' ] )
142+ cy . startAppServer ( 'component' )
137143
138144 cy . loginUser ( )
139145 cy . visitApp ( )
@@ -167,9 +173,9 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
167173
168174 context ( 'Runs - Cannot Find Project' , ( ) => {
169175 beforeEach ( ( ) => {
170- cy . withCtx ( async ( ctx ) => {
171- await ctx . actions . file . writeFileInProject ( 'cypress.config.js ', 'module.exports = {\'projectId\': \'abcdef42\'}' )
172- } )
176+ cy . scaffoldProject ( 'component-tests' )
177+ cy . openProject ( 'component-tests ', [ '--config-file' , 'cypressWithInvalidProjectId.config.js' ] )
178+ cy . startAppServer ( 'component' )
173179
174180 cy . loginUser ( )
175181 cy . remoteGraphQLIntercept ( async ( obj ) => {
@@ -217,9 +223,9 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
217223
218224 context ( 'Runs - Unauthorized Project' , ( ) => {
219225 beforeEach ( ( ) => {
220- cy . withCtx ( async ( ctx ) => {
221- await ctx . actions . file . writeFileInProject ( 'cypress.config.js' , 'module.exports = {\'projectId\': \'abcdef\'} ')
222- } )
226+ cy . scaffoldProject ( 'component-tests' )
227+ cy . openProject ( 'component-tests ')
228+ cy . startAppServer ( 'component' )
223229
224230 cy . loginUser ( )
225231 } )
@@ -278,9 +284,9 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
278284
279285 context ( 'Runs - Unauthorized Project Requested' , ( ) => {
280286 beforeEach ( ( ) => {
281- cy . withCtx ( async ( ctx ) => {
282- await ctx . actions . file . writeFileInProject ( 'cypress.config.js' , 'module.exports = {\'projectId\': \'abcdef\' } ')
283- } )
287+ cy . scaffoldProject ( 'component-tests' )
288+ cy . openProject ( 'component-tests ')
289+ cy . startAppServer ( 'component' )
284290
285291 cy . loginUser ( )
286292 cy . remoteGraphQLIntercept ( async ( obj ) => {
@@ -310,9 +316,9 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
310316
311317 context ( 'Runs - No Runs' , ( ) => {
312318 it ( 'when no runs and not connected, shows connect to dashboard button' , ( ) => {
313- cy . withCtx ( async ( ctx ) => {
314- await ctx . actions . file . writeFileInProject ( 'cypress. config.js ', 'module.exports = {projectId: null }' )
315- } )
319+ cy . scaffoldProject ( 'component-tests' )
320+ cy . openProject ( 'component-tests' , [ '-- config-file ', 'cypressWithoutProjectId.config.js' ] )
321+ cy . startAppServer ( 'component' )
316322
317323 cy . loginUser ( )
318324 cy . remoteGraphQLIntercept ( async ( obj ) => {
@@ -335,9 +341,9 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
335341 } )
336342
337343 it ( 'displays how to record prompt when connected and no runs' , ( ) => {
338- cy . withCtx ( async ( ctx ) => {
339- await ctx . actions . file . writeFileInProject ( 'cypress.config.js' , 'module.exports = {projectId: \'abcdef\'} ')
340- } )
344+ cy . scaffoldProject ( 'component-tests' )
345+ cy . openProject ( 'component-tests ')
346+ cy . startAppServer ( 'component' )
341347
342348 cy . loginUser ( )
343349 cy . remoteGraphQLIntercept ( async ( obj ) => {
@@ -360,8 +366,11 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
360366 } )
361367
362368 it ( 'displays a copy button' , ( ) => {
369+ cy . scaffoldProject ( 'component-tests' )
370+ cy . openProject ( 'component-tests' )
371+ cy . startAppServer ( 'component' )
372+
363373 cy . withCtx ( async ( ctx , o ) => {
364- await ctx . actions . file . writeFileInProject ( 'cypress.config.js' , 'module.exports = {projectId: \'abcdef\'}' )
365374 o . sinon . stub ( ctx . electronApi , 'copyTextToClipboard' )
366375 } )
367376
@@ -389,6 +398,12 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
389398 } )
390399
391400 context ( 'Runs - Runs List' , ( ) => {
401+ beforeEach ( ( ) => {
402+ cy . scaffoldProject ( 'component-tests' )
403+ cy . openProject ( 'component-tests' )
404+ cy . startAppServer ( 'component' )
405+ } )
406+
392407 it ( 'displays a list of recorded runs if a run has been recorded' , ( ) => {
393408 cy . loginUser ( )
394409 cy . visitApp ( )
@@ -446,6 +461,12 @@ describe('App: Runs', { viewportWidth: 1200 }, () => {
446461 } )
447462
448463 describe ( 'no internet connection' , ( ) => {
464+ beforeEach ( ( ) => {
465+ cy . scaffoldProject ( 'component-tests' )
466+ cy . openProject ( 'component-tests' )
467+ cy . startAppServer ( 'component' )
468+ } )
469+
449470 afterEach ( ( ) => {
450471 cy . goOnline ( )
451472 } )
0 commit comments