@@ -760,6 +760,27 @@ describe('studio functionality', () => {
760
760
cy . location ( ) . its ( 'hash' ) . and ( 'not.contain' , 'testId=' ) . and ( 'not.contain' , 'studio=' )
761
761
} )
762
762
763
+ it ( 'does not prompt for a URL until studio is active' , ( ) => {
764
+ launchStudio ( { specName : 'spec-w-visit.cy.js' , createNewTestFromSuite : true } )
765
+ cy . location ( ) . its ( 'hash' ) . should ( 'contain' , 'suiteId=r2' ) . and ( 'contain' , 'studio=' )
766
+ cy . waitForSpecToFinish ( )
767
+
768
+ cy . findByTestId ( 'aut-url-input' ) . should ( 'have.value' , 'http://localhost:4455/cypress/e2e/index.html' )
769
+ } )
770
+
771
+ it ( 'does not reload the page if we didnt open a test in studio' , ( ) => {
772
+ launchStudio ( { specName : 'spec-w-visit.cy.js' , createNewTestFromSuite : true } )
773
+
774
+ // set a property on the window to see if the page reloads
775
+ cy . window ( ) . then ( ( w ) => w [ 'beforeReload' ] = true )
776
+
777
+ // close new test mode
778
+ cy . findByTestId ( 'studio-header-studio-button' ) . click ( )
779
+
780
+ // if this property is still set on the window, then the page didn't reload
781
+ cy . window ( ) . then ( ( w ) => expect ( w [ 'beforeReload' ] ) . to . be . true )
782
+ } )
783
+
763
784
it ( 'removes the studio url parameters when closing studio new test' , ( ) => {
764
785
launchStudio ( { specName : 'spec-w-visit.cy.js' , createNewTestFromSuite : true } )
765
786
@@ -770,6 +791,68 @@ describe('studio functionality', () => {
770
791
cy . location ( ) . its ( 'hash' ) . and ( 'not.contain' , 'suiteId=' ) . and ( 'not.contain' , 'studio=' )
771
792
} )
772
793
794
+ it ( 'stays in new test mode when studio panel is opened when the spec is running' , ( ) => {
795
+ loadProjectAndRunSpec ( )
796
+
797
+ cy . waitForSpecToFinish ( )
798
+
799
+ cy . findByTestId ( 'studio-button' ) . click ( )
800
+ cy . findByTestId ( 'studio-panel' ) . should ( 'be.visible' )
801
+ cy . findByTestId ( 'new-test-button' ) . should ( 'be.visible' )
802
+
803
+ // Verify we're initially in new test mode
804
+ cy . location ( ) . its ( 'hash' ) . should ( 'contain' , 'suiteId=r1' ) . and ( 'not.contain' , 'testId=' )
805
+
806
+ // Now restart the spec, which will call interceptTest with the running test
807
+ // This is where the bug would manifest - it would incorrectly switch from
808
+ // "new test" mode to "edit the running test" mode
809
+ cy . get ( 'button.restart' ) . click ( )
810
+
811
+ cy . get ( '.test' ) . should ( 'have.length' , 1 )
812
+ cy . get ( '.test' ) . first ( ) . should ( 'have.class' , 'runnable-active' )
813
+
814
+ // verify we're still in new test mode
815
+ cy . findByTestId ( 'studio-panel' ) . should ( 'be.visible' )
816
+ cy . findByTestId ( 'new-test-button' ) . should ( 'be.visible' )
817
+
818
+ // these should not exist if we stayed in new test mode
819
+ cy . findByTestId ( 'studio-single-test-title' ) . should ( 'not.exist' )
820
+ cy . findByTestId ( 'record-button-recording' ) . should ( 'not.exist' )
821
+
822
+ // verify URL still shows suite mode, not edit test mode
823
+ cy . location ( ) . its ( 'hash' ) . should ( 'contain' , 'suiteId=r1' ) . and ( 'not.contain' , 'testId=' )
824
+ } )
825
+
826
+ it ( 'shows test body sections correctly when studio panel is open and page is refreshed' , ( ) => {
827
+ loadProjectAndRunSpec ( )
828
+
829
+ cy . waitForSpecToFinish ( )
830
+
831
+ cy . findByTestId ( 'studio-button' ) . click ( )
832
+ cy . findByTestId ( 'studio-panel' ) . should ( 'be.visible' )
833
+ cy . findByTestId ( 'new-test-button' ) . should ( 'be.visible' )
834
+
835
+ cy . reload ( )
836
+
837
+ cy . waitForSpecToFinish ( )
838
+
839
+ cy . findByTestId ( 'studio-panel' ) . should ( 'be.visible' )
840
+ cy . findByTestId ( 'new-test-button' ) . should ( 'be.visible' )
841
+
842
+ // verify test body section is visible after refresh
843
+ cy . get ( '.runnable-instruments' ) . should ( 'be.visible' )
844
+ cy . get ( '.runnable-commands-region' ) . should ( 'be.visible' )
845
+
846
+ // verify the test body hook is present
847
+ cy . get ( '.hook-item' ) . contains ( 'test body' ) . should ( 'be.visible' )
848
+
849
+ // verify commands are visible within the test body
850
+ cy . get ( '.command-name-visit' ) . should ( 'be.visible' )
851
+
852
+ // Verify URL parameters show suite mode, not test mode
853
+ cy . location ( ) . its ( 'hash' ) . should ( 'contain' , 'suiteId=r1' ) . and ( 'not.contain' , 'testId=' )
854
+ } )
855
+
773
856
describe ( 'prompt for a new url' , ( ) => {
774
857
const autUrl = 'http://localhost:4455/cypress/e2e/index.html'
775
858
const visitUrl = 'cypress/e2e/index.html'
0 commit comments