diff --git a/packages/server/lib/project-base.ts b/packages/server/lib/project-base.ts index d6e1de6430e..cf07575554f 100644 --- a/packages/server/lib/project-base.ts +++ b/packages/server/lib/project-base.ts @@ -485,6 +485,9 @@ export class ProjectBase extends EE { const studio = await this.ctx.coreData.studioLifecycleManager?.getStudio() + // Update the session id in the studio manager + studio?.updateSessionId(cloudStudioSessionId) + if (this.spec && studio?.protocolManager) { telemetryManager.mark(INITIALIZATION_MARK_NAMES.CAN_ACCESS_STUDIO_AI_START) const canAccessStudioAI = await studio?.canAccessStudioAI(this.browser) ?? false diff --git a/packages/server/test/unit/project_spec.js b/packages/server/test/unit/project_spec.js index 3b58f666e69..6162d6d480b 100644 --- a/packages/server/test/unit/project_spec.js +++ b/packages/server/test/unit/project_spec.js @@ -773,6 +773,7 @@ This option will not have an effect in Some-other-name. Tests that rely on web s const mockBeforeSpec = sinon.stub() const mockAccessStudioAI = sinon.stub().resolves(true) const mockCaptureStudioEvent = sinon.stub().resolves() + const mockUpdateSessionId = sinon.stub() this.project.spec = {} @@ -792,6 +793,8 @@ This option will not have an effect in Some-other-name. Tests that rely on web s dbPath: 'test-db-path', } + studioManager.updateSessionId = mockUpdateSessionId + const studioLifecycleManager = new StudioLifecycleManager() this.project.ctx.coreData.studioLifecycleManager = studioLifecycleManager @@ -838,6 +841,8 @@ This option will not have an effect in Some-other-name. Tests that rely on web s name: 'chrome', }) + expect(mockUpdateSessionId.getCall(0).args[0]).to.be.a.uuid() + expect(browsers.connectProtocolToBrowser).to.be.calledWith({ browser: this.project.browser, foundBrowsers: this.project.options.browsers, @@ -865,6 +870,7 @@ This option will not have an effect in Some-other-name. Tests that rely on web s const mockBeforeSpec = sinon.stub() const mockAccessStudioAI = sinon.stub().resolves(true) const mockCaptureStudioEvent = sinon.stub().resolves() + const mockUpdateSessionId = sinon.stub() this.project.spec = {} @@ -884,6 +890,8 @@ This option will not have an effect in Some-other-name. Tests that rely on web s dbPath: 'test-db-path', } + studioManager.updateSessionId = mockUpdateSessionId + const studioLifecycleManager = new StudioLifecycleManager() this.project.ctx.coreData.studioLifecycleManager = studioLifecycleManager @@ -922,6 +930,7 @@ This option will not have an effect in Some-other-name. Tests that rely on web s const { cloudStudioSessionId } = await studioInitPromise expect(cloudStudioSessionId).to.equal('existing-session-id') + expect(mockUpdateSessionId).to.be.calledOnceWith('existing-session-id') }) it('calls resetBrowserState during onStudioInit when AI is enabled', async function () {