Files
feedBack/tests/js/live_guitar_tone_source.test.js
d2b2a7e9f7 fix(tests): re-green the JS suite — 18 stale source-shape tests + 1 real seek-reason violation (#740)
main's JS suite has been red since the recent v3-library and player
refactors landed. 17 of 18 failures were test harnesses/regexes that
went stale behind real, intentional code changes; one was a genuine
contract violation in the code.

Code fix:
- session-resume seek passed 'resume' as its _audioSeek reason; the
  documented contract (enforced by song_seek.test.js) requires
  multi-word kebab-case. Renamed to 'session-resume' — no consumer
  string-matches specific reasons, so this is rename-safe.

Test updates (each pins the CURRENT contract):
- highway_colors_facade: inject HWC_PRESETS + applyHighwayStringPreset
  (new preset feature); lock presets/applyPreset into the surface test
- loop_api: stub _updateEditRegionBtn (new edit-region UI hook)
- song_close: sandbox gets window.feedBack.playQueue; assert a real
  close abandons the queue (the new queue-aware behavior)
- v3_keep_practicing: the shelf moved from client-side /api/stats/recent
  dedupe+gating to the server-side practice-suggestions recommender —
  tests now pin that (fetch, arrangement-aware card click, Promise.all)
- v3_songs_tuning: card row variable renamed song → shown (grouped cards)
- live_guitar_tone_source: accept literal ’ where ’ drifted in copy
- legacy_shim_hits: normalize CRLF before fixed-width region() slicing
  (Windows-only failure; char windows shrank by one char per line)

Suite: 987/987 locally (Windows), previously 968/987 (and 18 red on CI).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 14:35:07 +02:00

57 lines
2.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use strict';
const { test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const toneSource = require('../../static/v3/live-guitar-tone-source.js');
const INDEX_HTML = path.join(__dirname, '..', '..', 'static', 'v3', 'index.html');
test('default live guitar tone source is internal', () => {
assert.equal(toneSource.DEFAULT, 'internal');
assert.equal(toneSource.normalize(undefined), 'internal');
assert.equal(toneSource.normalize(''), 'internal');
assert.equal(toneSource.normalize('bogus'), 'internal');
});
test('normalize accepts external and spark values', () => {
assert.equal(toneSource.normalize('external_hardware'), 'external_hardware');
assert.equal(toneSource.normalize('spark_control_x'), 'spark_control_x');
});
test('shouldSuppressMonitorMuteHint only for external modes', () => {
assert.equal(toneSource.shouldSuppressMonitorMuteHint('internal'), false);
assert.equal(toneSource.shouldSuppressMonitorMuteHint('external_hardware'), true);
assert.equal(toneSource.shouldSuppressMonitorMuteHint('spark_control_x'), true);
assert.equal(toneSource.shouldSuppressMonitorMuteHint('invalid'), false);
});
test('labels include internal, external, and spark options', () => {
assert.match(toneSource.LABELS.internal, /fee\[dB\]ack internal tone/i);
assert.match(toneSource.LABELS.external_hardware, /External amp/i);
assert.match(toneSource.LABELS.spark_control_x, /Spark LIVE/i);
});
test('settings UI exposes tone source select with all options', () => {
const html = fs.readFileSync(INDEX_HTML, 'utf8');
assert.match(html, /id="setting-live-guitar-tone-source"/);
assert.match(html, /value="internal"/);
assert.match(html, /value="external_hardware"/);
assert.match(html, /value="spark_control_x"/);
assert.match(html, /Live guitar tone source/);
// Apostrophe form drifted from the &rsquo; entity to the literal in a
// copy pass — accept entity, typographic, or plain apostrophe.
assert.match(html, /won(?:&rsquo;||')t warn that no internal amp tone is loaded/);
});
test('player audio rail exposes tone source select', () => {
const html = fs.readFileSync(INDEX_HTML, 'utf8');
assert.match(html, /id="player-live-guitar-tone-source"/);
});
test('live-guitar-tone-source script is loaded in v3 shell', () => {
const html = fs.readFileSync(INDEX_HTML, 'utf8');
assert.match(html, /live-guitar-tone-source\.js/);
});