Skip to content

Commit dcc8e24

Browse files
fix: (cy.prompt) ensure to reset the prompt state when the event manager is torn down (indicating that we're no longer on the runner page) (#32301)
* fix: (cy.prompt) ensure to reset the prompt state when the event manager is torn down (indicating that we're no longer on the runner page) * move test * fix lint issue
1 parent fc37d0b commit dcc8e24

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

packages/app/cypress/e2e/runner/event-manager.cy.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,21 @@ describe('event-manager', () => {
5050
cy.wrap(() => eventManager.reporterBus.listeners('runner:next').length).invoke('call').should('equal', 1)
5151
})
5252
})
53+
54+
it('should reset the prompt store', () => {
55+
loadSpec({
56+
filePath: 'hooks/basic.cy.js',
57+
passCount: 2,
58+
})
59+
60+
cy.window().then((win) => {
61+
const eventManager = win.getEventManager()
62+
63+
cy.spy(eventManager['promptStore'], 'resetState').as('resetState')
64+
})
65+
66+
cy.visitApp(`specs`)
67+
68+
cy.get('@resetState').should('have.been.calledOnce')
69+
})
5370
})

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ export class EventManager {
908908
// clean up the cross origin logs in memory to prevent dangling references as the log objects themselves at this point will no longer be needed.
909909
crossOriginLogs = {}
910910
this.studioStore.setActive(false)
911+
this.promptStore.resetState()
911912
}
912913

913914
resetReporter () {

packages/server/test/unit/socket_spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ describe('lib/socket', () => {
329329
})
330330
})
331331
})
332+
332333
context('on(get:app:state)', () => {
333334
it('calls getSavedState with options and returns the state', function (done) {
334335
this.options.getSavedState.resolves({ reporterWidth: 500 })

0 commit comments

Comments
 (0)