fix(apps): consolidate FormzInput validators and fix login screen
- Move FormzInput validators to core/form_inputs/form_inputs.dart - Fix login_screen.dart syntax error (missing 'class' keyword) - Remove unused _isLoading field - Fix unnecessary const keywords - Update login_cubit and register_cubit imports - Remove duplicate FormzInput definitions from register_cubit - Add Toast and Banner UI feedback system - Remove legacy login/register screens (login_code, login_email, login_password, register_step2) - Remove unused warning_banner widget - Update tests for new error messages and DI setup
This commit is contained in:
@@ -8,17 +8,12 @@ void main() {
|
||||
final apiException = ApiException.fromDioError(dioException);
|
||||
|
||||
expect(apiException, isA<ApiException>());
|
||||
expect(apiException.message, contains('Request failed'));
|
||||
});
|
||||
|
||||
test('NetworkException has correct message', () {
|
||||
const exception = NetworkException('No internet');
|
||||
expect(exception.message, 'No internet');
|
||||
expect(apiException.message, contains('网络错误'));
|
||||
});
|
||||
|
||||
test('UnauthorizedException has default message', () {
|
||||
const exception = UnauthorizedException();
|
||||
expect(exception.message, 'Authentication required');
|
||||
expect(exception.message, '请重新登录');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,9 +4,13 @@ import 'package:mocktail/mocktail.dart';
|
||||
import 'package:social_app/main.dart';
|
||||
import 'package:social_app/features/auth/presentation/bloc/auth_bloc.dart';
|
||||
import 'package:social_app/features/auth/presentation/bloc/auth_state.dart';
|
||||
import 'package:social_app/features/auth/data/auth_repository.dart';
|
||||
import 'package:social_app/core/di/injection.dart';
|
||||
|
||||
class MockAuthBloc extends Mock implements AuthBloc {}
|
||||
|
||||
class MockAuthRepository extends Mock implements AuthRepository {}
|
||||
|
||||
class FakeAuthState extends Fake implements AuthState {}
|
||||
|
||||
void main() {
|
||||
@@ -14,6 +18,13 @@ void main() {
|
||||
registerFallbackValue(FakeAuthState());
|
||||
});
|
||||
|
||||
setUp(() async {
|
||||
if (sl.isRegistered<AuthRepository>()) {
|
||||
await sl.reset();
|
||||
}
|
||||
sl.registerSingleton<AuthRepository>(MockAuthRepository());
|
||||
});
|
||||
|
||||
testWidgets('Login screen loads correctly', (WidgetTester tester) async {
|
||||
final mockAuthBloc = MockAuthBloc();
|
||||
when(() => mockAuthBloc.state).thenReturn(AuthInitial());
|
||||
@@ -23,7 +34,7 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(LinksyApp(authBloc: mockAuthBloc));
|
||||
expect(find.text('linksy'), findsOneWidget);
|
||||
expect(find.text('继续'), findsOneWidget);
|
||||
expect(find.text('登录'), findsOneWidget);
|
||||
expect(find.text('还没有账号?去注册'), findsOneWidget);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user