Skip to content

Commit ec58d81

Browse files
committed
wip
1 parent 141b72b commit ec58d81

File tree

6 files changed

+67
-25
lines changed

6 files changed

+67
-25
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
"@playwright/test": "^1.28.1",
2929
"@segment/analytics-next": "workspace:^",
3030
"@segment/analytics-signals": "workspace:^",
31+
"@types/react": "^18.0.0",
32+
"@types/react-dom": "^18",
3133
"globby": "^11.0.2",
3234
"http-server": "14.1.1",
35+
"react": "^18.0.0",
36+
"react-aria-components": "^1.5.0",
37+
"react-dom": "^18.0.0",
3338
"tslib": "^2.4.1",
3439
"webpack": "^5.76.0",
3540
"webpack-cli": "^4.8.0"
36-
},
37-
"dependencies": {
38-
"react-aria-components": "^1.5.0"
3941
}
4042
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
import { TextField } from './TextField'
3+
4+
export const App: React.FC = () => {
5+
return (
6+
<main>
7+
<TextField label="some-text-field" />
8+
</main>
9+
)
10+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { test, expect } from '@playwright/test'
2+
import { waitForCondition } from '../../helpers/playwright-utils'
3+
import { IndexPage } from './index-page'
4+
5+
const basicEdgeFn = `const processSignal = (signal) => {}`
6+
7+
test('Collecting signals whenever a user enters text input and focuses out', async ({
8+
page,
9+
}) => {
10+
const indexPage = await new IndexPage().loadAndWait(page, basicEdgeFn, {
11+
disableSignalsRedaction: true,
12+
enableSignalsIngestion: true,
13+
})
14+
const fillAndConfirm = async (selector: string, text: string) => {
15+
await page.getByTestId(selector).fill(text)
16+
await page.getByTestId(selector).press('Enter')
17+
}
18+
await Promise.all([
19+
fillAndConfirm('aria-text-field', 'John Doe'),
20+
waitForCondition(
21+
() => indexPage.signalsAPI.getEvents('interaction').length > 0,
22+
{ errorMessage: 'No interaction signals found' }
23+
),
24+
])
25+
const interactionSignals = indexPage.signalsAPI.getEvents('interaction')
26+
27+
const data = expect.objectContaining({
28+
eventType: 'change',
29+
listener: 'mutation',
30+
change: {
31+
value: 'John Doe',
32+
},
33+
target: expect.objectContaining({
34+
attributes: expect.objectContaining({
35+
type: 'text',
36+
value: 'John Doe',
37+
}),
38+
tagName: 'INPUT',
39+
value: 'John Doe',
40+
}),
41+
})
42+
expect(interactionSignals[0].properties!.data).toMatchObject(data)
43+
})
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import React from 'react'
2-
import ReactDOM from 'react-dom'
3-
2+
import { createRoot } from 'react-dom/client'
43
import { AnalyticsBrowser } from '@segment/analytics-next'
54
import { SignalsPlugin } from '@segment/analytics-signals'
6-
import { TextField } from './components/TextField'
5+
import { App } from './components/App'
76

8-
/**
9-
* Not instantiating the analytics object here, as it will be instantiated in the test
10-
*/
117
window.SignalsPlugin = SignalsPlugin
128
window.analytics = new AnalyticsBrowser()
139

14-
const App = () => {
15-
return <TextField />
16-
}
17-
18-
ReactDOM.render(<App />, document.getElementById('root'))
10+
const container = document.getElementById('root')
11+
const root = createRoot(container!)
12+
root.render(<App />)

packages/signals/signals-integration-tests/src/tests/custom-elements/pages/Home.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,9 +3076,13 @@ __metadata:
30763076
"@playwright/test": ^1.28.1
30773077
"@segment/analytics-next": "workspace:^"
30783078
"@segment/analytics-signals": "workspace:^"
3079+
"@types/react": ^18.0.0
3080+
"@types/react-dom": ^18
30793081
globby: ^11.0.2
30803082
http-server: 14.1.1
3083+
react: ^18.0.0
30813084
react-aria-components: ^1.5.0
3085+
react-dom: ^18.0.0
30823086
tslib: ^2.4.1
30833087
webpack: ^5.76.0
30843088
webpack-cli: ^4.8.0

0 commit comments

Comments
 (0)