Skip to content
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

clearCookie not working anymore in 3.5.0 under certain baseUrls #5453

Closed
jweingarten opened this issue Oct 24, 2019 · 13 comments · Fixed by #5478
Closed

clearCookie not working anymore in 3.5.0 under certain baseUrls #5453

jweingarten opened this issue Oct 24, 2019 · 13 comments · Fixed by #5478
Assignees
Labels
type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0

Comments

@jweingarten
Copy link

jweingarten commented Oct 24, 2019

Our code used to do exactly what the documentation states:

cy.setCookie('foo', 'bar')
cy.clearCookie('foo')
cy.getCookie('foo').should('be.null')

This works with 3.4.1 and started failing with 3.5.0.

Since there are tickets about clearCookies not working this was the only way we actually could delete a specific cookie. Now even that doesn't work any longer.

@jennifer-shehane
Copy link
Member

Hey @jweingarten, the example you provided works in 3.5.0 in Chrome and Electron when run during cypress open in my MacOS Mohave OS.

Screen Shot 2019-10-24 at 1 28 31 PM

Please provide an entirely reproducible example - also, there is an open cookies issue involving 3.5.0 here - #5432 ensure your issue is not related to this one also.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Oct 24, 2019
@jweingarten
Copy link
Author

jweingarten commented Oct 24, 2019

Ok I found what you need to reproduce .... and that is basically setting a baseUrl in cypress.json.

Here the exact steps:

  • mkdir foo
  • cd foo
  • npm install cypress
  • mkdir cypress/integration
  • vi cypress/integration/sample_spec.js
  • copy/paste the following into sample_spec.js
describe('Load Main Dashoard after Login', function() {
    context('Login', function() {
      it('The Main Dashboard should be able to load now', function() {
        cy.setCookie('foo', 'bar')                                                
        cy.clearCookie('foo')
        cy.getCookie('foo').should('be.null')
      });
    });
}); 
  • vi cypress.json
  • copy/paste the following into cypress.json
{
  "baseUrl":"https://www.google.com"
}
  • node_modules/cypress/bin/cypress open
  • click sample_spec.js

Result: AssertionError: expected { Object (name, value, ...) } to be null

@jennifer-shehane
Copy link
Member

@jweingarten Thanks! I can reproduce this after setting a baseUrl in the cypress.json

I also confirmed this was introduced in 3.5.0

3.4.1 DEBUG cookies

Screen Shot 2019-10-24 at 4 01 01 PM

3.5.0 DEBUG cookies

Screen Shot 2019-10-24 at 4 01 56 PM

@jennifer-shehane jennifer-shehane added the type: regression A bug that didn't appear until a specific Cy version release label Oct 24, 2019
@cypress-bot cypress-bot bot added stage: needs investigating Someone from Cypress needs to look at this and removed stage: needs information Not enough info to reproduce the issue labels Oct 24, 2019
@ianldgs
Copy link

ianldgs commented Oct 25, 2019

Not only clearCookie, but apparently lots of things related to cookies and baseUrl.

Our tests have a fast login and logout implementation, like the docs show, that doesn't work anymore after updating to 3.5.0.

cy.request({
  method: 'POST',
  url: '/api/auth',
  body: {
    email,
    password,
  }
})

cy.getCookie('session').should('exist')

@ianldgs
Copy link

ianldgs commented Oct 25, 2019

Related: #3221 (might be fixable together)

@borecz
Copy link

borecz commented Oct 25, 2019

I am having the same.

@flotwig flotwig self-assigned this Oct 25, 2019
@flotwig
Copy link
Contributor

flotwig commented Oct 25, 2019

@ianldgs This is the issue you're having, there is already a fix in develop to be released soon: #5432

@flotwig
Copy link
Contributor

flotwig commented Oct 25, 2019

cy.setCookie('foo', 'bar')
cy.clearCookie('foo')
cy.getCookie('foo').should('be.null')

This works in some cases and fails in others (I've only tested in Electron, but results should be the same in Chrome). Here are the baseUrls I've tested:

So the issue seems related to setting cookies on a FQDN.

I have written some automated tests for this here: #5478

I'll continue working on fixing this in that PR.

@dwelle
Copy link

dwelle commented Oct 25, 2019

Not sure if it's related, but I couldn't get cypress to clear a cookie on a .-leading domain.

@flotwig
Copy link
Contributor

flotwig commented Oct 25, 2019

Thanks for the additional info!

There were some huge changes in how cookies are handled in Cypress 3.5.0. We went from a split approach (using Electron cookies APIs to control Electron and Chrome Extension API to control Chrome) to a different, unified approach (Chrome DevTools Protocol to control both Electron and Chrome). Once we get the initial bugs ironed out, this will hopefully be a much more reliable and maintainable approach.

@PetMou
Copy link

PetMou commented Oct 31, 2019

Additional: we use DELETE requests to reset test data. The GET requests still work, but the DELETE's don't work any more since 3.5.0. The requests now return a 403 status

@jennifer-shehane jennifer-shehane changed the title clearCookie not working anymore in 3.5.0 clearCookie not working anymore in 3.5.0 under certain baseUrls Nov 5, 2019
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Nov 6, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Nov 8, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 8, 2019

The code for this is done in cypress-io/cypress#5478, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 8, 2019

Released in 3.6.1.

@jennifer-shehane jennifer-shehane added the v3.5.0 🐛 Issue present since 3.5.0 label Dec 10, 2019
@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0
Projects
None yet
7 participants