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 <christian.a.cowan@gmail.com>
This commit is contained in:
ChrisBeWithYou
2026-07-18 16:55:21 -05:00
parent 81575345f5
commit 040bb411df
+17 -1
View File
@@ -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/);