forked from snowplow/snowplow-javascript-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonSessionUpdate.test.ts
More file actions
56 lines (49 loc) · 1.67 KB
/
Copy pathonSessionUpdate.test.ts
File metadata and controls
56 lines (49 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import F from 'lodash/fp';
import { fetchResults } from '../micro';
import { pageSetup } from './helpers';
import { Capabilities } from '@wdio/types';
describe('onSessionUpdate callback feature', () => {
const capabilities = browser.capabilities as Capabilities.DesiredCapabilities;
if (
capabilities.browserName === 'internet explorer' &&
(capabilities.version === '9' || capabilities.browserVersion === '10')
) {
fit('Skip IE 9 and 10', () => {});
return;
}
if (capabilities.browserName === 'safari' && capabilities.version === '8.0') {
fit('Skip Safari 8', () => {});
return;
}
let log: Array<unknown> = [];
let testIdentifier = '';
const logContains = (ev: unknown) => F.some(F.isMatch(ev as object), log);
const loadUrlAndWait = async (url: string) => {
await browser.url(url);
await browser.waitUntil(async () => (await $('#init').getText()) === 'true', {
timeout: 5000,
timeoutMsg: 'expected init after 5s',
interval: 250,
});
};
beforeAll(async () => {
testIdentifier = await pageSetup();
await loadUrlAndWait('/session-update-callback.html');
await browser.pause(2000);
log = await browser.call(async () => await fetchResults());
});
it(`properly runs the onSessionCallback`, async () => {
expect(
logContains({
event: {
app_id: 'onSessionCallback' + testIdentifier,
event: 'struct',
se_category: 'session_callback',
se_action: 'called',
},
})
).toBe(true);
const results = log.filter((event: any) => event.event.app_id === 'onSessionCallback' + testIdentifier);
expect(results.length).toEqual(2);
});
});