cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.

Home Page:https://cypress.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cy.session does not restore chat session since upgrades from Cypress v10.10

jeanabanto opened this issue · comments

Current behavior

Up until Cypress v10.10, chat sessions are restored successfully with cy.session.

cy.session_v10.10.0_1.mov

Since Cypress 11, and the current v12, chat sessions are not restored successfully, and in effect starts a new chat session.

cy.session_v10.11.0_1.mov

Desired behavior

Chat session should be restored successfully, i.e., chat history should not be deleted so that the app does not create a new session that in effect generates a new Zendesk ticket.

Test code to reproduce

This repo currently has Cypress v10.10 installed, thus is expected to pass the test.
Upgrading Cypress to 11 or the latest release will fail the same test.

https://github.com/jeanabanto/cypress-zendesk-chat/blob/main/cypress/tests/chat.spec.ts

Note: If trial period in Zendesk expires and the account used in this repo stops working, you can easily create your own trial account in Zendesk with chat and replace the relevant environment variables.

Cypress Version

12.3.0

Node version

16.15.0

Operating System

macOS 13.1 (22C65)

Debug Logs

No response

Other

No response

Looked into this a bit yesterday. Like your video shows (and my testing), it looks like you're having issues with the 10.10.0 -> 10.11.0 upgrade. There were changes to both cy.session and cy.origin and you utilize both in your test (iframe widgets).

Yes, this has been a blocker for our chat test scenarios. Would appreciate if this gets resolved soon or at least have any workaround for this (other than downgrading cypress).

I've just started using cy.session and I thought that I was doing something wrong. However, it looks like there is an issue inside Cypress itself.
It would be nice to have this resolved soon as it's a blocker for our tests.

I noticed if I don't use cy.visit() in it(), works as expected, the session is restored successfully.
Before:

beforeEach(() => {
  cy.session([username, password], () => {
    cy.login(username, password);
  },
    {
      validate() { cy.visit('/'); }
    });
});

it('Test 1', () => {});

it('Test 1', () => {});

But if I add cy.visit() to the test, the session is not restored properly.
After:

beforeEach(() => {
  cy.session([username, password], () => {
    cy.login(username, password);
  },
    {
      validate() { cy.visit('/'); }
    });
});

it('Test 1', () => {
cy.visit('/');
});

it('Test 1', () => {
cy.visit('/');
});

@jeanabanto I am picking this up from @ZachJW34

Can you send an entire recording of your Cypress test in Cypress open mode that show the reporter as well. When I try to reproduce this, this is afar as I can get with your code. (see video)

Screen.Recording.2023-02-03.at.3.49.05.PM.mov

@bubafinder Are you able to create a self-contained example project of what you are encountering? Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.

@jeanabanto Are there additional settings I need to change in my Zenhub account to get it to match how yours is set up?

@warrensplayer I'm not sure why the chat is not loading properly for you so I've created a new trial environment. Please pull the updates from https://github.com/jeanabanto/cypress-zendesk-chat.

Also, here's a full recording of the test in v10.10

chat.recording_compressed.mp4

Thanks for the reproduction @jeanabanto, I can see the test passing in 10.10 and failing in present version of Cypress, I have routed this to the team to look into the cy.session() issue.

Note for future investigation - appears to start in 11.0.1, and is not affected by turning testIsolation off.

I noticed if I don't use cy.visit() in it(), works as expected, the session is restored successfully. Before:

beforeEach(() => {
  cy.session([username, password], () => {
    cy.login(username, password);
  },
    {
      validate() { cy.visit('/'); }
    });
});

it('Test 1', () => {});

it('Test 1', () => {});

But if I add cy.visit() to the test, the session is not restored properly. After:

beforeEach(() => {
  cy.session([username, password], () => {
    cy.login(username, password);
  },
    {
      validate() { cy.visit('/'); }
    });
});

it('Test 1', () => {
cy.visit('/');
});

it('Test 1', () => {
cy.visit('/');
});

The quoted issue is probably caused by #25495