ronantakizawa/codereview-bench huggingface dataset:
Repository: cypress-io/cypress
File: packages/app/src/store/studio-store.ts (TypeScript)

Code before:
      this.testId = undefined
      this._updateUrlParams(['testId', 'suiteId'])
    },

    setCanAccessStudioAI (canAccessStudioAI: boolean) {
      this.canAccessStudioAI = canAccessStudioAI
    },

    setCloudStudioSessionId (cloudStudioSessionId: string) {
      this.cloudStudioSessionId = cloudStudioSessionId
    },

    setNewTestLineNumber (newTestLineNumber: number) {
      this.newTestLineNumber = newTestLineNumber
      this._updateUrlParams(['newTestLineNumber'])
    },

    clearRunnableIds () {
      this.testId = undefined
      this.suiteId = undefined
      this.newTestLineNumber = undefined
    },

    needsProtocolCleanup () {
      // Protocol cleanup (page reload) is only needed if Studio has actually been used for recording
      return this._hasStarted || this.logs.length > 0 || this._isStudioCreatedTest
    },

    openInstructionModal () {
      this.instructionModalIsOpen = true
    },

    closeInstructionModal () {
      this.instructionModalIsOpen = false
    },

    showSaveModal () {
      this.saveModalIsOpen = true
    },

    closeSaveModal () {
      this.saveModalIsOpen = false
    },

    startLoading () {
      this.isLoading = true
    },

    setActive (isActive: boolean) {
      this.isActive = isActive
    },

Review comment (suggestion):
I think we would want to cleanup protocol regardless of whether or not an action has been recorded since protocol would'e still been initialized and possibly written to. I'm thinking we may just need to check if there is a `testId`.

Code after:
      this.testId = undefined
      this._updateUrlParams(['testId', 'suiteId'])
    },

    setCanAccessStudioAI (canAccessStudioAI: boolean) {
      this.canAccessStudioAI = canAccessStudioAI
    },

    setCloudStudioSessionId (cloudStudioSessionId: string) {
      this.cloudStudioSessionId = cloudStudioSessionId
    },

    setNewTestLineNumber (newTestLineNumber: number) {
      this.newTestLineNumber = newTestLineNumber
      this._updateUrlParams(['newTestLineNumber'])
    },

    clearRunnableIds () {
      this.testId = undefined
      this.suiteId = undefined
      this.newTestLineNumber = undefined
    },

    needsProtocolCleanup () {
      // Protocol cleanup (page reload) is only needed if the user has actually entered single test mode in Studio
      return this._hasStarted || this.testId || this._isStudioCreatedTest
    },

    openInstructionModal () {
      this.instructionModalIsOpen = true
    },

    closeInstructionModal () {
      this.instructionModalIsOpen = false
    },

    showSaveModal () {
      this.saveModalIsOpen = true
    },

    closeSaveModal () {
      this.saveModalIsOpen = false
    },

    startLoading () {
      this.isLoading = true
    },

    setActive (isActive: boolean) {
      this.isActive = isActive
    },
Repository: cypress-io/cypress
File: packages/app/src/store/studio-store.ts (TypeScript)

