import { buildFlowLogReorderUnits, flattenFlowLogReorderUnits } from '@/utils/flowLogReorder' describe('flowLogReorder', () => { const logs = [ { id: 4, jointly_sign_id: 4, status: 0, created_at: '2026-07-15 10:00:00', node: { category: 'process' } }, { id: 2, jointly_sign_id: 2, status: 1, created_at: '2026-07-15 08:10:00', node: { category: 'process' } }, { id: 1, jointly_sign_id: 1, status: 1, created_at: '2026-07-15 08:00:00', node: { category: 'start' } }, { id: 3, jointly_sign_id: 2, status: 1, created_at: '2026-07-15 08:11:00', node: { category: 'process' } }, ] it('shows start first as locked, suggests handling last, and keeps jointly signed records together', () => { const units = buildFlowLogReorderUnits(logs) expect(units).toHaveLength(3) expect(units[0].logs.map((log) => log.id)).toEqual([1]) expect(units[0].locked).toBe(true) expect(units[0].lockReason).toBe('开始节点固定展示,不参与拖拽排序') expect(units[1].logs.map((log) => log.id)).toEqual([2, 3]) expect(units[1].locked).toBe(false) expect(units[2].logs.map((log) => log.id)).toEqual([4]) expect(units[2].locked).toBe(false) expect(flattenFlowLogReorderUnits(units)).toEqual([1, 2, 3, 4]) }) it('preserves persisted unit order when normalization is disabled', () => { const units = buildFlowLogReorderUnits(logs, false) expect(flattenFlowLogReorderUnits(units)).toEqual([4, 2, 3, 1]) }) })