Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

songs: stub AudioContext via vi.stubGlobal so scorePlayback tests pass in node env

[._.]/ Adam Eivy3887940daa63
diff --git a/client/src/lib/scorePlayback.js b/client/src/lib/scorePlayback.js
index d176aac982..c894ad5676 100644
--- a/client/src/lib/scorePlayback.js
+++ b/client/src/lib/scorePlayback.js
@@ -83,7 +83,9 @@ export const buildSchedule = (score, bpmOverride) => {
let sharedCtx = null;
const ctx = () => {
if (!sharedCtx) {
- const Ctor = window.AudioContext || window.webkitAudioContext;
+ const Ctor = typeof window !== 'undefined'
+ ? (window.AudioContext || window.webkitAudioContext)
+ : (globalThis.AudioContext || globalThis.webkitAudioContext);
sharedCtx = new Ctor();
}
return sharedCtx;
diff --git a/client/src/lib/scorePlayback.test.js b/client/src/lib/scorePlayback.test.js
index 47fe6575ae..413976010b 100644
--- a/client/src/lib/scorePlayback.test.js
+++ b/client/src/lib/scorePlayback.test.js
@@ -116,10 +116,10 @@ describe('createScorePlayer', () => {
beforeEach(() => {
audio.now = 0;
audio.oscillators = [];
- window.AudioContext = FakeAudioContext;
+ vi.stubGlobal('AudioContext', FakeAudioContext);
vi.useFakeTimers();
});
- afterEach(() => { vi.useRealTimers(); });
+ afterEach(() => { vi.useRealTimers(); vi.unstubAllGlobals(); });
const SCORE = parseScore('time: 4/4\ntempo: 120\n| C4q D4q E4q rq |');