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

Code before:
    cy.contains('Create test with Cypress Studio').click()

    inputNewTestName()

    // Cypress re-runs after the new test is saved.
    cy.waitForSpecToFinish()

    cy.get('.cm-content').invoke('text', 'cy.visit("cypress/e2e/index.html")')

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

    // verify recording is enabled to ensure the panel is fully ready
    cy.findByTestId('record-button-recording').should('have.text', 'Recording...')

    // we should have the commands we executed after we save
    cy.withCtx(async (ctx) => {
      const spec = await ctx.actions.file.readFileInProject('cypress/e2e/empty.cy.js')

      expect(spec.trim().replace(/\r/g, '')).to.equal(`
it('new-test', function() {
    cy.visit("cypress/e2e/index.html")
});`.trim())
    })
  })

  it('opens the name test screen from the welcome screen and creates a new test from an empty spec ', () => {
    loadProjectAndRunSpec({ specName: 'empty.cy.js', specSelector: 'title' })

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

    cy.get('[data-cy="studio-panel"]').should('be.visible')

    cy.contains('Create test with Cypress Studio').click()

    inputNewTestName()

    // Cypress re-runs after the new test is saved.
    cy.waitForSpecToFinish()

    cy.get('.cm-content').invoke('text', 'cy.visit("cypress/e2e/index.html")')

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

    // verify recording is enabled to ensure the panel is fully ready
    cy.findByTestId('record-button-recording').should('have.text', 'Recording...')

    // we should have the commands we executed after we save
    cy.withCtx(async (ctx) => {
      const spec = await ctx.actions.file.readFileInProject('cypress/e2e/empty.cy.js')

      expect(spec.trim().replace(/\r/g, '')).to.equal(`

Review comment (suggestion):
```suggestion
  it('opens the name test screen from the welcome screen and creates a new test from an empty spec', () => {
```

Code after:
    cy.contains('Create test with Cypress Studio').click()

    inputNewTestName()

    // Cypress re-runs after the new test is saved.
    cy.waitForSpecToFinish()

    cy.get('.cm-content').invoke('text', 'cy.visit("cypress/e2e/index.html")')

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

    // verify recording is enabled to ensure the panel is fully ready
    cy.findByTestId('record-button-recording').should('have.text', 'Recording...')

    // we should have the commands we executed after we save
    cy.withCtx(async (ctx) => {
      const spec = await ctx.actions.file.readFileInProject('cypress/e2e/empty.cy.js')

      expect(spec.trim().replace(/\r/g, '')).to.equal(`
it('new-test', function() {
    cy.visit("cypress/e2e/index.html")
});`.trim())
    })
  })

  it('opens the name test screen from the welcome screen and creates a new test from an empty spec', () => {
    loadProjectAndRunSpec({ specName: 'empty.cy.js', specSelector: 'title' })

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

    cy.get('[data-cy="studio-panel"]').should('be.visible')

    cy.contains('Create test with Cypress Studio').click()

    inputNewTestName()

    // Cypress re-runs after the new test is saved.
    cy.waitForSpecToFinish()

    cy.get('.cm-content').invoke('text', 'cy.visit("cypress/e2e/index.html")')

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

    // verify recording is enabled to ensure the panel is fully ready
    cy.findByTestId('record-button-recording').should('have.text', 'Recording...')

    // we should have the commands we executed after we save
    cy.withCtx(async (ctx) => {
      const spec = await ctx.actions.file.readFileInProject('cypress/e2e/empty.cy.js')

      expect(spec.trim().replace(/\r/g, '')).to.equal(`