test(client): 用例名统一为 should_<期望>_when_<条件>(155/155)

为什么:红线第 8 条门禁立即生效,要求 Flutter 测试命名合规;此前 155 条用例名是英文自然语言
或中文描述,合规数 0/155,属存量欠账,按"先补齐再上新功能"在本批处理。

- 25 个测试文件、155 条用例改名,按「文件 + 旧名」精确定位,每条断言命中恰好 1 次才替换
- 只改名字字面量:改动行 155 删 + 155 增,无一行不含字符串字面量(断言与用例体零改动)
- 门禁:dart analyze lib test = No issues found;flutter test = 155 全过
This commit is contained in:
Vicky committed 2026-10-16 09:41:14 +08:00
1 parent 1853e1845c
commit 0e5d550b50
25 files changed
+155 -155

No files matched your search

@@ -5,7 +5,7 @@ import 'package:shared_preferences_platform_interface/in_memory_shared_preferenc
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
void main() {
test('saved, liked and comments are kept by drama id', () async {
test('should_keep_saved_liked_and_comments_by_drama_id_when_toggled', () async {
final repository = InMemoryEngagementRepository();
final first = EngagementController(repository);
await first.load();
@@ -28,7 +28,7 @@ void main() {
expect(reopened.isSaved('signal'), isFalse);
});
test('local engagement survives a new repository instance', () async {
test('should_survive_new_repository_instance_when_engagement_is_local', () async {
SharedPreferencesAsyncPlatform.instance =
InMemorySharedPreferencesAsync.empty();
final first = EngagementController(SharedPreferencesEngagementRepository());
@@ -27,7 +27,7 @@ void main() {
return repository().load();
}
test('a first launch reads an empty snapshot', () async {
test('should_read_empty_snapshot_when_first_launch', () async {
final snapshot = await repository().load();
expect(snapshot.savedDramaIds, isEmpty);
@@ -35,7 +35,7 @@ void main() {
expect(snapshot.commentsByDrama, isEmpty);
});
test('a snapshot survives a save and reload round trip', () async {
test('should_survive_save_and_reload_round_trip_when_snapshot_is_stored', () async {
await repository().save(
const EngagementSnapshot(
savedDramaIds: {'signal', 'city'},
@@ -55,7 +55,7 @@ void main() {
});
});
test('an empty snapshot round trips as empty collections', () async {
test('should_round_trip_as_empty_collections_when_snapshot_is_empty', () async {
await repository().save(const EngagementSnapshot());
final loaded = await repository().load();
@@ -65,7 +65,7 @@ void main() {
expect(loaded.commentsByDrama, isEmpty);
});
test('corrupt or non-object payloads fall back to an empty snapshot', () async {
test('should_fall_back_to_empty_snapshot_when_payload_is_corrupt_or_not_an_object', () async {
for (final raw in <String>[
'',
'not json at all',
@@ -82,7 +82,7 @@ void main() {
}
});
test('wrongly typed fields are dropped instead of throwing', () async {
test('should_drop_mistyped_fields_when_payload_has_wrong_types', () async {
final snapshot = await loadRaw(
jsonEncode({
'saved': 'signal',
@@ -103,7 +103,7 @@ void main() {
});
});
test('a payload missing keys falls back per field', () async {
test('should_fall_back_per_field_when_payload_keys_are_missing', () async {
final snapshot = await loadRaw(jsonEncode({'saved': ['signal']}));
expect(snapshot.savedDramaIds, {'signal'});
@@ -111,7 +111,7 @@ void main() {
expect(snapshot.commentsByDrama, isEmpty);
});
test('save writes only json primitives', () async {
test('should_write_only_json_primitives_when_saving', () async {
await repository().save(
const EngagementSnapshot(
savedDramaIds: {'signal'},