Skip to content

armgit / lyftr

Public Imported from GitHub
0

Self-hosted fitness tracker. Log workouts, track nutrition, and monitor progress. Docker deployment, mobile-friendly.

test(e2e): split projects — chromium full, mobile @mobile-only (refs #44) (#47)

Carter26be1da34878
diff --git a/docs/TESTING.md b/docs/TESTING.md
index 2ae9183..25844ad 100644
--- a/docs/TESTING.md
+++ b/docs/TESTING.md
@@ -43,9 +43,25 @@ response shape, and DB persistence.
layer.
### 3. E2E — real browser, real user journeys
-Playwright (`web/e2e/*.spec.ts`), run under chromium and an iPhone-14 profile.
-For multi-step things a user actually does in the UI: register/login, log a
-workout, gym mode, the barcode scanner, the Settings server editor.
+Playwright (`web/e2e/*.spec.ts`). For multi-step things a user actually does in
+the UI: register/login, log a workout, gym mode, the barcode scanner, the
+Settings server editor.
+
+**Two projects, asymmetric by design:**
+- **chromium** runs the *full* suite — business logic is covered once here.
+- **mobile** (iPhone-14) runs *only* tests tagged `@mobile` — the flows where the
+ phone viewport itself is under test (gym mode, the barcode scanner) plus a
+ critical auth smoke. We do **not** re-run viewport-independent tests on mobile.
+
+Tag a test/`describe` `@mobile` when the **mobile viewport is the thing under
+test** (responsive layout, touch interactions, camera, mobile nav) or it's a
+thin critical smoke proving the app works at phone size. Otherwise leave it
+chromium-only.
+
+```ts
+test.describe('Gym Mode', { tag: '@mobile' }, () => { ... })
+test('scanner opens', { tag: '@mobile' }, async ({ page }) => { ... })
+```
- **Run:** `cd web && npm run test:e2e`
- **Speed:** minutes. Keep this layer **thin** — it's the slowest and most fragile.
diff --git a/web/e2e/auth.spec.ts b/web/e2e/auth.spec.ts
index 0c7c6ea..a281c90 100644
--- a/web/e2e/auth.spec.ts
+++ b/web/e2e/auth.spec.ts
@@ -3,7 +3,8 @@ import { test, expect } from '@playwright/test'
// These run logged-out, so override the shared authenticated storage state.
test.use({ storageState: { cookies: [], origins: [] } })
-test('registers a new user and lands on the dashboard', async ({ page }) => {
+// @mobile: critical smoke that auth + the app shell work at phone viewport.
+test('registers a new user and lands on the dashboard', { tag: '@mobile' }, async ({ page }) => {
const email = `e2e+${Date.now()}@lyftr.local`
await page.goto('/register')
await page.getByPlaceholder('[email protected]').fill(email)
diff --git a/web/e2e/food.spec.ts b/web/e2e/food.spec.ts
index 45ace95..e9d6371 100644
--- a/web/e2e/food.spec.ts
+++ b/web/e2e/food.spec.ts
@@ -171,7 +171,8 @@ test.describe('Food', () => {
// ─── Log food flow ─────────────────────────────────────────────────────────
- test('manual entry: log food and verify it appears in meal section', async ({ page }) => {
+ // @mobile: logging food is a core on-phone action — smoke it at phone viewport.
+ test('manual entry: log food and verify it appears in meal section', { tag: '@mobile' }, async ({ page }) => {
const name = `E2ELog-${Date.now()}`
await page.route('**/api/v1/food/search**', route =>
@@ -209,7 +210,8 @@ test.describe('Food', () => {
await expect(page.getByText('500').first()).toBeVisible()
})
- test('servings stepper scales macros in detail phase', async ({ page }) => {
+ // @mobile: touch stepper (+/- taps) — a phone-viewport touch interaction.
+ test('servings stepper scales macros in detail phase', { tag: '@mobile' }, async ({ page }) => {
await page.route('**/api/v1/food/search**', route =>
route.fulfill({
json: {
@@ -230,7 +232,8 @@ test.describe('Food', () => {
await expect(page.getByText('400').first()).toBeVisible()
})
- test('meal selector in detail phase updates active meal', async ({ page }) => {
+ // @mobile: touch chip selector that sets the entry's meal.
+ test('meal selector in detail phase updates active meal', { tag: '@mobile' }, async ({ page }) => {
await page.route('**/api/v1/food/search**', route =>
route.fulfill({ json: { data: [] } })
)
@@ -392,14 +395,14 @@ test.describe('Food', () => {
// ─── Barcode scanner ──────────────────────────────────────────────────────
- test('Scan button renders scan phase overlay with close button', async ({ page }) => {
+ test('Scan button renders scan phase overlay with close button', { tag: '@mobile' }, async ({ page }) => {
test.slow()
await page.goto('/food/log')
await page.getByRole('button', { name: /scan/i }).click()
await expect(page.getByRole('button', { name: 'Close scanner' })).toBeVisible({ timeout: 3000 })
})
- test('Close scanner button returns to search phase', async ({ page }) => {
+ test('Close scanner button returns to search phase', { tag: '@mobile' }, async ({ page }) => {
await page.goto('/food/log')
await page.getByRole('button', { name: /scan/i }).click()
await page.getByRole('button', { name: 'Close scanner' }).click()
diff --git a/web/e2e/weight.spec.ts b/web/e2e/weight.spec.ts
index d9b2ac8..19e6f3a 100644
--- a/web/e2e/weight.spec.ts
+++ b/web/e2e/weight.spec.ts
@@ -73,7 +73,8 @@ test.describe('Weight', () => {
}
})
- test('log weight via form adds entry to history', async ({ page }) => {
+ // @mobile: logging weight is a core on-phone action (numeric keypad) — smoke it.
+ test('log weight via form adds entry to history', { tag: '@mobile' }, async ({ page }) => {
const testDate = new Date(Date.now() - 14 * 86400000).toISOString().split('T')[0]
await page.getByRole('button', { name: /add date.*note/i }).click()
diff --git a/web/e2e/workouts.spec.ts b/web/e2e/workouts.spec.ts
index fc17b77..95f4379 100644
--- a/web/e2e/workouts.spec.ts
+++ b/web/e2e/workouts.spec.ts
@@ -181,7 +181,9 @@ test.describe('Workouts', () => {
let gymAuthToken: string
let gymExerciseId: number
-test.describe('Gym Mode', () => {
+// @mobile: Gym Mode is the mobile-first full-screen workout UX — run it on the
+// iPhone profile (it also runs on chromium via the full suite).
+test.describe('Gym Mode', { tag: '@mobile' }, () => {
test.beforeAll(async ({ request }) => {
const res = await request.post(`${API}/auth/login`, {
data: { email: TEST_EMAIL, password: TEST_PASSWORD }
diff --git a/web/playwright.config.ts b/web/playwright.config.ts
index dbbd406..218eea7 100644
--- a/web/playwright.config.ts
+++ b/web/playwright.config.ts
@@ -47,12 +47,18 @@ export default defineConfig({
dependencies: ['setup'],
},
{
+ // Mobile (iPhone-14) runs ONLY @mobile-tagged tests — the flows where the
+ // phone viewport itself is under test (gym mode, barcode scanner) plus a
+ // critical auth smoke. Chromium (above) runs the full suite, so business
+ // logic is covered once; the mobile project guards mobile-specific UX
+ // without re-running every viewport-independent test. See docs/TESTING.md.
name: 'mobile',
use: {
...devices['iPhone 14'],
storageState: 'e2e/.auth/user.json',
},
dependencies: ['setup'],
+ grep: /@mobile/,
},
],
})