Skip to content

Commit 8ac958a

Browse files
authored
Add e2e tests (#131)
* initial attempt * Add initial e2e:tests * Add e2e tests to PRs * Fix tests * fix unit tests * Fix to name for scheduled focus sessions * install playwright * try again * move e2e to release step * remove e2e from ci * fix test
1 parent f3ed9c9 commit 8ac958a

30 files changed

Lines changed: 479 additions & 106 deletions

.github/workflows/build_and_publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
4848

4949
- name: install frontend dependencies
50-
run: yarn install
50+
run: npm ci
5151

5252
- name: import Apple Developer Certificate
5353
env:

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ jobs:
1919
- name: Install dependencies
2020
run: npm ci
2121

22-
- name: Run tests
22+
- name: Run unit tests
2323
run: npm run test

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,7 @@ scripts/apps.csv
5353

5454
# Supabase
5555
supabase/supabase/
56-
supabase/.branches
56+
supabase/.branches
57+
58+
# Test Results
59+
test-results

e2e/home.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { test, expect } from '@playwright/test'
2+
3+
test('home page: renders key components', async ({ page }) => {
4+
// Mark onboarding as completed to avoid redirects
5+
await page.addInitScript(() => {
6+
localStorage.setItem('onboarding_completed', 'true')
7+
})
8+
await page.goto('/#/')
9+
10+
// Heading should render
11+
await expect(page.getByRole('heading', { name: /Welcome/i })).toBeVisible()
12+
13+
// Basic layout renders (TopNav and Sidebar landmarks)
14+
const linkCount = await page.getByRole('link').filter({ has: page.locator('svg') }).count()
15+
expect(linkCount).toBeGreaterThan(0)
16+
await expect(page.getByRole('button', { name: /Start Focus/i })).toBeVisible()
17+
})
18+

e2e/login.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { test, expect } from '@playwright/test'
2+
3+
test('login page: skip login navigates to accessibility onboarding', async ({ page }) => {
4+
await page.goto('/#/login')
5+
6+
await expect(page.getByRole('button', { name: 'Continue with Google' })).toBeVisible()
7+
await expect(page.getByRole('button', { name: 'Do this later' })).toBeVisible()
8+
9+
await page.getByRole('button', { name: 'Do this later' }).click()
10+
11+
await expect(page.getByRole('heading', { name: 'Enable Accessibility' })).toBeVisible()
12+
})
13+

package-lock.json

Lines changed: 68 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"author": "Paul Hovley <rphovley@gmail.com>",
77
"scripts": {
88
"dev": "tsc && vite",
9+
"dev:e2e": "VITE_E2E=1 tsc && vite",
910
"build": "tsc && vite build",
1011
"preview": "vite preview",
1112
"monitor:update": "node scripts/os-monitor-update.js",
@@ -16,7 +17,10 @@
1617
"tauri:build:x86_64": "tauri build --target x86_64-apple-darwin",
1718
"lint": "eslint src --max-warnings=0",
1819
"format": "eslint --fix src",
19-
"test": "vitest"
20+
"test": "vitest",
21+
"test:e2e": "playwright test",
22+
"test:e2e:ui": "playwright test --ui",
23+
"test:e2e:headed": "npx playwright test e2e/ --headed --project=chromium"
2024
},
2125
"dependencies": {
2226
"@dnd-kit/core": "^6.3.1",
@@ -73,10 +77,11 @@
7377
"zustand": "^5.0.3"
7478
},
7579
"devDependencies": {
80+
"@playwright/test": "^1.54.2",
7681
"@tauri-apps/cli": "^2.6.1",
7782
"@types/canvas-confetti": "^1.9.0",
7883
"@types/luxon": "^3.4.2",
79-
"@types/node": "^22.10.2",
84+
"@types/node": "^22.17.1",
8085
"@types/react": "^18.2.15",
8186
"@types/react-dom": "^18.2.7",
8287
"@typescript-eslint/eslint-plugin": "^8.19.1",

playwright.config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { defineConfig, devices } from '@playwright/test'
2+
3+
export default defineConfig({
4+
testDir: 'e2e',
5+
timeout: 30_000,
6+
use: {
7+
baseURL: 'http://localhost:1420',
8+
trace: 'on-first-retry',
9+
},
10+
webServer: {
11+
command: 'npm run dev:e2e',
12+
port: 1420,
13+
reuseExistingServer: !process.env.CI,
14+
timeout: 120_000,
15+
},
16+
projects: [
17+
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
18+
],
19+
})
20+

0 commit comments

Comments
 (0)