|
| 1 | +const { assert } = require('chai'); |
| 2 | +const fs = require('fs-extra'); |
| 3 | +const path = require('path'); |
| 4 | +const bootstrap = require('../test-bootstrap.js'); |
| 5 | + |
| 6 | +describe('Session cookies', function() { |
| 7 | + let app; |
| 8 | + before(async () => { |
| 9 | + await fs.outputJson(bootstrap.settingsFilePath, { |
| 10 | + ignoreSessionCookies: true |
| 11 | + }); |
| 12 | + app = await bootstrap.runAppDeffered(2000); |
| 13 | + }); |
| 14 | + |
| 15 | + after(async () => { |
| 16 | + if (app && app.isRunning()) { |
| 17 | + await app.stop(); |
| 18 | + } |
| 19 | + const basePath = path.join('test', 'playground'); |
| 20 | + await fs.remove(basePath); |
| 21 | + }); |
| 22 | + |
| 23 | + it('sets ignoreSessionCookies on CookieBridge when init', async () => { |
| 24 | + const result = await app.client.execute(async () => { |
| 25 | + /* global initScript */ |
| 26 | + return initScript.cookieBridge.ignoreSessionCookies; |
| 27 | + }); |
| 28 | + assert.isTrue(result.value); |
| 29 | + }); |
| 30 | + |
| 31 | + it('updates ignoreSessionCookies on CookieBridge instance', async () => { |
| 32 | + const result = await app.client.execute(async () => { |
| 33 | + document.body.dispatchEvent(new CustomEvent('settings-changed', { |
| 34 | + bubbles: true, |
| 35 | + detail: { |
| 36 | + name: 'ignoreSessionCookies', |
| 37 | + value: false, |
| 38 | + } |
| 39 | + })); |
| 40 | + return initScript.cookieBridge.ignoreSessionCookies; |
| 41 | + }); |
| 42 | + assert.isFalse(result.value); |
| 43 | + }); |
| 44 | + |
| 45 | + it('ignores other setting change events', async () => { |
| 46 | + const result = await app.client.execute(async () => { |
| 47 | + document.body.dispatchEvent(new CustomEvent('settings-changed', { |
| 48 | + bubbles: true, |
| 49 | + detail: { |
| 50 | + name: 'a', |
| 51 | + value: 'b', |
| 52 | + } |
| 53 | + })); |
| 54 | + return initScript.cookieBridge.ignoreSessionCookies; |
| 55 | + }); |
| 56 | + assert.isFalse(result.value); |
| 57 | + }); |
| 58 | +}); |
0 commit comments