Tasks 001: Split expenses
- Spec:
specs/001-split-expenses/spec.md - Plan:
specs/001-split-expenses/plan.md - Status: Approved
What you are approving
- 12 tasks, one at a time: tool setup, the calculations, saving, the style, then the parts of the page (people, expenses, result, reset) and a final check.
- Each task starts with its tests and ends only when
npm run checkis fully green. After each one I stop and show you the result. - One moment for you: task 6 (page style), where you look at the page and say whether colours and sizes suit you. Checks on a real phone and with a screen reader stay for the final verification.
- My decisions: in tests, automatic checks do not retry (so a flaky test cannot pass silently), and the code style check uses ESLint’s standard rule set.
- Review after verification: two new tasks (T13, T14), so 14 in all, above the limit of 12 per screen. They are small, separate corrections, requested by you, and they do not touch the tasks already done.
- The project has no type check (it is plain JavaScript): the kit asks for one only where it is needed, and it is not in the profile’s checks.
Legend
[ ]to do ·[~]in progress ·[x]done ·[!]blocked (add a note)[P]can run in parallel with the previous task (no shared files or dependencies)- Requires human action: work outside the repository (consoles, accounts, secrets, keys); listed under the task
Phase 1 - Setup / foundation
- T1 Set up the project, the tools and the single check command
- Covers: foundation for all R and AC (no requirement alone); profile Sections 5 and 6
- Depends on: -
- Files / areas:
package.json,package-lock.json,.gitignore(ignoresnode_modules, test reports,.DS_Store),eslint.config.js,playwright.config.js,scripts/serve.js, a placeholderindex.html,tests/unit/,tests/e2e/,project/profile.mdSection 5. - Tests: one unit smoke test (Node test runner) and one end-to-end smoke test that opens the placeholder page in Chromium and WebKit, to prove both runners before any task depends on them.
- Done when: each tool of plan Section 3 is checked with its verification command and the results are reported; exact versions (
@playwright/test1.65.1,@axe-core/playwright4.14.1,eslint10.15.0,@eslint/js10.0.1) are installed with a lock file and nolatest; the Chromium and WebKit test browsers are installed by Playwright’s own command;npm run checkruns lint, unit tests, end-to-end tests (both browsers), andnpm auditand passes; Section 5 of the profile holds the real commands. - Note: all four versions were verified on 2026-12-02; the two newest releases of Playwright and ESLint were skipped on purpose (plan Section 4). Done: Node’s test runner needs a file pattern in
test:unit, not a folder.
Phase 2 - Story slices
Foundation of the logic (used by every story)
- T2 Text catalogue and money module
- Covers: R9 (parse), R26 (format) · AC10, AC33 (format part)
- Depends on: T1
- Files / areas:
src/messages.it.js(all keys of design Section 5),src/money.js,tests/unit/money.test.js - Tests: unit: every input of AC10 with its expected result (accepted values in cents; the others give the right error code);
formatAmountgives “12,50 €” and “99.999,99 €”; “1.000,50” and “12,505” are rejected; a test that every catalogue key of the design exists. - Done when: the tests pass and fail if
parseAmountaccepts “12,505” or “0”;npm run checkpasses. - Note: the euro form uses a non-breaking space before the euro sign (what the platform produces); the catalogue is checked against the design text.
- T3 Rules for people and expenses
- Covers: R2, R3, R4, R5, R6, R8, R10, R12, R30 (rules part) · AC2-AC7 (unit part), AC9, AC11 (unit part), AC16 (unit part), AC37 (unit part)
- Depends on: T2
- Files / areas:
src/rules.js,tests/unit/rules.test.js - Tests: unit: names (trim, 1 to 30 visible characters including accented letters and a letter with a separate accent, duplicates ignoring case and accents, the 13th person); description 1 to 60; no sharer; no payer; the 501st expense;
canRemovePersonfor a payer and for a sharer. - Done when: all listed cases pass and each would fail if its rule were removed;
npm run checkpasses. - Note: name errors are checked in the order empty, too long, duplicate, limit; all expense errors are reported together.
- T4 Split, balances and minimal payments
- Covers: R11, R15, R16, R17 · AC12, AC13, AC14, AC15, AC20, AC21, AC22, AC23, AC24 (unit part)
- Depends on: T3
- Files / areas:
src/split.js,tests/unit/split.test.js - Tests: unit: the examples of AC12-AC15 and AC21-AC22; seeded random sets (up to 12 people, awkward cents): balances sum to 0 and applying all payments leaves 0 with no payment of 0 or less; count never above non-zero balances minus 1; the result is the same on repeated runs.
- Done when: all pass; the AC22 test fails against a greedy pairing;
npm run checkpasses. - Note: the AC22 example alone does not separate the exact method from a largest-first pairing (both give 2); an added case (+1 +3 +3 -5 -6 +4: 4 payments against 5) does.
- T5 Storage with full validation
- Covers: R19, R20, R21, R22 (logic part) · AC27 (unit part), AC28 (unit part), AC26 (unit part)
- Depends on: T3
- Files / areas:
src/storage.js,tests/unit/storage.test.js - Tests: unit with a fake storage: save then load returns the same record; each of these is rejected whole: unreadable text, unknown version, wrong types, extra fields, unknown payer, unknown sharer, duplicate names, 13 people, 501 expenses, amount out of range; a refused write returns
refusedand does not throw;resetAllleaves an empty record. - Done when: all pass;
npm run checkpasses. - Note: storage not available at all reads as empty and then refuses writes (R21); reset saves an empty record instead of removing the key.
Style and shell
- T6 Design system and page shell
- Covers: R28 (design system, 360 px, targets), R29 (policy), W2, W3 · AC35 (shell part), AC36 (policy part)
- Depends on: T1
- Requires human action: look at the shell on screen (light and dark) and say whether colours and sizes are fine.
- Files / areas:
project/design-system.md(tokens, light and dark values, components of design Section 4),styles.css,index.html(areas, landmarks, title, content policy),tests/e2e/shell.spec.js - Tests: e2e in Chromium and WebKit: the shell loads at 360 px with no horizontal scroll, axe reports no violations in light and dark, the policy tag is present and strict (a test fails if it allows external sources or connections), no hard-coded colour, spacing or size outside tokens (a check on the stylesheet), and reduced motion disables motion.
- Done when: tests pass, the human approves the look,
npm run checkpasses. - Note: adds
design-system-preview.html(a development specimen of every component, not part of the product, not to be published) andsrc/ui/text.js(fills texts from the catalogue); the page title and the name “BuddySplit” are the product name, not catalogue text.
US1 - People
- T7 People area with app state and saving
- Covers: R1-R6, R19 (save and restore), R23 (people), R24 (name field), R25 (names), R27 (no people) · AC1, AC2, AC3, AC4, AC5, AC6, AC7 (e2e part), AC30 (person part), AC32 (names), AC34 (no people), AC35 (this area)
- Depends on: T3, T5, T6
- Files / areas:
src/main.js(app state, load, save after each change),src/ui/people.js,tests/e2e/people.spec.js - Tests: e2e in both browsers: add, trim, empty, 30 versus 31 characters (accented), duplicates, 12 people; remove allowed and not allowed (a payer prepared through stored data); double tap and Enter twice give one person and no message; names with markup appear literally; reload keeps people in order; axe on each state; keyboard-only.
- Done when: all pass in both browsers;
npm run checkpasses. - Note: a repeated submit is ignored until the user types again (not on focus change); person announcements done after the change request (“Person added”, “Person removed”); the keyboard test uses Option+Tab for buttons in WebKit on macOS (a Safari setting).
US2 - Record an expense
- T8 Expense panel: add
- Covers: R7-R12 (UI), R23 (expenses), R24, R25 (descriptions), R27 (no expenses), R30 · AC8, AC11 (e2e), AC16 (e2e), AC30 (expense part), AC31, AC32 (descriptions), AC34 (no expenses), AC37 (e2e), AC12 (display only: the expense shows with its values)
- Depends on: T3, T7
- Files / areas:
src/ui/expense-panel.js,src/ui/expenses.js,tests/e2e/expense-add.spec.js - Tests: e2e in both browsers: the AC8 flow; no sharer, no payer, bad amount and bad description each rejected with their message and values kept; all people ticked at first, payer not chosen; 501st expense rejected (prepared record); double tap on “Save” gives one expense and no error; description with markup shown literally; focus moves into the panel and returns; Escape and “Cancel” close; axe on the panel.
- Done when: all pass;
npm run checkpasses. - Note: the panel is a native dialog (focus trap and Escape come from the browser; focus is given back explicitly because Safari does not focus clicked buttons); expense rows are plain rows until T9 makes them open the panel; “Expense saved” is announced; adds the panel component to
project/design-system.md.
US3 - Fix a mistake
- T9 Edit and delete an expense
- Covers: R13, R14 · AC17, AC18, AC19
- Depends on: T8
- Files / areas:
src/ui/expense-panel.js,src/ui/confirm.js,tests/e2e/expense-edit.spec.js - Tests: e2e: edit all four fields and see only new values; invalid edit leaves old values; the payer cannot be cleared; delete with confirmation removes it, without confirmation changes nothing; the list position is kept after an edit.
- Done when: all pass in both browsers;
npm run checkpasses. - Note: expense rows are now buttons; the confirmation is a native dialog (
src/ui/confirm.js, reused by T11); a repeated tap on the spot of a save or delete is swallowed for half a second so it cannot hit the page behind (src/main.js); T8 tests changed only to ignore the hidden delete button.
US4 - See who owes whom
- T10 Result area
- Covers: R15, R16, R17, R18, R27 (result) · AC21, AC22, AC23, AC24 (e2e part), AC25
- Depends on: T4, T9
- Files / areas:
src/ui/result.js,tests/e2e/result.spec.js - Tests: e2e: the AC21 and AC22 examples shown with the right wording (“is owed”, “owes”, “is even”, the payment rows), the “all even” message, an update after every add, edit, delete and person removal without reload; the result is a polite live region; axe.
- Note: with no people the area shows only “Everyone is even.”; a person at zero shows “is even” with no sign; the tap shield of T9 now swallows only the second tap of a double tap (
event.detail), so a quick new tap on the same spot is not lost.
US5 - Keep and clear the data
- T11 Notices, reset and reopening
- Covers: R19-R22 (UI) · AC26, AC27, AC28, AC29
- Depends on: T5, T10
- Files / areas:
src/ui/notices.js,src/ui/reset.js,tests/e2e/persistence.spec.js - Tests: e2e: a full session survives a reload with the same order and values; each kind of broken stored record gives the notice, shows no data and, after the confirmed offer, an empty working page; refused storage shows the notice and everything still works; reset with and without confirmation, also after reload; the confirmation says the data cannot be recovered.
- Note: saving not allowed is found by trying one save at load (nothing saved yet) and at every change; unreadable data is kept untouched until the user agrees or saves something new, which replaces it and removes the notice; the notices are drawn again only when they change, so a screen reader does not repeat them.
Phase 3 - Hardening
- T12 Final pass: accessibility, text, network, speed
- Covers: R25, R26, R28, R29 · AC32 (all places), AC33, AC35, AC36
- Depends on: T11
- Requires human action: none in this task; the real-phone and screen-reader checks are listed in
specs/001-split-expenses/manual-checks.mdfor theverifyphase. - Files / areas:
tests/e2e/hardening.spec.js,specs/001-split-expenses/manual-checks.md - Tests: e2e in both browsers: no request after load during a full session; no console output; every visible text comes from the catalogue and none is in English; amounts always in the “12,50 €” form; markup in names and descriptions shown literally in every place (lists, results, panel title, announcements); at 360 px no horizontal scroll and every control at least 44x44 px; axe on every state; the whole flow with keyboard only; in Chromium, with CPU slowed fourfold and a slow network profile, the page is usable within 3 seconds.
- Done when: all pass; the file of manual checks lists the phone test, the screen-reader pass and a timing on a phone;
npm run checkpasses;Active featurestays as is. - Note: each state is checked in a page of its own; the busiest page (12 people, 500 expenses) was usable after about 1.0 s with the CPU slowed fourfold and a 1.6 Mbit/s, 150 ms network (the check allows 3 s). Final verification is in the report of this task (fresh install, table of criteria, TBD search, leftovers).
Phase 4 - Fixes from verification 001 (run 1)
- T13 Unreadable saved data is replaced only after confirmation (finding F1)
- Covers: R20 · AC27
- Depends on: T11; design change CR1 (accepted 2026-12-02)
- Files / areas:
tests/e2e/persistence.spec.js(first: the test “using the page without answering replaces the unreadable data” becomes the opposite),src/main.js,src/ui/people.js,src/ui/expenses.js - Tests: e2e in both browsers: with unreadable stored data, the name field, “Add” and “Add expense” are not offered while the notice is shown; after a reload the stored text is still the unreadable one; after “Start again” and confirmation the page is empty and works; without confirmation nothing changes; axe on the notice state.
- Done when: all pass and the new test fails against the current code;
npm run checkpasses. - Note: the form of the people area and the add-expense button are hidden while the notice is shown; the old test “using the page without answering replaces the data” was turned into its opposite.
- T14 Names and descriptions need at least one visible character (finding F2)
- Covers: R2, R8, R20 · AC2, AC9, AC27 (unit part)
- Depends on: T3, T5
- Files / areas:
src/rules.js,tests/unit/rules.test.js,tests/unit/storage.test.js - Tests: unit: a name or description made only of a zero-width space (U+200B), only a lone combining accent (U+0301), or containing a control character (U+0000-U+001F, U+007F) is rejected with the “empty” code for no visible character and the existing codes otherwise; normal accented names and “Ánna” still pass; a stored record with such a name is rejected whole.
- Done when: all pass and each new case fails against the current code;
npm run checkpasses. - Note: “visible” is read from R2 (“each visible character counts”): a text with no visible character counts as empty, so it uses the existing empty message; a control character inside a name is rejected with the same message (no new catalogue text).
- Note: a text is visible if it has a letter, digit, punctuation mark or symbol (emoji count); control characters anywhere are rejected.
Notes / blockers
- Tools’ default settings that could weaken a gate, listed for the human: ESLint uses its standard recommended rule set (no stricter rules); Playwright runs with no automatic retries, so an unstable test fails instead of passing on a second try; no type checker exists (plain JavaScript). Change any of these by asking.
Change requests
- CR1 (design, for T13): in
design.md, the row “Notice: unreadable data” adds: while the notice is shown, the name field, “Add” and “Add expense” are not offered; the only way on is “Start again” with confirmation. Impact: one row of the design; spec unchanged (R20 already says to offer starting empty). Accepted by the human on 2026-12-02 and applied todesign.md.
Open questions
(none)
Interpretations
- Twelve tasks, within the limit for one screen; the pure-logic steps of the plan became T2-T5, the plan’s last step became T12.
manual-checks.mdis a new file not named in the plan; it holds what only the human can check (plan Section 11).- AC12 is proved by calculation in T4; T8 only shows that the expense appears with its values.
- Some criteria are split across tasks as marked: unit part where the rule lives, UI part where it appears (for example AC2-AC7 in T3 and T7).
- Tests that need data in a state the screen cannot reach quickly (501 expenses, a payer in use, broken records) use prepared stored records, as the plan says.
Approval
- Approved by: Luca Lanzano
- Date: 2026-12-02
Change log
- 2026-12-02: change request accepted by the human: T7 reopened for the person announcements; T8, T9 and T12 use the expense announcements (design status.*); approval reset to Draft.
- 2026-12-02: revision after verification 001: added T13 (F1) and T14 (F2); F3 to be accepted at closure; approval reset to Draft.