fix: do not override existingSession setup (#21226)

Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
This commit is contained in:
Sam Tsai
2022-04-28 17:56:44 -04:00
committed by GitHub
parent bc01e44338
commit 51b4bdc2ce
2 changed files with 27 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
// @see https://github.com/cypress-io/cypress/issues/17805
describe('issue 17805', { experimentalSessionAndOrigin: true }, () => {
it('recreates session on spec reload in open mode', () => {
let validateFlag = false
cy.session('persist_session', () => {
validateFlag = true
},
{
validate () {
if (validateFlag) {
return true
}
return false
},
})
})
after(() => {
if (cy.$$('.commands-container li.command:first', top.document).text().includes('(new)')) {
top.location.reload()
}
})
})

View File

@@ -209,7 +209,7 @@ export default function (Commands, Cypress, cy) {
* 1) if we only need currentOrigin localStorage, access sync
* 2) if cross-origin http, we need to load in iframe from our proxy that will intercept all http reqs at /__cypress/automation/*
* and postMessage() the localStorage value to us
* 3) if cross-origin https, since we pass-thru https conntections in the proxy, we need to
* 3) if cross-origin https, since we pass-thru https connections in the proxy, we need to
* send a message telling our proxy server to intercept the next req to the https domain,
* then follow 2)
*/
@@ -638,7 +638,7 @@ export default function (Commands, Cypress, cy) {
// we have a saved session on the server AND setup matches
if (serverStoredSession && serverStoredSession.setup === existingSession.setup.toString()) {
_.extend(existingSession, serverStoredSession)
_.extend(existingSession, _.omit(serverStoredSession, 'setup'))
existingSession.hydrated = true
} else {
onValidationError = throwValidationError