diff --git a/packages/app/cypress/e2e/studio/studio-cloud.cy.ts b/packages/app/cypress/e2e/studio/studio-cloud.cy.ts index e0a104e391a7..5018976290cf 100644 --- a/packages/app/cypress/e2e/studio/studio-cloud.cy.ts +++ b/packages/app/cypress/e2e/studio/studio-cloud.cy.ts @@ -205,4 +205,26 @@ describe('Studio Cloud', () => { // Verify that the AI output is correct cy.get('[data-cy="recommendation-editor"]').should('contain', aiOutput) }) + + it('does not exit studio mode if the spec is changed on the file system', () => { + launchStudio({ enableCloudStudio: true }) + + cy.findByTestId('studio-panel').should('be.visible') + + // update the spec on the file system to force a rerun through watched:file:changed + cy.withCtx(async (ctx) => { + await ctx.actions.file.writeFileInProject('cypress/e2e/spec.cy.js', ` +describe('studio functionality', () => { + it('visits a basic html page', () => { + // new comment + cy.visit('cypress/e2e/index.html') + }) +})`) + }) + + cy.waitForSpecToFinish() + + // verify studio is still open + cy.findByTestId('studio-panel').should('be.visible') + }) }) diff --git a/packages/app/src/runner/event-manager.ts b/packages/app/src/runner/event-manager.ts index b5c3326924c6..109f9f4aae19 100644 --- a/packages/app/src/runner/event-manager.ts +++ b/packages/app/src/runner/event-manager.ts @@ -43,7 +43,6 @@ interface AddGlobalListenerOptions { const driverToLocalAndReporterEvents = 'run:start run:end'.split(' ') const driverToSocketEvents = 'backend:request automation:request mocha recorder:frame dev-server:on-spec-update'.split(' ') const driverToLocalEvents = 'viewport:changed config stop url:changed page:loading visit:failed visit:blank cypress:in:cypress:runner:event'.split(' ') -const socketRerunEvents = 'runner:restart watched:file:changed'.split(' ') const socketToDriverEvents = 'net:stubbing:event request:event script:error cross:origin:cookies dev-server:on-spec-updated'.split(' ') const localToReporterEvents = 'reporter:log:add reporter:log:state:changed reporter:log:remove'.split(' ') @@ -158,7 +157,11 @@ export class EventManager { }) this.ws.on('watched:file:changed', () => { - this.studioStore.cancel() + // only cancel studio if cloud studio was not requested + if (!Cypress.env('LOCAL_STUDIO_PATH') && !Cypress.env('ENABLE_CLOUD_STUDIO')) { + this.studioStore.cancel() + } + rerun() }) @@ -168,9 +171,7 @@ export class EventManager { } }) - socketRerunEvents.forEach((event) => { - this.ws.on(event, rerun) - }) + this.ws.on('runner:restart', rerun) socketToDriverEvents.forEach((event) => { this.ws.on(event, (...args) => {