mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 12:55:16 -07:00
feat(config): add configuration window (#70)
This commit is contained in:
@@ -168,6 +168,37 @@ test('MpvIpcClient connect logs connect-request at debug level', () => {
|
||||
assert.equal(requestLogs.length, 1);
|
||||
});
|
||||
|
||||
test('MpvIpcClient reconnect clears stale connected state and starts a fresh transport connect', () => {
|
||||
const client = new MpvIpcClient('/tmp/mpv.sock', makeDeps());
|
||||
const calls: string[] = [];
|
||||
const connectionChanges: boolean[] = [];
|
||||
const resolved: unknown[] = [];
|
||||
client.on('connection-change', ({ connected }) => {
|
||||
connectionChanges.push(connected);
|
||||
});
|
||||
(client as any).connected = true;
|
||||
(client as any).connecting = false;
|
||||
(client as any).socket = {};
|
||||
(client as any).pendingRequests.set(10, (message: unknown) => {
|
||||
resolved.push(message);
|
||||
});
|
||||
(client as any).transport.shutdown = () => {
|
||||
calls.push('shutdown');
|
||||
};
|
||||
(client as any).transport.connect = () => {
|
||||
calls.push('connect');
|
||||
};
|
||||
|
||||
client.reconnect();
|
||||
|
||||
assert.deepEqual(calls, ['shutdown', 'connect']);
|
||||
assert.equal(client.connected, false);
|
||||
assert.equal((client as any).connecting, true);
|
||||
assert.equal((client as any).socket, null);
|
||||
assert.deepEqual(connectionChanges, [false]);
|
||||
assert.deepEqual(resolved, [{ request_id: 10, error: 'disconnected' }]);
|
||||
});
|
||||
|
||||
test('MpvIpcClient failPendingRequests resolves outstanding requests as disconnected', () => {
|
||||
const client = new MpvIpcClient('/tmp/mpv.sock', makeDeps());
|
||||
const resolved: unknown[] = [];
|
||||
@@ -385,6 +416,41 @@ test('MpvIpcClient connect does not force primary subtitle visibility from bindi
|
||||
assert.equal(hasPrimaryVisibilityMutation, false);
|
||||
});
|
||||
|
||||
test('MpvIpcClient snapshots current subtitles before connection side effects can hide them', () => {
|
||||
const commands: unknown[] = [];
|
||||
const client = new MpvIpcClient('/tmp/mpv.sock', makeDeps());
|
||||
(client as any).send = (command: unknown) => {
|
||||
commands.push(command);
|
||||
return true;
|
||||
};
|
||||
client.on('connection-change', ({ connected }) => {
|
||||
if (connected) {
|
||||
client.setSubVisibility(false);
|
||||
}
|
||||
});
|
||||
|
||||
const callbacks = (client as any).transport.callbacks;
|
||||
callbacks.onConnect();
|
||||
|
||||
const firstSubTextSnapshot = commands.findIndex((command) => {
|
||||
const args = (command as { command?: unknown[] }).command;
|
||||
return Array.isArray(args) && args[0] === 'get_property' && args[1] === 'sub-text';
|
||||
});
|
||||
const firstPrimaryHide = commands.findIndex((command) => {
|
||||
const args = (command as { command?: unknown[] }).command;
|
||||
return (
|
||||
Array.isArray(args) &&
|
||||
args[0] === 'set_property' &&
|
||||
args[1] === 'sub-visibility' &&
|
||||
(args[2] === false || args[2] === 'no')
|
||||
);
|
||||
});
|
||||
|
||||
assert.notEqual(firstSubTextSnapshot, -1);
|
||||
assert.notEqual(firstPrimaryHide, -1);
|
||||
assert.ok(firstSubTextSnapshot < firstPrimaryHide);
|
||||
});
|
||||
|
||||
test('MpvIpcClient setSubVisibility writes compatibility commands for visibility toggle', () => {
|
||||
const commands: unknown[] = [];
|
||||
const client = new MpvIpcClient('/tmp/mpv.sock', makeDeps());
|
||||
|
||||
Reference in New Issue
Block a user