Files
clide/test/builtin/claude/session_storage_test.dart
T
jpmschweitzerandClaude Opus 4.7 8907abeca7 add Claude session storage view with user-driven cleanup
The claude.session-storage command opens a modal listing the workspace's
session transcripts with their on-disk sizes (the <id>.jsonl plus the
<id>/ subagents dir) and a total. Each row deletes with a deliberate
two-click confirm; deletion is guarded against unsafe ids and clide never
removes transcripts on its own. SessionSummary gains a sizeBytes field and
session_index gains formatBytes + deleteSession.

T-148.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 17:02:20 +02:00

75 lines
2.2 KiB
Dart

import 'dart:io';
import 'package:clide/builtin/claude/src/session_index.dart';
import 'package:clide/builtin/claude/src/session_storage.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../helpers/kernel_fixture.dart';
import '../../helpers/widget_harness.dart';
void main() {
late KernelFixture f;
setUp(() async => f = await KernelFixture.create());
tearDown(() => f.dispose());
SessionSummary session(String id, int bytes) => SessionSummary(id: id, modified: DateTime.now(), firstUser: 'f', lastUser: 'l', sizeBytes: bytes);
testWidgets('shows the total and a two-click delete that calls the deleter', (tester) async {
final deleted = <String>[];
await tester.pumpWidget(harness(
f,
SessionStorageDialog(
dir: Directory.systemTemp,
sessions: [session('aaa', 2048)],
onClose: () {},
deleter: (d, id) async => deleted.add(id),
),
));
await tester.pump();
expect(find.text('Session storage · 2 KB total'), findsOneWidget);
expect(find.text('f … l'), findsOneWidget);
// First click arms the confirm; second click deletes.
await tester.tap(find.text('Delete'));
await tester.pump();
expect(find.text('Keep'), findsOneWidget);
await tester.tap(find.text('Delete'));
await tester.pump();
expect(deleted, ['aaa']);
expect(find.text('f … l'), findsNothing); // row removed
});
testWidgets('Escape closes', (tester) async {
var closed = false;
await tester.pumpWidget(harness(
f,
SessionStorageDialog(
dir: Directory.systemTemp,
sessions: [session('aaa', 1024)],
onClose: () => closed = true,
deleter: (_, __) async {},
),
));
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
expect(closed, isTrue);
});
testWidgets('empty list shows a message', (tester) async {
await tester.pumpWidget(harness(
f,
SessionStorageDialog(
dir: Directory.systemTemp,
sessions: const [],
onClose: () {},
deleter: (_, __) async {},
),
));
await tester.pump();
expect(find.text('No sessions found for this workspace.'), findsOneWidget);
});
}