Files
opsxshell/test/components/sftp/transferQueueSort.test.ts
T
Logan.LiandCursor 08696896f9 feat: harden local shell, SFTP, and desktop session reliability
Finder-launched terminals now inherit a login PATH so tools like ollama resolve, destructive SFTP/editor actions require confirmation, and terminal search plus window dragging work again. SSH forwards and RDP sessions keep listeners and survive reconnect without FastPath crashes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-16 16:08:11 +08:00

42 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { sortTransferTasks } from '../../../src/components/sftp/TransferPanel'
import type { TransferTask } from '../../../shared/types/sftp.types'
function task(
id: string,
status: TransferTask['status']
): TransferTask {
return {
id,
type: 'upload',
fileName: id,
filePath: `/${id}`,
status,
progress: status === 'transferring' ? 40 : 0,
total: 100,
transferred: status === 'transferring' ? 40 : 0,
}
}
describe('sortTransferTasks', () => {
it('puts transferring tasks first, then pending, then finished', () => {
const ordered = sortTransferTasks([
task('done', 'completed'),
task('wait', 'pending'),
task('active', 'transferring'),
task('fail', 'failed'),
task('wait2', 'pending'),
])
expect(ordered.map((t) => t.id)).toEqual(['active', 'wait', 'wait2', 'fail', 'done'])
})
it('keeps relative order within the same status', () => {
const ordered = sortTransferTasks([
task('a', 'pending'),
task('b', 'pending'),
task('c', 'pending'),
])
expect(ordered.map((t) => t.id)).toEqual(['a', 'b', 'c'])
})
})