Files
KomediruzeckiandGitHub e5931959c1 Retire the Express backend; run e2e against the Worker (#428)
* chore: retire the Express backend, run e2e against the Worker

backend/ had not shipped for a long time. ci.yml stopped testing it,
nothing deploys it, browser-only mode is IndexedDB and cloud mode is the
Worker. But it was a complete server — routes, models, repositories, its
own test suite — and it kept attracting fixes that could never reach a
user.

The one thing holding it in the tree was e2e.yml. 35 Playwright specs
drive the real built frontend, and something had to answer /api. That is
now wrangler dev against a local D1: the runtime that actually serves the
app, so the suite finally tests what ships.

playwright.config.ts starts both servers itself — wrangler on :8787 after
d1:migrate:local, then vite on :3800 with its proxy pinned at it — and
runs a setup project first. So `pnpm run test:e2e` does the whole thing
locally, which the four curl commands it replaces never did.

global.setup.ts registers the fixture account through the real API, marks
it verified, puts it on a plan without a profile cap, seeds the fixture
profile and signs in ONCE. Every context inherits that storageState.
Signing in per context was spending the per-IP login budget on machines
with enough cores to run a context per CPU. It also clears rate_limits
first: the local database survives between runs and so did the counters,
so the seventh run of an afternoon failed at sign-in with a 429.

e2e-seed.ts is the dataset, written where the tests are instead of inside
a server's seed routine. Two accounts, six categories, two years of
transactions, goals, a loan, three holdings, a paid and an unpaid bill.
Each of those exists because a page renders its empty state without it —
and the two years are because the transactions page paginates at 50 rows.

Also gone: db/, test/backend/, test/e2e/backend-api/, test/benchmark/,
Dockerfile, docker-compose.yml, .dockerignore, the nuke-* scripts, the
root start/lint:backend/test:backend scripts, and better-sqlite3, bcrypt
and sqlite3 from onlyBuiltDependencies.

* chore: finish the e2e move and update the docs for it

Full suite against the Worker: 514 passed, 1 skipped, 0 failed.

Three things the move surfaced:

api.spec.ts asserted `x-ratelimit-limit`, a header express-rate-limit
set on a server that no longer exists. The Worker's limiter counts in D1
and answers a refusal with Retry-After, so the test now drives the export
limiter until it refuses and checks that.

The retirement chart-zoom spec wheeled at boundingBox() centre without
scrolling first. boundingBox() reports document coordinates, so a chart
below the fold got a wheel event that scrolled the page instead of
zooming — and how far down it sits depends on the data.

Workers are capped at 4 rather than one per CPU. Every worker drives the
same local D1 through one wrangler process, and a machine with a lot of
cores turned that into enough contention that pages timed out on their
first fetch, which reads as "the goals list is empty".

AGENTS.md, README.md and CONTRIBUTING.md now describe a tree without
backend/ in it, and point at `pnpm test:e2e` and worker/.dev.vars.

* ci(e2e): install the worker's own dependencies

worker/ is deliberately not a pnpm workspace member, so the root
`pnpm install` never reached it. It did not matter until the suite
started needing its wrangler: `sh: 1: wrangler: not found`.

Same install deploy-worker.yml uses.

* ci(e2e): run the suite serially, so one workerd crash cannot sink it

Four Playwright workers on a 4-vCPU runner meant four headless Chromiums,
vite and wrangler's workerd at once. Twenty seconds in, wrangler dev printed
an empty error and exited; nothing restarts it, so all 17 remaining specs
failed on a 502 from the vite proxy rather than on anything they assert.

One worker on CI, one retry, and a 30-minute job bound.
2026-08-24 03:44:56 +02:00

132 lines
4.5 KiB
Markdown

# Contributing to Finance Manager
Thank you for your interest in contributing!
Before your first change, read **[AGENTS.md](./AGENTS.md)** — it says what ships, what is retired
but still in the tree, and the few rules that will bite you (migrations are append-only; only a
`v*` tag reaches production).
## Getting Started
### Prerequisites
- Node.js 20+
- pnpm 10+
### Setup
```bash
git clone https://github.com/Komediruzecki/finance-manager.git
cd finance-manager
pnpm install
```
### Development
Two things ship: the app and the API.
- **`frontend/`** — SolidJS SPA with Vite. Also runs with no server at all, on IndexedDB.
- **`worker/`** — the API: Hono on Cloudflare Workers, with D1 for data and R2 for receipts.
```bash
# The API on :8787 — wrangler dev against a local D1
pnpm run dev:worker
pnpm -C worker run d1:migrate:local # once, and after pulling new migrations
# The app on :3800, proxying /api to :8787
pnpm run dev
```
The Worker needs a `JWT_SECRET` to sign sessions. Put any string in `worker/.dev.vars` — locally it
signs for a database under `worker/.wrangler` that you can delete at any time.
## Workflow
1. **Find an issue** — Pick an open issue from [GitHub Issues](https://github.com/Komediruzecki/finance-manager/issues), or open one to discuss your idea first
2. **Create a feature branch** — Branch off `main`:
```bash
git checkout -b feat/issue-NUMBER-short-description
```
Use branch prefixes: `feat/`, `fix/`, `refactor/`, `docs/`, `chore/`
3. **Make changes** — Follow the code style and write tests
4. **Commit** — Use [Conventional Commits](https://www.conventionalcommits.org/):
```bash
git commit -m "feat: add transaction search"
git commit -m "fix: resolve pagination off-by-one"
```
5. **Push and open a PR** — Open a pull request against `main`
6. **CI must pass** — Lint, typecheck, build, and tests must all pass before review
## Testing
```bash
pnpm run test # frontend — vitest + fake-indexeddb
pnpm -C worker run test # worker — vitest in a real Worker isolate, against a real D1
pnpm run typecheck # both
pnpm run lint # frontend eslint
```
Neither suite needs a server running: the frontend fakes IndexedDB, and the Worker suite boots the
Worker itself with migrations applied.
New behaviour needs a test that fails without the change. A guard needs a test that fails when the
guard is removed — it is worth deleting the guard once to check that it does.
The Playwright suite is the exception — it drives the real built app against a real Worker:
```bash
pnpm run test:e2e # everything
pnpm -C frontend run test:e2e:smoke # the @smoke subset CI runs on pull requests
```
It starts both servers itself, applies the migrations, registers a fixture account and seeds it.
`frontend/tests/e2e-seed.ts` is the test data. Delete `worker/.wrangler` to start from an empty
database.
## Code Style
- TypeScript for frontend code
- ESLint + Prettier configured — run `pnpm run lint` before committing
- Follow existing patterns in the codebase
- **No emojis** — not in components, buttons, headings, labels, logs, or commit messages. Use an
SVG icon: reuse one from the file you are editing, or add a new icon component.
### Editable form controls
Read [`.claude/skills/solid-forms/SKILL.md`](.claude/skills/solid-forms/SKILL.md) before
adding an `<input>` or a list of editable rows. Four bugs have shipped from this area more
than once, and all four look correct in a diff:
- a `<For>` over editable rows rebuilds each row on every keystroke, so the field loses
focus after one character — use `<Index>`
- `value={n}` + `onInput={e => set(Number(e.currentTarget.value))}` writes back under the
caret, so the field cannot be emptied and cannot hold a decimal — use `NumberField`
- an unrounded derived number fails HTML5 `step` validation and silently blocks the whole
form from saving — round where the number is produced
- `<input type="month">` makes users click back one year at a time — use `MonthPicker`
## Pull Request Guidelines
- Keep PRs focused on a single change
- Include a clear description of what changed and why
- Link to the issue being resolved
- Ensure all checks pass before requesting review
## Reporting Bugs
Open an issue with:
- Steps to reproduce
- Expected vs actual behavior
- Browser and OS details
- Any relevant console errors
## Questions?
Open a [discussion](https://github.com/Komediruzecki/finance-manager/issues) or ask in an issue.