tests: Always set cookie path to / (to match non-test behavior)
parent
5666c34061
commit
137fa89d2a
|
@ -59,19 +59,14 @@ const helper = {};
|
|||
|
||||
// Can only happen when the iframe exists, so we're doing it separately from other cookies
|
||||
helper.clearPadPrefCookie = () => {
|
||||
helper.padChrome$.document.cookie = 'prefsHttp=;expires=Thu, 01 Jan 1970 00:00:00 GMT';
|
||||
helper.padChrome$.document.cookie = 'prefsHttp=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
|
||||
};
|
||||
|
||||
// Overwrite all prefs in pad cookie. Assumes http, not https.
|
||||
//
|
||||
// `helper.padChrome$.document.cookie` (the iframe) and `window.document.cookie`
|
||||
// seem to have independent cookies, UNLESS we put path=/ here (which we don't).
|
||||
// I don't fully understand it, but this function seems to properly simulate
|
||||
// padCookie.setPref in the client code
|
||||
helper.setPadPrefCookie = (prefs) => {
|
||||
const val = encodeURIComponent(JSON.stringify(prefs));
|
||||
helper.padChrome$.document.cookie =
|
||||
`prefsHttp=${val};expires=Thu, 01 Jan 3000 00:00:00 GMT`;
|
||||
`prefsHttp=${val};expires=Thu, 01 Jan 3000 00:00:00 GMT; path=/`;
|
||||
};
|
||||
|
||||
// Functionality for knowing what key event type is required for tests
|
||||
|
|
|
@ -76,14 +76,9 @@ describe('the test helper', function () {
|
|||
|
||||
// Now that we have a chrome, we can set a pad cookie
|
||||
// so we can confirm it gets wiped as well
|
||||
chrome$.document.cookie = 'prefsHtml=baz;expires=Thu, 01 Jan 3030 00:00:00 GMT';
|
||||
chrome$.document.cookie = 'prefsHtml=baz;expires=Thu, 01 Jan 3030 00:00:00 GMT; path=/';
|
||||
expect(chrome$.document.cookie).to.contain('prefsHtml=baz');
|
||||
|
||||
// Cookies are weird. Because it's attached to chrome$ (as helper.setPadCookies does)
|
||||
// AND we didn't put path=/, we shouldn't expect it to be visible on
|
||||
// window.document.cookie. Let's just be sure.
|
||||
expect(window.document.cookie).to.not.contain('prefsHtml=baz');
|
||||
|
||||
// give it a second to save the username on the server side
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
|
||||
|
@ -96,7 +91,6 @@ describe('the test helper', function () {
|
|||
expect(window.document.cookie).to.not.contain('token=foo');
|
||||
expect(window.document.cookie).to.not.contain('language=bar');
|
||||
expect(chrome$.document.cookie).to.contain('prefsHtml=baz');
|
||||
expect(window.document.cookie).to.not.contain('prefsHtml=baz');
|
||||
|
||||
expect(window.document.cookie).to.not.be(firstCookie);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const deletecookie = (name) => {
|
||||
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
|
||||
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/`;
|
||||
};
|
||||
|
||||
describe('Language select and change', function () {
|
||||
|
|
Loading…
Reference in New Issue