Subtract numbers #2

Closed
opened 2026-11-21 03:35:32 +00:00 by lab-admin · 15 comments
Owner

Add subtraction next to addition.

Requirements

  • API: op=subtract returns a - b.
  • UI: a − (minus) button that works like +. Pressing 7, −, 1, 0, = shows -3.
  • Addition keeps working; error handling stays the same (400 {"error"} for bad input).
  • Tests for the new operation in the module, API and page.

Acceptance criteria

  1. /api/calculate?a=2&b=5&op=subtract returns {"result":-3}.
  2. /api/calculate?a=0.5&b=0.25&op=subtract returns {"result":0.25}.
  3. op=add still works and an unknown op still returns 400.
  4. The page has a minus button and shows differences returned by the API.
Add subtraction next to addition. ## Requirements - API: `op=subtract` returns `a - b`. - UI: a `−` (minus) button that works like `+`. Pressing `7`, `−`, `1`, `0`, `=` shows `-3`. - Addition keeps working; error handling stays the same (`400 {"error"}` for bad input). - Tests for the new operation in the module, API and page. ## Acceptance criteria 1. `/api/calculate?a=2&b=5&op=subtract` returns `{"result":-3}`. 2. `/api/calculate?a=0.5&b=0.25&op=subtract` returns `{"result":0.25}`. 3. `op=add` still works and an unknown op still returns 400. 4. The page has a minus button and shows differences returned by the API.
Collaborator

Aira · queued

Aira picked up this task. Branch aira/2-subtract-numbers.

**Aira · queued** Aira picked up this task. Branch `aira/2-subtract-numbers`.
Collaborator

Aira · planning

Orchestrator thread started (composer-2.5). Planning on aira/2-subtract-numbers.

T3 thread: mcp:launch:3f79cce400bebb9c180944023ea917269230774dee793fbb184ddebbd481cbb9

**Aira · planning** Orchestrator thread started (composer-2.5). Planning on `aira/2-subtract-numbers`. T3 thread: `mcp:launch:3f79cce400bebb9c180944023ea917269230774dee793fbb184ddebbd481cbb9`
Collaborator

Aira · Plan (round 1) at 24229b41

Wrote docs/plans/issue-2.md for subtraction (API op=subtract, UI minus button, tests); committed and pushed aira/2-subtract-numbers.

docs/plans/issue-2.md

Issue #2: Subtract numbers

Goal

Extend the calculator with subtraction end-to-end: handle op=subtract in lib/calculator.js as a - b, expose it through the existing GET /api/calculate route (unchanged contract), and add a − (U+2212 minus) keypad button that behaves like +. The flow 7, −, 1, 0, = must display -3 via the API. Addition, validation, and error responses remain unchanged.

Acceptance criteria

  1. GET /api/calculate?a=2&b=5&op=subtract returns HTTP 200 with body {"result":-3}.
  2. GET /api/calculate?a=0.5&b=0.25&op=subtract returns HTTP 200 with body {"result":0.25}.
  3. GET /api/calculate?a=2&b=3&op=add still returns {"result":5}; unknown op (e.g. pow) still returns HTTP 400 with an error string.
  4. The page at / includes a minus button; pressing operands and = with subtraction selected shows the difference returned by the API (same pattern as addition).

Design

Calculator module (lib/calculator.js)

  • Extend calculate(a, b, op) with a branch for op === 'subtract': compute x - y after existing parseNumber on both operands.
  • Reuse the same post-operation check as add: if the result is not finite, throw result out of range.
  • Keep parseNumber and the unknown-op path unchanged (throw new Error('unknown operation') for anything other than add / subtract).

HTTP layer (server.js)

  • No route or validation changes required: handleCalculate already passes op through to calculate; new operation is recognized only in the module layer.
  • Confirm existing 400 mapping for unknown ops and invalid operands still applies to subtract.

UI (public/index.html)

  • Add a keypad button labeled − (minus sign, not hyphen-minus) with data-key="-" or a dedicated key value consistent with how operator selection is stored (e.g. data-key="−" with internal mapping to op=subtract in the fetch).
  • Introduce (or extend) operator state alongside left and afterOp: when the user presses + or −, commit the current operand as left and remember the chosen op (add vs subtract).
  • On =, call fetch with op set from the remembered operator (default add only if an operator was set; keep current guard if (left === null) return).
  • Example acceptance flow: digits 7 → − → 1, 0 → = → GET /api/calculate?a=7&b=10&op=subtract → display -3.
  • Preserve C, decimal input, and addition flow from issue #1.

