test(TEST-007): render-path tests for fundamentals_panel + scan_view#98
Conversation
REF-002 (#97) moved ~470 lines of rendering into ui/fundamentals_panel.py and ui/scan_view.py, which count toward the 87% coverage floor but had no direct tests (measured coverage dipped 89.15 -> 88.07). These tests cover the real render paths with the house pattern (monkeypatch the module's own `st` global with a recording fake): - fundamentals_panel: hidden without a symbol; criteria vs universal captions (incl. the UI-002 "why is this symbol different" wording); cached-verdict flow (disabled primary, Re-run button, session-cache provenance caption, humanized freshness); click-through runs the agent in the symbol-deterministic mode and caches the verdict; usage-limit -> gentle warning; agent failure -> redacted error; invalid cached verdict cleared; eligibility union/missing-universe behavior on the REAL helper (faked load_universe, cache cleared around each test); the four _format_data_freshness branches. - scan_view: empty-results branch; happy path chains chart symbol into the fundamentals panel; AUTH-003 export gate (viewer never reaches the button); export click records the OBS-003 audit event; failure expanders render with redacted messages; and the two-widget table/dropdown chart sync (fresh click wins, stale selection does not, dropped symbol falls back to first, no-chart/no-symbol returns None). Coverage: 88.07 -> 89.34% (floor 87); 1,411 tests pass. Gates: pre-commit validate, compileall, ruff, mypy (119 files), bandit, pip-audit all clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
DoRmAmMu1997
left a comment
There was a problem hiding this comment.
Self-review (posted as COMMENT — the bot runs as the PR author and cannot APPROVE). Verdict: Approve.
Risk points checked against the real modules:
st.cache_dataleakage —_eligible_symbols_setis a real@st.cache_data(ttl=600)function; the eligibility tests call the REAL helper, so its cache is cleared both before each test and in afinally:block. Without that, a cached universe set from these tests could bleed into any later suite that touches eligibility. Verified the full 1,411-test run passes in one process.- Button-response queue ordering —
_FakeColumn.buttonpops from a per-test queue; the panel renders primary-then-secondary deterministically (fundamentals_panel.py:126-144), so queue order is stable. Asserted on recorded labels, not just positions. fake_st.dataframes[-2:]— safe because the failure-expander test renders exactly the results frame plus the two failure frames; the slice can't pick up the results table since assertions check themessagecolumn, which only the failure frames have.- Namespace patching —
record_audit_event,_redact_secrets,_render_fundamentals_panel, and_render_cached_symbol_chartare patched onui.scan_view/ui.fundamentals_panel(the namespaces that read them), matching the house pattern; the originals are untouched for other suites. - Chart-sync state machine — the four transitions (default-to-first, fresh-click-wins, stale-selection-ignored, dropped-symbol-fallback) mirror scan_view.py:198-225 exactly, including the
chart_prev_table_row_{key}bookkeeping that distinguishes a fresh click from a persistent selection.
Gates: 1,411 passed, coverage 89.34% (floor 87), ruff/mypy/bandit/pip-audit/pre-commit/compileall clean. No production code touched; constraints/pyproject diff vs main is empty.
|
Codex review plan before fixes:
I’ll implement these on this branch with TDD, run the full repository/browser/security gates, push the follow-up, and report the final evidence here. |
DoRmAmMu1997
left a comment
There was a problem hiding this comment.
Codex review findings for TEST-007. These are reproducible behavior/security gaps in the paths this test PR is intended to protect.
Co-authored-by: Hemant <hemantdhamija@gmail.com> Co-authored-by: Codex <codex@openai.com>
Completion verdictComplete — no remaining reportable findings. This is a completion comment, not an approval. Commit A formal diff-security review found no remaining reportable findings. |
Ticket scope (TEST-007)
Goal: close the test gap left by REF-002 (#97) —
ui/fundamentals_panel.py(271 lines) andui/scan_view.py(200 lines) landed with zero direct tests, dipping measured coverage 89.15% → 88.07% against the 87% CI floor.In scope
st" — AGENTS.md §10): a per-file_FakeStreamlitrecording fake set onto the module's ownstglobal._is_eligible_for_fundamentals,_format_data_freshness,_render_results_with_chart,_has_rating_column); faking only true externals (agent,load_universe, chart builder, audit recorder).Out of scope (deliberate)
tests/test_app_orchestration.py; its re-export identity and_eligible_symbols_set.clear()seams are preserved untouched).This is ticket 1 of a 10-ticket second improvement wave (TEST-007, REF-003, AI-006, IPO-006, TEST-006, PERF-002, DEPLOY-004, QUAL-006, QUAL-007, DOC-003), each shipped as its own PR off
main.Summary
REF-002 (#97) moved ~470 lines of rendering out of
app.pyintoui/fundamentals_panel.pyandui/scan_view.py. Both modules count toward the 87% coverage floor but had no direct tests. This PR adds render-path tests for both modules and restores the headroom.Test-only change: two new files, no production code touched.
What's covered
tests/test_app_fundamentals_panel.pyData fetched: 06 Jul 2026, 08:15 UTC).fundamentals_verdict::{symbol}::{model}::{mode}.FundamentalsUsageLimitError→ gentle warning, not an error._is_eligible_for_fundamentals: union acrosshemant_super_45+nifty_100, tolerance for a missing universe CSV — with_eligible_symbols_set.clear()around every test so thest.cache_datastate can't leak into other suites._format_data_freshnessbranches.tests/test_app_scan_view.pyst.download_buttonor the CSV bytes build._render_results_with_chart: fresh table click wins, stale (persistent) selection does not clobber a fresh dropdown pick, a dropped symbol falls back to the first row, and no-symbol-column / no-chart-builder returnNone._has_rating_columntruth table.Gates (all green, local, Python 3.13)
pytest -q --cov=backend --cov=screeners --cov=ui --cov-fail-under=87pre_commit validate-configcompileallruff checkmypy(119 files)banditpip_audit -r constraints.txtconstraints.txt/pyproject.tomldiff vs main: empty (as required).Review
/code-review: Approve — verified the five risk points (cache_data leakage handled by explicitclear(), button-response queue ordering,dataframes[-2:]safety, namespace patching of imported names, chart-sync state transitions)./security-review: no findings (test-only diff; adds locks on the AUTH-003 gate, OBS-003 audit event, and secret redaction).🤖 Generated with Claude Code