Code before:
      this.suiteId = suiteId
      this.testId = undefined
      this._updateUrlParams(['testId', 'suiteId'])
    },

    setCanAccessStudioAI (canAccessStudioAI: boolean) {
      this.canAccessStudioAI = canAccessStudioAI
    },

    setCloudStudioSessionId (cloudStudioSessionId: string) {
      this.cloudStudioSessionId = cloudStudioSessionId
    },

    setNewTestLineNumber (newTestLineNumber: number) {
      this.newTestLineNumber = newTestLineNumber
      this._updateUrlParams(['newTestLineNumber'])
    },

    clearRunnableIds () {
      this.testId = undefined
      this.suiteId = undefined
      this.newTestLineNumber = undefined
    },

    needsProtocolCleanup () {
      // Protocol cleanup (page reload) is only needed if Studio has actually been used for recording
      return this._hasStarted || this.testId || this._isStudioCreatedTest
    },

    openInstructionModal () {
      this.instructionModalIsOpen = true
    },

    closeInstructionModal () {
      this.instructionModalIsOpen = false
    },

    showSaveModal () {
      this.saveModalIsOpen = true
    },

    closeSaveModal () {
      this.saveModalIsOpen = false
    },

    startLoading () {
      this.isLoading = true
    },

    setActive (isActive: boolean) {
      this.isActive = isActive

Review comment (suggestion):
```suggestion
      // Protocol cleanup (page reload) is only needed if the user has actually entered single test mode in Studio
```

Code after:
      this.suiteId = suiteId
      this.testId = undefined
      this._updateUrlParams(['testId', 'suiteId'])
    },

    setCanAccessStudioAI (canAccessStudioAI: boolean) {
      this.canAccessStudioAI = canAccessStudioAI
    },

    setCloudStudioSessionId (cloudStudioSessionId: string) {
      this.cloudStudioSessionId = cloudStudioSessionId
    },

    setNewTestLineNumber (newTestLineNumber: number) {
      this.newTestLineNumber = newTestLineNumber
      this._updateUrlParams(['newTestLineNumber'])
    },

    clearRunnableIds () {
      this.testId = undefined
      this.suiteId = undefined
      this.newTestLineNumber = undefined
    },

    needsProtocolCleanup () {
      // Protocol cleanup (page reload) is only needed if the user has actually entered single test mode in Studio
      return this._hasStarted || this.testId || this._isStudioCreatedTest
    },

    openInstructionModal () {
      this.instructionModalIsOpen = true
    },

    closeInstructionModal () {
      this.instructionModalIsOpen = false
    },

    showSaveModal () {
      this.saveModalIsOpen = true
    },

    closeSaveModal () {
      this.saveModalIsOpen = false
    },

    startLoading () {
      this.isLoading = true
    },

    setActive (isActive: boolean) {
      this.isActive = isActive
Repository: cypress-io/cypress
File: packages/app/src/store/studio-store.ts (TypeScript)

Code before:
    setCloudStudioRequested (cloudStudioRequested: boolean) {
      this.cloudStudioRequested = cloudStudioRequested
    },

    setShowUrlPrompt (shouldShowUrlPrompt: boolean) {
      this.showUrlPrompt = shouldShowUrlPrompt
    },

    setTestId (testId: string) {
      this.testId = testId
      this.suiteId = undefined
      this.newTestLineNumber = undefined
      this._updateUrlParams(['testId', 'suiteId', 'newTestLineNumber'])
    },

    setSuiteId (suiteId: string) {
      this.suiteId = suiteId
      this.testId = undefined
      this._updateUrlParams(['testId', 'suiteId'])
    },

    setCanAccessStudioAI (canAccessStudioAI: boolean) {
      this.canAccessStudioAI = canAccessStudioAI
    },

    setCloudStudioSessionId (cloudStudioSessionId: string) {
      this.sessionId = cloudStudioSessionId
      this._updateUrlParams(['sessionId'])
    },

    clearCloudStudioSessionId () {
      this.sessionId = undefined
      this._removeUrlParams(['sessionId'])
    },

    setNewTestLineNumber (newTestLineNumber: number) {
      this.newTestLineNumber = newTestLineNumber
      this._updateUrlParams(['newTestLineNumber'])
    },

    clearRunnableIds () {
      this.testId = undefined
      this.suiteId = undefined
      this.newTestLineNumber = undefined
    },

    needsProtocolCleanup () {
      // Protocol cleanup (page reload) is only needed if the user has actually entered single test mode in Studio
      return this._hasStarted || this.testId || this._isStudioCreatedTest
    },


Review comment (suggestion):
```suggestion
    setSessionId (sessionId: string) {
```

Code after:
    setCloudStudioRequested (cloudStudioRequested: boolean) {
      this.cloudStudioRequested = cloudStudioRequested
    },

    setShowUrlPrompt (shouldShowUrlPrompt: boolean) {
      this.showUrlPrompt = shouldShowUrlPrompt
    },

    setTestId (testId: string) {
      this.testId = testId
      this.suiteId = undefined
      this.newTestLineNumber = undefined
      this._updateUrlParams(['testId', 'suiteId', 'newTestLineNumber'])
    },

    setSuiteId (suiteId: string) {
      this.suiteId = suiteId
      this.testId = undefined
      this._updateUrlParams(['testId', 'suiteId'])
    },

    setCanAccessStudioAI (canAccessStudioAI: boolean) {
      this.canAccessStudioAI = canAccessStudioAI
    },

    setSessionId (sessionId: string) {
      this.sessionId = sessionId
      this._updateUrlParams(['sessionId'])
    },

    clearSessionId () {
      this.sessionId = undefined
      this._removeUrlParams(['sessionId'])
    },

    setNewTestLineNumber (newTestLineNumber: number) {
      this.newTestLineNumber = newTestLineNumber
      this._updateUrlParams(['newTestLineNumber'])
    },

    clearRunnableIds () {
      this.testId = undefined
      this.suiteId = undefined
      this.newTestLineNumber = undefined
    },

    needsProtocolCleanup () {
      // Protocol cleanup (page reload) is only needed if the user has actually entered single test mode in Studio
      return this._hasStarted || this.testId || this._isStudioCreatedTest
    },
Repository: cypress-io/cypress
File: packages/app/src/store/studio-store.ts (TypeScript)

Code before:
      this.cloudStudioRequested = cloudStudioRequested
    },

    setShowUrlPrompt (shouldShowUrlPrompt: boolean) {
      this.showUrlPrompt = shouldShowUrlPrompt
    },

    setTestId (testId: string) {
      this.testId = testId
      this.suiteId = undefined
      this.newTestLineNumber = undefined
      this._updateUrlParams(['testId', 'suiteId', 'newTestLineNumber'])
    },

    setSuiteId (suiteId: string) {
      this.suiteId = suiteId
      this.testId = undefined
      this._updateUrlParams(['testId', 'suiteId'])
    },

    setCanAccessStudioAI (canAccessStudioAI: boolean) {
      this.canAccessStudioAI = canAccessStudioAI
    },

    setCloudStudioSessionId (cloudStudioSessionId: string) {
      this.sessionId = cloudStudioSessionId
      this._updateUrlParams(['sessionId'])
    },

    clearCloudStudioSessionId () {
      this.sessionId = undefined
      this._removeUrlParams(['sessionId'])
    },

    setNewTestLineNumber (newTestLineNumber: number) {
      this.newTestLineNumber = newTestLineNumber
      this._updateUrlParams(['newTestLineNumber'])
    },

    clearRunnableIds () {
      this.testId = undefined
      this.suiteId = undefined
      this.newTestLineNumber = undefined
    },

    needsProtocolCleanup () {
      // Protocol cleanup (page reload) is only needed if the user has actually entered single test mode in Studio
      return this._hasStarted || this.testId || this._isStudioCreatedTest
    },

    openInstructionModal () {

Review comment (suggestion):
```suggestion
      this.sessionId = sessionId
```

Code after:
      this.cloudStudioRequested = cloudStudioRequested
    },

    setShowUrlPrompt (shouldShowUrlPrompt: boolean) {
      this.showUrlPrompt = shouldShowUrlPrompt
    },

    setTestId (testId: string) {
      this.testId = testId
      this.suiteId = undefined
      this.newTestLineNumber = undefined
      this._updateUrlParams(['testId', 'suiteId', 'newTestLineNumber'])
    },

    setSuiteId (suiteId: string) {
      this.suiteId = suiteId
      this.testId = undefined
      this._updateUrlParams(['testId', 'suiteId'])
    },

    setCanAccessStudioAI (canAccessStudioAI: boolean) {
      this.canAccessStudioAI = canAccessStudioAI
    },

    setSessionId (sessionId: string) {
      this.sessionId = sessionId
      this._updateUrlParams(['sessionId'])
    },

    clearSessionId () {
      this.sessionId = undefined
      this._removeUrlParams(['sessionId'])
    },

    setNewTestLineNumber (newTestLineNumber: number) {
      this.newTestLineNumber = newTestLineNumber
      this._updateUrlParams(['newTestLineNumber'])
    },

    clearRunnableIds () {
      this.testId = undefined
      this.suiteId = undefined
      this.newTestLineNumber = undefined
    },

    needsProtocolCleanup () {
      // Protocol cleanup (page reload) is only needed if the user has actually entered single test mode in Studio
      return this._hasStarted || this.testId || this._isStudioCreatedTest
    },

    openInstructionModal () {
Repository: cypress-io/cypress
File: packages/app/src/store/studio-store.ts (TypeScript)

Code before:

    setUrl (url?: string) {
      this.url = url
    },

    testFailed () {
      this.isFailed = true
    },

    setup (config) {
      const studio = this.getUrlParams()

      if (studio.newTestLineNumber) {
        this.setNewTestLineNumber(studio.newTestLineNumber)
      } else if (studio.testId) {
        this.setTestId(studio.testId)
      } else if (studio.suiteId) {
        this.setSuiteId(studio.suiteId)
      }

      if (studio.url) {
        this._initialUrl = studio.url
      }

      if (studio.cloudStudioSessionId) {
        this.sessionId = studio.cloudStudioSessionId
      }

      // if we have an existing test or are creating a new test, we need to start loading
      // otherwise if we have a suite, we can just set the studio active
      if (this.testId || studio.newTestLineNumber) {
        this.setAbsoluteFile(config.spec.absolute)
        this.startLoading()
      } else if (this.suiteId) {
        this.setActive(true)
      }
    },

    initialize () {
      if (this.newTestLineNumber) {
        getCypress().runner.setNewTestLineNumber(this.newTestLineNumber)
        // Creating a new test - need to bypass .only filtering
        getCypress().runner.setIsStudioCreatedTest(true)
        this._isStudioCreatedTest = true
      } else if (this.testId) {
        getCypress().runner.setOnlyTestId(this.testId)
        getCypress().runner.setIsStudioCreatedTest(this._isStudioCreatedTest)
      }
    },

    interceptTest (test) {

Review comment (suggestion):
```suggestion
      if (studio.sessionId) {
        this.sessionId = studio.sessionId
```

Code after:

    setUrl (url?: string) {
      this.url = url
    },

    testFailed () {
      this.isFailed = true
    },

    setup (config) {
      const studio = this.getUrlParams()

      if (studio.newTestLineNumber) {
        this.setNewTestLineNumber(studio.newTestLineNumber)
      } else if (studio.testId) {
        this.setTestId(studio.testId)
      } else if (studio.suiteId) {
        this.setSuiteId(studio.suiteId)
      }

      if (studio.url) {
        this._initialUrl = studio.url
      }

      if (studio.sessionId) {
        this.sessionId = studio.sessionId
      }

      // if we have an existing test or are creating a new test, we need to start loading
      // otherwise if we have a suite, we can just set the studio active
      if (this.testId || studio.newTestLineNumber) {
        this.setAbsoluteFile(config.spec.absolute)
        this.startLoading()
      } else if (this.suiteId) {
        this.setActive(true)
      }
    },

    initialize () {
      if (this.newTestLineNumber) {
        getCypress().runner.setNewTestLineNumber(this.newTestLineNumber)
        // Creating a new test - need to bypass .only filtering
        getCypress().runner.setIsStudioCreatedTest(true)
        this._isStudioCreatedTest = true
      } else if (this.testId) {
        getCypress().runner.setOnlyTestId(this.testId)
        getCypress().runner.setIsStudioCreatedTest(this._isStudioCreatedTest)
      }
    },

    interceptTest (test) {
Repository: cypress-io/cypress
File: packages/server/lib/util/chromium_flags.ts (TypeScript)

Code before:

  // Uncomment to force the deprecation of upload events
  //`--enable-features=PermissionsPolicyUnload,DeprecateUnload`,
]

// prepend -- to each flag and concatenate them together
export const formatChromeFlags = (flags) => flags.map((flag) => `--${flag}`)

// create an array of objects with name and value properties
// for each flag, splitting the flag on the first = character
export const formatElectronFlags = (flags) => {
  return flags.map((flag) => {
    const [name, value] = flag.split('=')

    return value ? { name, value } : { name }
  })
}

export const DEFAULT_CHROME_FLAGS = formatChromeFlags(DEFAULT_FLAGS)

export const DEFAULT_ELECTRON_FLAGS = [
  ...formatElectronFlags(DEFAULT_CHROME_FLAGS),
  // @see https://github.com/electron/electron/issues/46538
  // @see https://github.com/cypress-io/cypress/issues/32361
  ...formatElectronFlags(['--gtk-version=3']),
]


Review comment (suggestion):
@AtofStryker I'd want to make sure that this can easily be searched when we bump the next Electron version to remove if needed.

Code after:

  // Uncomment to force the deprecation of upload events
  //`--enable-features=PermissionsPolicyUnload,DeprecateUnload`,
]

// prepend -- to each flag and concatenate them together
export const formatChromeFlags = (flags) => flags.map((flag) => `--${flag}`)

// create an array of objects with name and value properties
// for each flag, splitting the flag on the first = character
export const formatElectronFlags = (flags) => {
  return flags.map((flag) => {
    const [name, value] = flag.split('=')

    return value ? { name, value } : { name }
  })
}

export const DEFAULT_CHROME_FLAGS = formatChromeFlags(DEFAULT_FLAGS)

export const DEFAULT_ELECTRON_FLAGS = [
  ...formatElectronFlags(DEFAULT_CHROME_FLAGS),
  // NOTE: Can likely be removed with Electron upgrade to 37+.
  // @see https://github.com/electron/electron/issues/46538
  // @see https://github.com/cypress-io/cypress/issues/32361
  ...formatElectronFlags(['--gtk-version=3']),
]
Repository: cypress-io/cypress
File: vitest.config.ts (TypeScript)

Code before:
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    projects: [
      '{packages,tools,scripts}/*/vi{test,te}.config.{ts,mjs}',
      'cli/vitest.config.*',
    ],
    exclude: ['**/node_modules/**', '**/dist/**', 'system-tests/**'],
    coverage: {
      provider: 'v8',
      reporter: ['clover'],
    },
    reporters: ['default', 'junit'],
  },
})


