Skip to content

Commit

Permalink
actually test app
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexErrant committed Nov 8, 2024
1 parent 8c41779 commit f5fc216
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
19 changes: 12 additions & 7 deletions app-playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:3013'
: 'https://app.pentive.localhost:3013'

/**
* See https://playwright.dev/docs/test-configuration.
Expand All @@ -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',
Expand All @@ -43,7 +46,7 @@ export default defineConfig({

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
use: { ...devices['Desktop Firefox'], ignoreHTTPSErrors: true },
},

{
Expand Down Expand Up @@ -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',
cwd: '../app',
url: baseURL,
ignoreHTTPSErrors: true,
reuseExistingServer: false, // always use a new server because tests require a prod build due to plugins.
},
})
4 changes: 2 additions & 2 deletions app-playwright/tests/example.spec.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
18 changes: 9 additions & 9 deletions app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
"shared-dom#tsc-build"
]
},
"app-playwright#test:run": {
"dependsOn": [
"app#build"
]
},
"deploy": {
"dependsOn": [
"build"
Expand Down

0 comments on commit f5fc216

Please sign in to comment.