Test layout

File Scope
test/calculator.test.js Unit tests for subtract and regressions on add / unknown op
test/server.test.js HTTP tests for subtract success cases (AC1–2), add still works, unknown op 400 (AC3)
test/ui.test.js Assert minus button present in HTML; keep existing digit/+/= checks

Files to change

File Action
lib/calculator.js Modify — add subtract branch in calculate
server.js No change (unless a bug found; not expected)
public/index.html Modify — minus button, operator state, dynamic op on =
test/calculator.test.js Modify — subtract unit cases
test/server.test.js Modify — subtract API cases + regression
test/ui.test.js Modify — require minus button in HTML

Do not edit .forgejo/workflows/ci.yml for this task.

Test plan

Unit (test/calculator.test.js)

Test Criterion
calculate('2', '5', 'subtract') → -3 AC1 (module)
calculate('0.5', '0.25', 'subtract') → 0.25 AC2 (module)
calculate('2', '3', 'add') → 5 AC3 regression
calculate('1', '2', 'pow') throws AC3 regression
Optional: subtract overflow / non-finite result → out of range Parity with add

HTTP API (test/server.test.js)

Test Criterion
?a=2&b=5&op=subtract → 200, result: -3 AC1
?a=0.5&b=0.25&op=subtract → 200, result: 0.25 AC2
?a=2&b=3&op=add → 200, result: 5 AC3
?a=1&b=2&op=pow → 400, error string AC3
Existing error cases (missing a/b, non-numeric, empty) with op=subtract where applicable AGENTS.md contract

All existing server tests (health, index, 404, add errors) must still pass.

UI / page (test/ui.test.js)

  • GET / HTML includes a minus control (e.g. data-key or button text −).
  • Existing assertion that HTML references /api/calculate remains valid.
  • Optional: document manual check 7 − 1 0 = → -3 in browser (automation out of scope for node --test).

Local gate

  • Run npm test before every push; all tests green.

Risks

Risk Mitigation
UI hardcodes op=add on = Plan requires storing selected operator; code review against AC4 flow
Confusing − (U+2212) vs - (ASCII) in tests UI test match on data-key or escaped minus in HTML; API uses string subtract
Subtraction produces -0 or float noise Mirror add behaviour: show API result as JSON number; assert exact values in tests from task
Breaking addition or validation Run full test suite; keep add and error tests unchanged except new subtract cases
Keypad layout overflow Place − adjacent to + following same grid pattern as issue #1

Implementation order

  1. lib/calculator.js subtract branch + unit tests in test/calculator.test.js
  2. API tests in test/server.test.js (module already wired)
  3. public/index.html minus button and operator state + test/ui.test.js
  4. Full npm test, then push aira/2-subtract-numbers

Attachment: plan-2-r1.md

