为什么:a) 应用对外名称要统一成 FruitShorts(产品名,nontonki 是原型代号); b) 首发市场是印尼,界面必须有印尼语;c) 归档要求"新增 id-ID 与改名合并生成一次 l10n,别分两次"。 改名: - pubspec name: nontonki → fruitshorts(Dart 包名),description 同步;28 个文件的 package: 导入前缀替换 - Android android:label、iOS CFBundleDisplayName/CFBundleName → FruitShorts - 图标资源 assets/icon/nontonki.png → fruitshorts.png(含 pubspec 两处引用) - README 同步(补印尼语说明,顺带修掉写错的模块名 reelshort-app-api → fruitshorts-app-api) 文案: - 三份 arb 的 appName → FruitShorts、brandMark → FRUITSHORTS、shareFooter → FruitShorts(不留 demo 标记) - 新增 lib/l10n/app_id.arb:174 个值键与 en/zh 完全一致,按印尼语习惯翻译(Coin→Koin、Episode→Episode) - 一次性 flutter gen-l10n 生成 app_localizations_id.dart;id 自动进入 supportedLocales,默认 locale 未改 - 新增 test/config/l10n_id_test.dart:钉住 id 文案、supportedLocales 含 id、品牌文案无 demo 标记、占位符渲染 不动:applicationId / bundle id(lumadrama 遗留,等裁定)、目录名、业务逻辑与页面结构、语言选择页(仍只有 en/zh) 门禁:dart analyze lib test 零告警;flutter test 159 全过(基线 155 + 新增 4);残留扫描 0 命中; 三份 arb 键集一致(174/174/174);真机(iPhone iOS 26.6.1)构建安装启动成功,devicectl 列出显示名 FruitShorts
82 lines
3.0 KiB
Dart
82 lines
3.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:provider/provider.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 'package:fruitshorts/core/data/remote/auth_api.dart';
|
|
import 'package:fruitshorts/core/data/remote/api_client.dart';
|
|
import 'package:fruitshorts/core/data/services/auth_controller.dart';
|
|
import 'package:fruitshorts/core/data/services/auth_session_store.dart';
|
|
import 'package:fruitshorts/l10n/app_localizations.dart';
|
|
import 'package:fruitshorts/pages/auth/auth_view.dart';
|
|
|
|
import '../support/fake_http_adapter.dart';
|
|
|
|
/// 登录/注册页的可读证据:校验提示 + 登录/注册切换 + 未登录时不会去发请求。
|
|
void main() {
|
|
setUp(() {
|
|
SharedPreferencesAsyncPlatform.instance =
|
|
InMemorySharedPreferencesAsync.empty();
|
|
});
|
|
|
|
Future<void> pumpAuthPage(WidgetTester tester, {bool signUp = false}) async {
|
|
final auth = AuthController(
|
|
AuthApi(
|
|
// 这个测试不联网:请求一律 500,正好用于验证"本地校验没过就不发请求"
|
|
ApiClient(
|
|
baseUrl: 'http://127.0.0.1:1',
|
|
adapter: FakeHttpAdapter((_) async => FakeHttpResponse('{}', 500)),
|
|
),
|
|
),
|
|
AuthSessionStore(),
|
|
);
|
|
await tester.pumpWidget(
|
|
ChangeNotifierProvider<AuthController>.value(
|
|
value: auth,
|
|
child: MaterialApp(
|
|
locale: const Locale('en'),
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
home: AuthPage(signUpMode: signUp),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
testWidgets('should_show_email_error_and_stay_on_page_when_form_is_empty', (tester) async {
|
|
await pumpAuthPage(tester);
|
|
|
|
expect(find.text('Welcome back'), findsOneWidget);
|
|
|
|
await tester.tap(find.byType(FilledButton));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Enter your email'), findsOneWidget);
|
|
expect(find.text('Welcome back'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('should_reject_weak_password_locally_when_only_letters_are_typed', (tester) async {
|
|
await pumpAuthPage(tester);
|
|
|
|
await tester.enterText(find.byType(TextField).first, 'a@b.com');
|
|
await tester.enterText(find.byType(TextField).last, 'abcdefgh');
|
|
await tester.tap(find.byType(FilledButton));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Password needs both letters and numbers'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('should_flip_between_sign_in_and_sign_up_when_switch_link_is_tapped', (tester) async {
|
|
await pumpAuthPage(tester);
|
|
expect(find.text('Welcome back'), findsOneWidget);
|
|
|
|
await tester.tap(find.text('New here? Create an account'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Create your account'), findsOneWidget);
|
|
expect(find.text('Already have an account? Sign in'), findsOneWidget);
|
|
});
|
|
}
|