@@ -2,6 +2,17 @@ import { launchStudio, loadProjectAndRunSpec, assertClosingPanelWithoutChanges }
2
2
3
3
const urlPrompt = '// Visit a page by entering a url in the address bar or typing a cy.visit command here'
4
4
5
+ const inputNewTestName = ( name : string = 'new-test' ) => {
6
+ cy . findByTestId ( 'new-test-button' ) . click ( )
7
+ cy . findByTestId ( 'test-name-input' ) . type ( name )
8
+ cy . findByTestId ( 'create-test-button' ) . click ( )
9
+
10
+ // verify recording is enabled to ensure the panel is fully ready
11
+ cy . findByTestId ( 'record-button-recording' ) . should ( 'have.text' , 'Recording...' )
12
+
13
+ cy . get ( '.studio-single-test-container' ) . should ( 'be.visible' )
14
+ }
15
+
5
16
describe ( 'Cypress Studio' , ( ) => {
6
17
function incrementCounter ( initialCount : number ) {
7
18
cy . getAutIframe ( ) . within ( ( ) => {
@@ -165,7 +176,7 @@ describe('studio functionality', () => {
165
176
} )
166
177
167
178
it ( 'does not enter single test mode when creating a new test' , ( ) => {
168
- launchStudio ( { specName : 'spec-w-multiple-tests.cy.js' , createNewTest : true } )
179
+ launchStudio ( { specName : 'spec-w-multiple-tests.cy.js' , createNewTestFromSuite : true } )
169
180
170
181
// verify we are not in single test mode
171
182
cy . get ( '.runnable-title' ) . should ( 'have.length' , 4 )
@@ -175,26 +186,22 @@ describe('studio functionality', () => {
175
186
cy . get ( '.runnable-title' ) . its ( 3 ) . should ( 'contain.text' , 'visits a basic html page 3' )
176
187
} )
177
188
178
- it ( 'creates a new test from an empty spec with url already defined ' , ( ) => {
179
- launchStudio ( { specName : 'spec-w-visit.cy.js' , createNewTest : true } )
189
+ it ( 'creates a new test from spec header ' , ( ) => {
190
+ launchStudio ( { specName : 'spec-w-visit.cy.js' , createNewTestFromSpecHeader : true } )
180
191
181
- cy . findByTestId ( 'new-test-button' ) . click ( )
182
- cy . findByTestId ( 'test-name-input' ) . type ( 'new-test' )
183
- cy . findByTestId ( 'create-test-button' ) . click ( )
192
+ inputNewTestName ( )
184
193
185
194
cy . contains ( 'new-test' ) . click ( )
186
195
187
- // verify recording is enabled to ensure the panel is fully ready
188
- cy . findByTestId ( 'record-button-recording' ) . should ( 'have.text' , 'Recording...' )
189
-
190
- cy . get ( '.studio-single-test-container' ) . should ( 'be.visible' )
191
-
192
196
cy . percySnapshot ( )
193
197
194
- incrementCounter ( 0 )
198
+ cy . get ( '.cm-content' ) . invoke ( 'text' , 'cy.visit("cypress/e2e/index.html")' )
195
199
196
200
cy . findByTestId ( 'studio-save-button' ) . click ( )
197
201
202
+ // verify recording is enabled to ensure the panel is fully ready
203
+ cy . findByTestId ( 'record-button-recording' ) . should ( 'have.text' , 'Recording...' )
204
+
198
205
// we should have the commands we executed after we save
199
206
cy . withCtx ( async ( ctx ) => {
200
207
const spec = await ctx . actions . file . readFileInProject ( 'cypress/e2e/spec-w-visit.cy.js' )
@@ -208,19 +215,18 @@ describe('studio functionality', () => {
208
215
it('visits a basic html page', () => {
209
216
cy.get('h1').should('have.text', 'Hello, Studio!')
210
217
})
218
+ })
211
219
212
- it('new-test', function() {
213
-
214
- cy.get('#increment').click();
215
- });
216
- })` . trim ( ) )
220
+ it('new-test', function() {
221
+ cy.visit("cypress/e2e/index.html")
222
+ });` . trim ( ) )
217
223
} )
218
224
} )
219
225
220
226
// TODO: this test fails in CI but passes locally
221
227
// http://github.com/cypress-io/cypress/issues/31248
222
228
it . skip ( 'creates a new test with a url that changes top' , function ( ) {
223
- launchStudio ( { specName : 'spec-w-foobar.cy.js' , createNewTest : true } )
229
+ launchStudio ( { specName : 'spec-w-foobar.cy.js' , createNewTestFromSuite : true } )
224
230
225
231
cy . origin ( 'http://foobar.com:4455' , ( ) => {
226
232
Cypress . require ( '../support/execute-spec' )
@@ -294,21 +300,12 @@ describe('studio functionality', () => {
294
300
} )
295
301
296
302
it ( 'creates a new test for a specific suite with the url already defined' , ( ) => {
297
- launchStudio ( { specName : 'spec-w-visit.cy.js' , createNewTest : true } )
303
+ launchStudio ( { specName : 'spec-w-visit.cy.js' , createNewTestFromSuite : true } )
298
304
299
305
// create a new test from a specific suite
300
- cy . findByTestId ( 'create-new-test-button' ) . click ( )
301
-
302
- cy . findByTestId ( 'new-test-button' ) . click ( )
303
- cy . findByTestId ( 'test-name-input' ) . type ( 'new-test' )
304
- cy . findByTestId ( 'create-test-button' ) . click ( )
306
+ cy . findByTestId ( 'create-new-test-from-suite' ) . click ( )
305
307
306
- cy . contains ( 'new-test' ) . click ( )
307
-
308
- // verify recording is enabled to ensure the panel is fully ready
309
- cy . findByTestId ( 'record-button-recording' ) . should ( 'have.text' , 'Recording...' )
310
-
311
- cy . get ( '.studio-single-test-container' ) . should ( 'be.visible' )
308
+ inputNewTestName ( )
312
309
313
310
cy . percySnapshot ( )
314
311
@@ -618,11 +615,9 @@ describe('studio functionality', () => {
618
615
} )
619
616
620
617
it ( 'updates the AUT url when creating a new test' , ( ) => {
621
- launchStudio ( { specName : 'navigation.cy.js' , createNewTest : true } )
618
+ launchStudio ( { specName : 'navigation.cy.js' , createNewTestFromSuite : true } )
622
619
623
- cy . findByTestId ( 'new-test-button' ) . click ( )
624
- cy . findByTestId ( 'test-name-input' ) . type ( 'new-test' )
625
- cy . findByTestId ( 'create-test-button' ) . click ( )
620
+ inputNewTestName ( )
626
621
627
622
cy . findByTestId ( 'aut-url-input' ) . should ( 'have.focus' ) . type ( 'cypress/e2e/navigation.html{enter}' )
628
623
@@ -650,7 +645,7 @@ describe('studio functionality', () => {
650
645
} )
651
646
652
647
it ( 'update the url with the suiteId and studio parameters when entering studio with a suite' , ( ) => {
653
- launchStudio ( { createNewTest : true } )
648
+ launchStudio ( { createNewTestFromSuite : true } )
654
649
655
650
cy . location ( ) . its ( 'hash' ) . should ( 'contain' , 'suiteId=r2' ) . and ( 'contain' , 'studio=' )
656
651
} )
@@ -663,9 +658,7 @@ describe('studio functionality', () => {
663
658
cy . location ( ) . its ( 'hash' ) . should ( 'contain' , 'suiteId=r1' ) . and ( 'contain' , 'studio=' )
664
659
665
660
// create a new test in the root suite
666
- cy . findByTestId ( 'new-test-button' ) . click ( )
667
- cy . findByTestId ( 'test-name-input' ) . type ( 'new-test' )
668
- cy . findByTestId ( 'create-test-button' ) . click ( )
661
+ inputNewTestName ( )
669
662
670
663
// the studio url parameters should be removed
671
664
cy . location ( ) . its ( 'hash' ) . and ( 'not.contain' , 'suiteId=' ) . and ( 'contain' , 'studio=' ) . and ( 'contain' , 'testId=r2' )
@@ -745,7 +738,7 @@ describe('studio functionality', () => {
745
738
} )
746
739
747
740
it ( 'removes the studio url parameters when closing studio new test' , ( ) => {
748
- launchStudio ( { specName : 'spec-w-visit.cy.js' , createNewTest : true } )
741
+ launchStudio ( { specName : 'spec-w-visit.cy.js' , createNewTestFromSuite : true } )
749
742
750
743
cy . location ( ) . its ( 'hash' ) . should ( 'contain' , 'suiteId=r2' ) . and ( 'contain' , 'studio=' )
751
744
0 commit comments