Skip to content

Commit 721057f

Browse files
committed
✅ Se actualizo el test para imagenes webp y ya no svg
1 parent d2b08e0 commit 721057f

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

test/features/login/views/login_view_test.dart

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ class MockAuthRepository extends Mock implements AuthRepository {
2727
}
2828

2929
class TestAssetBundle extends CachingAssetBundle {
30-
final String _svgDummy = '''
31-
<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
32-
<rect width="10" height="10" fill="transparent"/>
33-
</svg>
34-
''';
30+
// 1x1 Pixel transparente en formato PNG (Base64)
31+
// Esto evita que Image.asset falle al intentar decodificar bytes inválidos
32+
final String _base64Png =
33+
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
3534

3635
@override
3736
Future<String> loadString(String key, {bool cache = true}) async {
38-
return _svgDummy;
37+
return 'Simulated String Content';
3938
}
4039

4140
@override
4241
Future<ByteData> load(String key) async {
43-
final Uint8List bytes = utf8.encode(_svgDummy);
42+
// Decodificamos el PNG real para que el motor gráfico de Flutter no falle
43+
final Uint8List bytes = base64Decode(_base64Png);
4444
return ByteData.view(bytes.buffer);
4545
}
4646
}
@@ -90,7 +90,7 @@ void main() {
9090
}
9191

9292
testWidgets('Renderizado Inicial: Debe mostrar campos y botón', (tester) async {
93-
setScreenSize(tester); // 1. Ajustar pantalla
93+
setScreenSize(tester);
9494

9595
await tester.pumpWidget(createTestWidget());
9696
await tester.pumpAndSettle();
@@ -99,12 +99,11 @@ void main() {
9999
expect(find.byKey(const Key('login_email_input')), findsOneWidget);
100100
expect(find.byKey(const Key('login_password_input')), findsOneWidget);
101101

102-
// Al ser la pantalla alta, el botón debería ser visible sin scroll
103102
expect(find.byKey(const Key('login_button')), findsOneWidget);
104103
});
105104

106105
testWidgets('Login Exitoso: Debe navegar a /home', (tester) async {
107-
setScreenSize(tester); // 1. Ajustar pantalla
106+
setScreenSize(tester);
108107

109108
await tester.pumpWidget(createTestWidget());
110109
await tester.pumpAndSettle();
@@ -113,12 +112,11 @@ void main() {
113112
await tester.enterText(find.byKey(const Key('login_email_input')), 'profe@ipn.mx');
114113
await tester.enterText(find.byKey(const Key('login_password_input')), '123');
115114

116-
// 3. Cerrar teclado virtual (buena práctica)
115+
// 3. Cerrar teclado virtual
117116
await tester.testTextInput.receiveAction(TextInputAction.done);
118117
await tester.pump();
119118

120-
// 4. Presionar botón (Como la pantalla es alta, ya no necesitamos ensureVisible obligatoriamente,
121-
// pero lo dejamos por seguridad si el teclado estorba)
119+
// 4. Presionar botón
122120
final loginBtn = find.byKey(const Key('login_button'));
123121
await tester.ensureVisible(loginBtn);
124122
await tester.tap(loginBtn);
@@ -130,7 +128,7 @@ void main() {
130128
});
131129

132130
testWidgets('Login Fallido: Debe mostrar SnackBar con error', (tester) async {
133-
setScreenSize(tester); // 1. Ajustar pantalla
131+
setScreenSize(tester);
134132

135133
await tester.pumpWidget(createTestWidget());
136134
await tester.pumpAndSettle();

0 commit comments

Comments
 (0)