feat: 补充我的页内容区块

This commit is contained in:
Zhou Weidong committed 2026-10-22 21:44:03 +08:00
1 parent 7971ac18fc
commit 9953c955e3
23 files changed
+800 -9

No files matched your search

+4
View File
@@ -166,6 +166,10 @@ void main() {
logic.myAction(MyPageAction.following);
expect(logic.tab, 2);
logic.openFollowingHistory();
expect(logic.tab, 2);
expect(logic.followingHistoryRequest, 1);
logic.myAction(MyPageAction.resume);
expect(logic.tab, 0);
expect(logic.resumeRequest, 1);
+1
View File
@@ -27,6 +27,7 @@ void main() {
await pumpEventQueue();
expect(logic.recent.single.dramaId, 'signal');
expect(logic.watchRecordTotal, 1);
expect(logic.recentLoading, isFalse);
expect(logic.recentError, isNull);
logic.dispose();
+112
View File
@@ -3,7 +3,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/app.dart';
import 'package:fruitshorts/core/data/models/wallet.dart';
import 'package:fruitshorts/core/data/models/watch_progress.dart';
import 'package:fruitshorts/core/data/repositories/commerce_repository.dart';
import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
@@ -12,6 +14,7 @@ import 'package:fruitshorts/core/theme/app_dimens.dart';
import 'package:fruitshorts/core/theme/app_theme.dart';
import 'package:fruitshorts/l10n/app_localizations.dart';
import 'package:fruitshorts/pages/auth/auth_view.dart';
import 'package:fruitshorts/pages/mine/about_page.dart';
import 'package:fruitshorts/pages/mine/mine_types.dart';
import 'package:fruitshorts/pages/mine/widgets/mine_menu.dart';
import 'package:fruitshorts/pages/store/vip_page.dart';
@@ -40,7 +43,11 @@ void main() {
expect(find.byKey(const Key('mine-edit')), findsNothing);
expect(find.byKey(const Key('mine-vip')), findsOneWidget);
expect(find.byKey(const Key('mine-vip-open')), findsOneWidget);
expect(find.byKey(const Key('mine-continue-watching')), findsNothing);
expect(find.byKey(const Key('mine-stats')), findsOneWidget);
expect(find.text('—'), findsNWidgets(3));
expect(find.byKey(const Key('mine-menu')), findsOneWidget);
expect(find.byKey(const Key('mine-more-services')), findsOneWidget);
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
final surface = tester.widget<DecoratedBox>(
find.byKey(const Key('mine-page-surface')),
@@ -192,6 +199,14 @@ void main() {
AppColors.vipGoldEnd,
]);
expect(vipDecoration.boxShadow, isNull);
final order = [
tester.getTopLeft(find.byKey(const Key('mine-user-row'))).dy,
tester.getTopLeft(find.byKey(const Key('mine-vip'))).dy,
tester.getTopLeft(find.byKey(const Key('mine-stats'))).dy,
tester.getTopLeft(find.byKey(const Key('mine-menu'))).dy,
tester.getTopLeft(find.byKey(const Key('mine-more-services'))).dy,
];
expect(order, [...order]..sort());
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(const Key('mine-login')));
@@ -215,6 +230,33 @@ void main() {
expect(find.byKey(const Key('mine-login')), findsNothing);
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
expect(find.byType(FloatingActionButton), findsNothing);
expect(find.byKey(const Key('mine-continue-watching')), findsOneWidget);
expect(find.byKey(const Key('mine-continue-all')), findsOneWidget);
expect(find.text('Recent drama'), findsOneWidget);
expect(find.text('Episode 3'), findsWidgets);
String statValue(Key key) {
return tester
.widget<Text>(
find
.descendant(of: find.byKey(key), matching: find.byType(Text))
.first,
)
.data!;
}
expect(statValue(const Key('mine-stat-following')), '3');
expect(statValue(const Key('mine-stat-watch-records')), '1');
expect(statValue(const Key('mine-stat-coins')), '320');
final signedInOrder = [
tester.getTopLeft(find.byKey(const Key('mine-user-row'))).dy,
tester.getTopLeft(find.byKey(const Key('mine-vip'))).dy,
tester.getTopLeft(find.byKey(const Key('mine-continue-watching'))).dy,
tester.getTopLeft(find.byKey(const Key('mine-stats'))).dy,
tester.getTopLeft(find.byKey(const Key('mine-menu'))).dy,
tester.getTopLeft(find.byKey(const Key('mine-more-services'))).dy,
];
expect(signedInOrder, [...signedInOrder]..sort());
await tester.tap(find.byKey(const Key('mine-edit')));
await tester.pumpAndSettle();
@@ -228,6 +270,48 @@ void main() {
expect(tester.takeException(), isNull);
});
testWidgets('should_open_more_services_and_about_page', (tester) async {
await _pumpApp(tester, signedIn: false);
await _openMine(tester);
await tester.tap(find.byKey(const Key('mine-common-questions')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('mine-placeholder-page')), findsOneWidget);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('mine-about')));
await tester.pumpAndSettle();
expect(find.byType(MineAboutPage), findsOneWidget);
expect(find.byKey(const Key('mine-about-page')), findsOneWidget);
expect(find.text('Version 1.0.0'), findsOneWidget);
expect(
find.text(
AppLocalizations.of(
tester.element(find.byType(MineAboutPage)),
)!.aboutDescription,
),
findsOneWidget,
);
});
testWidgets('should_open_history_tab_from_continue_watching_all', (
tester,
) async {
await _pumpApp(
tester,
signedIn: true,
history: InMemoryWatchHistoryRepository(seed: [_recent]),
);
await _openMine(tester);
await tester.tap(find.byKey(const Key('mine-continue-all')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('following-page')), findsOneWidget);
expect(find.byKey(const Key('following-history-grid')), findsOneWidget);
});
testWidgets('should_open_vip_from_mine_without_floating_player', (
tester,
) async {
@@ -313,6 +397,7 @@ Future<void> _pumpApp(
WidgetTester tester, {
required bool signedIn,
WatchHistoryRepository? history,
CommerceRepository? commerce,
}) async {
tester.view.physicalSize = const Size(390, 1000);
tester.view.devicePixelRatio = 1;
@@ -337,7 +422,34 @@ Future<void> _pumpApp(
commentRepository: FakeCommentRepository(),
interactionRepository: FakeInteractionRepository(),
noticeRepository: FakeNoticeRepository(),
commerceRepository: commerce ?? const _MineWalletCommerceRepository(),
),
);
await tester.pumpAndSettle();
}
class _MineWalletCommerceRepository implements CommerceRepository {
const _MineWalletCommerceRepository();
@override
Future<WalletSnapshot> fetchWallet() async {
return const WalletSnapshot(
wallet: CoinWallet(
coinBalance: 320,
totalRechargedCoin: 500,
totalConsumedCoin: 180,
totalRefundedCoin: 0,
),
);
}
@override
Future<UnlockResult> unlock(String episodeId) async {
return const UnlockResult(
unlocked: true,
accessType: 'UNLOCKED',
coinCost: 0,
coinBalance: 320,
);
}
}