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

Code before:
      } else if (this.suiteId) {
        getCypress().runner.setOnlySuiteId(this.suiteId)
        // Creating a new test in a suite - need to bypass .only filtering
        getCypress().runner.setIsStudioCreatedTest(true)
        this._wasStudioCreatedTest = true
      } else if (this.testId) {
        if (this._wasStudioCreatedTest) {
          // This test was created by studio, so we need to set the test id
          getCypress().runner.setOnlyTestId(this.testId)
          getCypress().runner.setIsStudioCreatedTest(true)
        } else {
          // this is an existing test - respect .only filtering
          getCypress().runner.setOnlyTestId(this.testId)
          getCypress().runner.setIsStudioCreatedTest(false)
        }
      }
    },

    interceptTest (test) {
      // if this test is the one we created, we can just set the test id
      if (this.newTestLineNumber && test.invocationDetails?.line === this.newTestLineNumber) {
        this.setTestId(test.id)
        getCypress().runner.setIsStudioCreatedTest(true)
      } else if (this.suiteId) {
        this.setTestId(test.id)
        getCypress().runner.setIsStudioCreatedTest(true)
      }

      if (this.testId) {
        if (test.invocationDetails) {
          this.setFileDetails(test.invocationDetails)
        }

        this.setRunnableTitle(test.title)
      }
    },

    start () {
      this.isActive = true
      this.isLoading = false
      this.logs = []
      this._currentId = 1
      this._hasStarted = true

      const autStore = useAutStore()

      if (this._initialUrl || this.url) {
        this.visitUrl(this._initialUrl)
      }

      if (!this.url && autStore.url) {

Review comment (suggestion):
I'm not understanding why there's an if/else here if they are setting the exact same thing in each call. If it needs to just meet both conditions to apply, then maybe:

```
const isNewlyCreatedTest = this.newTestLineNumber && test.invocationDetails?.line === this.newTestLineNumber

if (isNewlyCreatedTest || this.suiteId) {
```

Code after:
      } else if (this.testId) {
        getCypress().runner.setOnlyTestId(this.testId)
        getCypress().runner.setIsStudioCreatedTest(this._isStudioCreatedTest)
      }
    },

    interceptTest (test) {
      // if this test is the one we created, we can just set the test id
      if ((this.newTestLineNumber && test.invocationDetails?.line === this.newTestLineNumber) || this.suiteId) {
        this._isStudioCreatedTest = true
        this.setTestId(test.id)
        getCypress().runner.setIsStudioCreatedTest(true)
      }

      if (this.testId) {
        if (test.invocationDetails) {
          this.setFileDetails(test.invocationDetails)
        }

        this.setRunnableTitle(test.title)
      }
    },

    start () {
      this.isActive = true
      this.isLoading = false
      this.logs = []
      this._currentId = 1
      this._hasStarted = true

      const autStore = useAutStore()

      if (this._initialUrl || this.url) {
        this.visitUrl(this._initialUrl)
      }

      if (!this.url && autStore.url) {
        this.setUrl(autStore.url)
      }
    },

    stop () {
      this.isActive = false
      this.isLoading = false
    },

    reset () {
      this.stop()

      this.logs = []
      this.url = undefined