Add chat files panel explorer shell with sorting and views
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/data/directory_listing.dart';
|
||||
import 'package:pipelines_app/features/chat/files/files_models.dart';
|
||||
|
||||
DirectoryEntry entry(String name, {bool dir = false, int? size}) =>
|
||||
DirectoryEntry(
|
||||
name: name,
|
||||
path: '/home/$name',
|
||||
isDir: dir,
|
||||
isGitRepo: false,
|
||||
hidden: false,
|
||||
size: size,
|
||||
);
|
||||
|
||||
void main() {
|
||||
test('reads optional size and modified fields without requiring them', () {
|
||||
final parsed = DirectoryEntry.fromJson({
|
||||
'name': 'report.md',
|
||||
'path': '/home/report.md',
|
||||
'is_dir': false,
|
||||
'modified': '2026-11-07T00:00:00Z',
|
||||
'size': 12,
|
||||
});
|
||||
expect(parsed.size, 12);
|
||||
expect(parsed.modified, '2026-11-07T00:00:00Z');
|
||||
expect(DirectoryEntry.fromJson({'name': 'unknown'}).size, isNull);
|
||||
});
|
||||
|
||||
test('sorts folders first and then by selected key', () {
|
||||
final sorted = sortFileEntries([
|
||||
entry('z.txt', size: 2),
|
||||
entry('apps', dir: true),
|
||||
entry('a.txt', size: 1),
|
||||
], const FilesSort(FilesSortKey.size));
|
||||
expect(sorted.map((item) => item.name), ['apps', 'a.txt', 'z.txt']);
|
||||
});
|
||||
|
||||
test('keeps folders first when sorting descending', () {
|
||||
final sorted = sortFileEntries([
|
||||
entry('z.txt', size: 2),
|
||||
entry('apps', dir: true),
|
||||
entry('a.txt', size: 1),
|
||||
], const FilesSort(FilesSortKey.name, ascending: false));
|
||||
expect(sorted.map((item) => item.name), ['apps', 'z.txt', 'a.txt']);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user