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 1 commit
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 @@ -269,6 +269,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
15 changes: 13 additions & 2 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
}

export const useStudioStore = defineStore('studioRecorder', {
Expand All @@ -138,10 +139,15 @@ export const useStudioStore = defineStore('studioRecorder', {
_currentId: 1,
canAccessStudioAI: false,
showUrlPrompt: true,
cloudStudioRequested: false,
}
},

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

setShowUrlPrompt (shouldShowUrlPrompt: boolean) {
this.showUrlPrompt = shouldShowUrlPrompt
},
Expand Down Expand Up @@ -498,6 +504,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 @@ -853,7 +864,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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

adding the ability to pass in addAssertion here allows us to control assertion recording from the cloud without having to move the whole assertion menu UI over - see the other PR for how we hook into this

if (!this._body) {
throw Error('this._body was not defined')
}
Expand All @@ -874,7 +885,7 @@ export const useStudioStore = defineStore('studioRecorder', {
$body: window.UnifiedRunner.CypressJQuery(this._body),
props: {
possibleAssertions: this._generatePossibleAssertions($el),
addAssertion: this._addAssertion,
addAssertion: addAssertion || this._addAssertion,
closeMenu: this._closeAssertionsMenu,
},
})
Expand Down
Loading