You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(app): fake the contract clients with one typed helper and split TransactionModal #425
The console's tests fake the contract clients by hand, and the largest component is too big to review. Once CI generates the contract clients before the JavaScript checks, the tests can use the real client types to catch drift.
As a developer changing a contract or the console, I want test fakes that fail the type check when they no longer match the contract, and components small enough to review.
Problems
37 test files mock config/clients with hand-built objects ({ current_epoch: vi.fn() }). A renamed method, a changed argument or a changed result shape still passes them.
Some fixtures no longer match the contracts: enum values without values, pending changes without their types, holder arguments narrower than the client's, and vault roles faked as undefined where the client returns null.
app/src/components/vault/TransactionModal.tsx is 2,158 lines and holds the copy and status text for about 16 actions. Its test, TransactionModal.test.tsx, is 3,300 lines.
Expected outcome
One shared, typed fake. A single test helper, typed with the generated client APIs, replaces the per-file client mocks. Each test names only the calls it uses. A wrong call name, argument or result shape fails the type check, and a faked read must carry its result.
Split TransactionModal and its test. The component splits by section (investor, cycle, emergency, configuration, governance, compliance) behind a small shell, and its test splits the same way with shared render helpers. Same rendered output, same props for callers, same test names and assertions.
Acceptance criteria
No test file mocks config/clients with a hand-built object; one typed helper builds the fakes
A faked call with a wrong name, argument or result type fails npm run typecheck
TransactionModal.tsx and TransactionModal.test.tsx are split into section files, and no file in the split is over 1,000 lines
The number of tests does not drop, and every existing test name still runs
Technical notes
A working version of both parts is in the history of #421 and can be reused:
Shared typed fake: c9c75ec (helper and the 37 migrations, with the fixture fixes) and 908a78b (a faked read must carry its result).
TransactionModal split: 80acc8e (component), d1d371b (tests) and df89ed1 (render helpers under app/src/test/).
#421 reverted them to keep that pull request to the CI change. They were written against that branch, so expect conflicts with later changes to the same files.
Activity