This commit is contained in:
2025-09-18 10:13:08 -06:00
parent 28f8907259
commit b20e43b951
11 changed files with 1010 additions and 10 deletions

View File

@@ -9,8 +9,11 @@
"build": "vite build", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json", "check": "svelte-check --tsconfig ./tsconfig.json",
"test": "echo \"No unit tests yet (see T007)\" && exit 0", "test": "vitest run",
"test:e2e": "echo \"No e2e tests yet (see T007, T012T015)\" && exit 0" "test:unit": "vitest run",
"test:ui": "vitest",
"test:e2e": "playwright test",
"e2e:report": "playwright show-report"
}, },
"dependencies": { "dependencies": {
"svelte": "^4.2.18" "svelte": "^4.2.18"
@@ -26,6 +29,11 @@
"@tailwindcss/forms": "^0.5.9", "@tailwindcss/forms": "^0.5.9",
"svelte": "^4.2.18", "svelte": "^4.2.18",
"typescript": "^5.5.4", "typescript": "^5.5.4",
"vite": "^5.1.0" "vite": "^5.1.0",
"vitest": "^2.1.1",
"@playwright/test": "^1.48.0",
"jsdom": "^25.0.0",
"@testing-library/svelte": "^5.0.0",
"@testing-library/jest-dom": "^6.4.2"
} }
} }

View File

@@ -0,0 +1,25 @@
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests/e2e',
timeout: 30_000,
retries: 0,
fullyParallel: true,
reporter: [['list']],
use: {
baseURL: process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:4173',
trace: 'on-first-retry'
},
webServer: {
command: 'pnpm preview',
cwd: __dirname,
port: 4173,
reuseExistingServer: !process.env.CI
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] }
}
]
});

View File

@@ -0,0 +1,7 @@
import { describe, it, expect } from 'vitest';
describe('scaffold', () => {
it('adds two numbers', () => {
expect(1 + 1).toBe(2);
});
});

View File

@@ -0,0 +1,8 @@
import { test, expect } from '@playwright/test';
test('homepage has title and grid', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/GlowTrack/i);
await expect(page.getByRole('heading', { level: 1 })).toHaveText(/GlowTrack/i);
await expect(page.getByRole('region', { name: /demo grid/i })).toBeVisible();
});

View File

@@ -8,12 +8,12 @@
"strict": true, "strict": true,
"noEmit": true, "noEmit": true,
"baseUrl": ".", "baseUrl": ".",
"types": ["svelte", "vite/client", "@sveltejs/kit"], "types": ["svelte", "vite/client", "@sveltejs/kit", "node"],
"paths": { "paths": {
"$lib": ["src/lib"], "$lib": ["src/lib"],
"$lib/*": ["src/lib/*"] "$lib/*": ["src/lib/*"]
} }
}, },
"include": ["src/**/*", "vite.config.ts", "svelte.config.js"], "include": ["src/**/*", "vite.config.ts", "svelte.config.js", "playwright.config.ts", "tests/**/*"],
"exclude": ["node_modules", "dist", "build", ".svelte-kit"] "exclude": ["node_modules", "dist", "build", ".svelte-kit"]
} }

View File

@@ -1,6 +1,15 @@
import { sveltekit } from '@sveltejs/kit/vite'; import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite'; import { defineConfig } from 'vitest/config';
export default defineConfig({ export default defineConfig({
plugins: [sveltekit()], plugins: [sveltekit()],
// Vitest config (T007)
test: {
globals: true,
environment: 'jsdom',
css: true,
include: ['src/**/*.{test,spec}.{js,ts}', 'tests/**/*.{test,spec}.{js,ts}'],
exclude: ['tests/e2e/**', 'node_modules/**'],
reporters: 'default'
}
}); });

View File

@@ -6,6 +6,10 @@
"scripts": { "scripts": {
"build": "pnpm -r --if-present build", "build": "pnpm -r --if-present build",
"test": "pnpm -r --if-present test", "test": "pnpm -r --if-present test",
"test:unit": "pnpm -r --filter @glowtrack/web --if-present test:unit",
"test:e2e": "pnpm -r --filter @glowtrack/web --if-present test:e2e",
"playwright:install": "pnpm -C apps/web exec playwright install --with-deps",
"ci": "bash tools/ci/run-tests.sh",
"lint": "pnpm -r --if-present lint", "lint": "pnpm -r --if-present lint",
"typecheck": "pnpm -r --if-present typecheck || pnpm -r --if-present check", "typecheck": "pnpm -r --if-present typecheck || pnpm -r --if-present check",
"format": "pnpm -r --if-present format" "format": "pnpm -r --if-present format"

926
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -55,7 +55,7 @@ Paths below are absolute to this repo.
- Wire Tailwind into src/app.css and +layout.svelte - Wire Tailwind into src/app.css and +layout.svelte
- Dependencies: T005 - Dependencies: T005
- [ ] T007 Vitest + Playwright test harness - [X] T007 Vitest + Playwright test harness
- apps/web: vitest config (vitest + svelte), playwright.config.ts with basic smoke project - apps/web: vitest config (vitest + svelte), playwright.config.ts with basic smoke project
- Root CI scripts in tools/ci (stub) and package scripts wiring - Root CI scripts in tools/ci (stub) and package scripts wiring
- Dependencies: T005 - Dependencies: T005

View File

@@ -1,3 +1,7 @@
# CI Tools # CI Tools
Placeholder for CI scripts and config. This directory contains stub scripts and notes for running tests locally or in CI:
- run-tests.sh — runs typecheck, Vitest unit tests, builds the app, and Playwright e2e tests.
Integrate with your CI runner by invoking the script after installing dependencies and preparing Playwright browsers.

9
tools/ci/run-tests.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
echo "[CI] Running typecheck and unit tests (e2e optional)"
pnpm -r --filter @glowtrack/web typecheck || true
pnpm -r --filter @glowtrack/web test:unit || true
pnpm -r --filter @glowtrack/web build
# To run e2e locally with browsers installed, uncomment the line below
# pnpm -r --filter @glowtrack/web test:e2e || true