**Aira · Plan (round 1) at `24229b41`** Wrote docs/plans/issue-2.md for subtraction (API op=subtract, UI minus button, tests); committed and pushed aira/2-subtract-numbers. <details><summary>docs/plans/issue-2.md</summary> # Issue #2: Subtract numbers ## Goal Extend the calculator with subtraction end-to-end: handle `op=subtract` in `lib/calculator.js` as `a - b`, expose it through the existing `GET /api/calculate` route (unchanged contract), and add a `−` (U+2212 minus) keypad button that behaves like `+`. The flow `7`, `−`, `1`, `0`, `=` must display `-3` via the API. Addition, validation, and error responses remain unchanged. ## Acceptance criteria 1. `GET /api/calculate?a=2&b=5&op=subtract` returns HTTP 200 with body `{"result":-3}`. 2. `GET /api/calculate?a=0.5&b=0.25&op=subtract` returns HTTP 200 with body `{"result":0.25}`. 3. `GET /api/calculate?a=2&b=3&op=add` still returns `{"result":5}`; unknown `op` (e.g. `pow`) still returns HTTP 400 with an `error` string. 4. The page at `/` includes a minus button; pressing operands and `=` with subtraction selected shows the difference returned by the API (same pattern as addition). ## Design ### Calculator module (`lib/calculator.js`) - Extend `calculate(a, b, op)` with a branch for `op === 'subtract'`: compute `x - y` after existing `parseNumber` on both operands. - Reuse the same post-operation check as `add`: if the result is not finite, throw `result out of range`. - Keep `parseNumber` and the unknown-op path unchanged (`throw new Error('unknown operation')` for anything other than `add` / `subtract`). ### HTTP layer (`server.js`) - No route or validation changes required: `handleCalculate` already passes `op` through to `calculate`; new operation is recognized only in the module layer. - Confirm existing 400 mapping for unknown ops and invalid operands still applies to subtract. ### UI (`public/index.html`) - Add a keypad button labeled `−` (minus sign, not hyphen-minus) with `data-key="-"` or a dedicated key value consistent with how operator selection is stored (e.g. `data-key="−"` with internal mapping to `op=subtract` in the fetch). - Introduce (or extend) operator state alongside `left` and `afterOp`: when the user presses `+` or `−`, commit the current operand as `left` and remember the chosen op (`add` vs `subtract`). - On `=`, call `fetch` with `op` set from the remembered operator (default `add` only if an operator was set; keep current guard `if (left === null) return`). - Example acceptance flow: digits `7` → `−` → `1`, `0` → `=` → `GET /api/calculate?a=7&b=10&op=subtract` → display `-3`. - Preserve `C`, decimal input, and addition flow from issue #1. ### Test layout | File | Scope | |------|--------| | `test/calculator.test.js` | Unit tests for `subtract` and regressions on `add` / unknown op | | `test/server.test.js` | HTTP tests for subtract success cases (AC1–2), `add` still works, unknown op 400 (AC3) | | `test/ui.test.js` | Assert minus button present in HTML; keep existing digit/`+`/`=` checks | ## Files to change | File | Action | |------|--------| | `lib/calculator.js` | **Modify** — add `subtract` branch in `calculate` | | `server.js` | **No change** (unless a bug found; not expected) | | `public/index.html` | **Modify** — minus button, operator state, dynamic `op` on `=` | | `test/calculator.test.js` | **Modify** — subtract unit cases | | `test/server.test.js` | **Modify** — subtract API cases + regression | | `test/ui.test.js` | **Modify** — require minus button in HTML | Do not edit `.forgejo/workflows/ci.yml` for this task. ## Test plan ### Unit (`test/calculator.test.js`) | Test | Criterion | |------|-----------| | `calculate('2', '5', 'subtract')` → `-3` | AC1 (module) | | `calculate('0.5', '0.25', 'subtract')` → `0.25` | AC2 (module) | | `calculate('2', '3', 'add')` → `5` | AC3 regression | | `calculate('1', '2', 'pow')` throws | AC3 regression | | Optional: subtract overflow / non-finite result → `out of range` | Parity with `add` | ### HTTP API (`test/server.test.js`) | Test | Criterion | |------|-----------| | `?a=2&b=5&op=subtract` → 200, `result: -3` | AC1 | | `?a=0.5&b=0.25&op=subtract` → 200, `result: 0.25` | AC2 | | `?a=2&b=3&op=add` → 200, `result: 5` | AC3 | | `?a=1&b=2&op=pow` → 400, `error` string | AC3 | | Existing error cases (missing `a`/`b`, non-numeric, empty) with `op=subtract` where applicable | AGENTS.md contract | All existing server tests (health, index, 404, add errors) must still pass. ### UI / page (`test/ui.test.js`) - `GET /` HTML includes a minus control (e.g. `data-key` or button text `−`). - Existing assertion that HTML references `/api/calculate` remains valid. - Optional: document manual check `7` `−` `1` `0` `=` → `-3` in browser (automation out of scope for `node --test`). ### Local gate - Run `npm test` before every push; all tests green. ## Risks | Risk | Mitigation | |------|------------| | UI hardcodes `op=add` on `=` | Plan requires storing selected operator; code review against AC4 flow | | Confusing `−` (U+2212) vs `-` (ASCII) in tests | UI test match on `data-key` or escaped minus in HTML; API uses string `subtract` | | Subtraction produces `-0` or float noise | Mirror add behaviour: show API `result` as JSON number; assert exact values in tests from task | | Breaking addition or validation | Run full test suite; keep `add` and error tests unchanged except new subtract cases | | Keypad layout overflow | Place `−` adjacent to `+` following same grid pattern as issue #1 | ## Implementation order 1. `lib/calculator.js` subtract branch + unit tests in `test/calculator.test.js` 2. API tests in `test/server.test.js` (module already wired) 3. `public/index.html` minus button and operator state + `test/ui.test.js` 4. Full `npm test`, then push `aira/2-subtract-numbers` </details> Attachment: [plan-2-r1.md](https://aira-lab.cluster-dev.spkey.co/attachments/ba58d511-e434-4d5c-bc52-ff4b2d602872)
Collaborator

