|
1 | 1 | import { mockClock, getSessionState, registerCleanupTask } from '../../../../test' |
2 | | -import { setCookie, deleteCookie, getCookie, getCurrentSite } from '../../../browser/cookie' |
| 2 | +import { setCookie, deleteCookie, getCookie } from '../../../browser/cookie' |
3 | 3 | import type { SessionState } from '../sessionState' |
4 | 4 | import { validateAndBuildConfiguration } from '../../configuration' |
5 | 5 | import type { InitConfiguration } from '../../configuration' |
@@ -93,28 +93,29 @@ describe('session in cookie strategy', () => { |
93 | 93 | { |
94 | 94 | initConfiguration: { clientToken: 'abc' }, |
95 | 95 | cookieOptions: {}, |
96 | | - cookieString: /^dd_cookie_test_[\w-]+=[^;]*;expires=[^;]+;path=\/;samesite=strict$/, |
| 96 | + cookieString: /^dd_[\w_-]+=[^;]*;expires=[^;]+;path=\/;samesite=strict$/, |
97 | 97 | description: 'should set samesite to strict by default', |
98 | 98 | }, |
99 | 99 | { |
100 | 100 | initConfiguration: { clientToken: 'abc', useSecureSessionCookie: true }, |
101 | 101 | cookieOptions: { secure: true }, |
102 | | - cookieString: /^dd_cookie_test_[\w-]+=[^;]*;expires=[^;]+;path=\/;samesite=strict;secure$/, |
| 102 | + cookieString: /^dd_[\w_-]+=[^;]*;expires=[^;]+;path=\/;samesite=strict;secure$/, |
103 | 103 | description: 'should add secure attribute when defined', |
104 | 104 | }, |
105 | 105 | { |
106 | 106 | initConfiguration: { clientToken: 'abc', trackSessionAcrossSubdomains: true }, |
107 | 107 | cookieOptions: { domain: 'foo.bar' }, |
108 | | - cookieString: new RegExp( |
109 | | - `^dd_cookie_test_[\\w-]+=[^;]*;expires=[^;]+;path=\\/;samesite=strict;domain=${getCurrentSite()}$` |
110 | | - ), |
| 108 | + cookieString: new RegExp('^dd_[\\w_-]+=[^;]*;expires=[^;]+;path=\\/;samesite=strict;domain='), |
111 | 109 | description: 'should set cookie domain when tracking accross subdomains', |
112 | 110 | }, |
113 | 111 | ].forEach(({ description, initConfiguration, cookieString }) => { |
114 | 112 | it(description, () => { |
115 | 113 | const cookieSetSpy = spyOnProperty(document, 'cookie', 'set') |
116 | 114 | selectCookieStrategy(initConfiguration) |
117 | | - expect(cookieSetSpy.calls.argsFor(0)[0]).toMatch(cookieString) |
| 115 | + expect(cookieSetSpy).toHaveBeenCalled() |
| 116 | + for (const call of cookieSetSpy.calls.all()) { |
| 117 | + expect(call.args[0]).toMatch(cookieString) |
| 118 | + } |
118 | 119 | }) |
119 | 120 | }) |
120 | 121 | }) |
|
0 commit comments