diff --git a/lib/common/widgets/fields/date_picker_field.dart b/lib/common/widgets/fields/date_picker_field.dart index 486f4308..1d8a7681 100644 --- a/lib/common/widgets/fields/date_picker_field.dart +++ b/lib/common/widgets/fields/date_picker_field.dart @@ -144,6 +144,7 @@ class DateChip extends StatelessWidget { Widget build(BuildContext context) { ColorScheme colorScheme = Theme.of(context).colorScheme; return CardContainer( + key: const Key("DateChip"), color: colorScheme.primary, margin: const EdgeInsets.all(0), child: Padding( diff --git a/test/common/widgets/fields/date_picker_field_test.dart b/test/common/widgets/fields/date_picker_field_test.dart index cc1a93a7..fbaf5392 100644 --- a/test/common/widgets/fields/date_picker_field_test.dart +++ b/test/common/widgets/fields/date_picker_field_test.dart @@ -17,19 +17,19 @@ void main() { testWidgets('with 1 date', (tester) async { final value = [DateTime(2021, 1, 1)]; await _renderWidget(tester, value: value); - final valueFinder = find.byType(DateChip); + final valueFinder = find.byKey(const Key("DateChip")); expect(valueFinder, findsOneWidget); }); testWidgets('with 2 dates', (tester) async { final value = [DateTime(2021, 1, 1), DateTime(2021, 1, 2)]; await _renderWidget(tester, value: value); - final valueFinder = find.byType(DateChip); + final valueFinder = find.byKey(const Key("DateChip")); expect(valueFinder, findsNWidgets(2)); }); testWidgets('with 10 dates', (tester) async { final value = List.generate(10, (index) => DateTime(2021, 1, 1)); await _renderWidget(tester, value: value); - final valueFinder = find.byType(DateChip); + final valueFinder = find.byKey(const Key("DateChip")); expect(valueFinder, findsNWidgets(10)); }); });