diff --git a/integration-test/playwright/breakage-reporting.spec.js b/integration-test/playwright/breakage-reporting.spec.js index e80e5f5de..1c16f99de 100644 --- a/integration-test/playwright/breakage-reporting.spec.js +++ b/integration-test/playwright/breakage-reporting.spec.js @@ -1,8 +1,8 @@ import { test, expect } from '@playwright/test' import { - readOutgoingMessages, simulateSubscriptionMessage, waitForCallCount, + readOutgoingMessages, simulateSubscriptionMessage, waitForCallCount } from '@duckduckgo/messaging/lib/test-utils.mjs' -import { ResultsCollector } from "./page-objects/results-collector.js"; +import { ResultsCollector } from './page-objects/results-collector.js' test('Breakage Reporting Feature', async ({ page }, testInfo) => { const htmlPage = '/breakage-reporting/index.html' @@ -11,7 +11,7 @@ test('Breakage Reporting Feature', async ({ page }, testInfo) => { const collector = ResultsCollector.create(page, testInfo) await collector.load(htmlPage, config) - const feature = new BreakageFeatureSpec(page); + const feature = new BreakageFeatureSpec(page) await feature.navigate() await page.evaluate(simulateSubscriptionMessage, { diff --git a/integration-test/playwright/harmful-apis.spec.js b/integration-test/playwright/harmful-apis.spec.js index 7c04f5296..35b6fe294 100644 --- a/integration-test/playwright/harmful-apis.spec.js +++ b/integration-test/playwright/harmful-apis.spec.js @@ -1,12 +1,12 @@ import { test, expect } from '@playwright/test' -import { ResultsCollector } from "./page-objects/results-collector.js"; +import { ResultsCollector } from './page-objects/results-collector.js' test.skip('Harmful APIs protections', async ({ page }, testInfo) => { const htmlPage = '/harmful-apis/index.html' const config = './integration-test/test-pages/harmful-apis/config/apis.json' const collector = ResultsCollector.create(page, testInfo) - await collector.load(htmlPage, config); + await collector.load(htmlPage, config) const results = await collector.runTests(); // note that if protections are disabled, the browser will show a device selection pop-up, which will never be dismissed diff --git a/integration-test/playwright/page-objects/results-collector.js b/integration-test/playwright/page-objects/results-collector.js index 39e637c38..40db28f91 100644 --- a/integration-test/playwright/page-objects/results-collector.js +++ b/integration-test/playwright/page-objects/results-collector.js @@ -1,12 +1,12 @@ -import { readFileSync } from "fs"; +import { readFileSync } from 'fs' import { mockAndroidMessaging, mockWebkitMessaging, mockWindowsMessaging, wrapWebkitScripts, wrapWindowsScripts -} from "@duckduckgo/messaging/lib/test-utils.mjs"; -import { perPlatform } from "../type-helpers.mjs"; +} from '@duckduckgo/messaging/lib/test-utils.mjs' +import { perPlatform } from '../type-helpers.mjs' /** * This is designed to allow you to execute Playwright tests using the various @@ -40,7 +40,7 @@ export class ResultsCollector { * @param {import('../type-helpers.mjs').Build} build * @param {import('../type-helpers.mjs').PlatformInfo} platform */ - constructor(page, build, platform) { + constructor (page, build, platform) { this.page = page this.build = build this.platform = platform @@ -53,9 +53,9 @@ export class ResultsCollector { * @param {string} htmlPath * @param {string} configPath */ - async load(htmlPath, configPath) { + async load (htmlPath, configPath) { const config = JSON.parse(readFileSync(configPath, 'utf8')) - await this.setup({config}) + await this.setup({ config }) await this.page.goto(htmlPath) return this } @@ -63,9 +63,9 @@ export class ResultsCollector { /** * @param {Record} values */ - withUserPreferences(values) { - this.#userPreferences = values; - return this; + withUserPreferences (values) { + this.#userPreferences = values + return this } /** @@ -73,15 +73,14 @@ export class ResultsCollector { * @param {Record} params.config * @return {Promise} */ - async setup(params) { - const {config,} = params - + async setup (params) { + const { config } = params const wrapFn = this.build.switch({ 'apple-isolated': () => wrapWebkitScripts, - 'apple': () => wrapWebkitScripts, + apple: () => wrapWebkitScripts, android: () => wrapWindowsScripts, - windows: () => wrapWindowsScripts, + windows: () => wrapWindowsScripts }) // read the built file from disk and do replacements @@ -98,8 +97,8 @@ export class ResultsCollector { const messagingMock = this.build.switch({ apple: () => mockWebkitMessaging, 'apple-isolated': () => mockWebkitMessaging, - 'windows': () => mockWindowsMessaging, - 'android': () => mockAndroidMessaging, + windows: () => mockWindowsMessaging, + android: () => mockAndroidMessaging }) await this.page.addInitScript(messagingMock, { @@ -115,7 +114,7 @@ export class ResultsCollector { await this.page.addInitScript(injectedJS) } - collectResultsFromPage() { + collectResultsFromPage () { return this.page.evaluate(() => { return new Promise(resolve => { // @ts-expect-error - this is added by the test framework @@ -149,7 +148,7 @@ export class ResultsCollector { * @param {import('@playwright/test').Page} page * @param {import('@playwright/test').TestInfo} testInfo */ - static create(page, testInfo) { + static create (page, testInfo) { // Read the configuration object to determine which platform we're testing against const { platformInfo, diff --git a/integration-test/playwright/webcompat.spec.js b/integration-test/playwright/webcompat.spec.js index 907923c17..512bd807d 100644 --- a/integration-test/playwright/webcompat.spec.js +++ b/integration-test/playwright/webcompat.spec.js @@ -1,5 +1,5 @@ import { test, expect } from '@playwright/test' -import { ResultsCollector } from "./page-objects/results-collector.js"; +import { ResultsCollector } from './page-objects/results-collector.js' test('web compat', async ({ page }, testInfo) => { const htmlPage = '/webcompat/index.html' diff --git a/integration-test/playwright/windows-permissions.spec.js b/integration-test/playwright/windows-permissions.spec.js index a75d05c7b..5dfe29817 100644 --- a/integration-test/playwright/windows-permissions.spec.js +++ b/integration-test/playwright/windows-permissions.spec.js @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test' -import { ResultsCollector } from "./page-objects/results-collector.js"; -import { windowsGlobalPolyfills } from "./shared.mjs"; +import { ResultsCollector } from './page-objects/results-collector.js' +import { windowsGlobalPolyfills } from './shared.mjs' test('Windows Permissions Usage', async ({ page }, testInfo) => { const htmlPage = '/permissions/index.html' @@ -12,7 +12,7 @@ test('Windows Permissions Usage', async ({ page }, testInfo) => { const collector = ResultsCollector.create(page, testInfo) await collector.load(htmlPage, config) - const results = await collector.collectResultsFromPage(); + const results = await collector.collectResultsFromPage() for (const result of results['Disabled Windows Permissions']) { expect(result.result).toEqual(result.expected)