[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:
109
components/settings/tabs/PluginStructuredSettingEditor.test.tsx
Normal file
109
components/settings/tabs/PluginStructuredSettingEditor.test.tsx
Normal file
@@ -0,0 +1,109 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
|
||||
import {
|
||||
createPluginStructuredDefaultValue,
|
||||
PluginStructuredSettingEditor,
|
||||
} from './PluginStructuredSettingEditor';
|
||||
|
||||
const labels = {
|
||||
add: 'Add item',
|
||||
remove: 'Remove item',
|
||||
moveUp: (index: number) => `Move ${index} up`,
|
||||
moveDown: (index: number) => `Move ${index} down`,
|
||||
};
|
||||
|
||||
test('structured setting defaults preserve nested const, object, and array semantics', () => {
|
||||
assert.deepEqual(createPluginStructuredDefaultValue({
|
||||
type: 'object',
|
||||
properties: {
|
||||
kind: { type: 'string', const: 'ssh' },
|
||||
enabled: { type: 'boolean' },
|
||||
ports: { type: 'array', items: { type: 'integer', minimum: 1 } },
|
||||
},
|
||||
required: ['kind', 'ports'],
|
||||
}), { kind: 'ssh', ports: [] });
|
||||
|
||||
assert.deepEqual(createPluginStructuredDefaultValue({
|
||||
type: 'array',
|
||||
minItems: 2,
|
||||
items: { type: 'string', minLength: 3 },
|
||||
}), ['xxx', 'xxx']);
|
||||
assert.equal(createPluginStructuredDefaultValue({ type: 'integer', maximum: -2 }), -2);
|
||||
});
|
||||
|
||||
test('structured table settings render native nested controls instead of a JSON textarea', () => {
|
||||
const setting = {
|
||||
id: 'com.example.routes',
|
||||
label: 'Routes',
|
||||
control: 'table',
|
||||
scope: 'application',
|
||||
scopeId: 'application',
|
||||
visible: true,
|
||||
sortable: true,
|
||||
valueSchema: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
name: { type: 'string', minLength: 1 },
|
||||
targets: { type: 'array', items: { type: 'string' }, maxItems: 3 },
|
||||
note: { type: 'string' },
|
||||
},
|
||||
required: ['name', 'targets'],
|
||||
},
|
||||
},
|
||||
} as NetcattyPluginSettingContribution;
|
||||
const html = renderToStaticMarkup(
|
||||
<PluginStructuredSettingEditor
|
||||
setting={setting}
|
||||
value={[{ name: 'Production', targets: ['host-1'] }]}
|
||||
disabled={false}
|
||||
onChange={() => {}}
|
||||
onCommit={() => {}}
|
||||
labels={labels}
|
||||
/>,
|
||||
);
|
||||
|
||||
assert.match(html, /aria-label="Routes name 1"/u);
|
||||
assert.match(html, /aria-label="Routes targets 1 1"/u);
|
||||
assert.match(html, /aria-label="Add item: note"/u);
|
||||
assert.match(html, />Add item</u);
|
||||
assert.doesNotMatch(html, /<textarea/u);
|
||||
});
|
||||
|
||||
test('structured enum controls select deserialized object values by canonical JSON equality', () => {
|
||||
const setting = {
|
||||
id: 'com.example.targets',
|
||||
label: 'Targets',
|
||||
control: 'list',
|
||||
scope: 'application',
|
||||
scopeId: 'application',
|
||||
visible: true,
|
||||
valueSchema: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
enum: [{ kind: 'host', id: 'one' }, { id: 'two', kind: 'host' }],
|
||||
properties: { id: { type: 'string' }, kind: { type: 'string' } },
|
||||
required: ['id', 'kind'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
},
|
||||
} as NetcattyPluginSettingContribution;
|
||||
const html = renderToStaticMarkup(
|
||||
<PluginStructuredSettingEditor
|
||||
setting={setting}
|
||||
value={[{ kind: 'host', id: 'two' }]}
|
||||
disabled={false}
|
||||
onChange={() => {}}
|
||||
onCommit={() => {}}
|
||||
labels={labels}
|
||||
/>,
|
||||
);
|
||||
|
||||
assert.match(html, /<option value="1" selected="">/u);
|
||||
assert.match(html, /\{"id":"two","kind":"host"\}/u);
|
||||
});
|
||||
Reference in New Issue
Block a user