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
+43
View File
@@ -0,0 +1,43 @@
import { describe, expect, it } from 'vitest';
import {
getFormContainerPath,
stripArrayIndices,
} from '../../../src/components-lib/editor/paths';
describe('getFormContainerPath', () => {
it('should reverse the innermost-first segments into configuration order', () => {
expect(getFormContainerPath({ path: ['dashboard', 'cast'] })).toEqual([
'cast',
'dashboard',
]);
});
it('should return an empty path without options', () => {
expect(getFormContainerPath()).toEqual([]);
});
it('should return an empty path without a path in the options', () => {
expect(getFormContainerPath({})).toEqual([]);
});
it('should not modify the passed segments', () => {
const path = ['dashboard', 'cast'];
getFormContainerPath({ path });
expect(path).toEqual(['dashboard', 'cast']);
});
});
describe('stripArrayIndices', () => {
it('should strip numeric segments', () => {
expect(stripArrayIndices(['cameras', 2, 'title'])).toEqual(['cameras', 'title']);
});
it('should strip numeric string segments', () => {
expect(stripArrayIndices(['cameras', '2', 'title'])).toEqual(['cameras', 'title']);
});
it('should leave paths without indices untouched', () => {
expect(stripArrayIndices(['live', 'controls'])).toEqual(['live', 'controls']);
});
});