Review comment (suggestion):
```suggestion
      '{packages,tooling,scripts}/*/vitest.config.{ts,mjs}',
```

Code after:
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    projects: [
      '{packages,tooling,scripts}/*/vitest.config.{ts,mjs}',
      'cli/vitest.config.*',
    ],
    exclude: ['**/node_modules/**', '**/dist/**', 'system-tests/**'],
    coverage: {
      provider: 'v8',
      reporter: ['clover'],
    },
    reporters: ['default', 'junit'],
  },
})
Repository: cypress-io/cypress
File: packages/data-context/graphql/schemaTypes/index.ts (TypeScript)

Code before:
/* eslint-disable padding-line-between-statements */
// created by autobarrel, do not modify directly

export * from './enumTypes/'
export * from './inputTypes/'
export * from './interfaceTypes/'
export * from './objectTypes/'
export * from './scalarTypes/'
export * from './unions/'


Review comment (suggestion):
```suggestion
export * from './enumTypes'
export * from './inputTypes'
export * from './interfaceTypes'
export * from './objectTypes'
export * from './scalarTypes'
export * from './unions'
```

Code after:
/* eslint-disable padding-line-between-statements */
// created by autobarrel, do not modify directly

export * from './enumTypes'
export * from './inputTypes'
export * from './interfaceTypes'
export * from './objectTypes'
export * from './scalarTypes'
export * from './unions'
Repository: cypress-io/cypress
File: system-tests/projects/e2e/cypress/e2e/cy_origin_error.cy.ts (TypeScript)

