feat(sacred-valley): drag-to-reorder with server-persisted layout
Adds HTML5 drag-to-reorder for .sv-card elements in Sacred Valley. The pure moveId helper is unit-tested. Drop calls PUT /api/dashboard/layout to persist the new card_order; DOM reflects the new order immediately. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
14
tests/frontend/reorder.test.js
Normal file
14
tests/frontend/reorder.test.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { moveId } from '../../public/components/sv_reorder.js';
|
||||
|
||||
describe('moveId', () => {
|
||||
it('moves an id before a target', () => {
|
||||
expect(moveId(['a', 'b', 'c'], 'c', 'a')).toEqual(['c', 'a', 'b']);
|
||||
});
|
||||
it('moving onto itself is a no-op', () => {
|
||||
expect(moveId(['a', 'b', 'c'], 'b', 'b')).toEqual(['a', 'b', 'c']);
|
||||
});
|
||||
it('moving to end when target is null appends', () => {
|
||||
expect(moveId(['a', 'b', 'c'], 'a', null)).toEqual(['b', 'c', 'a']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user