File size: 2,342 Bytes
6778ee0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | import { expectPlausibleInAction } from './support/test-utils'
import { test } from '@playwright/test'
import { LOCAL_SERVER_ADDR } from './support/server'
test.describe('manual extension', () => {
test('can trigger custom events with and without a custom URL if pageview was sent with the default URL', async ({
page
}) => {
await page.goto('/manual.html')
await expectPlausibleInAction(page, {
action: () => page.click('#pageview-trigger'),
expectedRequests: [
{ n: 'pageview', u: `${LOCAL_SERVER_ADDR}/manual.html` }
]
})
await expectPlausibleInAction(page, {
action: () => page.click('#custom-event-trigger'),
expectedRequests: [
{ n: 'CustomEvent', u: `${LOCAL_SERVER_ADDR}/manual.html` }
]
})
await expectPlausibleInAction(page, {
action: () => page.click('#custom-event-trigger-custom-url'),
expectedRequests: [
{ n: 'CustomEvent', u: `https://example.com/custom/location` }
]
})
})
test('can trigger custom events with and without a custom URL if pageview was sent with a custom URL', async ({
page
}) => {
await page.goto('/manual.html')
await expectPlausibleInAction(page, {
action: () => page.click('#pageview-trigger-custom-url'),
expectedRequests: [
{ n: 'pageview', u: `https://example.com/custom/location` }
]
})
await expectPlausibleInAction(page, {
action: () => page.click('#custom-event-trigger'),
expectedRequests: [
{ n: 'CustomEvent', u: `${LOCAL_SERVER_ADDR}/manual.html` }
]
})
await expectPlausibleInAction(page, {
action: () => page.click('#custom-event-trigger-custom-url'),
expectedRequests: [
{ n: 'CustomEvent', u: `https://example.com/custom/location` }
]
})
})
test('can trigger custom events with interactive: false', async ({
page
}) => {
await page.goto('/manual.html')
await expectPlausibleInAction(page, {
action: () =>
page.evaluate(() =>
window.plausible('Non-Interactive Custom Event', {
interactive: false
})
),
expectedRequests: [
{
n: 'Non-Interactive Custom Event',
u: `${LOCAL_SERVER_ADDR}/manual.html`,
i: false
}
]
})
})
})
|