feedBack/tests/js/playback_diagnostics.test.js
Bret Mogilefsky af2949677a
rename: slopsmith → feedBack, byron → got-feedBack (#537)
* Update GitHub repo references from feedback* to feedBack*

* rename: slopsmith -> feedBack, byron -> got-feedBack

Renames across the entire codebase:
- slopsmith/Slopsmith/SLOPSMITH/SlopSmith -> feedBack/FeedBack/FEEDBACK/FeedBack
- byron/Byron/Byrongamatos -> got-feedBack/got-feedBack/got-feedBack
- /home/byron/ -> /opt/got-feedBack/
- byron@ougsoft.com -> hi@got-feedBack.org
- github.com/byrongamatos/ -> github.com/got-feedback/
- com.byron. -> com.got-feedback.
- SLOPSMITH_ env vars -> FEEDBACK_ with backward-compat fallback
- Protocol/storage strings migrated with read-old/write-new pattern
- window.slopsmith JS API -> window.feedBack (canonical) + backward-compat alias

Refs: #rename-slopsmith

* rename: complete regen against current main + fix backward-compat alias

Regenerated the slopsmith->feedBack / byron->got-feedBack rename on top of
current main (3 commits had landed since the branch: #572/#554/#574),
resolving the four content conflicts in favour of main's newer content
(autoplay/auto-exit, accuracy-badge, Virtuoso re-home, feedpak badge).

Completion fixes on top of the mechanical rename:
- Re-apply rename to post-branch content the original rename never saw:
  window.slopsmith(.Tour) consumers in lessons.js / notifications.js /
  onboarding-tour.js, and the matching JS + python tests (autoplay_exit,
  progression_*, test_feedpak_extension FEEDBACK_* env vars). The test env
  vars now match server.py (which reads FEEDBACK_SYNC_STARTUP /
  FEEDBACK_SKIP_STARTUP_TASKS), so the sync-startup test exercises the real
  path again.
- Restore the window.slopsmith backward-compat alias dropped during conflict
  resolution, and move the bus aliases to AFTER the _feedBackExisting merge
  block so they reference the fully-assembled object (also fixes the
  loop_api.test.js API-surface regex, which the original PR latently broke).
- Drop the stray empty data/web_library.db (runtime DB lives in CONFIG_DIR)
  and gitignore it.
- Fix stale tone-source test: feed[dB]ack -> fee[dB]ack to match shipped
  source labels.

Verified locally (org CI billing-blocked): JS 819/819 pass; pytest 1669
passed / 1683 collected with 0 import errors; zero residual slopsmith/byron
except the two intentional window.slopsmith aliases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* rename: implement advertised backward-compat + prune dead community plugins

Address gaps where PR #537's "Backward compatibility" section was advertised
but not implemented, and clean up the community plugin list.

Env vars (FEEDBACK_* canonical, legacy SLOPSMITH_* honoured):
- New lib/env_compat.py (getenv_compat / env_flag_compat) + tests. server.py
  (_env_flag + all FEEDBACK_* reads), diagnostics_hardware, gp2midi and
  tailwind_rebuild now resolve the legacy alias, so existing SLOPSMITH_UI /
  SLOPSMITH_PLUGINS_DIR / etc. deployments keep working.
- Fix the rename collapsing plugins/__init__.py and minigames/routes.py from
  `FEEDBACK_PLUGINS_DIR or SLOPSMITH_PLUGINS_DIR` into a redundant
  `FEEDBACK_ or FEEDBACK_` (the fallback was silently lost).

Storage (app.js update-channel):
- Read feedBack-update-channel, fall back to legacy slopsmith-update-channel,
  and clear the legacy key on write — so a user's update-channel preference
  survives the rename instead of resetting to "stable".

Community plugin list (README): the rename rewrote third-party repo URLs we
don't own. Probed every one; their owners never renamed, so:
- Restore the 13 live community plugins to their real slopsmith-* names.
- Prune 6 that are 404 to the public (topkoa splitscreen/stems, OmikronApex
  tuner, Jafz2001 nam-rig-builder, DeathlySin song-preview, Erikcb91 shuffle).
- Fix a pre-existing Guitar Theory clone-command typo (nam-tone -> guitar-theory).

Verified: env_compat 7/7, JS 819/819, pytest 1690 collected / 0 import errors,
rename-sensitive + startup suites green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: byrongamatos <xasiklas@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 11:03:01 +02:00

118 lines
6.0 KiB
JavaScript

const { test } = require('node:test');
const assert = require('node:assert/strict');
const { loadPlayback, captureEvents, dispatch, diagnosticsSnapshot, makeTarget, makeAdapter } = require('./playback_test_harness');
test('exported diagnostics pseudonymize targets while local inspector may show display names', async () => {
const window = loadPlayback();
window.feedBack.playback.registerTransportAdapter(makeAdapter());
await dispatch(window, 'start', {
authorization: 'user-action',
requesterId: 'core.player.controls',
target: makeTarget({
filename: '/Users/example/DLC/Private Artist - Private Song_p.archive',
title: 'Private Song',
artist: 'Private Artist',
arrangement: 'Lead',
}),
});
const exported = diagnosticsSnapshot(window);
const local = diagnosticsSnapshot(window, { exportMode: 'local-inspector' });
const exportedText = JSON.stringify(exported);
assert.match(exported.state.target.targetId, /^target-/);
assert.match(exported.state.target.settingsKey, /^settings-v1-[a-z0-9]{7}$/);
assert.equal(exported.state.target.localDisplay, undefined);
assert.doesNotMatch(exportedText, /Private Song/);
assert.doesNotMatch(exportedText, /Private Artist/);
assert.doesNotMatch(exportedText, /DLC/);
assert.equal(local.state.target.settingsKey, exported.state.target.settingsKey);
assert.equal(local.state.target.localDisplay.title, 'Private Song');
assert.equal(local.state.target.localDisplay.artist, 'Private Artist');
});
test('diagnostic history is bounded for current and stopped sessions', async () => {
const window = loadPlayback();
window.feedBack.playback.registerTransportAdapter(makeAdapter());
for (let index = 0; index < 7; index += 1) {
await dispatch(window, 'start', { authorization: 'user-action', requesterId: 'core.player.controls', target: makeTarget({ filename: `song-${index}.archive`, title: `Song ${index}` }) });
for (let seek = 0; seek < 12; seek += 1) {
await dispatch(window, 'seek', { requesterId: 'core.player.controls', time: seek });
}
await dispatch(window, 'stop', { requesterId: 'core.player.controls', priority: 'user' });
}
const snapshot = diagnosticsSnapshot(window);
assert.ok(snapshot.history.current.recentOutcomes.length <= 50);
assert.ok(snapshot.history.current.lifecycleEvents.length <= 50);
assert.ok(snapshot.history.stoppedSessions.length <= 5);
for (const session of snapshot.history.stoppedSessions) {
assert.ok(session.recentOutcomes.length <= 20);
assert.ok(session.lifecycleEvents.length <= 20);
}
});
test('diagnostics contribution is exported under playback schema', async () => {
const window = loadPlayback();
window.feedBack.playback.registerTransportAdapter(makeAdapter());
await dispatch(window, 'start', { authorization: 'user-action', requesterId: 'core.player.controls', target: makeTarget() });
const contribution = window.feedBack.diagnostics.snapshotContributions().playback;
assert.equal(contribution.schema, 'feedBack.playback.diagnostics.v1');
assert.equal(contribution.domain, 'playback');
assert.equal(contribution.exportMode, 'exported');
assert.match(contribution.state.target.settingsKey, /^settings-v1-[a-z0-9]{7}$/);
assert.equal(contribution.state.target.localDisplay, undefined);
});
test('diagnostics redact caller-supplied route and stale session ids', async () => {
const window = loadPlayback();
window.feedBack.playback.registerTransportAdapter(makeAdapter());
await dispatch(window, 'start', { authorization: 'user-action', requesterId: 'core.player.controls', target: makeTarget() });
await dispatch(window, 'pause', { sessionId: '/Users/example/private-session?token=secret' }, 'plugin.remote');
window.feedBack.playback.recordRouteChange({ routeId: '/Users/example/native-route?token=secret', routeKind: 'desktop-native', state: 'active', safeReason: 'ok' });
const snapshot = diagnosticsSnapshot(window);
const encoded = JSON.stringify(snapshot);
const stale = snapshot.history.current.recentOutcomes.find(item => item.status === 'stale');
assert.match(snapshot.state.route.routeId, /^route-/);
assert.notEqual(snapshot.state.route.routeId, '/Users/example/native-route?token=secret');
assert.match(stale.sessionId, /^playback-/);
assert.notEqual(stale.sessionId, '/Users/example/private-session?token=secret');
assert.doesNotMatch(encoded, /private-session|native-route|token=secret|\/Users\/example/);
});
test('diagnostics redact requester ids and raw camel-case payload keys', async () => {
const window = loadPlayback();
window.feedBack.playback.registerTransportAdapter(makeAdapter());
await dispatch(window, 'start', { authorization: 'user-action', target: makeTarget() }, '/Users/example/plugin token=secret');
const degradedEvents = captureEvents(window, 'playback:degraded');
window.feedBack.playback.transportEvent('degraded', {
requesterId: '/Users/example/transport token=secret',
accessToken: 'plain-secret-token',
nativeHandleRef: 'native-secret-handle',
mediaStream: 'raw-stream-id',
reason: '/Users/example/private song.archive token=secret',
safeDetail: 'safe value',
});
window.feedBack.playback.recordBridgeHit({
bridgeId: '/Users/example/bridge token=secret',
legacySurface: 'window.playSong',
source: '/Users/example/source token=secret',
reason: '/Users/example/bridge path token=secret',
nativeHandleRef: 'native-secret-handle',
});
const snapshot = diagnosticsSnapshot(window);
const encoded = JSON.stringify({ snapshot, degradedEvents });
assert.match(snapshot.state.transport.requesterId, /path/);
assert.doesNotMatch(encoded, /plain-secret-token|native-secret-handle|raw-stream-id/);
assert.doesNotMatch(encoded, /private song|bridge path|\/Users\/example|token=secret|source-token-secret|bridge-token-secret/);
assert.match(encoded, /safe value/);
});