- 全部功能 gains 统计 (Stats): ranges Today/7/30/90 days/all time, a project scope (reusing the shared project sheet, plus "All projects"), session/prompt/token/cost/active-days/streak tiles, a daily activity chart (weekly past 92 days), token composition, efficiency tiles, model ranking by tokens/cost/steps and on-request tool-call stats; data comes from /api/experimental/session/stats and the day buckets use the device's IANA zone (a small platform channel; desktop falls back to UTC) - the model bars draw a full-width track with a left-aligned fill, so a small token share reads as a sliver instead of an empty bar - AI token strings read 词元 (not 令牌) in Chinese - the client's display name is Chamber Go (launcher, iOS, Linux window, About), package unchanged; pairing/login labels and the user-agent follow, so a newly paired device shows "Chamber Go" on the web client's "Connect to this server" list - bump to 0.5.6
115 lines
3.8 KiB
Dart
115 lines
3.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:openchamber/api/models.dart';
|
|
import 'package:openchamber/l10n.dart';
|
|
import 'package:openchamber/screens/scheduled_tasks_screen.dart';
|
|
import 'package:openchamber/state.dart';
|
|
import 'package:openchamber/widgets/project_picker.dart';
|
|
|
|
void main() {
|
|
setUp(() => L10n.instance.apply(AppLanguage.en));
|
|
tearDown(() => L10n.instance.apply(AppLanguage.zh));
|
|
|
|
test('a filesystem root keeps its own name', () {
|
|
expect(pathLeaf('/'), '/');
|
|
expect(pathLeaf('/home/me/project/'), 'project');
|
|
expect(pathLeaf(r'C:\Users\me'), 'me');
|
|
});
|
|
|
|
testWidgets('the picker lists checkouts and the Chat row', (tester) async {
|
|
final app = AppState();
|
|
addTearDown(app.dispose);
|
|
app.projects = const [
|
|
ProjectInfo(id: 'p1', canonical: '/home/me/project', name: 'My project'),
|
|
// The server also knows the root; it must not read as a blank row.
|
|
ProjectInfo(id: 'root', canonical: '/'),
|
|
// The same checkout listed twice (a project record and a sandbox).
|
|
ProjectInfo(
|
|
id: 'p2', canonical: '/home/me/project', name: 'My project', vcs: 'git'),
|
|
];
|
|
|
|
ProjectChoice? choice;
|
|
await tester.pumpWidget(MaterialApp(
|
|
home: Scaffold(
|
|
body: Builder(
|
|
builder: (context) => TextButton(
|
|
onPressed: () async {
|
|
choice = await showProjectPicker(context,
|
|
app: app, selected: AppState.chatTarget);
|
|
},
|
|
child: const Text('open'),
|
|
),
|
|
),
|
|
),
|
|
));
|
|
await tester.tap(find.text('open'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Choose project'), findsOneWidget);
|
|
expect(find.text('Chat'), findsWidgets);
|
|
expect(find.text('My project'), findsOneWidget);
|
|
// The root's label and its path are the same text.
|
|
expect(find.text('/'), findsWidgets);
|
|
|
|
await tester.tap(find.text('My project'));
|
|
await tester.pumpAndSettle();
|
|
expect(choice, isNotNull);
|
|
expect(choice!.canonical, '/home/me/project');
|
|
expect(choice!.isChat, isFalse);
|
|
});
|
|
|
|
testWidgets('the stats picker adds All projects and drops the Chat row',
|
|
(tester) async {
|
|
final app = AppState();
|
|
addTearDown(app.dispose);
|
|
app.projects = const [
|
|
ProjectInfo(id: 'p1', canonical: '/home/me/project', name: 'My project'),
|
|
];
|
|
|
|
ProjectChoice? choice;
|
|
await tester.pumpWidget(MaterialApp(
|
|
home: Scaffold(
|
|
body: Builder(
|
|
builder: (context) => TextButton(
|
|
onPressed: () async {
|
|
choice = await showProjectPicker(context,
|
|
app: app,
|
|
selected: allProjectsTarget,
|
|
includeAll: true,
|
|
includeChat: false);
|
|
},
|
|
child: const Text('open'),
|
|
),
|
|
),
|
|
),
|
|
));
|
|
await tester.tap(find.text('open'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('All projects'), findsOneWidget);
|
|
expect(find.text('Chat'), findsNothing);
|
|
expect(find.text('My project'), findsOneWidget);
|
|
|
|
await tester.tap(find.text('All projects'));
|
|
await tester.pumpAndSettle();
|
|
expect(choice, isNotNull);
|
|
expect(choice!.isAll, isTrue);
|
|
});
|
|
|
|
testWidgets('scheduled tasks open the same project sheet', (tester) async {
|
|
final app = AppState();
|
|
addTearDown(app.dispose);
|
|
app.projects = const [
|
|
ProjectInfo(id: 'p1', canonical: '/home/me/project', name: 'My project'),
|
|
];
|
|
|
|
await tester.pumpWidget(MaterialApp(home: ScheduledTasksScreen(app: app)));
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.text('My project'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Choose project'), findsOneWidget);
|
|
expect(find.text('My project'), findsWidgets);
|
|
});
|
|
}
|