Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/server/lib/project-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions packages/server/test/unit/project_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 = {}

Expand All @@ -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
Expand Down Expand Up @@ -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 () {
Expand Down
Loading