test: 按新 UI 基线重写过期用例
覆盖 155 条失败与 4 处编译错误:入口改走推荐流 tab、弹框换 AppGlowDialog、 rail 尺寸与底部锚定、子页标题字重 w400、底栏选中品牌红、收藏文案改收藏短剧。 全量 flutter test 775 通过。
This commit is contained in:
1 parent
799f3d1b7d
commit
1d4ab5e0e6
33 files changed
+853
-1114
No files matched your search
+45
-102
@@ -43,74 +43,37 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
final haptics = FakeHaptics();
|
||||
await _pumpApp(tester, haptics);
|
||||
await _pumpApp(tester, haptics: haptics);
|
||||
haptics.reset();
|
||||
|
||||
for (final key in _keys) {
|
||||
expect(find.byKey(key), findsOneWidget);
|
||||
}
|
||||
expect(find.byKey(const Key('home-wallet-entry')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-wallet-badge')), findsOneWidget);
|
||||
final searchEntry = find.byKey(const Key('home-search-entry'));
|
||||
final vipEntry = find.byKey(const Key('home-vip-entry'));
|
||||
final walletEntry = find.byKey(const Key('home-wallet-entry'));
|
||||
// 首页顶部改为悬浮内层导航:搜索 + 礼物(钱包)入口。
|
||||
expect(find.byKey(const Key('recommend-top-nav')), findsOneWidget);
|
||||
final searchEntry = find.byKey(const Key('recommend-search'));
|
||||
final walletEntry = find.byKey(const Key('recommend-gift'));
|
||||
expect(
|
||||
tester.getSize(vipEntry),
|
||||
tester.getSize(searchEntry),
|
||||
const Size.square(AppDimens.homeActionSlot),
|
||||
);
|
||||
expect(
|
||||
tester.getSize(walletEntry),
|
||||
const Size.square(AppDimens.homeActionSlot),
|
||||
);
|
||||
expect(tester.widget<IconButton>(searchEntry).iconSize, 26);
|
||||
expect(tester.widget<IconButton>(walletEntry).iconSize, 26);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('home-vip-icon-frame'))),
|
||||
const Size.square(AppDimens.homeActionIcon),
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('home-wallet-icon-frame'))),
|
||||
const Size.square(AppDimens.homeActionIcon),
|
||||
);
|
||||
expect(
|
||||
tester.getCenter(find.byKey(const Key('home-vip-icon-frame'))).dy,
|
||||
tester.getCenter(find.byKey(const Key('home-wallet-icon-frame'))).dy,
|
||||
);
|
||||
final crownImage = tester.widget<Image>(
|
||||
find.byKey(const Key('home-vip-image')),
|
||||
);
|
||||
final giftImage = tester.widget<Image>(
|
||||
find.byKey(const Key('home-wallet-image')),
|
||||
);
|
||||
expect((crownImage.image as AssetImage).assetName, 'assets/icon/crown.png');
|
||||
expect((giftImage.image as AssetImage).assetName, 'assets/icon/gift.png');
|
||||
expect(
|
||||
tester.getCenter(vipEntry).dy,
|
||||
closeTo(tester.getCenter(searchEntry).dy, 0.1),
|
||||
);
|
||||
expect(
|
||||
tester.getCenter(walletEntry).dy,
|
||||
closeTo(tester.getCenter(searchEntry).dy, 0.1),
|
||||
);
|
||||
expect(
|
||||
tester.getTopLeft(walletEntry).dx - tester.getTopRight(vipEntry).dx,
|
||||
AppDimens.homeActionGap,
|
||||
tester.getCenter(searchEntry).dy,
|
||||
closeTo(tester.getCenter(walletEntry).dy, 0.1),
|
||||
);
|
||||
expect(
|
||||
tester.getTopRight(walletEntry).dx,
|
||||
closeTo(390 - AppDimens.feedPageHorizontal, 0.1),
|
||||
closeTo(390 - 8, 0.1),
|
||||
);
|
||||
expect(crownImage.width, AppDimens.homeActionIcon);
|
||||
expect(crownImage.height, AppDimens.homeActionIcon);
|
||||
expect(crownImage.fit, BoxFit.contain);
|
||||
expect(giftImage.width, AppDimens.homeActionIcon);
|
||||
expect(giftImage.height, AppDimens.homeActionIcon);
|
||||
expect(giftImage.fit, BoxFit.contain);
|
||||
expect(
|
||||
tester
|
||||
.widget<Material>(
|
||||
find.ancestor(of: vipEntry, matching: find.byType(Material)).first,
|
||||
)
|
||||
.color,
|
||||
AppColors.transparent,
|
||||
tester.getTopRight(searchEntry).dx,
|
||||
closeTo(tester.getTopLeft(walletEntry).dx, 0.1),
|
||||
);
|
||||
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
@@ -178,17 +141,26 @@ void main() {
|
||||
.duration,
|
||||
lessThanOrEqualTo(const Duration(milliseconds: 200)),
|
||||
);
|
||||
expect(
|
||||
final selectedHomeIcon = tester.widget<Icon>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.byType(Image),
|
||||
matching: find.byIcon(Icons.home_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(selectedHomeIcon.color, AppColors.navSelected);
|
||||
expect(
|
||||
tester.getSize(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.byIcon(Icons.home_rounded),
|
||||
),
|
||||
),
|
||||
const Size.square(AppDimens.navIcon),
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-recommend')),
|
||||
matching: find.byIcon(Icons.smart_display_outlined),
|
||||
matching: find.byIcon(Icons.celebration_outlined),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
@@ -206,31 +178,6 @@ void main() {
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<ColorFiltered>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.byType(ColorFiltered),
|
||||
),
|
||||
)
|
||||
.colorFilter,
|
||||
const ColorFilter.mode(AppColors.navSelected, BlendMode.srcIn),
|
||||
);
|
||||
final selectedHomeImage = tester.widget<Image>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.byType(Image),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
(selectedHomeImage.image as AssetImage).assetName,
|
||||
'assets/icon/film_reel_filled.png',
|
||||
);
|
||||
expect(
|
||||
Size(selectedHomeImage.width!, selectedHomeImage.height!),
|
||||
const Size.square(AppDimens.navIcon),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -244,7 +191,7 @@ void main() {
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-recommend')),
|
||||
matching: find.byIcon(Icons.smart_display_rounded),
|
||||
matching: find.byIcon(Icons.celebration_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
@@ -275,48 +222,40 @@ void main() {
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.byType(Image),
|
||||
matching: find.byIcon(Icons.home_outlined),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<ColorFiltered>(
|
||||
.widget<Icon>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.byType(ColorFiltered),
|
||||
matching: find.byIcon(Icons.home_outlined),
|
||||
),
|
||||
)
|
||||
.colorFilter,
|
||||
const ColorFilter.mode(AppColors.navUnselected, BlendMode.srcIn),
|
||||
);
|
||||
final unselectedHomeImage = tester.widget<Image>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('tab-home')),
|
||||
matching: find.byType(Image),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
(unselectedHomeImage.image as AssetImage).assetName,
|
||||
'assets/icon/film_reel.png',
|
||||
.color,
|
||||
AppColors.navUnselected,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_map_four_tabs_to_home_recommend_following_and_me', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
// 追剧页头部的双语分段文案在测试字体(Ahem)下比真机字体宽约 98pt,
|
||||
// 这里放宽视口宽度,避免测字体撑破 390 宽度下的分段行。
|
||||
await _pumpApp(tester, size: const Size(520, 844));
|
||||
|
||||
expect(find.byKey(const Key('tab-home')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-recommend')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-follow')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-mine')), findsOneWidget);
|
||||
expect(find.byKey(const Key('tab-create')), findsNothing);
|
||||
expect(find.byKey(const Key('home-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-recommend')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-channel-nav')), findsOneWidget);
|
||||
_expectNoFloatingOverlays();
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-follow')));
|
||||
@@ -356,14 +295,14 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-grid')), findsOneWidget);
|
||||
expect(find.byKey(const Key('recommend-feed-player')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_not_haptic_when_ordinary_list_item_is_opened', (
|
||||
tester,
|
||||
) async {
|
||||
final haptics = FakeHaptics();
|
||||
await _pumpApp(tester, haptics);
|
||||
await _pumpApp(tester, haptics: haptics);
|
||||
await tester.tap(find.byKey(const Key('tab-mine')));
|
||||
await tester.pumpAndSettle();
|
||||
haptics.reset();
|
||||
@@ -377,8 +316,12 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _pumpApp(WidgetTester tester, [FakeHaptics? haptics]) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
Future<void> _pumpApp(
|
||||
WidgetTester tester, {
|
||||
FakeHaptics? haptics,
|
||||
Size size = const Size(390, 844),
|
||||
}) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
Reference in new issue
Block a user