From 040bb411df2a268f1a4f7593d8139144a7c80022 Mon Sep 17 00:00:00 2001 From: ChrisBeWithYou Date: Sat, 18 Jul 2026 16:55:21 -0500 Subject: [PATCH] test(v3): accept the tuning-perspective indirection in the badge guard The album-art badge now reads shownTuningName(), so the source-pattern guard no longer matched the inline `tuning_name || tuning` form and CI went red. Accept the helper, and pin the helper's own fallback in a companion test so the guard still fails if a guitar player's tuning label is ever dropped. Signed-off-by: ChrisBeWithYou --- tests/js/v3_songs_tuning.test.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/js/v3_songs_tuning.test.js b/tests/js/v3_songs_tuning.test.js index 913f472..604c463 100644 --- a/tests/js/v3_songs_tuning.test.js +++ b/tests/js/v3_songs_tuning.test.js @@ -67,11 +67,27 @@ test('v3 songs.js uses display helpers for album-art tuning badge', () => { const src = fs.readFileSync(SONGS_JS, 'utf8'); // The card renderer's row variable was renamed song → shown when grouped // cards landed (the badge reads the representative chart); accept either. - assert.match(src, /displayTuningName\((?:song|shown)\.tuning_name \|\| (?:song|shown)\.tuning\)/); + // The raw read then moved behind shownTuningName() so the badge can answer + // for the active tuning perspective — accept that indirection too, and pin + // the fallback inside the helper below so this stays a real guard. + assert.match( + src, + /displayTuningName\((?:(?:song|shown)\.tuning_name \|\| (?:song|shown)\.tuning|shownTuning)\)/, + ); assert.match(src, /displayTuningTargets/); assert.match(src, /parseRawTuningOffsets/); }); +test('the tuning-perspective helper still falls back to tuning_name || tuning', () => { + // shownTuningName() is what the badge now reads. With no perspective field + // set (guitar-lead, the default) it must resolve exactly what the badge + // used to read inline, or guitar players silently lose their tuning label. + const src = fs.readFileSync(SONGS_JS, 'utf8'); + const body = src.match(/function shownTuningName\(song\)\s*\{[\s\S]*?\n {4}\}/); + assert.ok(body, 'shownTuningName() not found — the badge read moved again'); + assert.match(body[0], /return song\.tuning_name \|\| song\.tuning;/); +}); + test('raw offset tuning_name does not appear in rendered card HTML', () => { const html = renderSongCardBadge({ tuning_name: '-2 0 0 0 -2' }, helpers); assert.doesNotMatch(html, /-2 0 0 0 -2/);