Skip to content

Commit

Permalink
Remove playwright directory nesting (#1108)
Browse files Browse the repository at this point in the history
* Remove playwright directory nesting

* Rename test files to match naming convention
  • Loading branch information
jonathanKingston authored Oct 15, 2024
1 parent f16b140 commit 0e81ff0
Show file tree
Hide file tree
Showing 35 changed files with 49 additions and 50 deletions.
3 changes: 1 addition & 2 deletions injected/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ npm run test-unit
```

#### Feature Integration Tests (playwright)
Everything within `integration-test/playwright` is integration tests controlled by Playwright. These should be defaulted
to for any new tests that include UI elements (such as click to load)
Everything within `integration-test` is integration tests controlled by Playwright.

```shell
npm run test-int
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from '@playwright/test'
import { DuckplayerOverlays } from './page-objects/duckplayer-overlays.js'
import { STORAGE_STATE } from '../../playwright-e2e.config.js'
import { STORAGE_STATE } from '../playwright-e2e.config.js'

test.describe('e2e: Dismiss cookies', () => {
test('storage locally', async ({ page }, workerInfo) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ import { windowsGlobalPolyfills } from '../shared.mjs'

// Every possible combination of UserValues
const userValues = {
/** @type {import("../../../src/features/duck-player.js").UserValues} */
/** @type {import("../../src/features/duck-player.js").UserValues} */
'always ask': {
privatePlayerMode: { alwaysAsk: {} },
overlayInteracted: false
},
/** @type {import("../../../src/features/duck-player.js").UserValues} */
/** @type {import("../../src/features/duck-player.js").UserValues} */
'always ask remembered': {
privatePlayerMode: { alwaysAsk: {} },
overlayInteracted: true
},
/** @type {import("../../../src/features/duck-player.js").UserValues} */
/** @type {import("../../src/features/duck-player.js").UserValues} */
enabled: {
privatePlayerMode: { enabled: {} },
overlayInteracted: false
},
/** @type {import("../../../src/features/duck-player.js").UserValues} */
/** @type {import("../../src/features/duck-player.js").UserValues} */
disabled: {
privatePlayerMode: { disabled: {} },
overlayInteracted: false
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { test, expect } from '@playwright/test'
import path from 'path'
import { readFileSync } from 'fs'
import { baseFeatures } from '../../src/features.js'
import { baseFeatures } from '../src/features.js'

const testRoot = path.join('integration-test', 'playwright')
const testRoot = path.join('integration-test')

function getHARPath (harFile) {
return path.join(testRoot, 'data', 'har', harFile)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions injected/playwright-e2e.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export default defineConfig({
projects: [
{
name: 'duckplayer-e2e-setup',
testMatch: ['integration-test/playwright/duckplayer.setup.e2e.spec.js'],
testMatch: ['integration-test/duckplayer.setup.e2e.spec.js'],
use: { injectName: 'apple-isolated', platform: 'macos' }
},
{
name: 'duckplayer-e2e',
testMatch: ['integration-test/playwright/duckplayer.e2e.spec.js'],
testMatch: ['integration-test/duckplayer.e2e.spec.js'],
use: {
injectName: 'apple-isolated',
platform: 'macos',
Expand Down
40 changes: 20 additions & 20 deletions injected/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,61 @@ export default defineConfig({
{
name: 'windows',
testMatch: [
'integration-test/playwright/duckplayer.spec.js',
'integration-test/playwright/duckplayer-remote-config.spec.js',
'integration-test/playwright/harmful-apis.spec.js',
'integration-test/playwright/windows-permissions.spec.js',
'integration-test/playwright/broker-protection.spec.js',
'integration-test/playwright/breakage-reporting.spec.js'
'integration-test/duckplayer.spec.js',
'integration-test/duckplayer-remote-config.spec.js',
'integration-test/harmful-apis.spec.js',
'integration-test/windows-permissions.spec.js',
'integration-test/broker-protection.spec.js',
'integration-test/breakage-reporting.spec.js'
],
use: { injectName: 'windows', platform: 'windows' }
},
{
name: 'apple-isolated',
testMatch: [
'integration-test/playwright/duckplayer.spec.js',
'integration-test/playwright/duckplayer-remote-config.spec.js',
'integration-test/playwright/broker-protection.spec.js'
'integration-test/duckplayer.spec.js',
'integration-test/duckplayer-remote-config.spec.js',
'integration-test/broker-protection.spec.js'
],
use: { injectName: 'apple-isolated', platform: 'macos' }
},
{
name: 'apple',
testMatch: [
'integration-test/playwright/webcompat.spec.js'
'integration-test/webcompat.spec.js'
],
use: { injectName: 'apple', platform: 'macos' }
},
{
name: 'ios',
testMatch: [
'integration-test/playwright/duckplayer-mobile.spec.js'
'integration-test/duckplayer-mobile.spec.js'
],
use: { injectName: 'apple-isolated', platform: 'ios', ...devices['iPhone 13'] }
},
{
name: 'android',
testMatch: [
'integration-test/playwright/duckplayer-mobile.spec.js'
'integration-test/duckplayer-mobile.spec.js'
],
use: { injectName: 'android', platform: 'android', ...devices['Galaxy S5'] }
},
{
name: 'chrome',
testMatch: [
'integration-test/playwright/remote-pages.spec.js',
'integration-test/test-cookie.js',
'integration-test/test-fingerprint.js',
'integration-test/test-navigator-interface.js',
'integration-test/test-pages.js',
'integration-test/test-utils.js',
'integration-test/test-web-compat.js'
'integration-test/remote-pages.spec.js',
'integration-test/cookie.spec.js',
'integration-test/fingerprint.spec.js',
'integration-test/navigator-interface.spec.js',
'integration-test/pages.spec.js',
'integration-test/utils.spec.js',
'integration-test/web-compat.spec.js'
],
use: { injectName: 'chrome', platform: 'extension', ...devices['Desktop Chrome'] }
},
{
name: 'firefox',
testMatch: 'integration-test/playwright/remote-pages.spec.js',
testMatch: 'integration-test/remote-pages.spec.js',
use: { injectName: 'firefox', platform: 'extension', ...devices['Desktop Firefox'] }
}
],
Expand Down
2 changes: 1 addition & 1 deletion injected/scripts/generate-har.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { chromium } from '@playwright/test'

const testPath = 'integration-test/playwright/data/har/duckduckgo.com/search.har'
const testPath = 'integration-test/data/har/duckduckgo.com/search.har'

async function init () {
const browser = await chromium.launch()
Expand Down
2 changes: 1 addition & 1 deletion messaging/lib/test-utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @typedef {import("../../messaging/index.js").RequestMessage} RequestMessage
* @typedef {import("../../messaging/index.js").NotificationMessage} NotificationMessage
* @typedef {WindowsRequestMessage | WindowsNotification | SubscriptionEvent} AnyWindowsMessage
* @typedef {import("../../injected/integration-test/playwright/type-helpers.mjs").PlatformInfo} PlatformInfo
* @typedef {import("../../injected/integration-test/type-helpers.mjs").PlatformInfo} PlatformInfo
*/
/**
* Install a mock interface for windows messaging
Expand Down
6 changes: 3 additions & 3 deletions special-pages/tests/page-objects/duck-player.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Mocks } from './mocks.js'
import { expect } from '@playwright/test'
import { join } from 'node:path'
import { perPlatform } from '../../../injected/integration-test/playwright/type-helpers.mjs'
import { perPlatform } from '../../../injected/integration-test/type-helpers.mjs'

const MOCK_VIDEO_ID = 'VIDEO_ID'
const MOCK_VIDEO_TITLE = 'Embedded Video - YouTube'
Expand All @@ -25,8 +25,8 @@ const html = {
}

/**
* @typedef {import('../../../injected/integration-test/playwright/type-helpers.mjs').Build} Build
* @typedef {import('../../../injected/integration-test/playwright/type-helpers.mjs').PlatformInfo} PlatformInfo
* @typedef {import('../../../injected/integration-test/type-helpers.mjs').Build} Build
* @typedef {import('../../../injected/integration-test/type-helpers.mjs').PlatformInfo} PlatformInfo
*/

export class DuckPlayerPage {
Expand Down
4 changes: 2 additions & 2 deletions special-pages/tests/page-objects/mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class Mocks {

/**
* @param {import("@playwright/test").Page} page
* @param {import("../../../injected/integration-test/playwright/type-helpers.mjs").Build} build
* @param {import("../../../injected/integration-test/playwright/type-helpers.mjs").PlatformInfo} platform
* @param {import("../../../injected/integration-test/type-helpers.mjs").Build} build
* @param {import("../../../injected/integration-test/type-helpers.mjs").PlatformInfo} platform
* @param {import("@duckduckgo/messaging").MessagingContext} messagingContext
*/
constructor (page, build, platform, messagingContext) {
Expand Down
6 changes: 3 additions & 3 deletions special-pages/tests/page-objects/newtab.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Mocks } from './mocks.js'
import { perPlatform } from '../../../injected/integration-test/playwright/type-helpers.mjs'
import { perPlatform } from '../../../injected/integration-test/type-helpers.mjs'
import { join } from 'node:path'

/**
* @typedef {import('../../../injected/integration-test/playwright/type-helpers.mjs').Build} Build
* @typedef {import('../../../injected/integration-test/playwright/type-helpers.mjs').PlatformInfo} PlatformInfo
* @typedef {import('../../../injected/integration-test/type-helpers.mjs').Build} Build
* @typedef {import('../../../injected/integration-test/type-helpers.mjs').PlatformInfo} PlatformInfo
*/

export class NewtabPage {
Expand Down
6 changes: 3 additions & 3 deletions special-pages/tests/page-objects/onboarding.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Mocks } from './mocks.js'
import { perPlatform } from '../../../injected/integration-test/playwright/type-helpers.mjs'
import { perPlatform } from '../../../injected/integration-test/type-helpers.mjs'
import { join } from 'node:path'
import { expect } from '@playwright/test'

/**
* @typedef {import('../../../injected/integration-test/playwright/type-helpers.mjs').Build} Build
* @typedef {import('../../../injected/integration-test/playwright/type-helpers.mjs').PlatformInfo} PlatformInfo
* @typedef {import('../../../injected/integration-test/type-helpers.mjs').Build} Build
* @typedef {import('../../../injected/integration-test/type-helpers.mjs').PlatformInfo} PlatformInfo
*/

export class OnboardingPage {
Expand Down
6 changes: 3 additions & 3 deletions special-pages/tests/page-objects/release-notes.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Mocks } from './mocks.js'
import { perPlatform } from '../../../injected/integration-test/playwright/type-helpers.mjs'
import { perPlatform } from '../../../injected/integration-test/type-helpers.mjs'
import { join } from 'node:path'
import { expect } from '@playwright/test'
import { sampleData } from '../../pages/release-notes/app/sampleData.js'

/**
* @typedef {import('../../../injected/integration-test/playwright/type-helpers.mjs').Build} Build
* @typedef {import('../../../injected/integration-test/playwright/type-helpers.mjs').PlatformInfo} PlatformInfo
* @typedef {import('../../../injected/integration-test/type-helpers.mjs').Build} Build
* @typedef {import('../../../injected/integration-test/type-helpers.mjs').PlatformInfo} PlatformInfo
* @typedef {import('../../types/release-notes').UpdateMessage} UpdateMessage
*/

Expand Down
6 changes: 3 additions & 3 deletions special-pages/tests/page-objects/special-error.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Mocks } from './mocks.js'
import { expect } from '@playwright/test'
import { perPlatform } from '../../../injected/integration-test/playwright/type-helpers.mjs'
import { perPlatform } from '../../../injected/integration-test/type-helpers.mjs'
import { join } from 'node:path'
import { sampleData } from '../../pages/special-error/src/js/sampleData'
import { createRequire } from 'node:module'
import { readFileSync } from 'node:fs'
const require = createRequire(import.meta.url)

/**
* @typedef {import('../../../injected/integration-test/playwright/type-helpers.mjs').Build} Build
* @typedef {import('../../../injected/integration-test/playwright/type-helpers.mjs').PlatformInfo} PlatformInfo
* @typedef {import('../../../injected/integration-test/type-helpers.mjs').Build} Build
* @typedef {import('../../../injected/integration-test/type-helpers.mjs').PlatformInfo} PlatformInfo
*/

export class SpecialErrorPage {
Expand Down

0 comments on commit 0e81ff0

Please sign in to comment.