feat(app): 剧场页九宫格与极简我的页

This commit is contained in:
Zhou Weidong committed 2026-10-20 05:28:51 +08:00
1 parent dc8ca7b743
commit 35338cbfc8
46 files changed
+2353 -4358

No files matched your search

+27 -44
View File
@@ -49,44 +49,34 @@ void main() {
},
);
test(
'should_map_category_id_to_discover_section_when_category_is_selected',
() async {
final repository = ScriptedCategoryRepository(
categories: const [
ContentCategory(id: '7', name: 'Romance'),
ContentCategory(id: '8', name: 'Action'),
test('should_return_category_dramas_when_category_id_exists', () async {
final repository = ScriptedCategoryRepository(
categories: const [
ContentCategory(id: '7', name: 'Romance'),
ContentCategory(id: '8', name: 'Action'),
],
feed: HomeFeed(
sections: [
FeedSection(code: 'hot', title: 'Hot', dramas: [_drama('hot-1')]),
FeedSection(code: 'new', title: 'New', dramas: [_drama('new-1')]),
FeedSection(
code: 'category-7',
title: 'Romance',
dramas: [_drama('romance-1')],
),
],
feed: HomeFeed(
sections: [
FeedSection(code: 'hot', title: 'Hot', dramas: [_drama('hot-1')]),
FeedSection(code: 'new', title: 'New', dramas: [_drama('new-1')]),
FeedSection(
code: 'category-7',
title: 'Romance',
dramas: [_drama('romance-1')],
),
],
),
);
final controller = CategoryController(repository);
),
);
final controller = CategoryController(repository);
await controller.load();
controller.selectCategory('7');
await controller.load();
expect(controller.selectedCode, 'category-7');
expect(controller.visibleDramas.map((drama) => drama.id), ['romance-1']);
expect(controller.selectedSectionMissing, isFalse);
controller.selectCategory('8');
expect(controller.selectedCode, 'category-8');
expect(controller.visibleDramas, isEmpty);
expect(controller.selectedSectionMissing, isTrue);
},
);
expect(controller.dramasOf('7').map((drama) => drama.id), ['romance-1']);
expect(controller.dramasOf('8'), isEmpty);
});
test(
'should_keep_hot_and_new_entries_when_discover_feed_provides_them',
'should_keep_hot_and_new_sections_when_discover_feed_provides_them',
() async {
final repository = ScriptedCategoryRepository(
feed: HomeFeed(
@@ -104,15 +94,12 @@ void main() {
final controller = CategoryController(repository);
await controller.load();
controller.selectCode(CategoryController.hotCode);
expect(controller.visibleDramas.map((drama) => drama.id), ['hot-1']);
controller.selectCode(CategoryController.newCode);
expect(controller.visibleDramas.map((drama) => drama.id), ['new-1']);
expect(controller.feed.sections.first.code, 'hot');
expect(controller.feed.sections[1].dramas.single.id, 'new-1');
},
);
test('should_dedupe_dramas_when_all_categories_are_selected', () async {
test('should_dedupe_dramas_when_feed_sections_overlap', () async {
final repository = ScriptedCategoryRepository(
feed: HomeFeed(
sections: [
@@ -129,11 +116,7 @@ void main() {
await controller.load();
expect(controller.selectedCode, CategoryController.allCode);
expect(controller.visibleDramas.map((drama) => drama.id), [
'same',
'other',
]);
expect(controller.feed.dramas.map((drama) => drama.id), ['same', 'other']);
});
test('should_clear_error_and_retry_when_initial_load_fails', () async {