Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip
Browse files Browse the repository at this point in the history
silesky committed Dec 12, 2024
1 parent 6405f93 commit 35349f4
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { test, expect } from '@playwright/test'
import { waitForCondition } from '../../helpers/playwright-utils'
import { IndexPage } from './index-page'

const basicEdgeFn = `const processSignal = (signal) => {}`

test('Collecting signals whenever a user enters text input and focuses out', async ({
page,
}) => {
const indexPage = await new IndexPage().loadAndWait(page, basicEdgeFn, {
disableSignalsRedaction: true,
enableSignalsIngestion: true,
})
const fillAndConfirm = async (selector: string, text: string) => {
await page.fill(selector, text)
await page.keyboard.press('Enter')
}
await Promise.all([
fillAndConfirm('[data-testid="aria-text-field"]', 'John Doe'),
waitForCondition(
() => indexPage.signalsAPI.getEvents('interaction').length > 0,
{ errorMessage: 'No interaction signals found' }
),
])
const interactionSignals = indexPage.signalsAPI.getEvents('interaction')

const data = expect.objectContaining({
eventType: 'change',
listener: 'mutation',
change: {
value: 'John Doe',
},
target: expect.objectContaining({
attributes: expect.objectContaining({
type: 'text',
value: 'John Doe',
}),
tagName: 'INPUT',
value: 'John Doe',
}),
})
expect(interactionSignals[0].properties!.data).toMatchObject(data)
})
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ const files = globby.sync('src/tests/*/index.bundle.{ts,tsx}', {
cwd: __dirname,
})

// e.g if file is src/tests/signals-vanilla/index.bundle.ts, then entry is { signals-vanilla: src/tests/signals-vanilla/index.bundle.ts }
const entries = files.reduce((acc, file) => {
const [dirName] = file.split('/').slice(-2)
const base = path.basename(dirName)

0 comments on commit 35349f4

Please sign in to comment.