Skip to content

Commit 280c417

Browse files
authored
internal: (studio) skip cancelling studio on watched:file:changed (#31804)
1 parent fed81d4 commit 280c417

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

packages/app/cypress/e2e/studio/studio-cloud.cy.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,26 @@ describe('Studio Cloud', () => {
205205
// Verify that the AI output is correct
206206
cy.get('[data-cy="recommendation-editor"]').should('contain', aiOutput)
207207
})
208+
209+
it('does not exit studio mode if the spec is changed on the file system', () => {
210+
launchStudio({ enableCloudStudio: true })
211+
212+
cy.findByTestId('studio-panel').should('be.visible')
213+
214+
// update the spec on the file system to force a rerun through watched:file:changed
215+
cy.withCtx(async (ctx) => {
216+
await ctx.actions.file.writeFileInProject('cypress/e2e/spec.cy.js', `
217+
describe('studio functionality', () => {
218+
it('visits a basic html page', () => {
219+
// new comment
220+
cy.visit('cypress/e2e/index.html')
221+
})
222+
})`)
223+
})
224+
225+
cy.waitForSpecToFinish()
226+
227+
// verify studio is still open
228+
cy.findByTestId('studio-panel').should('be.visible')
229+
})
208230
})

packages/app/src/runner/event-manager.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ interface AddGlobalListenerOptions {
4343
const driverToLocalAndReporterEvents = 'run:start run:end'.split(' ')
4444
const driverToSocketEvents = 'backend:request automation:request mocha recorder:frame dev-server:on-spec-update'.split(' ')
4545
const driverToLocalEvents = 'viewport:changed config stop url:changed page:loading visit:failed visit:blank cypress:in:cypress:runner:event'.split(' ')
46-
const socketRerunEvents = 'runner:restart watched:file:changed'.split(' ')
4746
const socketToDriverEvents = 'net:stubbing:event request:event script:error cross:origin:cookies dev-server:on-spec-updated'.split(' ')
4847
const localToReporterEvents = 'reporter:log:add reporter:log:state:changed reporter:log:remove'.split(' ')
4948

@@ -158,7 +157,11 @@ export class EventManager {
158157
})
159158

160159
this.ws.on('watched:file:changed', () => {
161-
this.studioStore.cancel()
160+
// only cancel studio if cloud studio was not requested
161+
if (!Cypress.env('LOCAL_STUDIO_PATH') && !Cypress.env('ENABLE_CLOUD_STUDIO')) {
162+
this.studioStore.cancel()
163+
}
164+
162165
rerun()
163166
})
164167

@@ -168,9 +171,7 @@ export class EventManager {
168171
}
169172
})
170173

171-
socketRerunEvents.forEach((event) => {
172-
this.ws.on(event, rerun)
173-
})
174+
this.ws.on('runner:restart', rerun)
174175

175176
socketToDriverEvents.forEach((event) => {
176177
this.ws.on(event, (...args) => {

0 commit comments

Comments
 (0)