Frontend: lightweight-charts jsdom mock contract tests (stub enrichment + canvas options) #227
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#227
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Summary
Reduce lightweight-charts stub drift (#105) by enriching the global jsdom mock and adding a contract test for
PriceChartLightweightCanvasthat asserts exact options passed tocreateChart/addSeries/applyOptionswithout running the real canvas library.Bundled scope: enrich
lightweightChartsJsdomMock.ts·PriceChartLightweightCanvasstub contract testsCurrent codebase
frontend-dapp/src/test/lightweightChartsJsdomMock.ts—createChart,addSeries,removeSeries, panes,timeScale().fitContent, minimalpriceScalelwChartTestDouble.seriesSpies,reset()vitest.config.ts,vitest.config.integration.tsvitest.config.charts.ts— does not load stub (#211)PriceChartLightweightCanvas.tsx— richcreateChartoptions (panes, crosshair, autoscaleInfoProvider)PriceChart.test.tsxuses spy counts; no assertion on option objectsStub does not record:
applyOptions,autoscaleInfoProvider, pane indices onaddSeries,removePanearguments, orResizeObserverlifecycle.Why this is needed
subscribeVisibleLogicalRangeChange) can ship while the mock stays minimal — green CI, broken browser.test:charts.Constraints and guardrails
test:chartssuite — stub complements, not replaces.npm run test:runfast — contract tests use mock only.PriceChart.test.tsxspy expectations must keep passing.getLastApplyOptions, etc.).Relevant files
frontend-dapp/src/test/lightweightChartsJsdomMock.tsfrontend-dapp/src/components/charts/PriceChartLightweightCanvas.tsxfrontend-dapp/src/components/charts/__tests__/PriceChartLightweightCanvas.test.tsx(new)frontend-dapp/src/components/charts/__tests__/PriceChart.test.tsxfrontend-dapp/vitest.config.tsdocs/testing.md,skills/AGENTS_FRONTEND_PRICE_CHART.md,skills/AGENTS_TESTING_P2_EPIC.mdRecommended direction
applyOptionscalls; captureautoscaleInfoProvideron candlestick series; recordaddSeries(..., paneIndex); implementremovePanewith index tracking matching production.PriceChartLightweightCanvas.test.tsx— render with fixture props; assertcreateChartcalled with expectedlayout.panes.enableResize: false, dimensions, crosshair mode; assert volume pane index1; assert autoscale provider wrapsclampUsdPriceChartAutoscalebehavior via invoking captured provider.skills/AGENTS_TESTING_P2_EPIC.md.Acceptance criteria
applyOptions,autoscaleInfoProvider, pane indices,removePane(2)for RSI off.PriceChartLightweightCanvas.test.tsxfails ifenableResizeor pane layout options regress.lwChartTestDouble.reset()clears new spies between tests.npm run test:rungreen; no change required totest:chartsunless shared fixtures extracted.docs/testing.mdstub section updated.Test plan — functional paths
createChart; candle + volume seriesapplyOptionson layoutaddSeriesline on pane 0;removeSerieson offaddPane;removePane(2)on offsetDataon prop changeseriesSpiesupdated; no secondcreateChartTest plan — attack vectors
original()throwsVerification criteria
npm run test:run— new contract tests + existingPriceChart.test.tsxpass.enableResize: false— contract test fails.Related issues
marked as related to #211
marked as related to #105
marked as related to #151
marked as related to #150
mentioned in commit
8e9f32365eImplementation summary (merged to
main)Reduced lightweight-charts jsdom stub drift (#105) by enriching the global mock and adding fast contract tests for
PriceChartLightweightCanvas(#227). Complements real-librarynpm run test:charts(#211, #229) — does not replace it.Code changes
frontend-dapp/src/test/lightweightChartsJsdomMock.ts: recordscreateChartoptions,applyOptionscalls,addSeries(pane index +autoscaleInfoProvider),timeScale().getVisibleLogicalRange; exportsgetLastCreateChartOptions(),getLastApplyOptions(),getCandlestickAutoscaleProvider(),addSeriesCalls;reset()clears new spies.PriceChartLightweightCanvas.test.tsx: new describe createChart contract —enableResize: false, crosshair mode, pane 0/1 series, autoscale clamp, MA7/RSI toggles,setDatawithout secondcreateChart, spy reset.Docs / agent playbooks
docs/testing.md,docs/frontend.md(price chart invariants)skills/AGENTS_FRONTEND_PRICE_CHART.md,skills/AGENTS_TESTING_P2_EPIC.mdVerification checklist
cd frontend-dapp && npm run test:run -- PriceChartLightweightCanvas.test.tsx— 17 tests green (8 lifecycle #225 + 9 contract #227)npm run test:run -- PriceChart.test.tsx— existing spy expectations still passlayout.panes.enableResize: trueinPriceChartLightweightCanvas.tsx→ contract test mount passes layout… failsnpm run test:chartsunchanged requirement (still green in CI)@brouie — please verify the checklist above on latest
mainwhen you have a moment. Leaving this issue open until sign-off.Verification complete (agent,
verify/issue-227worktree on54a6346)Verified all acceptance criteria and the checklist from the implementation comment on latest
main. No code changes required.What was verified
Acceptance criteria
applyOptions,autoscaleInfoProvider, pane indices,removePane(2)for RSI off — confirmed inlightweightChartsJsdomMock.ts+ contract testsPriceChartLightweightCanvas.test.tsxfails onenableResizeregression — temporarily setenableResize: true; mount passes layout… failed as expectedlwChartTestDouble.reset()clears new spies — dedicated test passesnpm run test:rungreen — 17 canvas tests + 20PriceChart.test.tsxtestsdocs/testing.mdstub section updated with #227 / #105 / #211 cross-linksFunctional test plan (stub contract)
createChart; candle + volumeapplyOptionswidth/height from containeraddSeriespane 0 /removeSeriesoffaddPane/removePane(2)offsetDataonly, no secondcreateChartAdditional
npm run test:charts— 21 passed, 1 skipped (real library suite unchanged)skills/AGENTS_FRONTEND_PRICE_CHART.md,skills/AGENTS_TESTING_P2_EPIC.mdCommands run
Manual checklist for future regressions
PriceChartLightweightCanvaslayout/pane options, runnpm run test:run -- PriceChartLightweightCanvas.test.tsxlightweightChartsJsdomMock.tsand contract testsnpm run test:charts— do not load jsdom stub invitest.config.charts.tsClosing — all issue-body and comment verification criteria pass.