diff --git a/packages/driver/cypress/integration/issues/17805_spec.js b/packages/driver/cypress/integration/issues/17805_spec.js new file mode 100644 index 0000000000..e26bf9f0a9 --- /dev/null +++ b/packages/driver/cypress/integration/issues/17805_spec.js @@ -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() + } + }) +}) diff --git a/packages/driver/src/cy/commands/sessions/index.ts b/packages/driver/src/cy/commands/sessions/index.ts index e901955df5..b7268891ee 100644 --- a/packages/driver/src/cy/commands/sessions/index.ts +++ b/packages/driver/src/cy/commands/sessions/index.ts @@ -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