cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.8k stars 3.17k forks source link

Cookies problem with experimentalSessionAndOrigin #24149

Closed HumptyHans closed 2 years ago

HumptyHans commented 2 years ago

Current behavior

The view of some pages depends on the option chosen in the \<select> element. Choosing an option changes the value of a specific cookie.

After enabling experimentalSessionAndOrigin selecting another view of the page is impossible, as the cookie is not updated.

The behavior of the page opened from cypress is shown in the video, although for some reason the select itself did not get captured:

https://user-images.githubusercontent.com/56405662/194306565-6e5248cc-9445-4a6f-9441-53da9988d353.mp4

Removing experimentalSessionAndOrigin: true from the config file resolves the issue.

Desired behavior

The correct behavior of the page is shown in the video: (select cannot be seen but it is there)

https://user-images.githubusercontent.com/56405662/194307717-2313b7be-8de7-4149-961f-957decae3bf0.mp4

Test code to reproduce

cypress.config.ts

import { defineConfig } from 'cypress';
import { readPdf } from './cypress/support/pdfHelpers';

export default defineConfig({
    e2e: {
        setupNodeEvents(
            on: Cypress.PluginEvents,
            config: Cypress.PluginConfigOptions
        ) {
            on('task', {
                readPdf,
            });
        },
        baseUrl: '***',
        env: {
            environment: 'test',
        },
        watchForFileChanges: false,
        retries: {
            runMode: 2,
            openMode: 0,
        },
        video: false,
        numTestsKeptInMemory: 15,
        experimentalSessionAndOrigin: true,
        testIsolation: 'legacy', // sometimes left in, sometimes commented out
    },
});

Cypress Version

10.9

Node version

16.17.0

Operating System

Linux Mint 20.3

Debug Logs

Click to open logs

``` cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/stock/purords?interface=ajax' }, request: undefined } +220ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +87ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +86ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:server:remote-states getting primary remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +2ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +63ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://app.mrpeasy.com.test/tasks/list +63ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +0ms cypress:server:stream_buffer stream buffer writeable final called +151ms cypress:network:agent addRequest called { isHttps: true, href: 'https://app.mrpeasy.com.test/tasks/list' } +150ms cypress:network:agent got family { family: 4, href: 'https://app.mrpeasy.com.test/tasks/list' } +0ms cypress:server:request received status code & headers on request { requestId: 'request34', statusCode: 200, headers: { 'content-type': 'text/html; charset=UTF-8', 'set-cookie': [ 'MRP-APP-ID=50; secure; SameSite=None; path=/; HttpOnly' ] } } +115ms cypress:server:request successful response received { requestId: 'request34' } +1ms cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/tasks/list' }, request: undefined } +116ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +51ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +51ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:server:remote-states getting primary remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +3ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +6ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://app.mrpeasy.com.test/create-button-links +6ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +1ms cypress:server:stream_buffer stream buffer writeable final called +60ms cypress:network:agent addRequest called { isHttps: true, href: 'https://app.mrpeasy.com.test/create-button-links' } +61ms cypress:network:agent got family { family: 4, href: 'https://app.mrpeasy.com.test/create-button-links' } +0ms cypress:server:request received status code & headers on request { requestId: 'request35', statusCode: 200, headers: { 'content-type': 'application/json', 'set-cookie': [ 'MRP-APP-ID=50; secure; SameSite=None; path=/; HttpOnly' ] } } +59ms cypress:server:request successful response received { requestId: 'request35' } +0ms cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/create-button-links' }, request: undefined } +59ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +49ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +49ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:server:remote-states getting primary remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +1ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1s cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +2ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://app.mrpeasy.com.test/stock/purords?interface=ajax +1s cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +0ms cypress:server:stream_buffer stream buffer writeable final called +1s cypress:network:agent addRequest called { isHttps: true, href: 'https://app.mrpeasy.com.test/stock/purords?interface=ajax' } +1s cypress:network:agent got family { family: 4, href: 'https://app.mrpeasy.com.test/stock/purords?interface=ajax' } +0ms cypress:server:request received status code & headers on request { requestId: 'request36', statusCode: 200, headers: { 'content-type': 'text/html; charset=UTF-8', 'set-cookie': [ 'MRP-APP-ID=50; secure; SameSite=None; path=/; HttpOnly', 'pur_ord_type_1=10; secure; SameSite=None; expires=Sat, 05-Nov-2022 12:10:35 GMT; path=/' ] } } +1s cypress:server:request successful response received { requestId: 'request36' } +0ms cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/stock/purords?interface=ajax' }, request: undefined } +1s cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +110ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +110ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:server:remote-states getting primary remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +0ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +1ms cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 58324 } +4s cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 50490 } +431ms cypress:server:server-base Got CONNECT request from region1.google-analytics.com:443 +5s cypress:https-proxy Writing browserSocket connection headers { url: 'region1.google-analytics.com:443', headLength: 0, headers: { host: 'region1.google-analytics.com:443', 'proxy-connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Cypress/10.9.0 Chrome/102.0.5005.148 Electron/19.0.8 Safari/537.36' } } +5s cypress:https-proxy Got first head bytes { url: 'region1.google-analytics.com:443', head: "\x16\x03\x01\x02@\x01\x00\x02<\x03\x03\x1E(5(�j��0�'����Ʀ�>�zz���SG����4 \x14C�,\b\r8�X8��\x0B�5�b͞�L4" } +1ms cypress:https-proxy Making intercepted connection to 33439 +0ms cypress:network:connect successfully connected { opts: { port: 33439, host: 'localhost', getDelayMsForRetry: [Function: getDelayForRetry] }, iteration: 0 } +5s cypress:https-proxy received upstreamSocket callback for request { port: 33439, hostname: 'localhost', err: undefined } +2ms cypress:server:util:socket_allowed allowing socket { localPort: 48170 } +148ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +3s cypress:network:cors Parsed URL { port: '443', tld: 'com', domain: 'google-analytics' } +1ms cypress:network:cors Parsed URL { port: '443', tld: 'com', domain: 'google-analytics' } +8ms cypress:server:remote-states getting remote state: undefined for: https://region1.google-analytics.com/g/collect?v=2&tid=G-Y5PKEP9JE5>m=2oea50&_p=1952409626&cid=425205416.1665058234&ul=en-us&sr=1920x1080&uaa=x86&uab=64&uafvl=%2520Not%2520A%253BBrand%3B99.0.0.0%7CChromium%3B102.0.5005.148&uamb=0&uam=&uap=Linux&uapv=5.4.0&uaw=0&uid=50-1&sid=1665058225&sct=1&seg=1&dl=https%3A%2F%2Fapp.mrpeasy.com.test%2F&dt=Purchase%20orders%20-%20Manufacturing%20resource%20planning%20system&_s=1 +3s cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +0ms cypress:server:stream_buffer appending chunk to buffer { bytesWritten: 0, chunkLength: 524 } +3s cypress:network:agent addRequest called { isHttps: true, href: 'https://region1.google-analytics.com/g/collect?v=2&tid=G-Y5PKEP9JE5>m=2oea50&_p=1952409626&cid=425205416.1665058234&ul=en-us&sr=1920x1080&uaa=x86&uab=64&uafvl=%2520Not%2520A%253BBrand%3B99.0.0.0%7CChromium%3B102.0.5005.148&uamb=0&uam=&uap=Linux&uapv=5.4.0&uaw=0&uid=50-1&sid=1665058225&sct=1&seg=1&dl=https%3A%2F%2Fapp.mrpeasy.com.test%2F&dt=Purchase%20orders%20-%20Manufacturing%20resource%20planning%20system&_s=1' } +3s cypress:network:agent got family { family: 4, href: 'https://region1.google-analytics.com/g/collect?v=2&tid=G-Y5PKEP9JE5>m=2oea50&_p=1952409626&cid=425205416.1665058234&ul=en-us&sr=1920x1080&uaa=x86&uab=64&uafvl=%2520Not%2520A%253BBrand%3B99.0.0.0%7CChromium%3B102.0.5005.148&uamb=0&uam=&uap=Linux&uapv=5.4.0&uaw=0&uid=50-1&sid=1665058225&sct=1&seg=1&dl=https%3A%2F%2Fapp.mrpeasy.com.test%2F&dt=Purchase%20orders%20-%20Manufacturing%20resource%20planning%20system&_s=1' } +0ms cypress:server:stream_buffer stream buffer writeable final called +2ms cypress:server:request received status code & headers on request { requestId: 'request37', statusCode: 204, headers: { 'content-type': 'text/plain' } } +3s cypress:server:request successful response received { requestId: 'request37' } +0ms cypress:net-stubbing:server:intercept-response InterceptResponse { req: { url: '/g/collect?v=2&tid=G-Y5PKEP9JE5>m=2oea50&_p=1952409626&cid=425205416.1665058234&ul=en-us&sr=1920x1080&uaa=x86&uab=64&uafvl=%2520Not%2520A%253BBrand%3B99.0.0.0%7CChromium%3B102.0.5005.148&uamb=0&uam=&uap=Linux&uapv=5.4.0&uaw=0&uid=50-1&sid=1665058225&sct=1&seg=1&dl=https%3A%2F%2Fapp.mrpeasy.com.test%2F&dt=Purchase%20orders%20-%20Manufacturing%20resource%20planning%20system&_s=1' }, request: undefined } +3s cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +18ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +18ms cypress:network:cors Parsed URL { port: '443', tld: 'com', domain: 'google-analytics' } +1ms cypress:server:remote-states getting primary remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } +1ms cypress:network:cors Parsed URL { port: '443', tld: 'com', domain: 'google-analytics' } +0ms cypress:network:cors Parsed URL { port: '443', tld: 'test', domain: 'com' } +1ms cypress:server:remote-states getting remote state: { auth: null, origin: 'https://app.mrpeasy.com.test', strategy: 'http', fileServer: null, domainName: 'com.test', props: { port: '443', tld: 'test', domain: 'com' } } for: https://com.test +1ms cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 50504 } +53ms cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 50482 } +118ms cypress:server:socket-base automation:request take:screenshot { titles: [ 'Procurement navigation tests', 'Navigate to Purchase orders select Items' ], testId: 'r3', testAttemptIndex: 1, simple: true, testFailure: true, capture: 'runner', clip: { x: 0, y: 0, width: 1000, height: 660 }, viewport: { width: 1280, height: 720 }, scaled: true, blackout: [], overwrite: false, startTime: '2022-10-06T12:10:39.810Z' } +7s cypress:server:screenshot (s38) capturing screenshot { titles: [ 'Procurement navigation tests', 'Navigate to Purchase orders select Items' ], testId: 'r3', testAttemptIndex: 1, simple: true, testFailure: true, capture: 'runner', clip: { x: 0, y: 0, width: 1000, height: 660 }, viewport: { width: 1280, height: 720 }, scaled: true, blackout: [], overwrite: false, startTime: '2022-10-06T12:10:39.810Z', specName: 'navigation-tests-procurement.cy.ts' } +8s cypress:server:screenshot (s38) ensureSafePath { withoutExt: '/home/eva/Mrpeasy/mrpeasy_e2e_tests/cypress/screenshots/navigation-tests-procurement.cy.ts/Procurement navigation tests -- Navigate to Purchase orders select Items (failed) (attempt 2)', extension: 'png', num: 0, maxSafeBytes: 254, maxSafePrefixBytes: 250 } +102ms cypress:server:screenshot (s38) save /home/eva/Mrpeasy/mrpeasy_e2e_tests/cypress/screenshots/navigation-tests-procurement.cy.ts/Procurement navigation tests -- Navigate to Purchase orders select Items (failed) (attempt 2).png +1ms cypress:lifecycle:EventRegistrar plugin event registered? { eventName: 'after:screenshot', isRegistered: false } +8s (Attempt 2 of 3) Navigate to Purchase orders select Items cypress:server:project onMocha retry +6s cypress:server:project onMocha test:after:run +48ms cypress:server:reporter got mocha event 'test:after:run' with args: [ { _testConfig: { testConfigList: [], unverifiedTestConfig: {}, applied: 'complete' }, id: 'r3', title: 'Navigate to Purchase orders select Items', err: { message: "Timed out retrying after 4000ms: expected '

Other

No response

mjhenkes commented 2 years ago

@HumptyHans, We've recently made several fixes around cookies not applying correctly with origin. Could you try your use case with our pre-release cypress version?

See this comment for more details on how to install the pre-release. https://github.com/cypress-io/cypress/commit/eaa1de7ff76cf0ae6730e8df19594b60b762be01#commitcomment-86037659

HumptyHans commented 2 years ago

@mjhenkes Yes, it worked!

Thank you very much for your answer! Will be waiting for version 10.10!