Aira · plan review

Plan pushed at 24229b41; independent Dodik plan review started.

**Aira · plan review** Plan pushed at `24229b41`; independent Dodik plan review started.
Collaborator

Aira · dodik-plan PASS on 24229b41

The issue #2 plan maps subtraction to four numbered criteria and specifies the right changes: a subtract branch in lib/calculator.js after the existing parseNumber and finite-result checks, no server.js route change because handleCalculate already forwards op and maps thrown errors to 400, and a U+2212 keypad button plus remembered operator in public/index.html so 7, minus, 1, 0, equals fetches a=7&b=10&op=subtract and displays -3. Unit and HTTP tests cover both success cases, the add regression, unknown op, and invalid operands; the page test adds the minus control beside the existing button checks. Scope stays on the calculator, the page, and the three test files. The current suite is 17 passing tests and matches that baseline.

Checks performed
  • Task requirements map to plan acceptance criteria 1–4, including 2−5=−3, 0.5−0.25=0.25, add and unknown-op regressions, and a minus button that shows the API difference.
  • Read lib/calculator.js, server.js, public/index.html, and test/calculator.test.js, test/server.test.js, and test/ui.test.js: calculate only implements add then throws unknown operation; handleCalculate passes op through and returns 400 {error}; the page hardcodes op=add and stores left/afterOp with data-key buttons.
  • Test plan proves AC1–AC2 at unit and HTTP level, AC3 with add and pow at both levels, and invalid, missing, and empty operands for subtract, plus the existing health, index, 404, and add error tests.
  • Files to change are limited to lib/calculator.js, public/index.html, and the three test files; server.js and .forgejo/workflows/ci.yml stay out of scope.
  • npm test: 17 passed, 0 failed, matching the plan’s description of current add, validation, and keypad coverage.

Attachment: dodik-plan-24229b41.json

**Aira · dodik-plan PASS on `24229b41`** The issue #2 plan maps subtraction to four numbered criteria and specifies the right changes: a subtract branch in lib/calculator.js after the existing parseNumber and finite-result checks, no server.js route change because handleCalculate already forwards op and maps thrown errors to 400, and a U+2212 keypad button plus remembered operator in public/index.html so 7, minus, 1, 0, equals fetches a=7&b=10&op=subtract and displays -3. Unit and HTTP tests cover both success cases, the add regression, unknown op, and invalid operands; the page test adds the minus control beside the existing button checks. Scope stays on the calculator, the page, and the three test files. The current suite is 17 passing tests and matches that baseline. <details><summary>Checks performed</summary> - Task requirements map to plan acceptance criteria 1–4, including 2−5=−3, 0.5−0.25=0.25, add and unknown-op regressions, and a minus button that shows the API difference. - Read lib/calculator.js, server.js, public/index.html, and test/calculator.test.js, test/server.test.js, and test/ui.test.js: calculate only implements add then throws unknown operation; handleCalculate passes op through and returns 400 {error}; the page hardcodes op=add and stores left/afterOp with data-key buttons. - Test plan proves AC1–AC2 at unit and HTTP level, AC3 with add and pow at both levels, and invalid, missing, and empty operands for subtract, plus the existing health, index, 404, and add error tests. - Files to change are limited to lib/calculator.js, public/index.html, and the three test files; server.js and .forgejo/workflows/ci.yml stay out of scope. - npm test: 17 passed, 0 failed, matching the plan’s description of current add, validation, and keypad coverage. </details> Attachment: [dodik-plan-24229b41.json](https://aira-lab.cluster-dev.spkey.co/attachments/6dcbcd5d-840f-4809-991d-802e507d21ad)
Collaborator

Aira · implementing

Plan approved by Dodik at 24229b41. Implementation started.

**Aira · implementing** Plan approved by Dodik at `24229b41`. Implementation started.
Collaborator

Aira · ci

