feat: Modernize the visual card editor. (#2586)

This commit is contained in:
Dermot Duffy
2026-07-20 20:44:16 -07:00
committed by GitHub
parent e204ec183f
commit b6e1de5999
146 changed files with 8487 additions and 5992 deletions
@@ -0,0 +1,53 @@
import { describe, expect, it } from 'vitest';
import { getDocLinkPath, getDocURL } from '../../../src/components-lib/editor/doc-links';
describe('getDocURL', () => {
it('should return the documentation URL for a known path', () => {
expect(getDocURL(['live', 'controls', 'thumbnails'])).toBe(
'https://card.camera/#/configuration/live?id=thumbnails',
);
});
it('should ignore array indices', () => {
expect(getDocURL(['cameras', 0, 'triggers'])).toBe(
'https://card.camera/#/configuration/cameras/README?id=triggers',
);
});
it('should return null for a path without documentation', () => {
expect(getDocURL(['unknown', 'path'])).toBeNull();
});
});
describe('getDocLinkPath', () => {
it('should not link a field', () => {
expect(
getDocLinkPath(['cameras'], { name: 'title', selector: { text: {} } }),
).toBeNull();
});
it('should link a group by its explicit documentation path', () => {
expect(
getDocLinkPath(['cameras', 2], {
type: 'expandable',
docPath: 'cameras.engine',
schema: [],
}),
).toEqual(['cameras', 'engine']);
});
it('should not link a group that has neither a name nor a path', () => {
expect(getDocLinkPath(['cameras'], { type: 'expandable', schema: [] })).toBeNull();
});
it('should order nested container paths into configuration order', () => {
expect(
getDocLinkPath(
['cameras', 2],
{ name: 'dashboard', type: 'expandable', schema: [] },
{ path: ['cast'] },
),
).toEqual(['cameras', 2, 'cast', 'dashboard']);
});
});