Skip to content

Commit 23f1bf5

Browse files
authored
Merge pull request #4 from chamika/add-tests
feat: extract handicap score calculation logic into a new module and add unit tests
2 parents e39e444 + cfa2cbf commit 23f1bf5

10 files changed

Lines changed: 630 additions & 64 deletions

File tree

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
frontend:
11+
name: Frontend CI
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: frontend
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
24+
cache: 'npm'
25+
cache-dependency-path: frontend/package-lock.json
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Sync SvelteKit
31+
run: npx svelte-kit sync
32+
33+
- name: Check Types
34+
run: npm run check
35+
36+
- name: Lint
37+
run: npm run lint
38+
39+
- name: Unit Tests
40+
run: npm run test:unit
41+
42+
- name: Install Playwright Browsers
43+
run: npx playwright install --with-deps
44+
45+
- name: E2E Tests
46+
run: npm run test:e2e
47+
48+
- name: Build
49+
run: npm run build
50+
51+
worker:
52+
name: Worker CI
53+
runs-on: ubuntu-latest
54+
defaults:
55+
run:
56+
working-directory: worker
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
61+
- name: Setup Node.js
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: '20'
65+
cache: 'npm'
66+
cache-dependency-path: worker/package-lock.json
67+
68+
- name: Install dependencies
69+
run: npm ci
70+
71+
- name: Build
72+
run: npx wrangler deploy --dry-run --outdir=dist

README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ This repository now contains two main pieces:
1212
- `frontend/` — A SvelteKit (TypeScript) frontend scaffold. The home page (`src/routes/+page.svelte`) contains tiles that link to individual tools (e.g. `/handicap`).
1313
- `worker/` — A Cloudflare Worker scaffold (TypeScript) using `Hono` for lightweight API endpoints. It exposes `/api/handicap` and `/api/health` handlers.
1414

15-
Quick start (local)
16-
-
15+
## Quick start (local)
16+
1717
Prereqs: Node 18+, npm, and `wrangler` for Cloudflare Workers.
1818

1919
1. Frontend
@@ -32,11 +32,36 @@ npm install
3232
npx wrangler dev
3333
```
3434

35-
Deploy notes
35+
## Running Tests
36+
The frontend includes both end-to-end tests (Playwright) and unit tests (Vitest).
37+
38+
```bash
39+
cd frontend
40+
```
41+
42+
### Unit Tests
43+
```bash
44+
npm run test:unit
45+
```
46+
47+
### End-to-End Tests
48+
```bash
49+
# Install Playwright browsers (first time only)
50+
npx playwright install
51+
# Run tests
52+
npm run test:e2e
53+
```
54+
55+
### Run all tests
56+
```bash
57+
npm run test
58+
```
59+
60+
### Deploy notes
3661
- Frontend: build with `npm run build` in `frontend/` and deploy to Cloudflare Pages. SvelteKit supports the Cloudflare adapter for Pages/Workers.
3762
- Worker: publish with `npx wrangler publish` (fill `account_id` in `worker/wrangler.toml`).
3863

39-
Next steps
64+
### Next steps
4065
- Wire the frontend to the Worker API endpoints health endpoint
4166
- Implement availability tracker
4267

frontend/eslint.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ export default defineConfig(
1919
globals: { ...globals.browser, ...globals.node }
2020
},
2121
rules: { // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
22-
// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
23-
"no-undef": 'off' }
22+
// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
23+
"no-undef": 'off',
24+
"svelte/no-navigation-without-resolve": "off"
25+
}
2426
},
2527
{
2628
files: [

0 commit comments

Comments
 (0)