Ready for review at 3aeb445f (PR #10). Waiting for CI.

Implemented subtract in lib/calculator.js, minus keypad and dynamic op in public/index.html, and tests in calculator/server/ui suites (22 passing); committed and pushed to aira/2-subtract-numbers.

**Aira · ci** Ready for review at `3aeb445f` (PR #10). Waiting for CI. Implemented subtract in lib/calculator.js, minus keypad and dynamic op in public/index.html, and tests in calculator/server/ui suites (22 passing); committed and pushed to aira/2-subtract-numbers.
Collaborator

Aira · CI passed on 3aeb445f

  • ci / test (pull_request): success
**Aira · CI passed on `3aeb445f`** - ci / test (pull_request): success
Collaborator

Aira · review

CI is green on 3aeb445f. Independent Dodik and code review started.

**Aira · review** CI is green on `3aeb445f`. Independent Dodik and code review started.
Collaborator

Aira · dodik PASS on 3aeb445f

Commit 3aeb445 adds op=subtract as a-b, a U+2212 minus button that sends that operation, and module, API, and page tests that fail if the new behavior is removed. npm test passed 22/22 with no skips; add and unknown-op errors are unchanged; the diff is limited to the planned files. Live API checks returned {"result":-3} and {"result":0.25}, and replaying 7, minus, 1, 0, = on the page script against the server displayed -3.

Checks performed
  • Diff vs origin/main is only lib/calculator.js, public/index.html, test/calculator.test.js, test/server.test.js, test/ui.test.js, and docs/plans/issue-2.md
  • AC1 and AC2: live GET /api/calculate subtract cases return 200 {"result":-3} and {"result":0.25}, covered by calculator and server tests
  • AC3: op=add still returns {"result":5}; op=pow returns 400 {"error":"unknown operation"}; existing invalid-input tests remain
  • AC4: page button data-key and label are U+2212; scripted 7 − 1 0 = displays -3 from the API; 9 + 4 = displays 13; UI test requires the minus key
  • npm test: 22 passed, 0 failed, 0 skipped, 0 todo; no weakened assertions or debug leftovers
  • README still points at the generic API contract and does not list operations, so it did not need an edit

Attachment: dodik-3aeb445f.json

**Aira · dodik PASS on `3aeb445f`** Commit 3aeb445 adds op=subtract as a-b, a U+2212 minus button that sends that operation, and module, API, and page tests that fail if the new behavior is removed. npm test passed 22/22 with no skips; add and unknown-op errors are unchanged; the diff is limited to the planned files. Live API checks returned {"result":-3} and {"result":0.25}, and replaying 7, minus, 1, 0, = on the page script against the server displayed -3. <details><summary>Checks performed</summary> - Diff vs origin/main is only lib/calculator.js, public/index.html, test/calculator.test.js, test/server.test.js, test/ui.test.js, and docs/plans/issue-2.md - AC1 and AC2: live GET /api/calculate subtract cases return 200 {"result":-3} and {"result":0.25}, covered by calculator and server tests - AC3: op=add still returns {"result":5}; op=pow returns 400 {"error":"unknown operation"}; existing invalid-input tests remain - AC4: page button data-key and label are U+2212; scripted 7 − 1 0 = displays -3 from the API; 9 + 4 = displays 13; UI test requires the minus key - npm test: 22 passed, 0 failed, 0 skipped, 0 todo; no weakened assertions or debug leftovers - README still points at the generic API contract and does not list operations, so it did not need an edit </details> Attachment: [dodik-3aeb445f.json](https://aira-lab.cluster-dev.spkey.co/attachments/7f17327e-86e1-4e46-a797-83a173f6c67a)
Collaborator

Aira · reviewer PASS on 3aeb445f

Subtraction is implemented consistently with the existing add path: lib/calculator.js parses operands and rejects non-finite results, server.js is unchanged and still maps errors to 400, and the UI stores pendingOp and sends the correct op on equals. All 22 tests pass, acceptance API cases match the plan, and manual checks for negatives, large magnitudes, and subtract overflow behave correctly without new security or regression issues.

Checks performed
  • Reviewed git diff origin/main...3aeb445 (calculator, index.html, tests, plan)
  • Ran npm test — 22/22 passing
  • Verified subtract API/module edge cases (negatives, large values, overflow → 400)
  • Compared UI operator flow to origin/main addition behavior
  • Confirmed GET /health and GET / contract unchanged in server.js

Attachment: reviewer-3aeb445f.json

**Aira · reviewer PASS on `3aeb445f`** Subtraction is implemented consistently with the existing add path: `lib/calculator.js` parses operands and rejects non-finite results, `server.js` is unchanged and still maps errors to 400, and the UI stores `pendingOp` and sends the correct `op` on equals. All 22 tests pass, acceptance API cases match the plan, and manual checks for negatives, large magnitudes, and subtract overflow behave correctly without new security or regression issues. <details><summary>Checks performed</summary> - Reviewed git diff origin/main...3aeb445 (calculator, index.html, tests, plan) - Ran npm test — 22/22 passing - Verified subtract API/module edge cases (negatives, large values, overflow → 400) - Compared UI operator flow to origin/main addition behavior - Confirmed GET /health and GET / contract unchanged in server.js </details> Attachment: [reviewer-3aeb445f.json](https://aira-lab.cluster-dev.spkey.co/attachments/73edfc5f-5a9d-457d-aa61-759688a28946)
Collaborator

Aira · qa

Dodik and the reviewer passed on 3aeb445f. Preview deployed at http://127.0.0.1:43553; QA started.

**Aira · qa** Dodik and the reviewer passed on `3aeb445f`. Preview deployed at http://127.0.0.1:43553; QA started.
Collaborator

Aira · qa PASS on 3aeb445f

The preview at http://127.0.0.1:43553 serves commit 3aeb445ff9. GET /api/calculate?op=subtract returns a-b for the required cases and for negatives and zeros, op=add still returns a sum, and missing, empty, non-numeric, and unknown inputs return 400 with an error field. The page includes a U+2212 minus button that sends op=subtract and displays the API result, so 7, minus, 1, 0, equals follows the same path as 7-10=-3.

Checks performed
  • GET http://127.0.0.1:43553/health returned 200 {"ok":true,"sha":"3aeb445ff9d48e0ad3911b3d9e5068ac62b2d933"}
  • GET /api/calculate?a=2&b=5&op=subtract returned 200 {"result":-3}
  • GET /api/calculate?a=0.5&b=0.25&op=subtract returned 200 {"result":0.25}
  • GET /api/calculate?a=7&b=10&op=subtract returned 200 {"result":-3}
  • GET /api/calculate?a=-3&b=-7&op=subtract returned 200 {"result":4}
  • GET /api/calculate?a=0&b=0&op=subtract returned 200 {"result":0}
  • GET /api/calculate?a=10&b=10&op=subtract returned 200 {"result":0}
  • GET /api/calculate?a=-1.5&b=2.5&op=subtract returned 200 {"result":-4}
  • GET /api/calculate?a=2&b=5&op=add returned 200 {"result":7}
  • GET /api/calculate?a=0.1&b=0.2&op=add returned 200 {"result":0.30000000000000004}
  • GET /api/calculate?a=2&b=5&op=multiply returned 400 {"error":"unknown operation"}
  • GET /api/calculate?b=5&op=subtract returned 400 {"error":"operand is required"}
  • GET /api/calculate?a=2&op=subtract returned 400 {"error":"operand is required"}
  • GET /api/calculate?a=&b=5&op=subtract returned 400 {"error":"operand must be a number"}
  • GET /api/calculate?a=2&b=&op=subtract returned 400 {"error":"operand must be a number"}
  • GET /api/calculate?a=foo&b=1&op=subtract returned 400 {"error":"operand must be a number"}
  • GET /api/calculate?a=2&b=bar&op=subtract returned 400 {"error":"operand must be a number"}
  • GET /api/calculate?a=1&b=2 returned 400 {"error":"operation is required"}
  • GET /api/calculate?a=2&b=1&op= returned 400 {"error":"operation is required"}
  • GET / returned 200 text/html with buttons 7,8,9,C,4,5,6,U+2212 minus,1,2,3,+,0,.,= and script that maps minus to op=subtract, fetches /api/calculate, and writes body.result into #display

Attachment: qa-3aeb445f.json

**Aira · qa PASS on `3aeb445f`** The preview at http://127.0.0.1:43553 serves commit 3aeb445ff9d48e0ad3911b3d9e5068ac62b2d933. GET /api/calculate?op=subtract returns a-b for the required cases and for negatives and zeros, op=add still returns a sum, and missing, empty, non-numeric, and unknown inputs return 400 with an error field. The page includes a U+2212 minus button that sends op=subtract and displays the API result, so 7, minus, 1, 0, equals follows the same path as 7-10=-3. <details><summary>Checks performed</summary> - GET http://127.0.0.1:43553/health returned 200 {"ok":true,"sha":"3aeb445ff9d48e0ad3911b3d9e5068ac62b2d933"} - GET /api/calculate?a=2&b=5&op=subtract returned 200 {"result":-3} - GET /api/calculate?a=0.5&b=0.25&op=subtract returned 200 {"result":0.25} - GET /api/calculate?a=7&b=10&op=subtract returned 200 {"result":-3} - GET /api/calculate?a=-3&b=-7&op=subtract returned 200 {"result":4} - GET /api/calculate?a=0&b=0&op=subtract returned 200 {"result":0} - GET /api/calculate?a=10&b=10&op=subtract returned 200 {"result":0} - GET /api/calculate?a=-1.5&b=2.5&op=subtract returned 200 {"result":-4} - GET /api/calculate?a=2&b=5&op=add returned 200 {"result":7} - GET /api/calculate?a=0.1&b=0.2&op=add returned 200 {"result":0.30000000000000004} - GET /api/calculate?a=2&b=5&op=multiply returned 400 {"error":"unknown operation"} - GET /api/calculate?b=5&op=subtract returned 400 {"error":"operand is required"} - GET /api/calculate?a=2&op=subtract returned 400 {"error":"operand is required"} - GET /api/calculate?a=&b=5&op=subtract returned 400 {"error":"operand must be a number"} - GET /api/calculate?a=2&b=&op=subtract returned 400 {"error":"operand must be a number"} - GET /api/calculate?a=foo&b=1&op=subtract returned 400 {"error":"operand must be a number"} - GET /api/calculate?a=2&b=bar&op=subtract returned 400 {"error":"operand must be a number"} - GET /api/calculate?a=1&b=2 returned 400 {"error":"operation is required"} - GET /api/calculate?a=2&b=1&op= returned 400 {"error":"operation is required"} - GET / returned 200 text/html with buttons 7,8,9,C,4,5,6,U+2212 minus,1,2,3,+,0,.,= and script that maps minus to op=subtract, fetches /api/calculate, and writes body.result into #display </details> Attachment: [qa-3aeb445f.json](https://aira-lab.cluster-dev.spkey.co/attachments/d4b5bced-5cdd-477f-8abe-5bda7b963492)
Collaborator

Aira · merging

QA passed on 3aeb445f. Merging.

**Aira · merging** QA passed on `3aeb445f`. Merging.
Collaborator

Aira · Merged PR #10

Merge commit 420a70ea9662416dc4224073b60656d67b6be444 from reviewed head 3aeb445ff9d48e0ad3911b3d9e5068ac62b2d933.

Gate Verdict Summary
ci pass ci / test (pull_request)
dodik pass Commit 3aeb445 adds op=subtract as a-b, a U+2212 minus button that sends that operation, and module, API, and page tests that fail if the new behavior is remove
reviewer pass Subtraction is implemented consistently with the existing add path: lib/calculator.js parses operands and rejects non-finite results, server.js is unchanged
qa pass The preview at http://127.0.0.1:43553 serves commit 3aeb445ff9. GET /api/calculate?op=subtract returns a-b for the required cases
**Aira · Merged PR #10** Merge commit `420a70ea9662416dc4224073b60656d67b6be444` from reviewed head `3aeb445ff9d48e0ad3911b3d9e5068ac62b2d933`. | Gate | Verdict | Summary | |---|---|---| | ci | pass | ci / test (pull_request) | | dodik | pass | Commit 3aeb445 adds op=subtract as a-b, a U+2212 minus button that sends that operation, and module, API, and page tests that fail if the new behavior is remove | | reviewer | pass | Subtraction is implemented consistently with the existing add path: `lib/calculator.js` parses operands and rejects non-finite results, `server.js` is unchanged | | qa | pass | The preview at http://127.0.0.1:43553 serves commit 3aeb445ff9d48e0ad3911b3d9e5068ac62b2d933. GET /api/calculate?op=subtract returns a-b for the required cases |
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/web-calculator-3#2
No description provided.