Skip to content

test: add fast, isolated unit coverage for freezeOrderComponents - #957

Merged
ryanio merged 1 commit into
ProjectOpenSea:mainfrom
batuhankocyigit:test/freeze-order-components-coverage
Aug 14, 2026
Merged

test: add fast, isolated unit coverage for freezeOrderComponents#957
ryanio merged 1 commit into
ProjectOpenSea:mainfrom
batuhankocyigit:test/freeze-order-components-coverage

Conversation

@batuhankocyigit

Copy link
Copy Markdown
Contributor

test: add fast, isolated unit coverage for freezeOrderComponents

Motivation

freezeOrderComponents (added recently to guarantee the orderComponents
exposed on a create action can't drift from what actually gets signed — see
its JSDoc in src/utils/order.ts) currently only has indirect coverage
through test/execute-approvals.spec.ts, which needs the full Hardhat
network (contract deployment, a signer, etc.) to run.

That's appropriate for testing the end-to-end feature, but the freezing
logic itself is a pure function with no on-chain dependency, and it's a
mutation-safety guarantee the JSDoc goes out of its way to explain the
reasoning for — exactly the kind of thing worth pinning down with a fast,
isolated unit test that runs in milliseconds and fails with a precise
message if the freezing behavior ever regresses.

What this adds

A freezeOrderComponents describe block in test/utils/order.spec.ts
(alongside the existing deductFees suite, since both live in
src/utils/order.ts), covering:

  • Returns the same object reference rather than a clone (the JSDoc is
    explicit that this is intentional, not an oversight).
  • Freezes the top-level OrderComponents object.
  • Deep-freezes offer items individually, not just the array wrapper.
  • Deep-freezes consideration items individually, and that the array
    itself rejects mutation (e.g. push).
  • Doesn't throw when a nested item was already frozen before the call
    (the Object.isFrozen short-circuit in deepFreeze).

Testing

  • npx tsc --noEmit — clean.
  • npx biome check test/utils/order.spec.ts — clean.
  • Ran the new suite directly: 9/9 passing (4 pre-existing deductFees
    cases + 5 new freezeOrderComponents cases), all in single-digit
    milliseconds since none of it touches the network.

Scope

Test-only change, one file. No production code touched.

@ryanio ryanio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks!

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.85%. Comparing base (f618d19) to head (74c73ad).
⚠️ Report is 358 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #957      +/-   ##
==========================================
+ Coverage   98.27%   98.85%   +0.57%     
==========================================
  Files          35       45      +10     
  Lines       14526    17579    +3053     
  Branches      660      897     +237     
==========================================
+ Hits        14276    17378    +3102     
+ Misses        245      194      -51     
- Partials        5        7       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ryanio
ryanio merged commit df79489 into ProjectOpenSea:main Aug 14, 2026
5 checks 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.

3 participants