Skip to content

Commit

Permalink
add ingestion integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljackins committed Oct 22, 2024
1 parent 93bf465 commit e238b8b
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { test, expect } from '@playwright/test'
import { waitForCondition } from '../../helpers/playwright-utils'
import { IndexPage } from './index-page'

const indexPage = new IndexPage()

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

test('ingestion not enabled -> will not send the signal', async ({ page }) => {
await indexPage.loadAndWait(page, basicEdgeFn, {
enableSignalsIngestion: false,
})

await indexPage.fillNameInput('John Doe')
const promise = await indexPage.waitForSignalsApiFlush()

await expect(promise).rejects.toThrow()
})

test('ingestion enabled -> will send the signal', async ({ page }) => {
await indexPage.loadAndWait(page, basicEdgeFn, {
enableSignalsIngestion: true,
})

await Promise.all([
indexPage.fillNameInput('John Doe'),
indexPage.waitForSignalsApiFlush(),
])

await waitForCondition(
() => indexPage.signalsAPI.getEvents('interaction').length > 0,
{ errorMessage: 'No interaction signals found' }
)

const interactionSignals = indexPage.signalsAPI.getEvents('interaction')
expect(interactionSignals.length > 0)
})

0 comments on commit e238b8b

Please sign in to comment.