feat(client): C 端 1-2 账号链路(邮箱登录/注册 + 令牌与 401 + 匿名/登录分叉)
为什么:客户端此前完全没有账号概念(mine 页的"登录"只是本地 demo 开关), 而受限动作(收藏/评论)要对到具体账号。本批把账号链路接上,为后续互动、进度同步、下载打底。 - AuthApi + AuthController + AuthSessionStore:注册/登录/登出/刷新,令牌与设备号存 shared_preferences (用 SharedPreferencesAsync,与 engagement 仓库同一套 API) - ApiClient:统一带 Authorization 与 X-Device-Id;401 自动刷新一次并重试,刷新失败清登录态走 onUnauthorized - 登录/注册页(pages/auth,沿用 binding/logic/view 与现有视觉):邮箱格式、密码 8-64 位含字母数字本地先校验, 错误提示走 l10n;登录/注册一键切换 - 匿名/登录分叉:首页、发现、详情保持匿名可看;收藏/点赞等受限动作走 ensureSignedIn() 弹底部提示引导登录 - mine 页展示真实账号(昵称 + uid),拿不到才回落到演示文案 - 测试:新增 auth 控制器(注册落盘/401 刷新重试/刷新失败清会话/登出)与登录页(校验/切换)用例; widget_test 改为预置本地会话(账号不再是本地开关);修掉 playback 用例对 host 大小写的环境依赖断言 门禁:flutter analyze 0 问题;flutter test 148 全过。
This commit is contained in:
1 parent
77d5748dbb
commit
e1b98df509
24 files changed
+2871
-1016
No files matched your search
+143
-184
@@ -6,12 +6,25 @@ import 'package:nontonki/pages/player/player_view.dart';
|
||||
import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
|
||||
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
||||
|
||||
import 'support/fake_catalog.dart';
|
||||
import 'support/widget_player.dart';
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
/// 默认按「已登录」起测:账号体系接上后,"登录"不再是本地演示开关,
|
||||
/// 而是本地会话(这里直接给 shared_preferences 的内存实现塞一份会话)。
|
||||
/// 昵称/uid 与演示文案保持一致,避免为显示细节改写既有断言。
|
||||
void seedSignedInSession() {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.empty();
|
||||
InMemorySharedPreferencesAsync.withData({
|
||||
'auth.accessToken': 'test-access',
|
||||
'auth.refreshToken': 'test-refresh',
|
||||
'auth.user':
|
||||
'{"uid":"M1CZWVYE","nickname":"Vicky sheng","avatarUrl":""}',
|
||||
});
|
||||
}
|
||||
|
||||
setUp(() {
|
||||
seedSignedInSession();
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
@@ -24,9 +37,12 @@ void main() {
|
||||
created.add(episode.id);
|
||||
return WidgetPlayer();
|
||||
},
|
||||
catalogRepository: FakeCatalogRepository(),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(created, hasLength(2));
|
||||
expect(find.byType(CircularProgressIndicator), findsNothing);
|
||||
await tester.drag(find.byType(PageView), const Offset(0, -550));
|
||||
@@ -48,25 +64,25 @@ void main() {
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('The Signal'), findsOneWidget);
|
||||
expect(find.byType(Slider), findsOneWidget);
|
||||
expect(find.text('Home'), findsWidgets);
|
||||
expect(find.text('Recommended'), findsOneWidget);
|
||||
expect(find.textContaining('Playing now'), findsOneWidget);
|
||||
expect(find.text('Recommended'), findsNothing);
|
||||
expect(find.text('Following'), findsNothing);
|
||||
expect(find.byTooltip('Episodes'), findsWidgets);
|
||||
expect(find.byTooltip('Watch in landscape'), findsOneWidget);
|
||||
expect(find.byTooltip('Clear screen'), findsOneWidget);
|
||||
expect(find.byTooltip('Picture in picture'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byTooltip('Explore series'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Watch episode 1'), findsOneWidget);
|
||||
expect(find.text('Episodes'), findsOneWidget);
|
||||
expect(find.text('Watch Full'), findsNothing);
|
||||
expect(find.byTooltip('Explore series'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('landscape control hides tabs and restores them on exit', (
|
||||
testWidgets('clear screen hides tabs and restores them on tap', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
@@ -75,16 +91,19 @@ void main() {
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byTooltip('Watch in landscape'));
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byTooltip('Clear screen'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-tabs-bar')), findsNothing);
|
||||
expect(find.byTooltip('Exit fullscreen'), findsOneWidget);
|
||||
await tester.tap(find.byTooltip('Exit fullscreen'));
|
||||
expect(find.byTooltip('Exit clear screen'), findsOneWidget);
|
||||
await tester.tap(find.byTooltip('Exit clear screen'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget);
|
||||
expect(find.byTooltip('Clear screen'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
@@ -97,17 +116,23 @@ void main() {
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byTooltip('Open quick menu'));
|
||||
expect(find.text('Continue Watching'), findsOneWidget);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.widget<PlayerPage>(find.byType(PlayerPage)).active, isFalse);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerPage>(find.byType(PlayerPage, skipOffstage: false))
|
||||
.active,
|
||||
isFalse,
|
||||
);
|
||||
expect(find.text('Quick access'), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(Drawer),
|
||||
matching: find.text('Same demo clip · free'),
|
||||
matching: find.text('7 EPISODES'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
@@ -118,15 +143,21 @@ void main() {
|
||||
expect(find.text('Watch episode 1'), findsOneWidget);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.widget<PlayerPage>(find.byType(PlayerPage)).active, isTrue);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerPage>(find.byType(PlayerPage, skipOffstage: false))
|
||||
.active,
|
||||
isFalse,
|
||||
);
|
||||
expect(find.text('Continue Watching'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byTooltip('Open quick menu'));
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('drawer-discover')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Trending Micro-Dramas'), findsOneWidget);
|
||||
expect(find.text('Continue Watching'), findsOneWidget);
|
||||
expect(
|
||||
Navigator.of(tester.element(find.text('Trending Micro-Dramas'))).canPop(),
|
||||
Navigator.of(tester.element(find.text('Continue Watching'))).canPop(),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
@@ -140,37 +171,26 @@ void main() {
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byTooltip('Captions'), findsNothing);
|
||||
await tester.tap(find.byTooltip('My'));
|
||||
await tester.tap(find.byKey(const Key('tab-my')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Continue Watching'), findsOneWidget);
|
||||
expect(find.text('History'), findsOneWidget);
|
||||
expect(find.text('Watchlist'), findsOneWidget);
|
||||
await tester.scrollUntilVisible(
|
||||
find.text('App Language'),
|
||||
120,
|
||||
scrollable: find
|
||||
.descendant(
|
||||
of: find.byType(ListView),
|
||||
matching: find.byType(Scrollable),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
expect(find.text('Vicky sheng'), findsOneWidget);
|
||||
expect(find.text('Coins'), findsOneWidget);
|
||||
expect(find.text('PREFERENCES'), findsOneWidget);
|
||||
await tester.tap(find.text('App Language'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('简体中文').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('我的'), findsWidgets);
|
||||
expect(find.text('继续观看'), findsOneWidget);
|
||||
expect(find.text('找剧'), findsOneWidget);
|
||||
await tester.tap(find.text('找剧'));
|
||||
expect(find.text('我的账户'), findsOneWidget);
|
||||
expect(find.text('首页'), findsOneWidget);
|
||||
await tester.tap(find.text('首页'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('热门短剧'), findsOneWidget);
|
||||
expect(find.text('排行榜'), findsOneWidget);
|
||||
expect(find.text('为你推荐'), findsOneWidget);
|
||||
expect(find.text('热门'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('home controls fit a compact Android viewport', (tester) async {
|
||||
@@ -180,16 +200,18 @@ void main() {
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Recommended'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('The Signal'), findsOneWidget);
|
||||
await tester.drag(find.byType(PageView), const Offset(0, -500));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('City Lights & Velvet Nights'), findsOneWidget);
|
||||
await tester.tap(find.byTooltip('Explore series'));
|
||||
await tester.tap(find.byKey(const Key('tab-discover')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Watch episode 1'));
|
||||
await tester.tap(find.text('City Lights & Velvet Nights'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(Slider), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -204,17 +226,18 @@ void main() {
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byTooltip('My'));
|
||||
await tester.tap(find.byKey(const Key('tab-my')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Continue Watching'), findsOneWidget);
|
||||
expect(find.text('History'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.tap(find.text('Home').last);
|
||||
expect(find.text('Vicky sheng'), findsOneWidget);
|
||||
expect(find.text('Coins'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.tap(find.text('Shorts'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Recommended'), findsOneWidget);
|
||||
expect(find.text('The Signal'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
@@ -226,58 +249,53 @@ void main() {
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Discover'));
|
||||
await tester.tap(find.text('Home'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Trending Micro-Dramas'), findsOneWidget);
|
||||
expect(find.text('Filter'), findsOneWidget);
|
||||
expect(find.text('Top Charts'), findsOneWidget);
|
||||
expect(find.text('New Releases'), findsOneWidget);
|
||||
expect(find.text('Watchlist'), findsOneWidget);
|
||||
expect(find.text('Same demo clip · free'), findsNWidgets(3));
|
||||
expect(find.text('Video pending'), findsOneWidget);
|
||||
expect(find.text('For You'), findsOneWidget);
|
||||
expect(find.text('Continue Watching'), findsOneWidget);
|
||||
expect(find.text('Rewards'), findsOneWidget);
|
||||
expect(find.text(r'$ 0'), findsOneWidget);
|
||||
expect(find.text('Urban Romance', skipOffstage: false), findsOneWidget);
|
||||
expect(
|
||||
find.text('Action · Thriller', skipOffstage: false),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byTooltip('Search'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.enterText(find.byType(TextField), 'Vengeance');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Vengeance Rising'), findsOneWidget);
|
||||
expect(find.text('Same demo clip · free'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Watchlist'));
|
||||
await tester.tap(find.byKey(const Key('tab-my-list')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('No shows here yet.'), findsOneWidget);
|
||||
await tester.tap(find.text('Home').last);
|
||||
await tester.tap(find.text('Shorts'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Recommended'), findsOneWidget);
|
||||
expect(find.text('The Signal'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('bottom tabs stay on one route and preserve Discover search', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('bottom tabs stay on one route', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Discover'));
|
||||
await tester.tap(find.text('Home'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(find.byType(TextField), 'Vengeance');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Vengeance Rising'), findsOneWidget);
|
||||
expect(find.text('Continue Watching'), findsOneWidget);
|
||||
expect(find.byTooltip('Search'), findsNothing);
|
||||
expect(
|
||||
Navigator.of(tester.element(find.byType(TextField))).canPop(),
|
||||
Navigator.of(tester.element(find.text('Continue Watching'))).canPop(),
|
||||
isFalse,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-my')));
|
||||
await tester.tap(find.byKey(const Key('tab-my-list')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('History'), findsOneWidget);
|
||||
expect(
|
||||
@@ -290,20 +308,20 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('tab-discover')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.widgetWithText(TextField, 'Vengeance'), findsOneWidget);
|
||||
expect(find.text('Vengeance Rising'), findsOneWidget);
|
||||
expect(find.text('Continue Watching'), findsOneWidget);
|
||||
expect(find.byTooltip('Search'), findsNothing);
|
||||
expect(
|
||||
Navigator.of(tester.element(find.byType(TextField))).canPop(),
|
||||
Navigator.of(tester.element(find.text('Continue Watching'))).canPop(),
|
||||
isFalse,
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('tab-my')));
|
||||
await tester.tap(find.byKey(const Key('tab-my-list')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('No shows here yet.'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Recommended'), findsOneWidget);
|
||||
expect(find.text('The Signal'), findsOneWidget);
|
||||
expect(
|
||||
Navigator.of(tester.element(find.text('Recommended'))).canPop(),
|
||||
Navigator.of(tester.element(find.text('The Signal'))).canPop(),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
@@ -317,9 +335,11 @@ void main() {
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('The Signal'), findsOneWidget);
|
||||
|
||||
await tester.drag(find.byType(PageView), const Offset(0, -550));
|
||||
@@ -327,66 +347,38 @@ void main() {
|
||||
expect(find.text('City Lights & Velvet Nights'), findsOneWidget);
|
||||
expect(find.textContaining('Episode 1'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byTooltip('Explore series'));
|
||||
await tester.tap(find.byKey(const Key('tab-discover')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('City Lights & Velvet Nights'), findsOneWidget);
|
||||
await tester.tap(find.text('Watch episode 1'));
|
||||
await tester.tap(find.text('City Lights & Velvet Nights'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(Slider), findsOneWidget);
|
||||
await tester.drag(find.byType(PageView), const Offset(0, -550));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('EPISODE 2 / 3'), findsOneWidget);
|
||||
expect(find.text('Episode 2 · Playing now'), findsOneWidget);
|
||||
expect(find.text('City Lights & Velvet Nights'), findsWidgets);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('home categories switch by video, top row and tap', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('shorts page has no category navigation', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byIcon(Icons.tune_rounded), findsNothing);
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Following'), findsNothing);
|
||||
expect(find.text('Animated'), findsNothing);
|
||||
expect(find.text('Live Action'), findsNothing);
|
||||
expect(find.text('Recommended'), findsNothing);
|
||||
expect(find.text('The Signal'), findsOneWidget);
|
||||
|
||||
await tester.drag(
|
||||
find.byKey(const Key('home-video-swipe')),
|
||||
const Offset(220, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('City Lights & Velvet Nights'), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-category-liveAction')), findsOneWidget);
|
||||
|
||||
await tester.drag(find.byType(PageView), const Offset(0, -550));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Vengeance Rising'), findsOneWidget);
|
||||
|
||||
await tester.drag(
|
||||
find.byKey(const Key('home-category-swipe')),
|
||||
const Offset(190, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('The Signal'), findsOneWidget);
|
||||
|
||||
await tester.drag(
|
||||
find.byKey(const Key('home-category-swipe')),
|
||||
const Offset(-190, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('City Lights & Velvet Nights'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-category-following')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('No dramas in this category yet.'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('home-category-recommended')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('The Signal'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
testWidgets('right rail saves, comments, likes and invokes share in order', (
|
||||
@@ -412,13 +404,15 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
final keys = [
|
||||
const Key('rail-like'),
|
||||
const Key('rail-save'),
|
||||
const Key('rail-comments'),
|
||||
const Key('rail-like'),
|
||||
const Key('rail-share'),
|
||||
];
|
||||
final tops = keys
|
||||
@@ -426,9 +420,9 @@ void main() {
|
||||
.toList();
|
||||
expect(tops, orderedEquals(tops.toList()..sort()));
|
||||
|
||||
await tester.tap(find.byKey(keys[0]));
|
||||
await tester.tap(find.byKey(const Key('rail-save')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(keys[1]));
|
||||
await tester.tap(find.byKey(const Key('rail-comments')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Only visible on this device'), findsOneWidget);
|
||||
await tester.enterText(find.byKey(const Key('comment-input')), 'Nice demo');
|
||||
@@ -438,75 +432,38 @@ void main() {
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(keys[2]));
|
||||
await tester.tap(find.byKey(keys[3]));
|
||||
await tester.tap(find.byKey(const Key('rail-like')));
|
||||
await tester.tap(find.byKey(const Key('rail-share')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(sharedText, contains('The Signal'));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'right swipe from leftmost category opens drawer and root stays',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
for (var i = 0; i < 3; i++) {
|
||||
await tester.drag(
|
||||
find.byKey(const Key('home-category-swipe')),
|
||||
const Offset(200, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
expect(find.text('No dramas in this category yet.'), findsOneWidget);
|
||||
await tester.drag(
|
||||
find.byKey(const Key('home-empty-swipe')),
|
||||
const Offset(200, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Quick access'), findsOneWidget);
|
||||
await tester.drag(find.byType(Drawer), const Offset(150, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Quick access'), findsOneWidget);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('system back steps categories then opens drawer without exit', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('system back opens the drawer and stays on home', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('City Lights & Velvet Nights'), findsOneWidget);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('The Signal'), findsOneWidget);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('No dramas in this category yet.'), findsOneWidget);
|
||||
expect(find.text('Continue Watching'), findsOneWidget);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Quick access'), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Quick access'), findsNothing);
|
||||
expect(find.text('Continue Watching'), findsOneWidget);
|
||||
expect(
|
||||
Navigator.of(
|
||||
tester.element(find.byKey(const Key('home-tabs-bar'))),
|
||||
).canPop(),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('My watchlist lists saved dramas across the home feed', (
|
||||
@@ -517,9 +474,11 @@ void main() {
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
const LumaDramaApp(playerFactory: createWidgetPlayer),
|
||||
LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-home')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('rail-save')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -527,7 +486,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('rail-save')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('tab-my')));
|
||||
await tester.tap(find.byKey(const Key('tab-my-list')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Watchlist'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
Reference in new issue
Block a user