Files
blumia 79221e57d7 feat: group the server's chats and use OpenChamber's project icons
Sessions under the server's managed chats root (chats/<date>/session-…) were
grouped per directory, so each one appeared as its own session-xxxxx band.
GET /api/fs/home now supplies the chats root plus its canonical and legacy
aliases; every chat folder becomes the single 聊天 group. The new-session
picker can target 聊天 too: the first send creates a fresh chat directory
before creating the session, and a new session started from an existing chat
gets a new one instead of sharing its folder.

Projects merge their OpenChamber settings row (label, icon key, colour,
iconBackground and uploaded/auto icon image) with /api/project. Group
headers, the picker and the draft chip draw the chosen icon in its colour,
and custom images are fetched through the client transport (SVG included)
with a themed fallback to the glyph. The chat group uses a chat bubble rather
than a folder.

0.4.8 (408).
2026-11-23 17:42:49 +08:00

46 lines
1.7 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:openchamber/api/models.dart';
void main() {
test('a Windows project path reads as its folder name', () {
expect(pathLeaf(r'C:\msys64\home\Gary\Sources\pineapple-notepad'),
'pineapple-notepad');
expect(pathLeaf('/home/blumia/Sources/telegram/'), 'telegram');
expect(pathLeaf('relative'), 'relative');
expect(
ProjectInfo(id: 'p', canonical: r'C:\work\pineapple-notepad').label,
'pineapple-notepad',
);
expect(
ProjectInfo(id: 'p', canonical: '/w/x', name: '显式名称').label,
'显式名称',
);
});
test('the same place compares across separators and Windows case', () {
expect(samePath(r'C:\x\y', 'C:/x/y'), isTrue);
expect(samePath(r'C:\X\y', r'c:\x\Y'), isTrue);
expect(samePath('/a/b/', '/a/b'), isTrue);
expect(samePath('/a/b', '/a/c'), isFalse);
// A POSIX path stays case-sensitive.
expect(samePath('/a/B', '/a/b'), isFalse);
});
test('slashPath only unifies separators', () {
expect(slashPath(r'C:\a\b\'), 'C:/a/b');
});
test('a directory is recognised under a chats root', () {
expect(isUnderDirectory('/home/me/.config/openchamber/chats/2026-11-23/x',
'/home/me/.config/openchamber/chats'), isTrue);
expect(isUnderDirectory(r'C:\Users\me\.config\openchamber\chats\a\b',
r'c:\users\me\.config\openchamber\chats'), isTrue);
expect(isUnderDirectory('/home/me/.config/openchamber/chats-other/x',
'/home/me/.config/openchamber/chats'), isFalse);
expect(isUnderDirectory('/home/me/project', '/home/me/.config/openchamber/chats'),
isFalse);
expect(isUnderDirectory('', '/x'), isFalse);
});
}