-
Notifications
You must be signed in to change notification settings - Fork 0
fix(coachhelm): coach-facing surfaces speak coach voice, not player voice #931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| // @vitest-environment jsdom | ||
| /** | ||
| * ============================================================================ | ||
| * InsightCard.tsx — `iconTone` valence override (bug #915) | ||
| * ---------------------------------------------------------------------------- | ||
| * A mined pattern's icon/accent was previously always derived from | ||
| * `priority` — a severity tier bucketed by |stroke_impact| MAGNITUDE, blind | ||
| * to sign. That let a high-magnitude plays-BETTER pattern land in the 'high' | ||
| * tier (a warning-orange flame, as if it were bad news) while a | ||
| * low-magnitude plays-WORSE pattern landed in 'medium' (a green sparkle, as | ||
| * if it were good news). | ||
| * | ||
| * These tests lock the fix: `iconTone` overrides BOTH the glyph and its | ||
| * wrap color independent of `priority`, so a caller with a genuinely signed | ||
| * metric can make icon+accent agree with "good or bad for the player" | ||
| * instead of "how large is this number". | ||
| * ========================================================================== */ | ||
| import { describe, it, expect } from 'vitest'; | ||
| import { render } from '@testing-library/react'; | ||
| import { InsightCard } from './InsightCard'; | ||
|
|
||
| /** The rendered lead icon's wrap <span> — carries the color classes. */ | ||
| function iconWrapClassName(container: HTMLElement): string { | ||
| const svg = container.querySelector('svg'); | ||
| expect(svg).not.toBeNull(); | ||
| const wrap = svg!.parentElement; | ||
| expect(wrap).not.toBeNull(); | ||
| return wrap!.className; | ||
| } | ||
|
|
||
| describe('InsightCard — iconTone valence override', () => { | ||
| it('with no iconTone, the icon wrap follows priority (unchanged default behavior)', () => { | ||
| const { container } = render( | ||
| <InsightCard priority="critical" title="Critical signal" />, | ||
| ); | ||
| const cls = iconWrapClassName(container); | ||
| expect(cls).toContain('text-fw-danger'); | ||
| expect(cls).toContain('bg-fw-danger-bg'); | ||
| }); | ||
|
|
||
| it('iconTone="positive" renders the success wrap even on a "critical" priority card', () => { | ||
| // Regression lock: a HIGH-magnitude plays-better pattern (severity | ||
| // 'critical') must still read as good news, not an alarm. | ||
| const { container } = render( | ||
| <InsightCard priority="critical" iconTone="positive" title="Plays better under fatigue" />, | ||
| ); | ||
| const cls = iconWrapClassName(container); | ||
| expect(cls).toContain('text-fw-success'); | ||
| expect(cls).toContain('bg-fw-success-bg'); | ||
| expect(cls).not.toContain('bg-fw-danger-bg'); | ||
| }); | ||
|
|
||
| it('iconTone="negative" renders the warning wrap even on a "medium"/"low" priority card', () => { | ||
| // Regression lock: a LOW-magnitude plays-worse pattern (severity | ||
| // 'medium'/'low') must still read as a leak, not a strength. | ||
| const { container: medium } = render( | ||
| <InsightCard priority="medium" iconTone="negative" title="Small leak" />, | ||
| ); | ||
| expect(iconWrapClassName(medium)).toContain('bg-fw-warning-bg'); | ||
| expect(iconWrapClassName(medium)).not.toContain('bg-fw-success-bg'); | ||
|
|
||
| const { container: low } = render( | ||
| <InsightCard priority="low" iconTone="negative" title="Small leak" />, | ||
| ); | ||
| expect(iconWrapClassName(low)).toContain('bg-fw-warning-bg'); | ||
| }); | ||
|
|
||
| it('iconTone="neutral" renders the neutral wrap regardless of priority', () => { | ||
| const { container } = render( | ||
| <InsightCard priority="high" iconTone="neutral" title="No clear direction" />, | ||
| ); | ||
| const cls = iconWrapClassName(container); | ||
| expect(cls).toContain('bg-surface-sunken'); | ||
| expect(cls).not.toContain('bg-fw-warning-bg'); | ||
| }); | ||
|
|
||
| it('two cards with the SAME priority tier but OPPOSITE iconTone render visibly different wraps', () => { | ||
| // The exact reported shape: same magnitude tier, opposite sign. | ||
| const { container: better } = render( | ||
| <InsightCard priority="medium" iconTone="positive" title="Better" />, | ||
| ); | ||
| const { container: worse } = render( | ||
| <InsightCard priority="medium" iconTone="negative" title="Worse" />, | ||
| ); | ||
| expect(iconWrapClassName(better)).not.toBe(iconWrapClassName(worse)); | ||
| }); | ||
|
|
||
| it('undefined iconTone is a true no-op — identical to omitting the prop entirely', () => { | ||
| const { container: omitted } = render(<InsightCard priority="low" title="A" />); | ||
| const { container: explicitUndefined } = render( | ||
| <InsightCard priority="low" iconTone={undefined} title="A" />, | ||
| ); | ||
| expect(iconWrapClassName(omitted)).toBe(iconWrapClassName(explicitUndefined)); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,3 +80,62 @@ describe('Ribbon — trend delta never double-signs a signed valueFormatter', () | |
| expect(text).not.toMatch(/[+\-−]{2}/); | ||
| }); | ||
| }); | ||
|
|
||
| /** | ||
| * Bug #915 — the "Score by round" trend delta rendered a falling (improving) | ||
| * score as an amber "▼" decline, because Ribbon never told Readout which | ||
| * raw direction was GOOD for the plotted metric. `goodDirection` fixes this | ||
| * by classifying via the shared `classifyTrend` and passing the resulting | ||
| * verdict through as Readout's `direction` override. | ||
| */ | ||
| describe('Ribbon — goodDirection (score/lower-is-better trend coloring)', () => { | ||
| function getDeltaDirection(): string | null { | ||
| const delta = document.querySelector('[data-slot="readout-delta"]'); | ||
| expect(delta).not.toBeNull(); | ||
| return delta!.getAttribute('data-direction'); | ||
| } | ||
|
Comment on lines
+92
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win Query user-visible state instead of DOM implementation details.
Drop this helper and assert the presence of the semantic visual glyphs ( ♻️ Proposed patternimport { screen } from '`@testing-library/react`';
// ... inside your test block
it('goodDirection="down": the SAME falling series now reads "up" (green)', () => {
render(<Ribbon title="Score by round" data={DECLINING} seriesName="Score" goodDirection="down" />);
// The 'up' direction visually renders a '▲' glyph
expect(screen.getByText(/▲/)).toBeInTheDocument();
});🤖 Prompt for AI AgentsSource: Path instructions |
||
|
|
||
| it('DEFAULT (goodDirection="up", unchanged): a falling series reads "down" — the old, still-correct behavior for higher-is-better metrics', () => { | ||
| render(<Ribbon title="SG total" data={DECLINING} seriesName="SG" />); | ||
| expect(getDeltaDirection()).toBe('down'); | ||
| }); | ||
|
|
||
| it('goodDirection="down": the SAME falling series now reads "up" (green) — a lower score is an improvement', () => { | ||
| render( | ||
| <Ribbon | ||
| title="Score by round" | ||
| data={DECLINING} | ||
| valueFormatter={(v) => v.toFixed(1)} | ||
| seriesName="Score" | ||
| goodDirection="down" | ||
| />, | ||
| ); | ||
| expect(getDeltaDirection()).toBe('up'); | ||
| }); | ||
|
|
||
| it('goodDirection="down": a RISING series (a worsening score) reads "down" (amber)', () => { | ||
| render( | ||
| <Ribbon | ||
| title="Score by round" | ||
| data={IMPROVING /* raw values rise 0.1 -> 0.66 */} | ||
| valueFormatter={(v) => v.toFixed(1)} | ||
| seriesName="Score" | ||
| goodDirection="down" | ||
| />, | ||
| ); | ||
| expect(getDeltaDirection()).toBe('down'); | ||
| }); | ||
|
|
||
| it('goodDirection="down": a flat series (within the deadzone) reads "flat" regardless', () => { | ||
| render( | ||
| <Ribbon | ||
| title="Score by round" | ||
| data={[{ x: 'R1', y: 72 }, { x: 'R2', y: 72 }]} | ||
| valueFormatter={(v) => v.toFixed(1)} | ||
| seriesName="Score" | ||
| goodDirection="down" | ||
| />, | ||
| ); | ||
| expect(getDeltaDirection()).toBe('flat'); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: njrini99-code/helmv3
Length of output: 15653
🏁 Script executed:
Repository: njrini99-code/helmv3
Length of output: 6408
🏁 Script executed:
Repository: njrini99-code/helmv3
Length of output: 14368
Add the missing
framer-motiontest mocksrc/test/setup.tsx:12-67mocksnext/navigation,next/font/google,next/image, and@number-flow/react, but notframer-motion.InsightCard.test.tsx:18-20needs a localvi.mock('framer-motion', ...)or a shared mock withuseReducedMotionso these assertions stay deterministic.🤖 Prompt for AI Agents
Source: Path instructions