-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/signals/signals-integration-tests/src/tests/signals-vanilla/signals-find.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { test, expect } from '@playwright/test' | ||
import { IndexPage } from './index-page' | ||
|
||
const indexPage = new IndexPage() | ||
|
||
test('should find the most recent signal', async ({ page }) => { | ||
const basicEdgeFn = `const processSignal = (signal) => { | ||
if (signal.type === 'interaction' && signal.data.target.id === 'complex-button') { | ||
const mostRecentSignal = signals.find(signal, 'userDefined') | ||
if (mostRecentSignal.data.num === 2) { | ||
analytics.track('correct signal found') | ||
} | ||
} | ||
}` | ||
|
||
await indexPage.loadAndWait(page, basicEdgeFn) | ||
const tapiFlush = indexPage.waitForTrackingApiFlush() | ||
await indexPage.addUserDefinedSignal({ num: 1 }) | ||
await indexPage.addUserDefinedSignal({ num: 2 }) | ||
await indexPage.clickComplexButton() | ||
await tapiFlush | ||
const lastEvent = indexPage.trackingAPI.lastEvent() | ||
expect(lastEvent.event).toEqual('correct signal found') | ||
}) |