fix: issue-1049, issue-1039, issue-1035, issue-1032, issue-995, issue-993

This commit is contained in:
misha
2026-08-26 08:42:47 +03:00
parent 6265e865e9
commit de7bf8dc19
22 changed files with 509 additions and 192 deletions

View File

@@ -1,7 +1,10 @@
import 'dart:async';
import 'package:eatvio_app/core/app_config.dart';
import 'package:eatvio_app/core/app_initializer.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/loader.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
import 'package:eatvio_app/features/settings/models/profile_settings_model.dart';
@@ -130,5 +133,52 @@ void main() {
expect(find.byType(GeneralInfoScreen), findsOneWidget);
});
testWidgets('лоадер при сохранении появляется вместо кнопки, а не поверх экрана', (tester) async {
final cubit = MockSettingsCubit();
const state = SettingsState.loaded(
profileSettings: mockProfileSettings,
profileDetails: mockProfileDetails,
profile: mockProfile,
hasActiveConsultation: false,
);
final saveCompleter = Completer<void>();
when(cubit.state).thenReturn(state);
when(cubit.stream).thenAnswer((_) => Stream.value(state));
when(cubit.close()).thenAnswer((_) async => Future<void>.value());
when(cubit.updateProfileDetails(profileDetailsModel: anyNamed('profileDetailsModel'))).thenAnswer((_) => saveCompleter.future);
when(cubit.updateProfileSettings(profileSettingsModel: anyNamed('profileSettingsModel'))).thenAnswer((_) async {});
final settingsEntity = SettingsEntity(profileSettingsModel: mockProfileSettings, profileDetailsModel: mockProfileDetails, settingsCubit: cubit);
await tester.pumpWidget(
BlocProvider<SettingsCubit>.value(
value: cubit,
child: wrap(GeneralInfoScreen(settingsEntity: settingsEntity)),
),
);
await tester.pump();
expect(find.text('Сохранить'), findsOneWidget);
expect(find.byType(Loader), findsNothing);
await tester.tap(find.text('Сохранить'));
await tester.pump();
expect(find.text('Сохранить'), findsNothing);
expect(find.byType(Loader), findsOneWidget);
expect(find.text('Введите имя'), findsOneWidget);
final loaderSize = tester.getSize(find.byType(Loader));
expect(loaderSize.height, lessThan(60));
saveCompleter.complete();
await tester.pump();
await tester.pump(const Duration(milliseconds: 50));
expect(find.text('Сохранить'), findsOneWidget);
expect(find.byType(Loader), findsNothing);
});
});
}