chore: 更新国际化翻译及 UI 组件优化

This commit is contained in:
zl-q
2026-03-30 09:07:30 +08:00
parent 0f3175e303
commit 60318b7aaa
28 changed files with 1360 additions and 66 deletions
@@ -3,6 +3,7 @@ import 'dart:typed_data';
import 'package:flutter_test/flutter_test.dart';
import 'package:social_app/core/chat/chat_api.dart';
import 'package:social_app/core/chat/chat_history_repository.dart';
import 'package:social_app/data/cache/cache_scope.dart';
import 'package:social_app/data/cache/cache_store.dart';
class _FakeChatApi implements ChatApi {
@@ -42,6 +43,7 @@ class _FakeChatApi implements ChatApi {
@override
Future<Stream<String>> streamRunEvents(
String threadId, {
required String runId,
String? lastEventId,
}) {
throw UnimplementedError();
@@ -79,6 +81,14 @@ class _FakeChatApi implements ChatApi {
}
void main() {
setUp(() {
CacheScope.configureProvider(() => null);
});
tearDown(() {
CacheScope.resetProvider();
});
test('loads first-page history from cache on second read', () async {
final chatApi = _FakeChatApi();
chatApi.setHistory('first:default', {
@@ -113,4 +123,32 @@ void main() {
expect(second.messages.length, 1);
expect(chatApi.historyCalls['first:default'], 1);
});
test('separates history cache by global scope provider', () async {
final chatApi = _FakeChatApi();
chatApi.setHistory('first:default', {
'scope': 'history_day',
'threadId': 't1',
'day': '2026-03-29',
'hasMore': false,
'messages': const [],
});
final repository = ChatHistoryRepository(
chatApi: chatApi,
store: HybridCacheStore(
memory: MemoryCacheStore(),
persistent: PersistentCacheStore(),
),
);
var scope = 'user-a';
CacheScope.configureProvider(() => scope);
await repository.loadHistory();
scope = 'user-b';
await repository.loadHistory();
expect(chatApi.historyCalls['first:default'], 2);
});
}