From b839e480d930fb6c09be6ddf55dcfd0df0f9e62a Mon Sep 17 00:00:00 2001 From: Vesa Laakso <482561+valscion@users.noreply.github.com> Date: Thu, 5 Jan 2023 15:35:28 +0200 Subject: [PATCH] Show how httpOnly cookies are still broken --- .../allow_reading_session_on_js_side.rb | 6 --- cypress/e2e/spec.cy.js | 40 +++---------------- 2 files changed, 6 insertions(+), 40 deletions(-) delete mode 100644 config/initializers/allow_reading_session_on_js_side.rb diff --git a/config/initializers/allow_reading_session_on_js_side.rb b/config/initializers/allow_reading_session_on_js_side.rb deleted file mode 100644 index f735c38..0000000 --- a/config/initializers/allow_reading_session_on_js_side.rb +++ /dev/null @@ -1,6 +0,0 @@ -Rails.application.config.session_store( - :cookie_store, - key: '_cypress_cookie_issue_reproduction_session', - # We want to be able to read the server-set cookies on JS side - httponly: false -) diff --git a/cypress/e2e/spec.cy.js b/cypress/e2e/spec.cy.js index 01ec7b1..bba9bd7 100644 --- a/cypress/e2e/spec.cy.js +++ b/cypress/e2e/spec.cy.js @@ -4,23 +4,9 @@ describe('issue https://github.com/cypress-io/cypress/issues/25174 reproduction' cy.get('#do-xhr-request').click() cy.contains('A cookie has been set').should('be.visible') - cy.get('#client-cookies-json').invoke('text').should(text => { - const parsedText = JSON.parse(text) - // There should only be one cookie here - expect(parsedText).to.have.length(1) - }); - - // Debug with cy.getAllCookies if that exists (Cypress v12.1.0+ only) - if (cy.getAllCookies) { - cy.getAllCookies().then(cookies => cy.log("Cookie domains are:", cookies.map(c => c.domain))) - } - - cy.get('#client-cookies-json-timeout').invoke('text').should(text => { - const parsedText = JSON.parse(text) - // This is the strange thing! - // There should only be one cookie here, too - expect(parsedText).to.have.length(1) - }); + // This is the strange thing! There should only be one cookie set + cy.getAllCookies().then(cookies => cy.log("Cookie domains are:", cookies.map(c => c.domain))) + cy.getAllCookies().should('have.length', 1) }) it('creates two cookies with a fetch request', () => { @@ -28,22 +14,8 @@ describe('issue https://github.com/cypress-io/cypress/issues/25174 reproduction' cy.get('#do-fetch-request').click() cy.contains('A cookie has been set').should('be.visible') - cy.get('#client-cookies-json').invoke('text').should(text => { - const parsedText = JSON.parse(text) - // There should only be one cookie here - expect(parsedText).to.have.length(1) - }); - - // Debug with cy.getAllCookies if that exists (Cypress v12.1.0+ only) - if (cy.getAllCookies) { - cy.getAllCookies().then(cookies => cy.log("Cookie domains are:", cookies.map(c => c.domain))) - } - - cy.get('#client-cookies-json-timeout').invoke('text').should(text => { - const parsedText = JSON.parse(text) - // This is the strange thing! - // There should only be one cookie here, too - expect(parsedText).to.have.length(1) - }); + // This is the strange thing! There should only be one cookie set + cy.getAllCookies().then(cookies => cy.log("Cookie domains are:", cookies.map(c => c.domain))) + cy.getAllCookies().should('have.length', 1) }) })