From 3c198af44f698899cd4deac345ae07670311b7c9 Mon Sep 17 00:00:00 2001 From: Matthew Schile Date: Thu, 29 May 2025 16:00:25 -0600 Subject: [PATCH 1/2] internal: (studio) skip cancelling studio on watched:file:changed --- .../app/cypress/e2e/studio/studio-cloud.cy.ts | 22 +++++++++++++++++++ packages/app/src/runner/event-manager.ts | 11 +++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/app/cypress/e2e/studio/studio-cloud.cy.ts b/packages/app/cypress/e2e/studio/studio-cloud.cy.ts index e0a104e391a7..d511430ab146 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('exits 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) => { From 5a32613f57d3ae3d3efeed0dc2f9551f288bfd6e Mon Sep 17 00:00:00 2001 From: Matthew Schile Date: Thu, 29 May 2025 16:18:52 -0600 Subject: [PATCH 2/2] update test title --- packages/app/cypress/e2e/studio/studio-cloud.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/cypress/e2e/studio/studio-cloud.cy.ts b/packages/app/cypress/e2e/studio/studio-cloud.cy.ts index d511430ab146..5018976290cf 100644 --- a/packages/app/cypress/e2e/studio/studio-cloud.cy.ts +++ b/packages/app/cypress/e2e/studio/studio-cloud.cy.ts @@ -206,7 +206,7 @@ describe('Studio Cloud', () => { cy.get('[data-cy="recommendation-editor"]').should('contain', aiOutput) }) - it('exits studio mode if the spec is changed on the file system', () => { + 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')