Skip to content

Commit

Permalink
Fix integration tests to account for deprecated types
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein committed Sep 3, 2024
1 parent 1b658d3 commit 79470a4
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ declare var findFirstEventForPageViewId: (id: string) => Record<string, unknown>
declare var findLastEventForPageViewId: (id: string) => Record<string, unknown>;

describe('Activity tracking with callbacks', () => {
if (browser.capabilities.browserName === 'internet explorer') {
fit('Skip IE', () => true);
const browserName = 'browserName' in browser.capabilities && browser.capabilities.browserName;
if (browserName === 'internet explorer') {
fit('Skip IE', () => {});
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const loadUrlAndWait = async (url: string) => {
};

describe('Snowplow Micro integration', () => {
if (browser.capabilities.browserName === 'internet explorer') {
fit('Skip IE', () => true);
const browserName = 'browserName' in browser.capabilities && browser.capabilities.browserName;
if (browserName === 'internet explorer') {
fit('Skip IE', () => {});
return;
}

Expand Down
5 changes: 3 additions & 2 deletions trackers/javascript-tracker/test/integration/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { WaitUntilOptions } from 'webdriverio';
import util from 'util';
import { Capabilities } from '@wdio/types';

declare module WebdriverIO {
interface Browser {
Expand Down Expand Up @@ -48,8 +49,8 @@ export async function pageSetup() {
if (!dockerUrl) {
throw 'dockerInstanceUrl not available in `browser.sharedStore`';
}
const testIdentifier =
browser.capabilities.browserName + '_' + browser.capabilities.browserVersion + '_' + Math.random();
const capabilities = browser.capabilities as Capabilities.DesiredCapabilities;
const testIdentifier = capabilities.browserName + '_' + capabilities.browserVersion + '_' + Math.random();
await browser.url('/index.html');
await browser.setCookies([
{ name: 'container', value: dockerUrl },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ const geoContext = {
};

describe('Snowplow Micro integration', () => {
if (browser.capabilities.browserName === 'internet explorer') {
fit('Skip IE', () => true);
const browserName = 'browserName' in browser.capabilities && browser.capabilities.browserName;
if (browserName === 'internet explorer') {
fit('Skip IE', () => {});
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
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 (
browser.capabilities.browserName === 'internet explorer' &&
(browser.capabilities.version === '9' || browser.capabilities.browserVersion === '10')
capabilities.browserName === 'internet explorer' &&
(capabilities.version === '9' || capabilities.browserVersion === '10')
) {
fit('Skip IE 9 and 10', () => true);
fit('Skip IE 9 and 10', () => {});
return;
}

if (browser.capabilities.browserName === 'safari' && browser.capabilities.version === '8.0') {
fit('Skip Safari 8', () => true);
if (capabilities.browserName === 'safari' && capabilities.version === '8.0') {
fit('Skip Safari 8', () => {});
return;
}

Expand Down
24 changes: 14 additions & 10 deletions trackers/javascript-tracker/test/media/media.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from 'lodash';
import { fetchResults } from '../micro';
import { pageSetup, waitUntil } from '../integration/helpers';
import { Capabilities } from '@wdio/types';

const playVideoElement1Callback = () => {
return (done: (_: void) => void) => {
Expand Down Expand Up @@ -102,7 +103,8 @@ const makeExpectedEvent = (
},
};

if (browser.capabilities.browserName === 'internet explorer') {
const browserName = 'browserName' in browser.capabilities && browser.capabilities.browserName;
if (browserName === 'internet explorer') {
data.context[0].data.defaultMuted = false;
}

Expand Down Expand Up @@ -151,16 +153,17 @@ describe('Media Tracking', () => {
}
};

const capabilities = browser.capabilities as Capabilities.DesiredCapabilities;
if (
browser.capabilities.browserName === 'internet explorer' &&
(browser.capabilities.version === '9' || browser.capabilities.browserVersion === '10')
capabilities.browserName === 'internet explorer' &&
(capabilities.version === '9' || capabilities.browserVersion === '10')
) {
fit('Skip IE 9 and 10', () => true);
fit('Skip IE 9 and 10', () => {});
return;
}

if (browser.capabilities.browserName === 'safari' && browser.capabilities.version === '8.0') {
fit('Skip Safari 8', () => true);
if (capabilities.browserName === 'safari' && capabilities.version === '8.0') {
fit('Skip Safari 8', () => {});
return;
}

Expand Down Expand Up @@ -515,13 +518,14 @@ describe('Media Tracking', () => {
Object.entries(expected).forEach(([name, properties]) => {
// I can't find a good way of triggering an error event for firefox 53 or chrome 60, so they can
// be skipped for now (events past 'error' are fired as a result of the error occouring)
const capabilities = browser.capabilities as Capabilities.DesiredCapabilities;
if (
(name === 'error' &&
browser.capabilities.browserName === 'firefox' &&
browser.capabilities.browserVersion === '53.0') ||
(browser.capabilities.browserName === 'chrome' && browser.capabilities.version === '60.0.3112.78')
capabilities.browserName === 'firefox' &&
capabilities.browserVersion === '53.0') ||
(capabilities.browserName === 'chrome' && capabilities.version === '60.0.3112.78')
) {
fit('Skip events from error', () => true);
fit('Skip events from error', () => {});
return;
} else {
it('tracks ' + name, () => {
Expand Down
26 changes: 14 additions & 12 deletions trackers/javascript-tracker/test/media/vimeo.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { VimeoEvent } from '@snowplow/browser-plugin-vimeo-tracking';
import { pageSetup } from '../integration/helpers';
import { fetchResults } from '../micro';
import { Capabilities } from '@wdio/types';

function compareContextObjects(expected: any, received: any) {
expect(expected.schema).toEqual(received.schema);
Expand Down Expand Up @@ -51,37 +52,38 @@ const makeContext = () => {
};

const skipBrowsers = (browser: any) => {
if (browser.capabilities.browserName === 'internet explorer' && browser.capabilities.version === '9') {
fit('Skip IE 9', () => true);
const capabilities = browser.capabilities as Capabilities.DesiredCapabilities;
if (capabilities.browserName === 'internet explorer' && capabilities.version === '9') {
fit('Skip IE 9', () => {});
return;
}

if (browser.capabilities.browserName === 'internet explorer' && browser.capabilities.browserVersion === '10') {
fit('Skip IE 10', () => true);
if (capabilities.browserName === 'internet explorer' && capabilities.browserVersion === '10') {
fit('Skip IE 10', () => {});
return;
}

// element not interactable: Element is not displayed
if (browser.capabilities.browserName === 'internet explorer' && browser.capabilities.browserVersion === '11') {
fit('Skip IE 11', () => true);
if (capabilities.browserName === 'internet explorer' && capabilities.browserVersion === '11') {
fit('Skip IE 11', () => {});
return;
}

// Unknown command: {"name":"sendKeysToActiveElement","parameters":{"value":["k"]}}
if (browser.capabilities.browserName === 'safari' && browser.capabilities.version === '8.0') {
fit('Skip Safari 8', () => true);
if (capabilities.browserName === 'safari' && capabilities.version === '8.0') {
fit('Skip Safari 8', () => {});
return;
}

// Element is obscured (WARNING: The server did not provide any stacktrace information)
if (browser.capabilities.browserName === 'MicrosoftEdge' && browser.capabilities.browserVersion === '13.10586') {
fit('Skip Edge 13', () => true);
if (capabilities.browserName === 'MicrosoftEdge' && capabilities.browserVersion === '13.10586') {
fit('Skip Edge 13', () => {});
return;
}

// Driver info: driver.version: unknown
if (browser.capabilities.browserName === 'firefox' && browser.capabilities.version === '53.0') {
fit('Skip Firefox 53', () => true);
if (capabilities.browserName === 'firefox' && capabilities.version === '53.0') {
fit('Skip Firefox 53', () => {});
return;
}
};
Expand Down
21 changes: 12 additions & 9 deletions trackers/javascript-tracker/test/media/youtube.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fetchResults } from '../micro';
import { pageSetup, waitUntil } from '../integration/helpers';
import { Capabilities } from '@wdio/types';

declare var player: YT.Player;

Expand Down Expand Up @@ -67,14 +68,15 @@ const compare = (expected: any, received: any) => {
let log: Array<unknown> = [];

function shouldSkipBrowser(browser: any): boolean {
const capabilities = browser.capabilities as Capabilities.DesiredCapabilities;
return (
browser.capabilities.browserName === 'internet explorer' ||
capabilities.browserName === 'internet explorer' ||
// Unknown command: {"name":"sendKeysToActiveElement","parameters":{"value":["k"]}}, Safari 12 keeps crashing
(browser.capabilities.browserName === 'safari' && browser.capabilities.browserVersion < 14) ||
(capabilities.browserName === 'safari' && parseInt(capabilities.browserVersion ?? "") < 14) ||
// Element is obscured (WARNING: The server did not provide any stacktrace information)
(browser.capabilities.browserName === 'MicrosoftEdge' && browser.capabilities.browserVersion === '13.10586') ||
(capabilities.browserName === 'MicrosoftEdge' && capabilities.browserVersion === '13.10586') ||
// Driver info: driver.version: unknown
(browser.capabilities.browserName === 'firefox' && browser.capabilities.version === '53.0')
(capabilities.browserName === 'firefox' && capabilities.version === '53.0')
);
}

Expand Down Expand Up @@ -112,7 +114,7 @@ describe('Youtube tracking', () => {

describe('YouTube Tracker', () => {
if (shouldSkipBrowser(browser)) {
fit('Skip browser', () => true);
fit('Skip browser', () => {});
return;
}

Expand Down Expand Up @@ -188,13 +190,14 @@ describe('Youtube tracking', () => {
};

Object.entries(expected).forEach(([name, properties]) => {
if (browser.capabilities.browserName === 'internet explorer' && name === 'playbackratechange') {
const capabilities = browser.capabilities as Capabilities.DesiredCapabilities;
if (capabilities.browserName === 'internet explorer' && name === 'playbackratechange') {
return;
// The hotkey for playback rate change doesn't work in IE
// Trying to create a key sequence to change the option in the UI has proved to be
// very unreliable, so this test is skipped
}
if (browser.capabilities.browserName === 'safari' && name == 'percentprogress') {
if (capabilities.browserName === 'safari' && name == 'percentprogress') {
return;
// percentprogress events seem not be tracked reliably in Safari, should investigate why
}
Expand All @@ -208,7 +211,7 @@ describe('Youtube tracking', () => {

describe('YouTube Tracker (2 videos, 1 tracker)', () => {
if (shouldSkipBrowser(browser)) {
fit('Skip browser', () => true);
fit('Skip browser', () => {});
return;
}

Expand Down Expand Up @@ -251,7 +254,7 @@ describe('Youtube tracking', () => {

describe('YouTube Tracker (1 video, 2 trackers)', () => {
if (shouldSkipBrowser(browser)) {
fit('Skip browser', () => true);
fit('Skip browser', () => {});
return;
}

Expand Down

0 comments on commit 79470a4

Please sign in to comment.