test: cut low-value tests, rewrite the rest around behavior, parallelize lanes (#285)

This commit is contained in:
sudacode authored and GitHub committed 2026-10-05 00:07:44 -07:00
1 parent 4b6842d034
commit b48083ddd8
368 files changed
+18045 -60331

No files matched your search

+165 -523
View File
@@ -1,620 +1,262 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createAutoplayReadyGate } from './autoplay-ready-gate';
import type { MergedToken } from '../../types';
import {
createAutoplayReadyGate,
type AutoplayReadyGateDeps,
type AutoplayReadySignal,
} from './autoplay-ready-gate';
test('autoplay ready gate suppresses duplicate media signals for the same media', async () => {
const commands: Array<Array<string | boolean>> = [];
type MpvCommand = Array<string | boolean>;
const PLUGIN_READY: MpvCommand = ['script-message', 'subminer-autoplay-ready'];
const FAKE_TIMER = 1 as unknown as ReturnType<typeof setTimeout>;
const settle = () => new Promise<void>((resolve) => setTimeout(resolve, 0));
const isUnpause = (command: MpvCommand): boolean =>
command[0] === 'set_property' && command[1] === 'pause' && command[2] === false;
// Builds a gate against a connected fake mpv that starts paused. An unpause command
// flips `mpv.paused`; scheduled retries queue in `scheduled` until run explicitly.
function createGate(overrides: Partial<AutoplayReadyGateDeps> = {}) {
const commands: MpvCommand[] = [];
const scheduled: Array<() => void> = [];
const mpv = { paused: true };
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => true,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => true,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
},
}) as never,
getPlaybackPaused: () => mpv.paused,
getMpvClient: () => ({
connected: true,
requestProperty: async () => mpv.paused,
send: ({ command }) => {
commands.push(command);
if (isUnpause(command)) mpv.paused = false;
},
}),
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
commands.push(PLUGIN_READY);
},
schedule: (callback) => {
scheduled.push(callback);
return 1 as never;
return FAKE_TIMER;
},
logDebug: () => {},
...overrides,
});
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null });
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null });
return {
gate,
commands,
scheduled,
mpv,
pluginSignals: () => commands.filter((command) => command[0] === 'script-message'),
unpauseCount: () => commands.filter(isUnpause).length,
// Delivers a forced-while-paused subtitle signal and lets async release attempts settle.
signal: async (text: string, tokens: MergedToken[] | null = null) => {
gate.maybeSignalPluginAutoplayReady({ text, tokens }, { forceWhilePaused: true });
await settle();
},
// Runs queued retries one at a time, including retries they schedule, until none remain.
runScheduled: async () => {
for (let callback = scheduled.shift(); callback; callback = scheduled.shift()) {
callback();
await settle();
}
},
};
}
await new Promise((resolve) => setTimeout(resolve, 0));
const firstScheduled = scheduled.shift();
firstScheduled?.();
await new Promise((resolve) => setTimeout(resolve, 0));
test('autoplay ready gate signals the plugin once per media across duplicate signals and release retries', async () => {
const h = createGate();
assert.deepEqual(
commands.filter((command) => command[0] === 'script-message'),
[['script-message', 'subminer-autoplay-ready']],
);
assert.ok(
commands.some(
(command) => command[0] === 'set_property' && command[1] === 'pause' && command[2] === false,
),
);
await h.signal('字幕');
await h.signal('字幕');
await h.runScheduled();
assert.deepEqual(h.pluginSignals(), [PLUGIN_READY]);
assert.equal(h.unpauseCount(), 1);
});
test('autoplay ready gate retry loop does not re-signal plugin readiness', async () => {
const commands: Array<Array<string | boolean>> = [];
const scheduled: Array<() => void> = [];
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => true,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => true,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
},
}) as never,
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
},
schedule: (callback) => {
scheduled.push(callback);
return 1 as never;
},
logDebug: () => {},
});
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
for (const callback of scheduled.splice(0, 3)) {
callback();
await new Promise((resolve) => setTimeout(resolve, 0));
}
assert.deepEqual(
commands.filter((command) => command[0] === 'script-message'),
[['script-message', 'subminer-autoplay-ready']],
);
assert.equal(
commands.filter(
(command) => command[0] === 'set_property' && command[1] === 'pause' && command[2] === false,
).length > 0,
true,
);
});
test('autoplay ready gate requests overlay pointer recovery when media readiness is signaled', async () => {
const commands: Array<Array<string | boolean>> = [];
test('autoplay ready gate requests overlay pointer recovery once per released media', async () => {
let pointerRecoveryRequests = 0;
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => true,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => true,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
},
}) as never,
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
},
const h = createGate({
requestOverlayPointerRecovery: () => {
pointerRecoveryRequests += 1;
},
schedule: (callback) => {
queueMicrotask(callback);
return 1 as never;
},
logDebug: () => {},
});
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
gate.maybeSignalPluginAutoplayReady(
{ text: '字幕その2', tokens: null },
{ forceWhilePaused: true },
);
await new Promise((resolve) => setTimeout(resolve, 0));
await h.signal('字幕');
await h.signal('字幕その2');
assert.equal(pointerRecoveryRequests, 1);
});
test('autoplay ready gate reports the released autoplay signal once', async () => {
const releasedSignals: string[] = [];
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => true,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => true,
send: () => {},
}) as never,
signalPluginAutoplayReady: () => {},
const h = createGate({
onAutoplayReadyReleased: (signal) => {
releasedSignals.push(signal.payload.text);
},
schedule: (callback) => {
queueMicrotask(callback);
return 1 as never;
},
logDebug: () => {},
});
gate.maybeSignalPluginAutoplayReady(
{ text: '__warm__', tokens: null },
{ forceWhilePaused: true },
);
await new Promise((resolve) => setTimeout(resolve, 0));
gate.maybeSignalPluginAutoplayReady(
{ text: '次の字幕', tokens: null },
{ forceWhilePaused: true },
);
await new Promise((resolve) => setTimeout(resolve, 0));
await h.signal('__warm__');
await h.signal('次の字幕');
assert.deepEqual(releasedSignals, ['__warm__']);
});
test('autoplay ready gate does not unpause again after a later manual pause on the same media', async () => {
const commands: Array<Array<string | boolean>> = [];
let playbackPaused = true;
const manualPauseCases: Array<{
name: string;
afterManualPause: (h: ReturnType<typeof createGate>) => Promise<void>;
}> = [
{
name: 'autoplay ready gate does not unpause again after a later manual pause on the same media',
afterManualPause: (h) => h.signal('字幕その2'),
},
{
name: 'autoplay ready gate cancels release retries after playback is paused again',
afterManualPause: (h) => h.runScheduled(),
},
];
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => playbackPaused,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => playbackPaused,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
if (command[0] === 'set_property' && command[1] === 'pause' && command[2] === false) {
playbackPaused = false;
}
},
}) as never,
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
},
schedule: (callback) => {
queueMicrotask(callback);
return 1 as never;
},
logDebug: () => {},
for (const c of manualPauseCases) {
test(c.name, async () => {
const h = createGate();
await h.signal('字幕');
assert.equal(h.unpauseCount(), 1);
h.mpv.paused = true;
await c.afterManualPause(h);
assert.equal(h.unpauseCount(), 1);
assert.equal(h.mpv.paused, true);
});
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
playbackPaused = true;
gate.maybeSignalPluginAutoplayReady(
{ text: '字幕その2', tokens: null },
{ forceWhilePaused: true },
);
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(
commands.filter(
(command) => command[0] === 'set_property' && command[1] === 'pause' && command[2] === false,
).length,
1,
);
});
test('autoplay ready gate cancels release retries after playback is paused again', async () => {
const commands: Array<Array<string | boolean>> = [];
const scheduled: Array<() => void> = [];
let playbackPaused = true;
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => playbackPaused,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => playbackPaused,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
if (command[0] === 'set_property' && command[1] === 'pause' && command[2] === false) {
playbackPaused = false;
}
},
}) as never,
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
},
schedule: (callback) => {
scheduled.push(callback);
return 1 as never;
},
logDebug: () => {},
});
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
playbackPaused = true;
const retry = scheduled.shift();
retry?.();
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(
commands.filter(
(command) => command[0] === 'set_property' && command[1] === 'pause' && command[2] === false,
).length,
1,
);
});
}
test('autoplay ready gate suppresses release after manual current-media dismissal', async () => {
const commands: Array<Array<string | boolean>> = [];
const h = createGate();
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => true,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => true,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
},
}) as never,
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
},
schedule: (callback) => {
queueMicrotask(callback);
return 1 as never;
},
logDebug: () => {},
});
h.gate.markCurrentMediaAutoplayReady();
await h.signal('字幕');
gate.markCurrentMediaAutoplayReady();
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
assert.deepEqual(commands, []);
assert.deepEqual(h.commands, []);
});
test('autoplay ready gate defers plugin readiness until the signal target is ready', async () => {
const commands: Array<Array<string | boolean>> = [];
let targetReady = false;
const deferredReleaseCases: Array<{
name: string;
release: (h: ReturnType<typeof createGate>) => Promise<void>;
}> = [
{
name: 'autoplay ready gate defers plugin readiness until the signal target is ready',
release: async (h) => {
h.gate.flushPendingAutoplayReadySignal();
await settle();
},
},
{
name: 'autoplay ready gate retries deferred readiness without an external flush event',
release: (h) => h.runScheduled(),
},
];
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => true,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => true,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
},
}) as never,
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
},
isSignalTargetReady: () => targetReady,
schedule: (callback) => {
queueMicrotask(callback);
return 1 as never;
},
logDebug: () => {},
for (const c of deferredReleaseCases) {
test(c.name, async () => {
let targetReady = false;
const h = createGate({ isSignalTargetReady: () => targetReady });
await h.signal('字幕');
assert.deepEqual(h.commands, []);
assert.equal(h.scheduled.length, 1);
targetReady = true;
await c.release(h);
assert.deepEqual(h.pluginSignals(), [PLUGIN_READY]);
assert.equal(h.unpauseCount(), 1);
});
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
assert.deepEqual(commands, []);
targetReady = true;
gate.flushPendingAutoplayReadySignal();
await new Promise((resolve) => setTimeout(resolve, 0));
assert.deepEqual(
commands.filter((command) => command[0] === 'script-message'),
[['script-message', 'subminer-autoplay-ready']],
);
assert.equal(
commands.some(
(command) => command[0] === 'set_property' && command[1] === 'pause' && command[2] === false,
),
true,
);
});
test('autoplay ready gate retries deferred readiness without an external flush event', async () => {
const commands: Array<Array<string | boolean>> = [];
const scheduled: Array<() => void> = [];
let targetReady = false;
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => true,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => true,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
},
}) as never,
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
},
isSignalTargetReady: () => targetReady,
schedule: (callback) => {
scheduled.push(callback);
return 1 as never;
},
logDebug: () => {},
});
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
assert.deepEqual(commands, []);
assert.equal(scheduled.length, 1);
targetReady = true;
scheduled.shift()?.();
await new Promise((resolve) => setTimeout(resolve, 0));
assert.deepEqual(
commands.filter((command) => command[0] === 'script-message'),
[['script-message', 'subminer-autoplay-ready']],
);
assert.equal(
commands.some(
(command) => command[0] === 'set_property' && command[1] === 'pause' && command[2] === false,
),
true,
);
});
}
test('autoplay ready gate keeps deferred startup readiness retries active for cold starts', async () => {
const commands: Array<Array<string | boolean>> = [];
const scheduled: Array<() => void> = [];
const h = createGate({ isSignalTargetReady: () => false });
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => true,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => true,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
},
}) as never,
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
},
isSignalTargetReady: () => false,
schedule: (callback) => {
scheduled.push(callback);
return 1 as never;
},
logDebug: () => {},
});
gate.maybeSignalPluginAutoplayReady(
{ text: '__warm__', tokens: null },
{ forceWhilePaused: true },
);
await new Promise((resolve) => setTimeout(resolve, 0));
await h.signal('__warm__');
for (let attempt = 1; attempt <= 100; attempt += 1) {
assert.equal(scheduled.length, 1, `missing deferred readiness retry ${attempt}`);
scheduled.shift()?.();
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(h.scheduled.length, 1, `missing deferred readiness retry ${attempt}`);
h.scheduled.shift()?.();
await settle();
}
assert.deepEqual(commands, []);
assert.deepEqual(h.commands, []);
});
test('autoplay ready gate drops deferred readiness after media changes before flush', async () => {
const commands: Array<Array<string | boolean>> = [];
let targetReady = false;
let currentMediaPath = '/media/video-1.mkv';
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
const h = createGate({
getCurrentMediaPath: () => currentMediaPath,
getCurrentVideoPath: () => null,
getPlaybackPaused: () => true,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => true,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
},
}) as never,
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
},
isSignalTargetReady: () => targetReady,
schedule: (callback) => {
queueMicrotask(callback);
return 1 as never;
},
logDebug: () => {},
});
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
await h.signal('字幕');
currentMediaPath = '/media/video-2.mkv';
targetReady = true;
gate.flushPendingAutoplayReadySignal();
await new Promise((resolve) => setTimeout(resolve, 0));
h.gate.flushPendingAutoplayReadySignal();
await settle();
assert.deepEqual(commands, []);
assert.deepEqual(h.commands, []);
});
test('autoplay ready gate passes the pending subtitle signal to the readiness predicate', async () => {
const commands: Array<Array<string | boolean>> = [];
const observed: Array<Pick<AutoplayReadySignal, 'requestedAtMs'> & { text: string }> = [];
let targetReadyText: string | null = null;
let observedText: string | null = null;
let observedRequestedAtMs: number | null = null;
let now = 1_000;
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => true,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => true,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
},
}) as never,
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
},
isSignalTargetReady: ((signal: { payload: { text: string }; requestedAtMs: number }) => {
observedText = signal.payload.text;
observedRequestedAtMs = signal.requestedAtMs;
const h = createGate({
isSignalTargetReady: (signal) => {
observed.push({ text: signal.payload.text, requestedAtMs: signal.requestedAtMs });
return targetReadyText === signal.payload.text;
}) as never,
now: () => now,
schedule: (callback) => {
queueMicrotask(callback);
return 1 as never;
},
logDebug: () => {},
now: () => now,
});
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
await h.signal('字幕');
assert.equal(observedText, '字幕');
assert.equal(observedRequestedAtMs, 1_000);
assert.deepEqual(commands, []);
assert.deepEqual(observed, [{ text: '字幕', requestedAtMs: 1_000 }]);
assert.deepEqual(h.commands, []);
now = 2_000;
targetReadyText = '字幕';
gate.flushPendingAutoplayReadySignal();
await new Promise((resolve) => setTimeout(resolve, 0));
h.gate.flushPendingAutoplayReadySignal();
await settle();
assert.equal(observedRequestedAtMs, 1_000);
assert.deepEqual(
commands.filter((command) => command[0] === 'script-message'),
[['script-message', 'subminer-autoplay-ready']],
);
// The flushed signal keeps its original request time instead of the flush time.
assert.deepEqual(observed.at(-1), { text: '字幕', requestedAtMs: 1_000 });
assert.deepEqual(h.pluginSignals(), [PLUGIN_READY]);
});
function createTokenizationGateHarness(deps: { isTokenizationReady: () => boolean }) {
const commands: Array<Array<string | boolean>> = [];
const gate = createAutoplayReadyGate({
isAppOwnedFlowInFlight: () => false,
getCurrentMediaPath: () => '/media/video.mkv',
getCurrentVideoPath: () => null,
getPlaybackPaused: () => true,
getMpvClient: () =>
({
connected: true,
requestProperty: async () => true,
send: ({ command }: { command: Array<string | boolean> }) => {
commands.push(command);
},
}) as never,
signalPluginAutoplayReady: () => {
commands.push(['script-message', 'subminer-autoplay-ready']);
},
isTokenizationReady: deps.isTokenizationReady,
schedule: (callback) => {
queueMicrotask(callback);
return 1 as never;
},
logDebug: () => {},
});
return { gate, commands };
}
test('autoplay ready gate ignores untokenized signals until tokenization warmup is ready', async () => {
let tokenizationReady = false;
const h = createGate({ isTokenizationReady: () => tokenizationReady });
test('autoplay ready gate ignores untokenized signals while tokenization warmup is pending', async () => {
const { gate, commands } = createTokenizationGateHarness({
isTokenizationReady: () => false,
});
await h.signal('字幕');
assert.deepEqual(h.commands, []);
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
tokenizationReady = true;
await h.signal('字幕');
assert.deepEqual(commands, []);
assert.deepEqual(h.pluginSignals(), [PLUGIN_READY]);
});
test('autoplay ready gate releases tokenized signals while tokenization warmup is pending', async () => {
const { gate, commands } = createTokenizationGateHarness({
isTokenizationReady: () => false,
});
const h = createGate({ isTokenizationReady: () => false });
gate.maybeSignalPluginAutoplayReady(
{ text: '字幕', tokens: [{ surface: '字幕' }] as never },
{ forceWhilePaused: true },
);
await new Promise((resolve) => setTimeout(resolve, 0));
await h.signal('字幕', [{ surface: '字幕' }] as unknown as MergedToken[]);
assert.deepEqual(
commands.filter((command) => command[0] === 'script-message'),
[['script-message', 'subminer-autoplay-ready']],
);
});
test('autoplay ready gate releases untokenized signals once tokenization warmup is ready', async () => {
let tokenizationReady = false;
const { gate, commands } = createTokenizationGateHarness({
isTokenizationReady: () => tokenizationReady,
});
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
assert.deepEqual(commands, []);
tokenizationReady = true;
gate.maybeSignalPluginAutoplayReady({ text: '字幕', tokens: null }, { forceWhilePaused: true });
await new Promise((resolve) => setTimeout(resolve, 0));
assert.deepEqual(
commands.filter((command) => command[0] === 'script-message'),
[['script-message', 'subminer-autoplay-ready']],
);
assert.deepEqual(h.pluginSignals(), [PLUGIN_READY]);
});