-
Notifications
You must be signed in to change notification settings - Fork 4
feat(editor): grid-health pill in the transport LCD — Map Health at a glance, click to fix #268
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
727fff4
Add the grid-health pill to the transport LCD
b3cbb5d
Guard the pill's colour write on the band, not on style.color
byrongamatos 3afbf74
Grid pill click: don't claim the grid "agrees" when there is no verdict
byrongamatos f333833
chore: untrack the node_modules symlink
byrongamatos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * The transport-LCD grid-health pill (Map Health follow-up): a glanceable | ||
| * "how much of the grid agrees with the recording" percent, coloured by the | ||
| * worst state present, with click-to-fix jumping to the worst drifting bar. | ||
| * | ||
| * Pinned here: the pill percent counts only JUDGEABLE bars (grey never dilutes | ||
| * or inflates the score — the wash's no-crying-wolf rule), the colour is the | ||
| * worst band present, an unjudgeable song yields NO verdict (dash, never a | ||
| * fake 100%), and the worst-bar picker ranks any red over any amber with | ||
| * drift as the tiebreak. Fails on main (the pures don't exist there). | ||
| * | ||
| * Run: node tests/map_health_pill.test.mjs | ||
| */ | ||
| import assert from 'node:assert'; | ||
|
|
||
| globalThis.document = globalThis.document || { | ||
| getElementById: () => null, addEventListener: () => {}, activeElement: null, | ||
| }; | ||
| globalThis.localStorage = globalThis.localStorage || { getItem: () => null, setItem: () => {} }; | ||
| globalThis.window = globalThis.window || globalThis; | ||
|
|
||
| const { _mapHealthPillPure, _mapHealthWorstPure } = await import('../src/map-health.js'); | ||
|
|
||
| let pass = 0, fail = 0; | ||
| function t(name, fn) { | ||
| try { fn(); pass++; console.log(' ok ' + name); } | ||
| catch (e) { fail++; console.error(' FAIL ' + name + ': ' + e.message); } | ||
| } | ||
|
|
||
| const M = (band, driftFrac = 0, measure = 1) => ({ band, driftFrac, measure, startTime: measure * 2 }); | ||
|
|
||
| t('the percent counts judgeable bars only — grey neither dilutes nor inflates', () => { | ||
| // 8 green + 2 amber + 10 grey: 80% of the JUDGEABLE bars agree. | ||
| const measures = [ | ||
| ...Array.from({ length: 8 }, () => M('green')), | ||
| M('amber', 0.08), M('amber', 0.06), | ||
| ...Array.from({ length: 10 }, () => M('grey')), | ||
| ]; | ||
| const pill = _mapHealthPillPure({ measures }); | ||
| assert.strictEqual(pill.pct, 80); | ||
| assert.strictEqual(pill.judged, 10); | ||
| }); | ||
|
|
||
| t('the colour is the worst state present', () => { | ||
| assert.strictEqual(_mapHealthPillPure({ measures: [M('green'), M('green')] }).band, 'green'); | ||
| assert.strictEqual(_mapHealthPillPure({ measures: [M('green'), M('amber')] }).band, 'amber'); | ||
| assert.strictEqual(_mapHealthPillPure({ measures: [M('green'), M('amber'), M('red', 0.2)] }).band, 'red'); | ||
| }); | ||
|
|
||
| t('nothing judgeable = no verdict, never a fake 100%', () => { | ||
| assert.strictEqual(_mapHealthPillPure({ measures: [M('grey'), M('grey')] }), null); | ||
| assert.strictEqual(_mapHealthPillPure({ measures: [] }), null); | ||
| assert.strictEqual(_mapHealthPillPure(null), null); | ||
| }); | ||
|
|
||
| t('the worst bar: any red beats any amber; within a band the biggest drift wins', () => { | ||
| const measures = [ | ||
| M('green', 0, 1), M('amber', 0.11, 2), M('amber', 0.08, 3), | ||
| M('red', 0.13, 4), M('red', 0.30, 5), M('grey', 0, 6), | ||
| ]; | ||
| const worst = _mapHealthWorstPure({ measures }); | ||
| assert.strictEqual(worst.measure, 5, 'the reddest red'); | ||
| const amberOnly = _mapHealthWorstPure({ measures: measures.slice(0, 3) }); | ||
| assert.strictEqual(amberOnly.measure, 2, 'no red → the worst amber'); | ||
| assert.strictEqual(_mapHealthWorstPure({ measures: [M('green'), M('grey')] }), null, | ||
| 'nothing drifting → null (the click says so instead of jumping)'); | ||
| }); | ||
|
|
||
| console.log(`\n${pass} passed, ${fail} failed`); | ||
| process.exit(fail ? 1 : 0); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.