Skip to content

internal: (studio) do not record events if cloud studio is enabled #31858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 13, 2025
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
31 changes: 31 additions & 0 deletions packages/app/cypress/e2e/studio/studio-cloud.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,35 @@ describe('studio functionality', () => {
// verify studio is still open
cy.findByTestId('studio-panel').should('be.visible')
})

it('does not record studio commands when cloud studio is enabled', () => {
launchStudio({ enableCloudStudio: true })

cy.findByTestId('studio-panel').should('be.visible')

// Attempt to perform actions that would normally be recorded in regular studio
// but should NOT be recorded in when cloud studio is enabled because event listeners are not attached
cy.getAutIframe().within(() => {
cy.get('p').contains('Count is 0')

// Try to click the increment button - this should NOT be recorded
// because cloud studio event listeners should not be attached
cy.get('#increment').realClick().then(() => {
cy.get('p').contains('Count is 1')
})
})

// Verify that no legacy studio commands were recorded
cy.get('.command-is-studio').should('not.exist')

// Verify that the actual DOM interactions still work (button was clicked, counter incremented)
// but they just weren't recorded by the legacy studio event listeners
cy.getAutIframe().within(() => {
cy.get('p').should('contain', 'Count is 1')
})

cy.findByTestId('studio-panel').should('be.visible')

cy.get('[data-cy="studio-toolbar"]').should('not.exist')
})
})
2 changes: 2 additions & 0 deletions packages/app/src/runner/SpecRunnerOpenMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ useSubscription({ query: StudioStatus_ChangeDocument }, (_, data) => {
})

const cloudStudioRequested = computed(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I think I need this for cy.prompt actually.

studioStore.setCloudStudioRequested(props.gql.cloudStudioRequested || false)

return props.gql.cloudStudioRequested
})

Expand Down
17 changes: 14 additions & 3 deletions packages/app/src/store/studio-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ interface StudioRecorderState {

canAccessStudioAI: boolean
showUrlPrompt: boolean
cloudStudioRequested: boolean
cloudStudioSessionId?: string
}

Expand All @@ -139,11 +140,16 @@ export const useStudioStore = defineStore('studioRecorder', {
_currentId: 1,
canAccessStudioAI: false,
showUrlPrompt: true,
cloudStudioRequested: false,
cloudStudioSessionId: undefined,
}
},

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

setShowUrlPrompt (shouldShowUrlPrompt: boolean) {
this.showUrlPrompt = shouldShowUrlPrompt
},
Expand Down Expand Up @@ -504,6 +510,11 @@ export const useStudioStore = defineStore('studioRecorder', {

this._body = body

// if we're in cloud studio, we shouldn't attach our own listeners - cloud studio will handle it
if (this.cloudStudioRequested) {
return
}

for (const event of eventTypes) {
this._body.addEventListener(event, this._recordEvent, {
capture: true,
Expand Down Expand Up @@ -859,7 +870,7 @@ export const useStudioStore = defineStore('studioRecorder', {
return $el.hasClass('__cypress-studio-assertions-menu')
},

_openAssertionsMenu (event) {
_openAssertionsMenu (event, addAssertion?: ($el: HTMLElement | JQuery<HTMLElement>, ...args: AssertionArgs) => void, generatePossibleAssertions?: ($el: JQuery<Element>) => PossibleAssertions) {
if (!this._body) {
throw Error('this._body was not defined')
}
Expand All @@ -879,8 +890,8 @@ export const useStudioStore = defineStore('studioRecorder', {
$el,
$body: window.UnifiedRunner.CypressJQuery(this._body),
props: {
possibleAssertions: this._generatePossibleAssertions($el),
addAssertion: this._addAssertion,
possibleAssertions: generatePossibleAssertions ? generatePossibleAssertions($el) : this._generatePossibleAssertions($el),
addAssertion: addAssertion || this._addAssertion,
closeMenu: this._closeAssertionsMenu,
},
})
Expand Down
Loading