Code before:
    column: 10,
    message: 'Expected to find element',
    stack: ['cy_origin_error.cy.ts'],
    before () {
      cy.visit('/primary_origin.html')
    },
  })

  fail('failure when using dependency', this, () => {
    cy.origin('http://www.foobar.com:4466', () => {
      Cypress.require('../support/util')

      cy.get('#doesnotexist', { timeout: 1 })
    })
  })

  verify('failure when using dependency', this, {
    line: 35,
    column: 10,
    message: 'Expected to find element',
    stack: ['cy_origin_error.cy.ts'],
    before () {
      cy.visit('/primary_origin.html')
    },
    skipTitleValidation: true,
  })

  fail('failure when using assertion', this, () => {
    cy.origin('http://www.foobar.com:4466', () => {
      cy.get('#doesnotexist', { timeout: 1 }).should('exist')
    })
  })

  verify('failure when using assertion', this, {
    line: 52,
    column: 47,
    message: 'Expected to find element',
    stack: ['cy_origin_error.cy.ts'],
    before () {
      cy.visit('/primary_origin.html')
    },
  })
})


Review comment (suggestion):
```suggestion
    // Skip title validation here since the command is deep enough in the test that it does not show the command title
    skipTitleValidation: true,
```

Code after:
    column: 10,
    message: 'Expected to find element',
    stack: ['cy_origin_error.cy.ts'],
    before () {
      cy.visit('/primary_origin.html')
    },
  })

  fail('failure when using dependency', this, () => {
    cy.origin('http://www.foobar.com:4466', () => {
      Cypress.require('../support/util')

      cy.get('#doesnotexist', { timeout: 1 })
    })
  })

  verify('failure when using dependency', this, {
    line: 35,
    column: 10,
    message: 'Expected to find element',
    stack: ['cy_origin_error.cy.ts'],
    before () {
      cy.visit('/primary_origin.html')
    },
    // Skip title validation here since the command is deep enough in the test that it does not show the command title
    skipTitleValidation: true,
  })

  fail('failure when using assertion', this, () => {
    cy.origin('http://www.foobar.com:4466', () => {
      cy.get('#doesnotexist', { timeout: 1 }).should('exist')
    })
  })

  verify('failure when using assertion', this, {
    line: 53,
    column: 47,
    message: 'Expected to find element',
    stack: ['cy_origin_error.cy.ts'],
    before () {
      cy.visit('/primary_origin.html')
    },
  })
})
Repository: cypress-io/cypress
File: system-tests/test/posix_exit_codes_spec.ts (TypeScript)

