Skip to content

Commit e79472b

Browse files
committed
wip
1 parent 98ff882 commit e79472b

17 files changed

+26
-23
lines changed

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 = `globalThis.processSignal = (signal) => {}`
6+
const basicEdgeFn = `function 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 = `globalThis.processSignal = (signal) => {}`
5+
const basicEdgeFn = `function 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-
globalThis.processSignal = (signal) => {
19+
function 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: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { SegmentEvent } from '@segment/analytics-next'
66
/**
77
* This test ensures that
88
*/
9-
const indexPage = new IndexPage()
109

1110
const normalizeSnapshotEvent = (el: SegmentEvent) => {
1211
return {
@@ -35,9 +34,10 @@ const snapshot = (
3534
).map(normalizeSnapshotEvent)
3635

3736
test('Segment events', async ({ page }) => {
37+
const indexPage = new IndexPage()
3838
const basicEdgeFn = `
3939
// this is a process signal function
40-
globalThis.processSignal = (signal) => {
40+
function processSignal(signal) {
4141
if (signal.type === 'interaction' && signal.data.eventType === 'click') {
4242
analytics.identify('john', { found: true })
4343
analytics.group('foo', { hello: 'world' })
@@ -61,11 +61,12 @@ test('Segment events', async ({ page }) => {
6161
expect(trackingApiReqs).toEqual(snapshot)
6262
})
6363

64-
test('Should dispatch events from signals that occurred before analytics was instantiated', async ({
64+
test.only('Should dispatch events from signals that occurred before analytics was instantiated', async ({
6565
page,
6666
}) => {
67+
const indexPage = new IndexPage()
6768
const edgeFn = `
68-
globalThis.processSignal = (signal) => {
69+
function processSignal(signal) {
6970
if (signal.type === 'navigation' && signal.data.action === 'pageLoad') {
7071
analytics.page('dispatched from signals - navigation')
7172
}
@@ -76,23 +77,25 @@ test('Should dispatch events from signals that occurred before analytics was ins
7677

7778
await indexPage.load(page, edgeFn)
7879
const flush = Promise.all([
80+
indexPage.addUserDefinedSignal(),
7981
indexPage.waitForSignalsApiFlush(),
8082
indexPage.waitForTrackingApiFlush(),
8183
])
8284

83-
// add a user defined signal before analytics is instantiated
84-
void indexPage.addUserDefinedSignal()
8585
await flush
8686

8787
const trackingApiReqs = indexPage.trackingAPI.getEvents()
8888
expect(trackingApiReqs).toHaveLength(2)
8989

9090
const pageEvents = trackingApiReqs.find((el) => el.type === 'page')!
91+
9192
expect(pageEvents).toBeTruthy()
9293
expect(pageEvents.name).toEqual('dispatched from signals - navigation')
9394

9495
const userDefinedEvents = trackingApiReqs.find((el) => el.type === 'track')!
95-
expect(userDefinedEvents).toBeTruthy()
96+
if (!userDefinedEvents) {
97+
console.warn('invariant', trackingApiReqs)
98+
}
9699
expect(userDefinedEvents.event).toEqual(
97100
'dispatched from signals - userDefined'
98101
)

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-
globalThis.processSignal = (signal) => {
7+
function processSignal(signal) {
88
if (signal.type === 'interaction') {
99
const eventName = signal.data.eventType + ' ' + '[' + signal.type + ']'
1010
analytics.track(eventName, signal.data)

packages/signals/signals-integration-tests/src/tests/signals-vanilla/button-click-complex.test.ts

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

4-
const basicEdgeFn = `globalThis.processSignal = (signal) => {}`
4+
const basicEdgeFn = `function processSignal(signal) {}`
55
let indexPage: IndexPage
66
test.beforeEach(async ({ page }) => {
77
indexPage = await new IndexPage().loadAndWait(page, basicEdgeFn)

packages/signals/signals-integration-tests/src/tests/signals-vanilla/change-input.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 = `globalThis.processSignal = (signal) => {}`
5+
const basicEdgeFn = `function processSignal(signal) {}`
66

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

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

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

4-
const basicEdgeFn = `globalThis.processSignal = (signal) => {}`
4+
const basicEdgeFn = `function processSignal(signal) {}`
55

66
let indexPage: IndexPage
77

packages/signals/signals-integration-tests/src/tests/signals-vanilla/network-signals-allow-list.test.ts

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

4-
const basicEdgeFn = `globalThis.processSignal = (signal) => {}`
4+
const basicEdgeFn = `function processSignal(signal) {}`
55

66
test('network signals allow and disallow list', async ({ page }) => {
77
const indexPage = await new IndexPage().loadAndWait(page, basicEdgeFn, {

packages/signals/signals-integration-tests/src/tests/signals-vanilla/network-signals-fetch.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 { commonSignalData } from '../../helpers/fixtures'
33
import { IndexPage } from './index-page'
44

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

77
test.describe('network signals - fetch', () => {
88
let indexPage: IndexPage

0 commit comments

Comments
 (0)