diff --git a/.gitignore b/.gitignore index 862326e..bd26ef5 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,7 @@ # broccoli-debug /DEBUG/ -.DS_Store \ No newline at end of file +.DS_Store +/test-results/ +/playwright-report/ +/playwright/.cache/ diff --git a/e2e/index.spec.ts b/e2e/index.spec.ts new file mode 100644 index 0000000..1d20682 --- /dev/null +++ b/e2e/index.spec.ts @@ -0,0 +1,7 @@ +import { test, expect } from '@playwright/test'; + +test('has title', async ({ page }) => { + await page.goto('/'); + + await expect(page).toHaveTitle(/EmberBoilerplate/); +}); diff --git a/package.json b/package.json index b36b03d..e93f600 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "@glint/environment-ember-template-imports": "^1.2.1", "@glint/template": "^1.2.1", "@nullvoxpopuli/eslint-configs": "^3.2.2", + "@playwright/test": "^1.39.0", "@triptyk/ember-input": "~2.0.0-alpha.11", "@triptyk/ember-input-validation": "~2.0.0-alpha.11", "@triptyk/ember-simple-auth-token": "~5.3.2", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..1787fc3 --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,77 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './e2e', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: 'http://127.0.0.1:4200', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + + { + name: 'firefox', + use: { ...devices['Desktop Firefox'] }, + }, + + { + name: 'webkit', + use: { ...devices['Desktop Safari'] }, + }, + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { ...devices['Pixel 5'] }, + // }, + // { + // name: 'Mobile Safari', + // use: { ...devices['iPhone 12'] }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + // }, + // { + // name: 'Google Chrome', + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + // }, + ], + + /* Run your local dev server before starting the tests */ + webServer: { + command: 'pnpm run start', + url: 'http://127.0.0.1:4200', + reuseExistingServer: !process.env.CI, + }, +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3a15181..4afe9a2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -103,6 +103,9 @@ devDependencies: '@nullvoxpopuli/eslint-configs': specifier: ^3.2.2 version: 3.2.2(@babel/core@7.23.2)(@babel/eslint-parser@7.22.15)(@typescript-eslint/eslint-plugin@6.8.0)(@typescript-eslint/parser@6.8.0)(eslint-config-prettier@9.0.0)(eslint-plugin-ember@11.11.1)(eslint-plugin-qunit@8.0.1)(eslint@8.51.0)(prettier@3.0.3)(typescript@5.2.2) + '@playwright/test': + specifier: ^1.39.0 + version: 1.39.0 '@triptyk/ember-input': specifier: ~2.0.0-alpha.11 version: 2.0.0-alpha.11(@babel/core@7.23.2)(@glint/template@1.2.1)(ember-flatpickr@4.0.0)(ember-source@5.3.0) @@ -3272,6 +3275,14 @@ packages: tslib: 2.6.2 dev: true + /@playwright/test@1.39.0: + resolution: {integrity: sha512-3u1iFqgzl7zr004bGPYiN/5EZpRUSFddQBra8Rqll5N0/vfpqlP9I9EXqAoGacuAbX6c9Ulg/Cjqglp5VkK6UQ==} + engines: {node: '>=16'} + hasBin: true + dependencies: + playwright: 1.39.0 + dev: true + /@pnpm/constants@7.1.1: resolution: {integrity: sha512-31pZqMtjwV+Vaq7MaPrT1EoDFSYwye3dp6BiHIGRJmVThCQwySRKM7hCvqqI94epNkqFAAYoWrNynWoRYosGdw==} engines: {node: '>=16.14'} @@ -10607,6 +10618,14 @@ packages: dev: true optional: true + /fsevents@2.3.2: + resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + requiresBuild: true + dev: true + optional: true + /fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -13937,6 +13956,22 @@ packages: find-up: 3.0.0 dev: true + /playwright-core@1.39.0: + resolution: {integrity: sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==} + engines: {node: '>=16'} + hasBin: true + dev: true + + /playwright@1.39.0: + resolution: {integrity: sha512-naE5QT11uC/Oiq0BwZ50gDmy8c8WLPRTEWuSSFVG2egBka/1qMoSqYQcROMT9zLwJ86oPofcTH2jBY/5wWOgIw==} + engines: {node: '>=16'} + hasBin: true + dependencies: + playwright-core: 1.39.0 + optionalDependencies: + fsevents: 2.3.2 + dev: true + /pluralize@8.0.0: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} diff --git a/public/mockServiceWorker.js b/public/mockServiceWorker.js index fce44f7..51d85ee 100644 --- a/public/mockServiceWorker.js +++ b/public/mockServiceWorker.js @@ -174,7 +174,7 @@ async function handleRequest(event, requestId) { async function resolveMainClient(event) { const client = await self.clients.get(event.clientId) - if (client.frameType === 'top-level') { + if (client?.frameType === 'top-level') { return client }