diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index f826af84..5a213160 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -86,6 +86,13 @@ jobs: working-directory: ./app-playwright run: npx playwright install --with-deps + # https://github.com/microsoft/playwright/issues/30538#issuecomment-2185965508 + - name: Install system dependencies for WebKit + # Some WebKit dependencies seem to lay outside the cache and will need to be installed separately + if: ${{ steps.cache-playwright-browsers.outputs.cache-hit == 'true' }} + working-directory: ./app-playwright + run: npx playwright install-deps webkit + - name: turbo run: pnpm turbo:all --force $FORCE_TURBO_ALL env: diff --git a/app-playwright/playwright.config.ts b/app-playwright/playwright.config.ts index 1c56cd16..76e96abe 100644 --- a/app-playwright/playwright.config.ts +++ b/app-playwright/playwright.config.ts @@ -9,6 +9,9 @@ import { defineConfig, devices } from '@playwright/test' // dotenv.config({ path: path.resolve(__dirname, '.env') }); const isCI = Boolean(process.env.CI) +const baseURL = isCI + ? 'http://localhost:3023' + : 'https://app.pentive.localhost:3023' /** * See https://playwright.dev/docs/test-configuration. @@ -28,7 +31,7 @@ export default defineConfig({ /* 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:3000', + baseURL, /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', @@ -43,7 +46,7 @@ export default defineConfig({ { name: 'firefox', - use: { ...devices['Desktop Firefox'] }, + use: { ...devices['Desktop Firefox'], ignoreHTTPSErrors: true }, }, { @@ -73,9 +76,11 @@ export default defineConfig({ ], /* Run your local dev server before starting the tests */ - // webServer: { - // command: 'npm run start', - // url: 'http://127.0.0.1:3000', - // reuseExistingServer: !process.env.CI, - // }, + webServer: { + command: 'pnpm run preview --port 3023', + cwd: '../app', + url: baseURL, + ignoreHTTPSErrors: true, + reuseExistingServer: false, // always use a new server because tests require a prod build due to plugins. + }, }) diff --git a/app-playwright/tests/example.spec.ts b/app-playwright/tests/example.spec.ts index 1ac56923..83c97b6b 100644 --- a/app-playwright/tests/example.spec.ts +++ b/app-playwright/tests/example.spec.ts @@ -1,10 +1,10 @@ import { test, expect } from '@playwright/test' test('has title', async ({ page }) => { - await page.goto('https://playwright.dev/') + await page.goto('/') // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Playwright/) + await expect(page).toHaveTitle(/Pentive App/) }) test('get started link', async ({ page }) => { diff --git a/app/vite.config.ts b/app/vite.config.ts index 6870e12c..cc46dced 100644 --- a/app/vite.config.ts +++ b/app/vite.config.ts @@ -5,14 +5,17 @@ import checker from 'vite-plugin-checker' import fs from 'fs' import { VitePWA } from 'vite-plugin-pwa' +const isCI = Boolean(process.env.CI) + export default defineConfig(({ mode }: UserConfig) => { const keyPath = './.cert/key.pem' const certPath = './.cert/cert.pem' - let key - let cert - if (mode === 'development') { - key = fs.readFileSync(keyPath) - cert = fs.readFileSync(certPath) + let https + if (mode === 'development' && !isCI) { + https = { + key: fs.readFileSync(keyPath), + cert: fs.readFileSync(certPath), + } } // grep 3FBCE1B6-ABA3-4179-80B3-A965F8D087BC // We're using the version number due to https://developer.chrome.com/docs/workbox/service-worker-deployment/#its-all-in-the-timing:~:text=Problems%20arise%20in%20situations%20when%20unversioned%20static%20assets%20are%20cached @@ -27,10 +30,7 @@ export default defineConfig(({ mode }: UserConfig) => { const serverOptions = { port: 3013, strictPort: true, - https: { - key, - cert, - }, + https, headers: { // eslint-disable-next-line @typescript-eslint/naming-convention 'Cross-Origin-Opener-Policy': 'same-origin', diff --git a/turbo.json b/turbo.json index f71533c6..079ac0c2 100644 --- a/turbo.json +++ b/turbo.json @@ -43,6 +43,11 @@ "shared-dom#tsc-build" ] }, + "app-playwright#test:run": { + "dependsOn": [ + "app#build" + ] + }, "deploy": { "dependsOn": [ "build"