[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
92
application/state/usePluginContributions.test.tsx
Normal file
92
application/state/usePluginContributions.test.tsx
Normal file
@@ -0,0 +1,92 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
|
||||
import {
|
||||
collectOwnedPluginMenus,
|
||||
createPluginContributionRefreshGuard,
|
||||
failClosedPluginContributionLoad,
|
||||
resolvePluginContributionLoadState,
|
||||
usePluginContributions,
|
||||
} from './usePluginContributions';
|
||||
|
||||
function Probe() {
|
||||
const contributions = usePluginContributions();
|
||||
return (
|
||||
<span>
|
||||
{contributions.available ? 'available' : 'unavailable'}:{contributions.snapshot.plugins.length}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
test('plugin contributions fail closed during server rendering', () => {
|
||||
assert.equal(renderToStaticMarkup(<Probe />), '<span>unavailable:0</span>');
|
||||
});
|
||||
|
||||
test('plugin contribution refresh failures discard the last successful snapshot', () => {
|
||||
const failure = failClosedPluginContributionLoad('bridge unavailable');
|
||||
assert.equal(failure.available, false);
|
||||
assert.equal(failure.snapshot.plugins.length, 0);
|
||||
assert.match(failure.error.message, /bridge unavailable/u);
|
||||
});
|
||||
|
||||
test('plugin contribution query changes hide the prior snapshot synchronously', () => {
|
||||
const staleSnapshot = {
|
||||
locale: 'en',
|
||||
plugins: [{ id: 'com.example.stale' }],
|
||||
} as NetcattyPluginContributionSnapshot;
|
||||
const selected = resolvePluginContributionLoadState({
|
||||
currentQueryKey: '{"context":{"terminal.sessionId":"session-2"}}',
|
||||
loadedQueryKey: '{"context":{"terminal.sessionId":"session-1"}}',
|
||||
snapshot: staleSnapshot,
|
||||
available: true,
|
||||
loading: false,
|
||||
});
|
||||
|
||||
assert.equal(selected.available, false);
|
||||
assert.equal(selected.loading, true);
|
||||
assert.equal(selected.snapshot.plugins.length, 0);
|
||||
});
|
||||
|
||||
test('plugin contribution refreshes reject stale asynchronous results', async () => {
|
||||
const guard = createPluginContributionRefreshGuard();
|
||||
const committed: string[] = [];
|
||||
const oldRequestIsCurrent = guard.begin();
|
||||
let resolveOld: (() => void) | undefined;
|
||||
const oldRequest = new Promise<void>((resolve) => { resolveOld = resolve; }).then(() => {
|
||||
if (oldRequestIsCurrent()) committed.push('old');
|
||||
});
|
||||
|
||||
const newRequestIsCurrent = guard.begin();
|
||||
if (newRequestIsCurrent()) committed.push('new');
|
||||
resolveOld?.();
|
||||
await oldRequest;
|
||||
|
||||
assert.deepEqual(committed, ['new']);
|
||||
assert.equal(oldRequestIsCurrent(), false);
|
||||
assert.equal(newRequestIsCurrent(), true);
|
||||
guard.invalidate();
|
||||
assert.equal(newRequestIsCurrent(), false);
|
||||
});
|
||||
|
||||
test('owned menu rendering inherits command icons when a placement has no override', () => {
|
||||
const commandIcon = { kind: 'theme', name: 'play' } as const;
|
||||
const plugins = [{
|
||||
id: 'com.example.menu',
|
||||
commands: [{ id: 'com.example.menu.run', title: 'Run', enabled: true, icon: commandIcon }],
|
||||
menus: [{
|
||||
id: 'com.example.menu:menu:0',
|
||||
command: 'com.example.menu.run',
|
||||
location: 'terminal/toolbar',
|
||||
title: 'Run',
|
||||
visible: true,
|
||||
enabled: true,
|
||||
}],
|
||||
}] as unknown as NetcattyPluginContributionSnapshot['plugins'];
|
||||
|
||||
assert.deepEqual(collectOwnedPluginMenus(plugins)[0], {
|
||||
...plugins[0].menus[0],
|
||||
pluginId: 'com.example.menu',
|
||||
icon: commandIcon,
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user