Files
Void-Homelab/tests/frontend/reorder.test.js
root e368ea41d8 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>
2026-06-02 22:39:57 +10:00

15 lines
526 B
JavaScript

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']);
});
});