Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Osbourne committed Sep 12, 2024
1 parent 70162e3 commit 6050caf
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 27 deletions.
6 changes: 3 additions & 3 deletions integration-test/playwright/breakage-reporting.spec.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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, {
Expand Down
4 changes: 2 additions & 2 deletions integration-test/playwright/harmful-apis.spec.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
35 changes: 17 additions & 18 deletions integration-test/playwright/page-objects/results-collector.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -53,35 +53,34 @@ 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
}

/**
* @param {Record<string, any>} values
*/
withUserPreferences(values) {
this.#userPreferences = values;
return this;
withUserPreferences (values) {
this.#userPreferences = values
return this
}

/**
* @param {object} params
* @param {Record<string, any>} params.config
* @return {Promise<void>}
*/
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
Expand All @@ -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, {
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion integration-test/playwright/webcompat.spec.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 3 additions & 3 deletions integration-test/playwright/windows-permissions.spec.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)
Expand Down

0 comments on commit 6050caf

Please sign in to comment.