From 108ba970f6e95dfe190969fedb081df39eac5579 Mon Sep 17 00:00:00 2001 From: Louis-Philippe Date: Thu, 5 Sep 2024 10:54:52 -0400 Subject: [PATCH] Remove setting flag --- lib/constants/preferences_flags.dart | 2 -- .../more/settings/settings_manager.dart | 8 ------- .../schedule/schedule_settings_viewmodel.dart | 8 ------- .../more/settings/settings_manager_test.dart | 16 +------------ .../schedule_default_test.dart | 4 ++-- .../schedule_settings_viewmodel_test.dart | 24 ------------------- 6 files changed, 3 insertions(+), 59 deletions(-) diff --git a/lib/constants/preferences_flags.dart b/lib/constants/preferences_flags.dart index e8127505b..0f9baa579 100644 --- a/lib/constants/preferences_flags.dart +++ b/lib/constants/preferences_flags.dart @@ -9,8 +9,6 @@ enum PreferencesFlag { // Schedule flags scheduleCalendarFormat, scheduleStartWeekday, - // TODO remove - scheduleOtherWeekday, scheduleShowTodayBtn, scheduleShowWeekEvents, scheduleLaboratoryGroup, diff --git a/lib/features/more/settings/settings_manager.dart b/lib/features/more/settings/settings_manager.dart index 0acb0830a..27e7396d1 100644 --- a/lib/features/more/settings/settings_manager.dart +++ b/lib/features/more/settings/settings_manager.dart @@ -172,14 +172,6 @@ class SettingsManager with ChangeNotifier { settings.putIfAbsent( PreferencesFlag.scheduleStartWeekday, () => startingWeekDay); - final otherWeekDay = await _preferencesService - .getString(PreferencesFlag.scheduleOtherWeekday) - .then((value) => value == null - ? WeekDays.monday - : EnumToString.fromString(WeekDays.values, value)); - settings.putIfAbsent( - PreferencesFlag.scheduleOtherWeekday, () => otherWeekDay); - final showTodayBtn = await _preferencesService .getBool(PreferencesFlag.scheduleShowTodayBtn) ?? true; diff --git a/lib/features/schedule/schedule_settings_viewmodel.dart b/lib/features/schedule/schedule_settings_viewmodel.dart index cd4ffe83d..af0b411f6 100644 --- a/lib/features/schedule/schedule_settings_viewmodel.dart +++ b/lib/features/schedule/schedule_settings_viewmodel.dart @@ -65,14 +65,6 @@ class ScheduleSettingsViewModel WeekDays? get otherDayOfWeek => _otherDayOfWeek; - set otherDayOfWeek(WeekDays? day) { - setBusy(true); - _settingsManager.setString(PreferencesFlag.scheduleOtherWeekday, - EnumToString.convertToString(day)); - _otherDayOfWeek = day; - setBusy(false); - } - /// List of possible days to show in the calendar view List otherDayPossible = [ WeekDays.saturday, diff --git a/test/features/more/settings/settings_manager_test.dart b/test/features/more/settings/settings_manager_test.dart index 727099232..6b3cf7fdb 100644 --- a/test/features/more/settings/settings_manager_test.dart +++ b/test/features/more/settings/settings_manager_test.dart @@ -48,9 +48,6 @@ void main() { PreferencesServiceMock.stubGetString( preferencesServiceMock, PreferencesFlag.scheduleStartWeekday, toReturn: null); - PreferencesServiceMock.stubGetString( - preferencesServiceMock, PreferencesFlag.scheduleOtherWeekday, - toReturn: null); PreferencesServiceMock.stubGetString( preferencesServiceMock, PreferencesFlag.scheduleCalendarFormat, toReturn: null); @@ -67,7 +64,6 @@ void main() { remoteConfigServiceMock); final expected = { - PreferencesFlag.scheduleOtherWeekday: WeekDays.monday, PreferencesFlag.scheduleStartWeekday: StartingDayOfWeek.monday, PreferencesFlag.scheduleCalendarFormat: CalendarFormat.week, PreferencesFlag.scheduleShowTodayBtn: true, @@ -82,9 +78,6 @@ void main() { verify(preferencesServiceMock .getString(PreferencesFlag.scheduleStartWeekday)) .called(1); - verify(preferencesServiceMock - .getString(PreferencesFlag.scheduleOtherWeekday)) - .called(1); verify(preferencesServiceMock .getString(PreferencesFlag.scheduleCalendarFormat)) .called(1); @@ -106,9 +99,6 @@ void main() { PreferencesServiceMock.stubGetString( preferencesServiceMock, PreferencesFlag.scheduleStartWeekday, toReturn: EnumToString.convertToString(StartingDayOfWeek.sunday)); - PreferencesServiceMock.stubGetString( - preferencesServiceMock, PreferencesFlag.scheduleOtherWeekday, - toReturn: EnumToString.convertToString(WeekDays.monday)); PreferencesServiceMock.stubGetString( preferencesServiceMock, PreferencesFlag.scheduleCalendarFormat, toReturn: EnumToString.convertToString(CalendarFormat.month)); @@ -123,7 +113,6 @@ void main() { toReturn: false); final expected = { - PreferencesFlag.scheduleOtherWeekday: WeekDays.monday, PreferencesFlag.scheduleStartWeekday: StartingDayOfWeek.sunday, PreferencesFlag.scheduleCalendarFormat: CalendarFormat.month, PreferencesFlag.scheduleShowTodayBtn: false, @@ -134,10 +123,7 @@ void main() { final result = await manager.getScheduleSettings(); expect(result, expected); - - verify(preferencesServiceMock - .getString(PreferencesFlag.scheduleOtherWeekday)) - .called(1); + verify(preferencesServiceMock .getString(PreferencesFlag.scheduleStartWeekday)) .called(1); diff --git a/test/features/schedule/schedule_defaut/schedule_default_test.dart b/test/features/schedule/schedule_defaut/schedule_default_test.dart index 18571c3d9..50cbbd52a 100644 --- a/test/features/schedule/schedule_defaut/schedule_default_test.dart +++ b/test/features/schedule/schedule_defaut/schedule_default_test.dart @@ -17,7 +17,7 @@ void main() { testWidgets('Displays no schedule message when there are no events', (WidgetTester tester) async { await tester.pumpWidget(localizedWidget( - child: const ScheduleDefault(calendarEvents: [], loaded: true))); + child: const ScheduleDefault(calendarEvents: [], loaded: true, displaySaturday: true))); await tester.pumpAndSettle(); expect(find.text(intl.no_schedule_available), findsOneWidget); }); @@ -25,7 +25,7 @@ void main() { testWidgets('Displays no empty schedule message when loading', (WidgetTester tester) async { await tester.pumpWidget(localizedWidget( - child: const ScheduleDefault(calendarEvents: [], loaded: false))); + child: const ScheduleDefault(calendarEvents: [], loaded: false, displaySaturday: true))); await tester.pumpAndSettle(); expect(find.text(intl.no_schedule_available), findsNothing); }); diff --git a/test/features/schedule/schedule_settings_viewmodel_test.dart b/test/features/schedule/schedule_settings_viewmodel_test.dart index ffea3b7b6..6277eec5d 100644 --- a/test/features/schedule/schedule_settings_viewmodel_test.dart +++ b/test/features/schedule/schedule_settings_viewmodel_test.dart @@ -283,30 +283,6 @@ void main() { }); }); - group("setter scheduleShowWeekendDays - ", () { - test("scheduleShowWeekendDays is updated on the settings", () async { - SettingsManagerMock.stubSetString( - settingsManagerMock, PreferencesFlag.scheduleShowWeekendDays); - - const expected = true; - - // Call the setter. - - viewModel.showWeekendDays = expected; - - await untilCalled(settingsManagerMock.setBool( - PreferencesFlag.scheduleShowWeekendDays, any)); - - expect(viewModel.showWeekendDays, true); - expect(viewModel.isBusy, false); - - verify(settingsManagerMock.setBool( - PreferencesFlag.scheduleShowWeekendDays, any)) - .called(1); - verifyNoMoreInteractions(settingsManagerMock); - }); - }); - group("setter startingDayOfWeek - ", () { test("startingDayOfWeek is updated on the settings", () async { SettingsManagerMock.stubSetString(