perf(app): quick slide page transitions, close work after the page leaves, instant star/close/reopen

This commit is contained in:
2026-10-24 00:47:32 +01:00
parent fe7311ade0
commit f997964761
5 changed files with 172 additions and 12 deletions
@@ -0,0 +1,53 @@
import 'dart:async';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/data/chat_repository.dart';
import 'chat_test_harness.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_controller.dart';
import 'fake_chat_gateway.dart';
void main() {
late FakeChatGateway gateway;
late ChatSessionsController controller;
late Completer<JsonMap> reply;
setUp(() async {
gateway = FakeChatGateway()
..sessionsReply = {
'chat_sessions': [
{'id': 's1', 'title': 'One', 'directory': '/w', 'starred': false},
],
};
reply = Completer<JsonMap>();
gateway.actionHandler = (_, _) => reply.future;
controller = ChatSessionsController(
ChatRepository(gateway),
localStore: MemoryChatSessionLocalStore(),
);
await controller.refresh();
});
tearDown(() => controller.dispose());
bool starred() => controller.sessions.single['starred'] == true;
test('a star shows at once, before the server answers', () async {
final pending = controller.star('s1', true);
expect(starred(), isTrue);
reply.complete({
'chat_session': {'id': 's1', 'starred': true},
});
await pending;
expect(controller.errorFor('s1'), isNull);
});
test('a refused star is undone and the reason is shown', () async {
final pending = controller.star('s1', true);
expect(starred(), isTrue);
reply.completeError(StateError('star refused'));
await pending;
expect(starred(), isFalse);
expect(controller.errorFor('s1'), contains('star refused'));
});
}