Added a recipes page at /recipes where a cook pastes a recipe as… #11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "osf/75-verification-auto-auto-approve-per-run"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What was done
/recipeswhere a cook pastes a recipe as plain text, picks the servings and Metric or US, and sees it back scaled and converted one ingredient a line, with each line that did not read reported beside its line number (src/pages.ts).Serves Nfirst line then one ingredient a line — quantity, optional unit, name — where a quantity may be a whole number, a decimal, a fraction, or a mixed number and a unit may be left off, so2 eggsreads (src/recipe.ts).src/scale.ts).src/convert.ts).src/shopping.ts).npm testruns the unit tests only; the new browser test ine2e/recipes.spec.tsis a separate command (npm run test:e2e) that needs Postgres, so it is not part of the unit run.6 eggs,14 oz flour) was kept as the spec and the product changed to match it, rather than adjusting the test.How to review
osf/75-verification-auto-auto-approve-per-run) and install its dependencies withnpm install.npx tsc --noEmit; it should be clean.npm test; the new recipe, scale, convert, shopping, page, and route tests all pass, and it starts an embedded Postgres ifDATABASE_URLis not set.npx playwright install chromium, thennpm run test:e2e; the two new tests ine2e/recipes.spec.tspass (the suite needsDATABASE_URL, as in CI).DATABASE_URLat a reachable Postgres, start the server withnpm start, and open/recipes; pasteServes 2,200 g flour,a pinch of salt,2 eggs, enter 4, choose US, and press Show recipe to see14 oz flour,4 eggs, andLine 3: a pinch of salt (no quantity), then press Add to list to see the shopping list.src/server.tsfor the/recipesroutes, thensrc/pages.tsfor the page.Code review
Reviewed the recipes change (src/recipe.ts, src/scale.ts, src/convert.ts, src/shopping.ts, the /recipes page and routes, and its unit, server, and e2e tests) against the five spec deltas: every scenario is implemented, user output is escaped in element and attribute context, and the routes sit before the GET /
branch as required. One real defect: nearestQuarterOrThird in src/scale.ts walked from 1/4 up in an O(quantity) loop building and sorting ~24*quantity objects, so one valid pasted line with a large count (parseQuantity accepts digit strings of any length) could freeze the single-threaded server for minutes; I replaced it with a constant-time nearest-multiple computation that keeps the tie-to-the-smaller and 1/4-floor behavior, and added a regression test. No generated files, caches, secrets, or scratch artifacts are in the commit (node_modules, test-results, and playwright-report are gitignored). tsc, the six touched test files (61 tests), the Playwright test listing, and the release-notes check all pass.Left for you
src/server.ts:15: readBody has no size cap, so the new POST /recipes route (like the pre-existing POST / route) accepts arbitrarily large form bodies. Left as-is: it is the shared pre-existing pattern, and capping it would change the shortener's routes too, which is outside this change's scope.Fixed before the commit
src/scale.ts:60: nearestQuarterOrThird built and sorted 2*(12*quantity+2) candidate objects, so a valid pasted line with a large count (parseQuantity accepts digit strings of any length, e.g. 99999999999999 eggs) would hang the single-threaded server on one form submission. Replaced with an O(1) nearest-multiple of 1/4 and 1/3 (a half rounds to the smaller, the smallest multiple is 1/4, a tie between the two families goes to the smaller value); behavior is unchanged for all spec-pinned amounts, and a regression test was added in test/scale.test.ts.Tests
All 47 scenarios of
scale-recipes-and-shopping-listhave a tagged test.The test lint found, in the run's tests on the last check:
Recorded, not decided
e2e/recipes.spec.ts:1B7: no relative import: this file asserts on things it constructed itself, which is the measured 'asserted on my own mock' failuretest/recipes-page.test.ts:1B7: nothing imported here looks like the module under test ('recipes-page')test/recipes-server.test.ts:1B7: nothing imported here looks like the module under test ('recipes-server')Braid run
scale-recipes-and-shopping-list(23 steps, 2 retried)f2d06e7d1cOpened by Braid.
ce3e80ddfff2d06e7d1cScale a recipe, convert its units, and build a shopping listto Added a recipes page at/recipeswhere a cook pastes a recipe as…f2d06e7d1c608369c283