Repository: cypress-io/cypress
File: packages/app/cypress/e2e/studio/studio.cy.ts (TypeScript)

Code before:
    cy.findByTestId('studio-save-button').click()

    cy.location().its('hash').should('contain', 'testId=r3').and('contain', 'studio=')
  })

  it('removes the studio url parameters when closing studio existing test with the back button', () => {
    launchStudio()

    cy.location().its('hash').should('contain', 'testId=r3').and('contain', 'studio=')

    cy.get('[data-cy="studio-back-button"]').click()

    cy.location().its('hash').and('not.contain', 'testId=').and('not.contain', 'studio=')
  })

  it('removes the studio url parameters when closing studio existing test with the studio header button', () => {
    launchStudio()

    cy.location().its('hash').should('contain', 'testId=r3').and('contain', 'studio=')

    cy.findByTestId('studio-header-studio-button').click()

    cy.location().its('hash').and('not.contain', 'testId=').and('not.contain', 'studio=')
  })

  it('does not prompt for URL when creating a new test in studio', () => {
    launchStudio({ specName: 'spec-w-visit.cy.js', createNewTestFromSuite: true })
    cy.location().its('hash').should('contain', 'suiteId=r2').and('contain', 'studio=')
    cy.waitForSpecToFinish()

    cy.findByTestId('aut-url-input').should('have.value', 'http://localhost:4455/cypress/e2e/index.html')
  })

  it('does not reload the page if we didnt open a test in studio', () => {
    launchStudio({ specName: 'spec-w-visit.cy.js', createNewTestFromSuite: true })

    // set a property on the window to see if the page reloads
    cy.window().then((w) => w['beforeReload'] = true)

    // close new test mode
    cy.findByTestId('studio-header-studio-button').click()

    // if this property is still set on the window, then the page didn't reload
    cy.window().then((w) => expect(w['beforeReload']).to.be.true)
  })

  it('removes the studio url parameters when closing studio new test', () => {
    launchStudio({ specName: 'spec-w-visit.cy.js', createNewTestFromSuite: true })

    cy.location().its('hash').should('contain', 'suiteId=r2').and('contain', 'studio=')


Review comment (suggestion):
```suggestion
  it('does not prompt for a URL until studio is active', () => {
```

Code after:
    cy.findByTestId('record-button-recording').should('be.visible')

    incrementCounter(0)

    cy.location().its('hash').should('contain', 'testId=r3').and('contain', 'studio=')

    // update the spec on the file system by changing the
    // test name which will cause the save to fail since
    // the test won't be found
    cy.withCtx(async (ctx) => {
      await ctx.actions.file.writeFileInProject('cypress/e2e/spec.cy.js', `
describe('studio functionality', () => {
  it('CHANGED - visits a basic html page', () => {
    cy.visit('cypress/e2e/index.html')

    // new command
    cy.get('h1').should('have.text', 'Hello, Studio!')
  })
})`)
    })

    cy.wait(200)

    cy.findByTestId('studio-save-button').click()

    cy.location().its('hash').should('contain', 'testId=r3').and('contain', 'studio=')
  })

  it('removes the studio url parameters when closing studio existing test with the back button', () => {
    launchStudio()

    cy.location().its('hash').should('contain', 'testId=r3').and('contain', 'studio=')

    cy.get('[data-cy="studio-back-button"]').click()

    cy.location().its('hash').and('not.contain', 'testId=').and('not.contain', 'studio=')
  })

  it('removes the studio url parameters when closing studio existing test with the studio header button', () => {
    launchStudio()

    cy.location().its('hash').should('contain', 'testId=r3').and('contain', 'studio=')

    cy.findByTestId('studio-header-studio-button').click()

    cy.location().its('hash').and('not.contain', 'testId=').and('not.contain', 'studio=')
  })

  it('does not prompt for a URL until studio is active', () => {
    launchStudio({ specName: 'spec-w-visit.cy.js', createNewTestFromSuite: true })
    cy.location().its('hash').should('contain', 'suiteId=r2').and('contain', 'studio=')