Skip to content

Commit cae6681

Browse files
committed
update tests
1 parent 6c11922 commit cae6681

22 files changed

+38
-21
lines changed

.buildkite/pipeline.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ steps:
8484
- yarn install --immutable
8585
- echo "+++ Run Browser integration tests :pray:"
8686
- yarn turbo run --filter=@internal/browser-integration-tests test:int
87+
- yarn turbo run --filter=@internal/browser-integration-tests test:int
8788
retry:
8889
automatic:
8990
- exit_status: '*'

packages/signals/signals-integration-tests/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
"scripts": {
99
".": "yarn run -T turbo run --filter=@internal/signals-integration-tests...",
1010
"build": "webpack",
11-
"test:int": "playwright test",
11+
"test:int": "playwright test && yarn test:global-sandbox",
1212
"test:vanilla": "playwright test src/tests/signals-vanilla",
1313
"test:perf": "playwright test src/tests/performance",
1414
"test:custom": "playwright test src/tests/custom",
15+
"test:global-sandbox": "SANDBOX_STRATEGY=global yarn test:vanilla && SANDBOX_STRATEGY=global yarn test:custom",
1516
"watch": "webpack -w",
1617
"lint": "yarn concurrently 'yarn:eslint .' 'yarn:tsc --noEmit'",
1718
"concurrently": "yarn run -T concurrently",
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import type { FullConfig } from '@playwright/test'
22
import { execSync } from 'child_process'
3+
import { envConfig } from './src/helpers/env-config'
34

45
export default function globalSetup(_cfg: FullConfig) {
5-
console.log('Executing global setup...')
6+
console.log(`Executing playwright.global-setup.ts...\n`)
7+
console.log(`Using envConfig: ${JSON.stringify(envConfig, undefined, 2)}\n`)
68
execSync('yarn build', { stdio: 'inherit' })
7-
console.log('Finished global setup.')
9+
console.log('Finished global setup.\n')
810
}

packages/signals/signals-integration-tests/src/helpers/base-page-object.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
SignalAPIRequestBuffer,
88
TrackingAPIRequestBuffer,
99
} from './network-utils'
10+
import { envConfig } from './env-config'
1011

1112
export class BasePage {
1213
protected page!: Page
@@ -63,6 +64,7 @@ export class BasePage {
6364
await this.page.goto(url, { waitUntil: 'domcontentloaded' })
6465
if (!options.skipSignalsPluginInit) {
6566
void this.invokeAnalyticsLoad({
67+
sandboxStrategy: envConfig.SANDBOX_STRATEGY ?? 'iframe',
6668
flushInterval: 500,
6769
...signalSettings,
6870
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { SignalsSettingsConfig } from '@segment/analytics-signals/dist/types/core/signals'
2+
3+
// This is for testing with the global sandbox strategy with an npm script, that executes processSignal in the global scope
4+
// If we change this to be the default, this can be rejiggered
5+
const SANDBOX_STRATEGY = process.env.SANDBOX_STRATEGY as
6+
| SignalsSettingsConfig['sandboxStrategy']
7+
| undefined
8+
9+
export const envConfig = {
10+
SANDBOX_STRATEGY,
11+
}

packages/signals/signals-integration-tests/src/tests/custom-elements/custom-select.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { waitForCondition } from '../../helpers/playwright-utils'
33
import { IndexPage } from './index-page'
44
import type { SegmentEvent } from '@segment/analytics-next'
55

6-
const basicEdgeFn = `const processSignal = (signal) => {}`
6+
const basicEdgeFn = `globalThis.processSignal = (signal) => {}`
77

88
test('Collecting signals whenever a user selects an item', async ({ page }) => {
99
const indexPage = await new IndexPage().loadAndWait(page, basicEdgeFn, {

packages/signals/signals-integration-tests/src/tests/custom-elements/custom-textfield.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test'
22
import { waitForCondition } from '../../helpers/playwright-utils'
33
import { IndexPage } from './index-page'
44

5-
const basicEdgeFn = `const processSignal = (signal) => {}`
5+
const basicEdgeFn = `globalThis.processSignal = (signal) => {}`
66

77
test('Collecting signals whenever a user enters text input and focuses out', async ({
88
page,

packages/signals/signals-integration-tests/src/tests/performance/memory-leak.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ declare global {
1616

1717
const basicEdgeFn = `
1818
// this is a process signal function
19-
const processSignal = (signal) => {
19+
globalThis.processSignal = (signal) => {
2020
if (signal.type === 'interaction') {
2121
const eventName = signal.data.eventType + ' ' + '[' + signal.type + ']'
2222
analytics.track(eventName, signal.data)

packages/signals/signals-integration-tests/src/tests/signals-vanilla/all-segment-events.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const snapshot = (
3737
test('Segment events', async ({ page }) => {
3838
const basicEdgeFn = `
3939
// this is a process signal function
40-
const processSignal = (signal) => {
40+
globalThis.processSignal = (signal) => {
4141
if (signal.type === 'interaction' && signal.data.eventType === 'click') {
4242
analytics.identify('john', { found: true })
4343
analytics.group('foo', { hello: 'world' })
@@ -65,7 +65,7 @@ test('Should dispatch events from signals that occurred before analytics was ins
6565
page,
6666
}) => {
6767
const edgeFn = `
68-
const processSignal = (signal) => {
68+
globalThis.processSignal = (signal) => {
6969
if (signal.type === 'navigation' && signal.data.action === 'pageLoad') {
7070
analytics.page('dispatched from signals - navigation')
7171
}

packages/signals/signals-integration-tests/src/tests/signals-vanilla/basic.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { IndexPage } from './index-page'
44

55
const basicEdgeFn = `
66
// this is a process signal function
7-
const processSignal = (signal) => {
7+
globalThis.processSignal = (signal) => {
88
if (signal.type === 'interaction') {
99
const eventName = signal.data.eventType + ' ' + '[' + signal.type + ']'
1010
analytics.track(eventName, signal.data)

0 commit comments

Comments
 (0)