-
Notifications
You must be signed in to change notification settings - Fork 3.3k
internal: (studio) fix studio and runner states during opening, closing, and refreshing #32153
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
Changes from all commits
807b949
9a0521e
967300c
e94f9be
4df5587
071e1a4
62a2550
ed87881
d516243
b541855
95faad5
8bc82a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,16 +307,25 @@ export class EventManager { | |
studioInitSuite({ suiteId }) | ||
}) | ||
|
||
const maybeCleanUpProtocol = () => { | ||
const needsReload = this.studioStore.needsProtocolCleanup() | ||
|
||
this.studioStore.cancel() | ||
|
||
// only reload the page if Studio has actually been used for recording | ||
if (needsReload) { | ||
window.location.reload() | ||
} | ||
} | ||
|
||
this.reporterBus.on('studio:cancel', () => { | ||
this.ws.emit('studio:destroy', ({ error }) => { | ||
if (error) { | ||
// eslint-disable-next-line no-console | ||
console.error(error) | ||
} | ||
|
||
this.studioStore.cancel() | ||
// Reloading for now. This is the easiest way to clear out the protocol code from the front end | ||
window.location.reload() | ||
maybeCleanUpProtocol() | ||
}) | ||
}) | ||
|
||
|
@@ -366,9 +375,7 @@ export class EventManager { | |
console.error(error) | ||
} | ||
|
||
this.studioStore.cancel() | ||
// Reloading for now. This is the easiest way to clear out the protocol code from the front end | ||
window.location.reload() | ||
maybeCleanUpProtocol() | ||
}) | ||
}) | ||
|
||
|
@@ -857,7 +864,8 @@ export class EventManager { | |
performance.measure('run', 'run-s', 'run-e') | ||
}) | ||
|
||
const hasRunnableId = !!this.studioStore.testId || !!this.studioStore.suiteId | ||
const hasActiveStudio = !!this.studioStore.testId || | ||
!!this.studioStore.newTestLineNumber | ||
|
||
const studioSingleTestActive = this.studioStore.newTestLineNumber != null || !!this.studioStore.testId | ||
|
||
|
@@ -869,7 +877,7 @@ export class EventManager { | |
autoScrollingEnabled: runState.autoScrollingEnabled, | ||
isSpecsListOpen: runState.isSpecsListOpen, | ||
scrollTop: runState.scrollTop, | ||
studioActive: hasRunnableId, | ||
studioActive: hasActiveStudio, | ||
studioSingleTestActive, | ||
} as ReporterStartInfo) | ||
} | ||
|
@@ -928,7 +936,9 @@ export class EventManager { | |
} | ||
|
||
_interceptStudio (displayProps) { | ||
if (this.studioStore.isActive) { | ||
// Only intercept logs when Studio is actually recording a specific test | ||
// Don't intercept when Studio is just open in "new test" mode | ||
if (this.studioStore.isActive && this.studioStore.testId) { | ||
Comment on lines
+939
to
+941
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this function still needed? We don't even display logs anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah this still gets called - we don't display anything but it seems like if the logs are intercepted here, they don't get displayed in the command log. So I need to update this because otherwise when we refresh the page and studio is open to "new test", the test body section doesn't get displayed in the left panel. |
||
displayProps.hookId = this.studioStore.hookId | ||
|
||
if (displayProps.name === 'visit' && displayProps.state === 'failed') { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,6 +175,11 @@ export const useStudioStore = defineStore('studioRecorder', { | |
this.newTestLineNumber = undefined | ||
}, | ||
|
||
needsProtocolCleanup () { | ||
// Protocol cleanup (page reload) is only needed if the user has actually entered single test mode in Studio | ||
return this._hasStarted || this.testId || this._isStudioCreatedTest | ||
}, | ||
|
||
openInstructionModal () { | ||
this.instructionModalIsOpen = true | ||
}, | ||
|
@@ -246,7 +251,7 @@ export const useStudioStore = defineStore('studioRecorder', { | |
|
||
interceptTest (test) { | ||
// if this test is the one we created, we can just set the test id | ||
if ((this.newTestLineNumber && test.invocationDetails?.line === this.newTestLineNumber) || this.suiteId) { | ||
if ((this.newTestLineNumber && test.invocationDetails?.line === this.newTestLineNumber) || (this.suiteId && this._hasStarted)) { | ||
this._isStudioCreatedTest = true | ||
this.setTestId(test.id) | ||
getCypress().runner.setIsStudioCreatedTest(true) | ||
|
@@ -848,7 +853,7 @@ export const useStudioStore = defineStore('studioRecorder', { | |
}, | ||
|
||
needsUrl: (state) => { | ||
return state.isActive && !state.url && !state.isFailed | ||
return state.isActive && !state.url && !state.isFailed && state._hasStarted | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was causing the AUT URL to get removed whenever the panel was open at all, even if it was just the new test screen |
||
}, | ||
|
||
testError: (state) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a couple tests to verify this new behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added tests for both of these 👍🏻