2024-11-21 17:29:52 +03:00
|
|
|
const { mockRequest, expectCustomEvent } = require('./support/test-utils')
|
|
|
|
const { expect, test } = require('@playwright/test')
|
2023-06-14 12:23:11 +03:00
|
|
|
|
|
|
|
test.describe('with revenue script extension', () => {
|
2023-06-19 14:59:47 +03:00
|
|
|
test('sends revenue currency and amount in manual mode', async ({ page }) => {
|
2023-06-14 12:23:11 +03:00
|
|
|
const plausibleRequestMock = mockRequest(page, '/api/event')
|
2024-11-21 17:29:52 +03:00
|
|
|
await page.goto('/revenue.html')
|
2023-06-19 14:59:47 +03:00
|
|
|
await page.click('#manual-purchase')
|
2023-06-14 12:23:11 +03:00
|
|
|
|
|
|
|
const plausibleRequest = await plausibleRequestMock
|
|
|
|
expect(plausibleRequest.postDataJSON()["$"]).toEqual({amount: 15.99, currency: "USD"})
|
2024-11-21 17:29:52 +03:00
|
|
|
})
|
2023-06-19 14:59:47 +03:00
|
|
|
|
|
|
|
test('sends revenue currency and amount with tagged class name', async ({ page }) => {
|
|
|
|
const plausibleRequestMock = mockRequest(page, '/api/event')
|
2024-11-21 17:29:52 +03:00
|
|
|
await page.goto('/revenue.html')
|
2023-06-19 14:59:47 +03:00
|
|
|
await page.click('#tagged-purchase')
|
|
|
|
|
|
|
|
const plausibleRequest = await plausibleRequestMock
|
|
|
|
expect(plausibleRequest.postDataJSON()["$"]).toEqual({amount: "13.32", currency: "EUR"})
|
2024-11-21 17:29:52 +03:00
|
|
|
})
|
|
|
|
})
|