analytics/tracker/test/support/verify-playwright-wrapper.js

19 lines
691 B
JavaScript

import { compileFile } from '../../compiler/index.js'
import variantsFile from '../../compiler/variants.json' with { type: 'json' }
const VARIANT = variantsFile.manualVariants.find(variant => variant.name === 'verifier-v1.js')
export default async function verify(page, context) {
const {url, expectedDataDomain} = context
const debug = context.debug ? true : false
const verifierCode = await compileFile(VARIANT, { returnCode: true })
await page.goto(url)
await page.evaluate(verifierCode)
return await page.evaluate(async ({expectedDataDomain, debug}) => {
return await window.verifyPlausibleInstallation(expectedDataDomain, debug)
}, {expectedDataDomain, debug})
}