Code before:
import systemTests from '../lib/system-tests'

describe('posix exit codes', () => {
  systemTests.setup()

  describe('when posix exit codes are enabled', () => {
    systemTests.it('returns 1 when there are failing tests', {
      spec: 'simple_failing.cy.js',
      posixExitCodes: true,
      expectedExitCode: 1,
      browser: ['electron'],
      project: 'e2e',
    })

    systemTests.it('returns 2 when there are 2 failing tests and posix is disabled', {
      spec: 'simple_failing.cy.js',
      posixExitCodes: false,
      expectedExitCode: 2,
      browser: ['electron'],
      project: 'e2e',
    })

    systemTests.it('returns 0 when there are no failing tests', {
      spec: 'simple_passing.cy.js',
      posixExitCodes: true,
      expectedExitCode: 0,
      browser: ['electron'],
      project: 'e2e',
    })
  })
})


Review comment (bug):
```suggestion
    systemTests.it('returns 1 when there are multiple failing tests', {
```

Code after:
import systemTests from '../lib/system-tests'

describe('posix exit codes', () => {
  systemTests.setup()

  describe('when posix exit codes are enabled', () => {
    const posixExitCodes = true

    systemTests.it('returns 1 when there are multiple failing tests', {
      spec: 'simple_failing.cy.js',
      posixExitCodes,
      expectedExitCode: 1,
      browser: ['electron'],
      project: 'e2e',
    })

    systemTests.it('returns 0 when there are no failing tests', {
      spec: 'simple_passing.cy.js',
      posixExitCodes: true,
      expectedExitCode: 0,
      browser: ['electron'],
      project: 'e2e',
    })
  })

  describe('when posix exit codes are disabled', () => {
    const posixExitCodes = false

    systemTests.it('returns 2 when there are 2 failing tests', {
      spec: 'simple_failing.cy.js',
      posixExitCodes,
      expectedExitCode: 2,