Skip to content

Cover the calculation engine with Vitest and gate deploys on it - #11

Merged
YurMil merged 1 commit into
mainfrom
test/engine-unit-tests
Sep 14, 2026
Merged

YurMil merged 1 commit into
mainfrom
test/engine-unit-tests

Conversation

@YurMil

@YurMil YurMil commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Summary

Shell Rolling was the only calculator in the catalog without tests, while its output is a length people cut plate to. This PR adds a Vitest suite for the calculation engine and makes it a gate on both pull requests and deploys.

Closes the code part of YurMil/cadautoscript.com#153; the validation cases are published on the site in a companion PR.

What is covered (87 tests)

Suite Covers
math/cylinder.test.ts Neutral diameter from OD and from ID, the worked DN 2000 example, ID/OD confusion (exactly 2πt, independent of K), K-factor limits, weld gap, bend lines
math/cone.test.ts Sector radii and angle from the frustum relations, both arcs equal the neutral circumferences, gap removed on the neutral fibre, agreement with the cylinder in the near-cylindrical limit, blank rectangle bounds
math/validation.test.ts Non-positive / NaN / infinite input, K outside (0, 1], gap vs. circumference, wall thicker than the neutral radius, mode-specific guards
math/eccentric-cone.test.ts Port of tools/verify-eccentric-cone.ts
utils/pattern-dimensions.test.ts Port of tools/verify-bend-dimensions.ts
shareLink.test.ts Port of tools/verify-share-link.ts

Reference values are derived by hand from the closed-form relations in docs/calculations.md, never copied from the engine's output. The three tools/verify-*.ts scripts keep their checks and tolerances and are removed together with the verify:* npm scripts.

CI

  • New ci.yml: npm cinpm testnpm run build on every pull request.
  • deploy.yml: npm test runs between install and build, so a failing test stops the release before anything is published.

A typecheck gate is intentionally not added: tsc currently reports three pre-existing errors in App.tsx and Scene.tsx, unrelated to this change.

Behaviour documented, not changed

  • K = 0 is rejected ("must be positive"), K = 1 is accepted.
  • A cone whose neutral diameters differ by less than 1 mm is rejected in favour of cylinder mode.

Verification

  • npm ci, npm test (87 passed), npx eslint on the new files, npm run build — all pass locally.
  • A temporary failing test makes npm test exit with code 1.

🤖 Generated with Claude Code

The engine computes developed lengths people cut plate to, and had no
automated tests. Add a Vitest suite whose reference values are derived
by hand from the closed-form relations, not from the engine's output:

- cylinder: neutral diameter from OD and from ID, the exact 2*pi*t
  ID/OD confusion, K-factor at the range limits, weld gap, bend lines
- cone: sector radii and angle, gap on the neutral fibre, agreement
  with the cylinder in the near-cylindrical limit, blank rectangle
- validation: non-positive and non-finite input, K outside (0, 1],
  gap vs. circumference, wall thicker than the neutral radius
- the three tools/verify-*.ts scripts are ported to Vitest with the
  same checks and tolerances, and removed

Tests now run on every pull request (ci.yml) and before the build in
deploy.yml, so a failing test stops a release.

Refs YurMil/cadautoscript.com#153

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-14T16:21:53.330876Z b215c89 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b215c8916d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
@YurMil
YurMil merged commit c25da03 into main Sep 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant