-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat: (studio) support @cypress/grep
package in Cypress Studio
#32311
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
Merged
+83
−0
Merged
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
86676e0
feat: (studio) support `@cypress/grep` package in Cypress Studio
astone123 1e6139f
add comment back
astone123 973940f
remove logs
astone123 7c8eae6
remove unnecessary comments
astone123 b7124aa
guard line replace
astone123 dbfef2f
add unit test
astone123 b1d1aec
send features object
astone123 ec428c5
Merge branch 'develop' into studio-grep-support
astone123 50891be
changelog
astone123 556fc12
Merge branch 'develop' into studio-grep-support
astone123 2f5809f
remove stack changes from app
astone123 a9606da
remove test
astone123 f31a08d
fix types
astone123 c49f931
revert changes
astone123 64d5a69
Merge branch 'develop' into studio-grep-support
astone123 87ac447
comment
astone123 5813d52
Merge branch 'develop' into studio-grep-support
astone123 adab034
update changelog
astone123 8a8f8a9
add type for stackUtils
astone123 1cf88cc
Merge branch 'develop' into studio-grep-support
astone123 11d8ef9
Update packages/app/src/store/studio-store.ts
astone123 4ad6f32
Merge branch 'develop' into studio-grep-support
astone123 fca6c14
Merge branch 'develop' into studio-grep-support
astone123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,7 @@ interface StudioRecorderState { | |
sessionId?: string | ||
_isStudioCreatedTest: boolean | ||
newTestLineNumber?: number | ||
_originalGrepSettings: Record<string, string> | ||
} | ||
|
||
function getUrlParams () { | ||
|
@@ -148,6 +149,7 @@ export const useStudioStore = defineStore('studioRecorder', { | |
sessionId: persistedSessionId, | ||
newTestLineNumber: undefined, | ||
_isStudioCreatedTest: false, | ||
_originalGrepSettings: {}, | ||
} | ||
}, | ||
|
||
|
@@ -254,6 +256,12 @@ export const useStudioStore = defineStore('studioRecorder', { | |
this.sessionId = studio.sessionId | ||
} | ||
|
||
if (studio.newTestLineNumber || studio.testId) { | ||
mschile marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (this.detectAndStoreGrepSettings()) { | ||
this.clearGrepSettings() | ||
} | ||
} | ||
|
||
// if we have an existing test or are creating a new test, we need to start loading | ||
// otherwise if we have a suite, we can just set the studio active | ||
if (this.testId || studio.newTestLineNumber) { | ||
|
@@ -276,6 +284,62 @@ export const useStudioStore = defineStore('studioRecorder', { | |
} | ||
}, | ||
|
||
detectAndStoreGrepSettings () { | ||
const grepEnvVars = [ | ||
'grep', | ||
'grepTags', 'grep-tags', | ||
'grepUntagged', 'grep-untagged', | ||
'grepOmitFiltered', 'grep-omit-filtered', | ||
] | ||
|
||
this._originalGrepSettings = {} | ||
|
||
try { | ||
const cypress = getCypress() | ||
|
||
for (const envVar of grepEnvVars) { | ||
const value = cypress.env(envVar) | ||
|
||
if (value != null) { | ||
this._originalGrepSettings[envVar] = value | ||
} | ||
} | ||
|
||
return Object.keys(this._originalGrepSettings).length > 0 | ||
} catch { | ||
return false | ||
} | ||
}, | ||
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. Bug: Grep Settings Overwritten on Repeated Setup CallsThe |
||
|
||
clearGrepSettings () { | ||
try { | ||
const cypress = getCypress() | ||
|
||
for (const envVar of Object.keys(this._originalGrepSettings)) { | ||
cypress.env(envVar, null) | ||
} | ||
} catch { | ||
// Cypress not ready, skip | ||
} | ||
}, | ||
|
||
restoreGrepSettings () { | ||
// Only restore if we have settings to restore | ||
if (Object.keys(this._originalGrepSettings).length === 0) { | ||
return | ||
} | ||
|
||
try { | ||
const cypress = getCypress() | ||
|
||
for (const [envVar, value] of Object.entries(this._originalGrepSettings)) { | ||
cypress.env(envVar, value) | ||
} | ||
} catch { | ||
// Cypress not ready, skip | ||
} | ||
}, | ||
|
||
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 && this._hasStarted)) { | ||
|
@@ -319,18 +383,23 @@ export const useStudioStore = defineStore('studioRecorder', { | |
reset () { | ||
this.stop() | ||
|
||
this.restoreGrepSettings() | ||
|
||
this.logs = [] | ||
this.url = undefined | ||
this._hasStarted = false | ||
this._currentId = 1 | ||
this.isFailed = false | ||
this.showUrlPrompt = true | ||
this._isStudioCreatedTest = false | ||
this._originalGrepSettings = {} | ||
|
||
this._maybeResetRunnables() | ||
}, | ||
|
||
cancel () { | ||
this.restoreGrepSettings() | ||
mschile marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
astone123 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
this.reset() | ||
this.clearRunnableIds() | ||
this._removeUrlParams() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.