mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
* fix(#3613): automated AI fix * fix(ai): preserve owners when reusing active host sessions * fix(ai): match opening connection identity before host tab reuse * fix(ai): preserve serial settings when matching reusable tabs * fix: capture restored plugin connection before host reuse --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import { test } from 'node:test';
|
|
import type { TerminalSession } from './models';
|
|
import { findReusableHostSession } from './hostOpenSession';
|
|
|
|
function tab(id: string, status: TerminalSession['status'], extra: Partial<TerminalSession> = {}): TerminalSession {
|
|
return { id, hostId: 'host-1', hostLabel: 'Host', hostname: 'example.invalid', username: 'user', status, ...extra };
|
|
}
|
|
|
|
test('host reuse prefers a connected tab over a connecting tab for the same host', () => {
|
|
assert.deepEqual(findReusableHostSession([
|
|
tab('other-host', 'connected', { hostId: 'host-2' }),
|
|
tab('retrying', 'connecting'),
|
|
tab('live', 'connected'),
|
|
], 'host-1'), { sessionId: 'live', connected: true });
|
|
});
|
|
|
|
test('host reuse keeps the same tab during the reconnect delay and connection attempt', () => {
|
|
assert.deepEqual(findReusableHostSession([tab('retrying', 'connecting')], 'host-1'), {
|
|
sessionId: 'retrying', connected: false,
|
|
});
|
|
});
|
|
|
|
test('host reuse excludes restored placeholders and inactive disconnected tabs', () => {
|
|
assert.equal(findReusableHostSession([
|
|
tab('manual-disconnect', 'disconnected'),
|
|
tab('restored', 'disconnected', { restoreState: 'restored-disconnected' }),
|
|
tab('restoring', 'connecting', { restoreState: 'restored-disconnected' }),
|
|
], 'host-1'), undefined);
|
|
assert.equal(findReusableHostSession([tab('live', 'connected')], ''), undefined);
|
|
});
|