fix preview inputs and markup preview

This commit is contained in:
2026-03-27 21:34:51 -07:00
parent 66f1bca046
commit 63bdc70456
13 changed files with 501 additions and 316 deletions

View File

@@ -0,0 +1,31 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { buildDefaultWidgetValues, getDefaultWidgetValue } from '../src/nodeWidgetDefaults.js';
test('enum widget defaults honor opts.default instead of the first option', () => {
assert.equal(
getDefaultWidgetValue([['line', 'rectangle', 'circle', 'arrow'], { default: 'arrow' }]),
'arrow',
);
});
test('buildDefaultWidgetValues keeps non-data required widget defaults', () => {
assert.deepEqual(
buildDefaultWidgetValues({
input: {
required: {
input: ['ANNOTATION_SOURCE', { label: 'Input' }],
shape: [['line', 'rectangle', 'circle', 'arrow'], { default: 'arrow' }],
stroke_color: ['STRING', { default: '#ff0000', color_picker: true }],
stroke_width: ['INT', { default: 3 }],
},
},
}),
{
shape: 'arrow',
stroke_color: '#ff0000',
stroke_width: 3,
},
);
});