fix: tests fix

This commit is contained in:
misha
2026-11-18 16:55:36 +03:00
parent b05d3b891b
commit ce073b5a95
8 changed files with 64 additions and 43 deletions

View File

@@ -86,6 +86,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
await tester.pumpAndSettle();
@@ -108,6 +109,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
await tester.pumpAndSettle();
@@ -131,6 +133,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
await tester.pumpAndSettle();
@@ -153,6 +156,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
await tester.pumpAndSettle();
@@ -175,6 +179,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
await tester.pumpAndSettle();
@@ -196,6 +201,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
await tester.pumpAndSettle();
@@ -217,6 +223,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
await tester.pumpAndSettle();
@@ -237,6 +244,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
await tester.pumpAndSettle();
@@ -257,6 +265,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
await tester.pumpAndSettle();

View File

@@ -18,6 +18,11 @@ Widget _wrap(Widget child) {
);
}
Future<void> _pump(WidgetTester tester, Widget child) async {
await tester.pumpWidget(_wrap(child));
await tester.pump();
}
void main() {
group('ChatConsultationHeader', () {
testWidgets('вызывает onInfoTap по тапу на info', (tester) async {
@@ -27,13 +32,12 @@ void main() {
hasPersonalDiet: false,
);
await tester.pumpWidget(
_wrap(
ChatConsultationHeader(
progress: progress,
showInfoButton: true,
onInfoTap: () => tapped++,
),
await _pump(
tester,
ChatConsultationHeader(
progress: progress,
showInfoButton: true,
onInfoTap: () => tapped++,
),
);
@@ -54,13 +58,12 @@ void main() {
expect(progress.showProgressPlank, isTrue);
expect(progress.dietStatus, PersonalDietStatus.proposed);
await tester.pumpWidget(
_wrap(
ChatConsultationHeader(
progress: progress,
showInfoButton: false,
onInfoTap: () {},
),
await _pump(
tester,
ChatConsultationHeader(
progress: progress,
showInfoButton: false,
onInfoTap: () {},
),
);

View File

@@ -15,6 +15,11 @@ Widget _wrap(Widget child) {
);
}
Future<void> _pump(WidgetTester tester, Widget child) async {
await tester.pumpWidget(_wrap(child));
await tester.pump();
}
void main() {
group('ConsultationProgressPlank', () {
testWidgets('не строит шаги при showProgressPlank=false', (tester) async {
@@ -24,9 +29,7 @@ void main() {
);
expect(progress.showProgressPlank, isFalse);
await tester.pumpWidget(
_wrap(ConsultationProgressPlank(progress: progress)),
);
await _pump(tester, ConsultationProgressPlank(progress: progress));
expect(
find.descendant(
@@ -48,9 +51,7 @@ void main() {
);
expect(progress.showProgressPlank, isTrue);
await tester.pumpWidget(
_wrap(ConsultationProgressPlank(progress: progress)),
);
await _pump(tester, ConsultationProgressPlank(progress: progress));
final s = S.of(tester.element(find.byType(ConsultationProgressPlank)));
@@ -70,12 +71,11 @@ void main() {
hasPersonalDiet: false,
);
await tester.pumpWidget(
_wrap(
SizedBox(
width: 360,
child: ConsultationProgressPlank(progress: progress),
),
await _pump(
tester,
SizedBox(
width: 360,
child: ConsultationProgressPlank(progress: progress),
),
);

View File

@@ -15,6 +15,11 @@ Widget _wrap(Widget child) {
);
}
Future<void> _pump(WidgetTester tester, Widget child) async {
await tester.pumpWidget(_wrap(child));
await tester.pump();
}
Widget _chip(
ChosenPlanStateEnum state, {
bool hasPersonalDiet = true,
@@ -32,9 +37,7 @@ Widget _chip(
void main() {
group('PersonalDietStatusChip', () {
testWidgets('notRequired + active ничего не показывает', (tester) async {
await tester.pumpWidget(
_wrap(_chip(ChosenPlanStateEnum.stateInited, hasPersonalDiet: false)),
);
await _pump(tester, _chip(ChosenPlanStateEnum.stateInited, hasPersonalDiet: false));
expect(
find.descendant(
@@ -47,7 +50,7 @@ void main() {
});
testWidgets('proposed показывает personal_diet_proposed', (tester) async {
await tester.pumpWidget(_wrap(_chip(ChosenPlanStateEnum.stateStarted)));
await _pump(tester, _chip(ChosenPlanStateEnum.stateStarted));
final s = S.of(tester.element(find.byType(PersonalDietStatusChip)));
@@ -55,12 +58,11 @@ void main() {
});
testWidgets('proposed с названием показывает имя диеты', (tester) async {
await tester.pumpWidget(
_wrap(
_chip(
ChosenPlanStateEnum.stateStarted,
personalDietName: 'Индивидуальный план питания',
),
await _pump(
tester,
_chip(
ChosenPlanStateEnum.stateStarted,
personalDietName: 'Индивидуальный план питания',
),
);
@@ -75,7 +77,7 @@ void main() {
testWidgets('notProposed показывает personal_diet_not_proposed', (
tester,
) async {
await tester.pumpWidget(_wrap(_chip(ChosenPlanStateEnum.statePaid)));
await _pump(tester, _chip(ChosenPlanStateEnum.statePaid));
final s = S.of(tester.element(find.byType(PersonalDietStatusChip)));
@@ -83,9 +85,7 @@ void main() {
});
testWidgets('canceled показывает orderCanceled', (tester) async {
await tester.pumpWidget(
_wrap(_chip(ChosenPlanStateEnum.stateCanceledByTheInitiator)),
);
await _pump(tester, _chip(ChosenPlanStateEnum.stateCanceledByTheInitiator));
final s = S.of(tester.element(find.byType(PersonalDietStatusChip)));
@@ -93,9 +93,7 @@ void main() {
});
testWidgets('paymentFailed показывает payment_failed', (tester) async {
await tester.pumpWidget(
_wrap(_chip(ChosenPlanStateEnum.statePaymentFailed)),
);
await _pump(tester, _chip(ChosenPlanStateEnum.statePaymentFailed));
final s = S.of(tester.element(find.byType(PersonalDietStatusChip)));

View File

@@ -34,6 +34,7 @@ void main() {
testWidgets('показывает заголовок Есть промокод? и кнопки Применить/Пропустить', (tester) async {
await tester.pumpWidget(createTestWidget());
await tester.pump();
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
@@ -44,6 +45,7 @@ void main() {
testWidgets('Применить с пустым полем показывает ошибку и не закрывает', (tester) async {
await tester.pumpWidget(createTestWidget());
await tester.pump();
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
@@ -64,6 +66,7 @@ void main() {
},
),
);
await tester.pump();
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
@@ -78,6 +81,7 @@ void main() {
testWidgets('Пропустить закрывает шторку', (tester) async {
await tester.pumpWidget(createTestWidget());
await tester.pump();
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
@@ -101,6 +105,7 @@ void main() {
onRemove: () async => true,
),
);
await tester.pump();
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
@@ -128,6 +133,7 @@ void main() {
},
),
);
await tester.pump();
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
@@ -156,6 +162,7 @@ void main() {
},
),
);
await tester.pump();
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();

View File

@@ -98,6 +98,7 @@ void main() {
await tester.pumpWidget(createTestWidget(planId: planId));
await tester.pump();
await tester.pump();
expect(find.byType(Loader), findsOneWidget);
expect(find.text('Сбербанк'), findsNothing);

View File

@@ -106,6 +106,7 @@ void main() {
Future<void> openSheet(WidgetTester tester, {double? amount}) async {
await pumpApp(tester, amount: amount);
await tester.pump();
await tester.tap(find.text('open'));
await tester.pump();
await tester.pump();

View File

@@ -19,6 +19,7 @@ void main() {
testWidgets('VideoCallParticipantNameLabel renders consultant role above name', (tester) async {
await tester.pumpWidget(
MaterialApp(
locale: const Locale('en'),
localizationsDelegates: const [S.delegate, ...GlobalMaterialLocalizations.delegates],
supportedLocales: S.delegate.supportedLocales,
home: const Scaffold(
@@ -26,6 +27,7 @@ void main() {
),
),
);
await tester.pump();
expect(find.text('Alex'), findsOneWidget);
expect(find.text('Eatvio consultant'), findsOneWidget);