diff --git a/lib/components/organisms/pill_sheet/setting_pill_sheet_view.dart b/lib/components/organisms/pill_sheet/setting_pill_sheet_view.dart index 049ba4af90..e4d4fa6888 100644 --- a/lib/components/organisms/pill_sheet/setting_pill_sheet_view.dart +++ b/lib/components/organisms/pill_sheet/setting_pill_sheet_view.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:pilll/entity/pill_sheet_group.codegen.dart'; import 'package:pilll/utils/analytics.dart'; import 'package:pilll/components/atoms/color.dart'; import 'package:pilll/components/organisms/pill_mark/pill_mark.dart'; @@ -7,7 +8,6 @@ import 'package:pilll/components/organisms/pill_mark/pill_mark_with_number_layou import 'package:pilll/components/organisms/pill_sheet/pill_sheet_view_layout.dart'; import 'package:pilll/entity/pill_mark_type.dart'; import 'package:pilll/entity/pill_sheet_type.dart'; -import 'package:pilll/entity/setting.codegen.dart'; import 'package:pilll/entity/weekday.dart'; class SettingPillSheetView extends StatelessWidget { diff --git a/lib/components/template/setting_menstruation/setting_menstruation_pill_sheet_list.dart b/lib/components/template/setting_menstruation/setting_menstruation_pill_sheet_list.dart index d46c84fbdb..c03ad237e5 100644 --- a/lib/components/template/setting_menstruation/setting_menstruation_pill_sheet_list.dart +++ b/lib/components/template/setting_menstruation/setting_menstruation_pill_sheet_list.dart @@ -4,8 +4,8 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:pilll/components/molecules/dots_page_indicator.dart'; import 'package:pilll/components/organisms/pill_sheet/pill_sheet_view_layout.dart'; import 'package:pilll/components/organisms/pill_sheet/setting_pill_sheet_view.dart'; +import 'package:pilll/entity/pill_sheet_group.codegen.dart'; import 'package:pilll/entity/pill_sheet_type.dart'; -import 'package:pilll/entity/setting.codegen.dart'; class SettingMenstruationPillSheetList extends HookConsumerWidget { final List pillSheetTypes; diff --git a/lib/entity/pill_sheet_group.codegen.dart b/lib/entity/pill_sheet_group.codegen.dart index 189bdbb1c1..7ee1f5d635 100644 --- a/lib/entity/pill_sheet_group.codegen.dart +++ b/lib/entity/pill_sheet_group.codegen.dart @@ -77,7 +77,7 @@ class PillSheetGroup with _$PillSheetGroup { case PillSheetAppearanceMode.date: return 0; case PillSheetAppearanceMode.sequential: - return pillNumbersForSequential.firstWhereOrNull((element) => isSameDay(element.date, today()))?.number ?? 0; + return pillNumbersForCyclicSequential.firstWhereOrNull((element) => isSameDay(element.date, today()))?.number ?? 0; case PillSheetAppearanceMode.cyclicSequential: return pillNumbersForCyclicSequential.firstWhereOrNull((element) => isSameDay(element.date, today()))?.number ?? 0; } @@ -94,7 +94,7 @@ class PillSheetGroup with _$PillSheetGroup { case PillSheetAppearanceMode.date: return 0; case PillSheetAppearanceMode.sequential: - return pillNumbersForSequential.firstWhereOrNull((element) => isSameDay(element.date, activePillSheetLastTakenDate))?.number ?? 0; + return pillNumbersForCyclicSequential.firstWhereOrNull((element) => isSameDay(element.date, activePillSheetLastTakenDate))?.number ?? 0; case PillSheetAppearanceMode.cyclicSequential: return pillNumbersForCyclicSequential.firstWhereOrNull((element) => isSameDay(element.date, activePillSheetLastTakenDate))?.number ?? 0; } @@ -106,7 +106,7 @@ class PillSheetGroup with _$PillSheetGroup { case PillSheetAppearanceMode.date: return 0; case PillSheetAppearanceMode.sequential: - return pillNumbersForSequential.last.number; + return pillNumbersForCyclicSequential.last.number; case PillSheetAppearanceMode.cyclicSequential: return pillNumbersForCyclicSequential.last.number; } @@ -132,7 +132,6 @@ class PillSheetGroup with _$PillSheetGroup { case PillSheetAppearanceMode.date: return _pillNumberInPillSheet(pillNumberInPillSheet: lastTakenPillNumber); case PillSheetAppearanceMode.sequential: - return _sequentialPillSheetNumber(pageIndex: pillSheet.groupIndex, pillNumberInPillSheet: lastTakenPillNumber); case PillSheetAppearanceMode.cyclicSequential: return _cycleSequentialPillSheetNumber(pageIndex: pillSheet.groupIndex, pillNumberInPillSheet: lastTakenPillNumber); } @@ -151,7 +150,6 @@ class PillSheetGroup with _$PillSheetGroup { } late final List pillNumbersInPillSheet = _pillNumbersInPillSheet(); - late final List pillNumbersForSequential = _pillNumbersForSequential(); late final List pillNumbersForCyclicSequential = _pillNumbersForCyclicSequential(); } @@ -174,7 +172,6 @@ extension PillSheetGroupDisplayDomain on PillSheetGroup { case PillSheetAppearanceMode.date: return _pillNumberInPillSheet(pillNumberInPillSheet: pillNumberInPillSheet); case PillSheetAppearanceMode.sequential: - return _sequentialPillSheetNumber(pageIndex: pageIndex, pillNumberInPillSheet: pillNumberInPillSheet); case PillSheetAppearanceMode.cyclicSequential: return _cycleSequentialPillSheetNumber(pageIndex: pageIndex, pillNumberInPillSheet: pillNumberInPillSheet); } @@ -191,7 +188,6 @@ extension PillSheetGroupDisplayDomain on PillSheetGroup { case PillSheetAppearanceMode.date: return pillNumbersInPillSheet.firstWhere((e) => isSameDay(e.date, date)).number; case PillSheetAppearanceMode.sequential: - return pillNumbersForSequential.firstWhere((e) => isSameDay(e.date, date)).number; case PillSheetAppearanceMode.cyclicSequential: return pillNumbersForCyclicSequential.firstWhere((e) => isSameDay(e.date, date)).number; } @@ -219,7 +215,7 @@ extension PillSheetGroupDisplayDomain on PillSheetGroup { PillSheetAppearanceMode.date => premiumOrTrial ? _displayPillSheetDate(pageIndex: pageIndex, pillNumberInPillSheet: pillNumberInPillSheet) : _pillNumberInPillSheet(pillNumberInPillSheet: pillNumberInPillSheet), - PillSheetAppearanceMode.sequential => _sequentialPillSheetNumber(pageIndex: pageIndex, pillNumberInPillSheet: pillNumberInPillSheet), + PillSheetAppearanceMode.sequential => _cycleSequentialPillSheetNumber(pageIndex: pageIndex, pillNumberInPillSheet: pillNumberInPillSheet), PillSheetAppearanceMode.cyclicSequential => _cycleSequentialPillSheetNumber(pageIndex: pageIndex, pillNumberInPillSheet: pillNumberInPillSheet), }; return pillNumber.toString(); @@ -246,21 +242,6 @@ extension PillSheetGroupDisplayDomain on PillSheetGroup { return DateTimeFormatter.monthAndDay(pillSheets[pageIndex].displayPillTakeDate(pillNumberInPillSheet)); } - @visibleForTesting - int sequentialPillSheetNumber({ - required int pageIndex, - required int pillNumberInPillSheet, - }) { - return _sequentialPillSheetNumber(pageIndex: pageIndex, pillNumberInPillSheet: pillNumberInPillSheet); - } - - int _sequentialPillSheetNumber({ - required int pageIndex, - required int pillNumberInPillSheet, - }) { - return pillNumbersForSequential.where((e) => e.pillSheet.groupIndex == pageIndex).toList()[pillNumberInPillSheet - 1].number; - } - @visibleForTesting int cycleSequentialPillSheetNumber({ required int pageIndex, @@ -301,7 +282,6 @@ extension PillSheetGroupPillNumberDomain on PillSheetGroup { case PillSheetAppearanceMode.date: return pillNumbersInPillSheet; case PillSheetAppearanceMode.sequential: - return pillNumbersForSequential; case PillSheetAppearanceMode.cyclicSequential: return pillNumbersForCyclicSequential; } @@ -532,3 +512,29 @@ class PillSheetGroupDisplayNumberSetting with _$PillSheetGroupDisplayNumberSetti factory PillSheetGroupDisplayNumberSetting.fromJson(Map json) => _$PillSheetGroupDisplayNumberSettingFromJson(json); } + +@JsonEnum(valueField: 'value') +enum PillSheetAppearanceMode { + @JsonValue('number') + number, + @JsonValue('date') + date, + // 古い値。cyclicSequentialに変更した。一時的に両立されていた + @JsonValue('sequential') + sequential, + @JsonValue('cyclicSequential') + cyclicSequential, +} + +extension PillSheetAppearanceModeExt on PillSheetAppearanceMode { + bool get isSequential { + switch (this) { + case PillSheetAppearanceMode.number: + case PillSheetAppearanceMode.date: + return false; + case PillSheetAppearanceMode.sequential: + case PillSheetAppearanceMode.cyclicSequential: + return true; + } + } +} diff --git a/lib/entity/setting.codegen.dart b/lib/entity/setting.codegen.dart index d7319d36fb..d7dce2e7f7 100644 --- a/lib/entity/setting.codegen.dart +++ b/lib/entity/setting.codegen.dart @@ -1,3 +1,4 @@ +import 'package:pilll/entity/pill_sheet_group.codegen.dart'; import 'package:pilll/entity/pill_sheet_type.dart'; import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; @@ -26,30 +27,6 @@ class ReminderTime with _$ReminderTime { static const int minimumCount = 1; } -enum PillSheetAppearanceMode { - @JsonValue('number') - number, - @JsonValue('date') - date, - @JsonValue('sequential') - sequential, - @JsonValue('cyclicSequential') - cyclicSequential, -} - -extension PillSheetAppearanceModeExt on PillSheetAppearanceMode { - bool get isSequential { - switch (this) { - case PillSheetAppearanceMode.number: - case PillSheetAppearanceMode.date: - return false; - case PillSheetAppearanceMode.sequential: - case PillSheetAppearanceMode.cyclicSequential: - return true; - } - } -} - class SettingFirestoreFieldKeys { static const pillSheetAppearanceMode = 'pillSheetAppearanceMode'; static const timezoneDatabaseName = 'timezoneDatabaseName'; diff --git a/lib/features/initial_setting/initial_setting_state.codegen.dart b/lib/features/initial_setting/initial_setting_state.codegen.dart index 9a868a31b8..053a946a99 100644 --- a/lib/features/initial_setting/initial_setting_state.codegen.dart +++ b/lib/features/initial_setting/initial_setting_state.codegen.dart @@ -3,6 +3,7 @@ import 'dart:math'; import 'package:flutter_native_timezone/flutter_native_timezone.dart'; import 'package:pilll/entity/firestore_id_generator.dart'; import 'package:pilll/entity/link_account_type.dart'; +import 'package:pilll/entity/pill_sheet_group.codegen.dart'; import 'package:pilll/utils/datetime/date_add.dart'; import 'package:pilll/utils/datetime/day.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/lib/features/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart b/lib/features/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart index 6b63e1eed0..a35bf68a09 100644 --- a/lib/features/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart +++ b/lib/features/initial_setting/today_pill_number/select_today_pill_number_pill_sheet_list.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:pilll/entity/pill_sheet_group.codegen.dart'; import 'package:pilll/utils/analytics.dart'; import 'package:pilll/components/molecules/dots_page_indicator.dart'; import 'package:pilll/components/organisms/pill_sheet/pill_sheet_view_layout.dart'; @@ -8,7 +9,6 @@ import 'package:pilll/components/organisms/pill_sheet/setting_pill_sheet_view.da import 'package:pilll/features/initial_setting/initial_setting_state.codegen.dart'; import 'package:pilll/features/initial_setting/initial_setting_state_notifier.dart'; import 'package:pilll/entity/pill_sheet_type.dart'; -import 'package:pilll/entity/setting.codegen.dart'; class SelectTodayPillNumberPillSheetList extends HookConsumerWidget { final InitialSettingState state; diff --git a/lib/features/record/components/add_pill_sheet_group/display_number_setting.dart b/lib/features/record/components/add_pill_sheet_group/display_number_setting.dart index 3b2af2196f..c37ac647e0 100644 --- a/lib/features/record/components/add_pill_sheet_group/display_number_setting.dart +++ b/lib/features/record/components/add_pill_sheet_group/display_number_setting.dart @@ -8,7 +8,6 @@ import 'package:pilll/components/atoms/color.dart'; import 'package:pilll/components/atoms/font.dart'; import 'package:pilll/components/atoms/text_color.dart'; import 'package:pilll/entity/pill_sheet_group.codegen.dart'; -import 'package:pilll/entity/setting.codegen.dart'; import 'package:pilll/utils/formatter/text_input_formatter.dart'; class DisplayNumberSetting extends HookConsumerWidget { diff --git a/lib/features/record/components/header/today_taken_pill_number.dart b/lib/features/record/components/header/today_taken_pill_number.dart index 76b0454fa5..d058fa0429 100644 --- a/lib/features/record/components/header/today_taken_pill_number.dart +++ b/lib/features/record/components/header/today_taken_pill_number.dart @@ -6,7 +6,6 @@ import 'package:pilll/components/atoms/text_color.dart'; import 'package:pilll/entity/pill_sheet_group.codegen.dart'; import 'package:pilll/entity/pill_sheet_type.dart'; import 'package:flutter/material.dart'; -import 'package:pilll/entity/setting.codegen.dart'; class TodayTakenPillNumber extends StatelessWidget { final PillSheetGroup? pillSheetGroup; diff --git a/lib/features/record/components/pill_sheet/components/record_page_rest_duration_dialog.dart b/lib/features/record/components/pill_sheet/components/record_page_rest_duration_dialog.dart index 56eedceb69..1c6c21e776 100644 --- a/lib/features/record/components/pill_sheet/components/record_page_rest_duration_dialog.dart +++ b/lib/features/record/components/pill_sheet/components/record_page_rest_duration_dialog.dart @@ -4,7 +4,6 @@ import 'package:pilll/components/atoms/button.dart'; import 'package:pilll/components/atoms/font.dart'; import 'package:pilll/components/atoms/text_color.dart'; import 'package:pilll/entity/pill_sheet_group.codegen.dart'; -import 'package:pilll/entity/setting.codegen.dart'; import 'package:pilll/features/localizations/l.dart'; import 'package:pilll/utils/formatter/date_time_formatter.dart'; @@ -121,7 +120,6 @@ class RecordPageRestDurationDialogTitle extends StatelessWidget { final dateString = DateTimeFormatter.monthAndDay(date); return dateString; case PillSheetAppearanceMode.sequential: - return L.withNumber((pillSheetGroup.sequentialLastTakenPillNumber + 1).toString()); case PillSheetAppearanceMode.cyclicSequential: return L.withNumber((pillSheetGroup.sequentialLastTakenPillNumber + 1).toString()); } diff --git a/lib/features/record/components/setting/components/appearance_mode/select_appearance_mode_modal.dart b/lib/features/record/components/setting/components/appearance_mode/select_appearance_mode_modal.dart index 36d7e9b649..124b4c177f 100644 --- a/lib/features/record/components/setting/components/appearance_mode/select_appearance_mode_modal.dart +++ b/lib/features/record/components/setting/components/appearance_mode/select_appearance_mode_modal.dart @@ -74,18 +74,6 @@ class SelectAppearanceModeModal extends HookConsumerWidget { text: L.pillNumber, isPremiumFunction: false, ), - _row( - context, - setting: setting, - pillSheetGroup: pillSheetGroup, - setSetting: setSetting, - setPillSheetGroup: setPillSheetGroup, - registerReminderLocalNotification: registerReminderLocalNotification, - user: user, - mode: PillSheetAppearanceMode.sequential, - text: L.pillDays, - isPremiumFunction: false, - ), _row( context, setting: setting, diff --git a/lib/features/record/components/setting/components/rest_duration/begin_manual_rest_duration.dart b/lib/features/record/components/setting/components/rest_duration/begin_manual_rest_duration.dart index ab28313bba..40653e380b 100644 --- a/lib/features/record/components/setting/components/rest_duration/begin_manual_rest_duration.dart +++ b/lib/features/record/components/setting/components/rest_duration/begin_manual_rest_duration.dart @@ -3,7 +3,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:flutter/material.dart'; import 'package:pilll/entity/pill_sheet.codegen.dart'; import 'package:pilll/entity/pill_sheet_group.codegen.dart'; -import 'package:pilll/entity/setting.codegen.dart'; import 'package:pilll/features/localizations/l.dart'; import 'package:pilll/features/record/components/pill_sheet/components/record_page_rest_duration_dialog.dart'; import 'package:pilll/features/record/components/setting/components/rest_duration/invalid_already_taken_pill_dialog.dart'; diff --git a/lib/features/release_note/release_note.dart b/lib/features/release_note/release_note.dart index b3999f90fa..efc013a37c 100644 --- a/lib/features/release_note/release_note.dart +++ b/lib/features/release_note/release_note.dart @@ -42,9 +42,12 @@ class ReleaseNote extends StatelessWidget { alignment: Alignment.center, child: Container( padding: const EdgeInsets.only(top: 40, left: 40, right: 40), - child: Text( - L.addedDisplayModePillDaysCycle, - style: const TextStyle( + child: const Text( + '', + // (周期)を消すことになったので無効化。リリースノート自体も無効化する + // "addedDisplayModePillDaysCycle": "表示モード服用日数(周期)が追加されました", + // L.addedDisplayModePillDaysCycle, + style: TextStyle( fontFamily: FontFamily.japanese, fontWeight: FontWeight.w600, fontSize: 16, @@ -102,15 +105,18 @@ void showReleaseNotePreDialog(BuildContext context) async { if (storage.getBool(key) ?? false) { return; } + await storage.setBool(key, true); + // NOTE: (周期)のリリース後に、(周期)を消すことにした。リリースノートに現在記載されている。そのため一旦リリースノート自体を無効 + return; - if (context.mounted) { - showDialog( - context: context, - builder: (context) { - return const ReleaseNote(); - }); - } + // if (context.mounted) { + // showDialog( + // context: context, + // builder: (context) { + // return const ReleaseNote(); + // }); + // } } void openReleaseNote() async { diff --git a/lib/features/settings/menstruation/setting_menstruation_page.dart b/lib/features/settings/menstruation/setting_menstruation_page.dart index 6b1813f3de..f28a5df340 100644 --- a/lib/features/settings/menstruation/setting_menstruation_page.dart +++ b/lib/features/settings/menstruation/setting_menstruation_page.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:pilll/entity/pill_sheet_group.codegen.dart'; import 'package:pilll/features/localizations/l.dart'; import 'package:pilll/utils/analytics.dart'; import 'package:pilll/components/template/setting_menstruation/setting_menstruation_dynamic_description.dart'; import 'package:pilll/components/template/setting_menstruation/setting_menstruation_page_template.dart'; import 'package:pilll/components/template/setting_menstruation/setting_menstruation_pill_sheet_list.dart'; import 'package:pilll/entity/pill_sheet_type.dart'; -import 'package:pilll/entity/setting.codegen.dart'; import 'package:pilll/provider/setting.dart'; class SettingMenstruationPage extends HookConsumerWidget { @@ -21,7 +21,7 @@ class SettingMenstruationPage extends HookConsumerWidget { title: L.aboutMenstruation, pillSheetList: SettingMenstruationPillSheetList( pillSheetTypes: setting.pillSheetEnumTypes, - appearanceMode: PillSheetAppearanceMode.sequential, + appearanceMode: PillSheetAppearanceMode.cyclicSequential, selectedPillNumber: (pageIndex) { final passedTotalCount = summarizedPillCountWithPillSheetTypesToIndex(pillSheetTypes: setting.pillSheetEnumTypes, toIndex: pageIndex); if (passedTotalCount >= setting.pillNumberForFromMenstruation) { diff --git a/lib/features/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart b/lib/features/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart index 368558cece..58335c1f3a 100644 --- a/lib/features/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart +++ b/lib/features/settings/today_pill_number/setting_today_pill_number_pill_sheet_list.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:pilll/entity/pill_sheet_group.codegen.dart'; import 'package:pilll/utils/analytics.dart'; import 'package:pilll/components/molecules/dots_page_indicator.dart'; import 'package:pilll/components/organisms/pill_sheet/pill_sheet_view_layout.dart'; import 'package:pilll/components/organisms/pill_sheet/setting_pill_sheet_view.dart'; import 'package:pilll/entity/pill_sheet_type.dart'; -import 'package:pilll/entity/setting.codegen.dart'; class SettingTodayPillNumberPillSheetList extends HookConsumerWidget { final List pillSheetTypes; diff --git a/lib/l10n/app_af.arb b/lib/l10n/app_af.arb index f5d37a3198..cd969aa6b7 100644 --- a/lib/l10n/app_af.arb +++ b/lib/l10n/app_af.arb @@ -1866,7 +1866,7 @@ "@purchaseErrorPurchasePendingError": { "description": "課金の有効化が完了しておりません。しばらく時間をおいてからご確認ください" }, - "launchError": "`'n` 'Ongesteldheid: 'n fout het voorgekom tydens opstart.", + "launchError": "`'n` '{ErrorMessagesConnection}: 'n fout het voorgekom tydens opstart.", "@launchError": { "description": "起動時にエラーが発生しました\n{ErrorMessagesConnection}\n詳細:", "placeholders": { diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index d895874358..b8edc6a52b 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -641,13 +641,9 @@ "@pillNumber": { "description": "ピル番号" }, - "pillDays": "服用日数", - "@pillDays": { - "description": "服用日数" - }, - "pillDaysCycle": "服用日数(周期)", + "pillDaysCycle": "服用日数", "@pillDaysCycle": { - "description": "服用日数(周期)" + "description": "服用日数" }, "pillSheetEnded": "ピルシートが終了しました", "@pillSheetEnded": { @@ -1015,10 +1011,6 @@ "@viewPremiumFeatures": { "description": "プレミアム機能を見る" }, - "addedDisplayModePillDaysCycle": "表示モード服用日数(周期)が追加されました", - "@addedDisplayModePillDaysCycle": { - "description": "表示モード服用日数(周期)が追加されました" - }, "seeDetails": "詳細を見る", "@seeDetails": { "description": "詳細を見る" diff --git a/test/components/organisms/pill_sheet/setting_pill_sheet_view_test.dart b/test/components/organisms/pill_sheet/setting_pill_sheet_view_test.dart index 6454a0c6e2..132e7524c3 100644 --- a/test/components/organisms/pill_sheet/setting_pill_sheet_view_test.dart +++ b/test/components/organisms/pill_sheet/setting_pill_sheet_view_test.dart @@ -1,7 +1,7 @@ import 'package:pilll/components/organisms/pill_mark/pill_marks.dart'; import 'package:pilll/components/organisms/pill_sheet/setting_pill_sheet_view.dart'; +import 'package:pilll/entity/pill_sheet_group.codegen.dart'; import 'package:pilll/entity/pill_sheet_type.dart'; -import 'package:pilll/entity/setting.codegen.dart'; import 'package:pilll/utils/environment.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/test/entity/pill_sheet_group_display_domain_test.dart b/test/entity/pill_sheet_group_display_domain_test.dart index 4c7f1ef905..c9aa5907c3 100644 --- a/test/entity/pill_sheet_group_display_domain_test.dart +++ b/test/entity/pill_sheet_group_display_domain_test.dart @@ -3,7 +3,6 @@ import 'package:pilll/entity/firestore_id_generator.dart'; import 'package:pilll/entity/pill_sheet.codegen.dart'; import 'package:pilll/entity/pill_sheet_group.codegen.dart'; import 'package:pilll/entity/pill_sheet_type.dart'; -import 'package:pilll/entity/setting.codegen.dart'; import 'package:pilll/utils/datetime/day.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; @@ -275,550 +274,6 @@ void main() { }); }); - // NOTE: 服用お休み期間に左右されない - group("#displaySequentialPillSheetNumber", () { - group("ピルシートが一つの場合", () { - test("begin: 2020-09-01, end: 2020-09-28", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-18"), - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - createdAt: now(), - ); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 1); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 28); - }); - - // NOTE: 直接このテストケースの結果に関わってこない部分ではあるが、書いちゃったので残している - group("服用お休み期間を持つ場合", () { - test("服用お休みが終わっていない場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-24")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - createdAt: now(), - ); - - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 1); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 22), 22); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 28); - }); - - test("服用お休みが終わっている場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-24")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - endDate: DateTime.parse("2020-09-23"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - createdAt: now(), - ); - - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 1); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 22), 22); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 28); - }); - group("複数の服用お休み期間を持つ場合", () { - test("最後の服用お休みが終わっていない場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-12"), - createdDate: DateTime.parse("2020-09-12"), - endDate: DateTime.parse("2020-09-15"), - ), - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - createdAt: now(), - ); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 1); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 12), 12); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 22), 22); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 28); - }); - test("最後の服用お休み期間が終わっている場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - // 服用お休みを考慮しない場合は28日間 - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - // 3日分 - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-12"), - createdDate: DateTime.parse("2020-09-12"), - endDate: DateTime.parse("2020-09-15"), - ), - // 3日分 - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - endDate: DateTime.parse("2020-09-25"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - createdAt: now(), - ); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 1); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 12), 12); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 22), 22); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 28); - }); - }); - }); - - group("displayNumberSettingの設定がある場合", () { - test("開始番号が設定されている", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-24")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(beginPillNumber: 10), - ); - - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 19); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 22), 31); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 37); - }); - - test("終了番号が設定されている", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-24")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(endPillNumber: 11), - ); - - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 1); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 11), 11); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 12), 1); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 22), 11); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 6); - }); - test("開始と終了どちらも設定されている", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - createdAt: now(), - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - displayNumberSetting: const PillSheetGroupDisplayNumberSetting( - beginPillNumber: 10, - endPillNumber: 20, - ), - ); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 19); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 12), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 22), 20); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 15); - }); - }); - }); - group("ピルシートが複数(2つ)の場合", () { - test("(begin: 2020-09-01, end: 2020-09-28),(begin: 2020-09-29, end: 2020-10-26)", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-10-10")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-29"), - lastTakenDate: null, - groupIndex: 1, - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet, pillSheet2], - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - createdAt: now(), - ); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 1); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 28); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 1), 29); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 10), 38); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 28), 56); - }); - - group("displayNumberSettingの設定がある場合", () { - test("開始番号が設定されている", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-10-10")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-29"), - lastTakenDate: null, - groupIndex: 1, - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(beginPillNumber: 10), - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - ); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 19); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 37); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 1), 38); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 10), 47); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 28), 65); - }); - - test("終了番号が設定されている", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-24")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(endPillNumber: 11), - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - ); - - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 1); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 11), 11); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 12), 1); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 22), 11); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 6); - }); - test("開始番号が設定されている", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-10-10")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-29"), - lastTakenDate: null, - groupIndex: 1, - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(endPillNumber: 40), - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - ); - - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 1); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 28); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 1), 29); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 10), 38); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 28), 16); - }); - test("開始と終了どちらも設定されている", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-10-10")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-29"), - lastTakenDate: null, - groupIndex: 1, - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(beginPillNumber: 10, endPillNumber: 40), - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - ); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 1), 10); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 10), 19); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 0, pillNumberInPillSheet: 28), 37); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 1), 38); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 10), 16); - expect(pillSheetGroup.sequentialPillSheetNumber(pageIndex: 1, pillNumberInPillSheet: 28), 34); - }); - }); - }); - }); - group("#displayCycleSequentialPillSheetNumber", () { group("ピルシートが一つの場合", () { test("begin: 2020-09-01, end: 2020-09-28", () { diff --git a/test/entity/pill_sheet_group_test.dart b/test/entity/pill_sheet_group_test.dart index c30d9353ce..c813ea008f 100644 --- a/test/entity/pill_sheet_group_test.dart +++ b/test/entity/pill_sheet_group_test.dart @@ -19,746 +19,11 @@ void main() { group("#lastTakenPillNumberWithoutDate", () { group("ピルシートが一つの場合", () { - test("today: 2020-09-19, begin: 2020-09-14, end: 2020-09-18", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-19")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-14"), - lastTakenDate: DateTime.parse("2020-09-18"), - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.lastTakenPillNumberWithoutDate, 5); - }); - group("服用お休み期間を持つ場合", () { - test("服用お休みが終わっていない場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.lastTakenPillNumberWithoutDate, 22); - }); - - test("服用お休みが終わっている場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - endDate: DateTime.parse("2020-09-25"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.lastTakenPillNumberWithoutDate, 25); - }); - group("複数の服用お休み期間を持つ場合", () { - test("最後の服用お休みが終わっていない場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-12"), - createdDate: DateTime.parse("2020-09-12"), - endDate: DateTime.parse("2020-09-15"), - ), - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.lastTakenPillNumberWithoutDate, 19); - }); - test("最後の服用お休み期間が終わっている場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - // 服用お休みを考慮しない場合は28日間 - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - // 3日分 - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-12"), - createdDate: DateTime.parse("2020-09-12"), - endDate: DateTime.parse("2020-09-15"), - ), - // 3日分 - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - endDate: DateTime.parse("2020-09-25"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.lastTakenPillNumberWithoutDate, 22); - }); - }); - }); - }); - group("has two pill sheets", () { - test("it is plane pattern", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-29")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2022-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: null, - groupIndex: 1, - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.lastTakenPillNumberWithoutDate, 28); - }); - test("with begin display number setting", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-29")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2022-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: null, - createdAt: now(), - groupIndex: 1, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(beginPillNumber: 2), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.lastTakenPillNumberWithoutDate, 29); - }); - test("with end display number setting", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-29")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2022-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: null, - createdAt: now(), - groupIndex: 1, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(endPillNumber: 28), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.lastTakenPillNumberWithoutDate, 28); - }); - test("with begin and end display number setting", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-29")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2022-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: null, - createdAt: now(), - groupIndex: 1, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(beginPillNumber: 2, endPillNumber: 28), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.lastTakenPillNumberWithoutDate, 2); - }); - }); - }); - group("#sequentialTodayPillNumber", () { - group("ピルシートが一つの場合", () { - test("today: 2020-09-19, begin: 2020-09-14, end: 2020-09-18", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-19")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-14"), - lastTakenDate: DateTime.parse("2020-09-18"), - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.sequentialTodayPillNumber, 6); - }); - test("today: 2020-09-28, begin: 2020-09-01, end: 2020-09-28", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.sequentialTodayPillNumber, 28); - }); - group("服用お休み期間を持つ場合", () { - test("服用お休みが終わっていない場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.sequentialTodayPillNumber, 22); - }); - - test("服用お休みが終わっている場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - endDate: DateTime.parse("2020-09-25"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.sequentialTodayPillNumber, 25); - }); - group("複数の服用お休み期間を持つ場合", () { - test("最後の服用お休みが終わっていない場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-12"), - createdDate: DateTime.parse("2020-09-12"), - endDate: DateTime.parse("2020-09-15"), - ), - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.sequentialTodayPillNumber, 19); - }); - test("最後の服用お休み期間が終わっている場合", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - // 服用お休みを考慮しない場合は28日間 - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - createdAt: now(), - restDurations: [ - // 3日分 - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-12"), - createdDate: DateTime.parse("2020-09-12"), - endDate: DateTime.parse("2020-09-15"), - ), - // 3日分 - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-22"), - createdDate: DateTime.parse("2020-09-22"), - endDate: DateTime.parse("2020-09-25"), - ) - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.sequentialTodayPillNumber, 22); - }); - }); - }); - }); - group("has two pill sheets", () { - test("it is plane pattern", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-29")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2020-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: null, - groupIndex: 1, - createdAt: now(), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - createdAt: now(), - ); - expect(pillSheetGroup.sequentialTodayPillNumber, 29); - }); - test("with begin display number setting", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-29")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2020-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: null, - createdAt: now(), - groupIndex: 1, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(beginPillNumber: 2), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialTodayPillNumber, 30); - }); - test("with end display number setting", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-29")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2020-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: null, - createdAt: now(), - groupIndex: 1, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(endPillNumber: 28), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialTodayPillNumber, 1); - }); - test("with begin and end display number setting", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-29")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2020-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: null, - createdAt: now(), - groupIndex: 1, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(beginPillNumber: 2, endPillNumber: 28), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialTodayPillNumber, 3); + group("服用お休み期間を持つ場合", () { + group("複数の服用お休み期間を持つ場合", () {}); }); }); + group("has two pill sheets", () {}); }); group("#sequentialLastTakenPillNumber", () { @@ -790,130 +55,7 @@ void main() { ); expect(pillSheetGroup.sequentialLastTakenPillNumber, 0); }); - test("it is taken", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-19")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-14"), - lastTakenDate: DateTime.parse("2020-09-17"), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - createdAt: now(), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - createdAt: now(), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialLastTakenPillNumber, 4); - }); - test("it is boundary test", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-28"), - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - createdAt: now(), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - createdAt: now(), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialLastTakenPillNumber, 28); - }); group("pillsheet has rest durations", () { - test("rest duration is not ended", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-22"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-23"), - createdDate: DateTime.parse("2020-09-23"), - ), - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - createdAt: now(), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialLastTakenPillNumber, 22); - }); - test("rest duration is ended", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-27"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-23"), - createdDate: DateTime.parse("2020-09-23"), - endDate: DateTime.parse("2020-09-25"), - ), - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - createdAt: now(), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialLastTakenPillNumber, 25); - }); test("rest duration is ended and not yet taken pill", () { final mockTodayRepository = MockTodayService(); todayRepository = mockTodayRepository; @@ -950,302 +92,9 @@ void main() { expect(pillSheetGroup.sequentialLastTakenPillNumber, 0); }); - group("pillsheet has plural rest durations", () { - test("last rest duration is not ended", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-22"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-12"), - createdDate: DateTime.parse("2020-09-12"), - endDate: DateTime.parse("2020-09-15"), - ), - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-26"), - createdDate: DateTime.parse("2020-09-26"), - ), - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - createdAt: now(), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialLastTakenPillNumber, 19); - }); - test("last rest duration is ended", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2020-09-28")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2020-09-01"), - lastTakenDate: DateTime.parse("2020-09-22"), - createdAt: now(), - restDurations: [ - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-12"), - createdDate: DateTime.parse("2020-09-12"), - endDate: DateTime.parse("2020-09-15"), - ), - RestDuration( - id: "rest_duration_id", - beginDate: DateTime.parse("2020-09-26"), - createdDate: DateTime.parse("2020-09-26"), - endDate: DateTime.parse("2020-09-27"), - ), - ], - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id"], - pillSheets: [pillSheet], - createdAt: now(), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialLastTakenPillNumber, 19); - }); - }); - }); - group("has two pill sheets", () { - test("it is plane pattern", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-30")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2020-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: DateTime.parse("2022-03-29"), - createdAt: now(), - groupIndex: 1, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - createdAt: now(), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialLastTakenPillNumber, 29); - }); - test("with begin display number setting", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-30")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2020-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: DateTime.parse("2022-03-29"), - createdAt: now(), - groupIndex: 1, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(beginPillNumber: 2), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialLastTakenPillNumber, 30); - }); - test("with end display number setting", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-30")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2020-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: DateTime.parse("2022-03-29"), - createdAt: now(), - groupIndex: 1, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(endPillNumber: 28), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialLastTakenPillNumber, 1); - }); - - test("with end display number setting", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-30")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2020-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: DateTime.parse("2022-03-29"), - createdAt: now(), - groupIndex: 1, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(endPillNumber: 28), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialLastTakenPillNumber, 1); - }); - test("with begin and end display number setting", () { - final mockTodayRepository = MockTodayService(); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(DateTime.parse("2022-03-30")); - - const sheetType = PillSheetType.pillsheet_21; - final pillSheet1 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-01"), - lastTakenDate: DateTime.parse("2020-03-28"), - createdAt: now(), - groupIndex: 0, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - final pillSheet2 = PillSheet( - id: firestoreIDGenerator(), - beginingDate: DateTime.parse("2022-03-29"), - lastTakenDate: DateTime.parse("2022-03-29"), - createdAt: now(), - groupIndex: 1, - typeInfo: PillSheetTypeInfo( - dosingPeriod: sheetType.dosingPeriod, - name: sheetType.fullName, - totalCount: sheetType.totalCount, - pillSheetTypeReferencePath: sheetType.rawPath, - ), - ); - // created at and id are anything value - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["sheet_id", "sheet_id2"], - pillSheets: [pillSheet1, pillSheet2], - createdAt: now(), - displayNumberSetting: const PillSheetGroupDisplayNumberSetting(beginPillNumber: 2, endPillNumber: 28), - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, - ); - expect(pillSheetGroup.sequentialLastTakenPillNumber, 3); - }); + group("pillsheet has plural rest durations", () {}); }); + group("has two pill sheets", () {}); }); }); diff --git a/test/features/initial_setting/initial_setting_state_notifier_test.dart b/test/features/initial_setting/initial_setting_state_notifier_test.dart index 50f8cb5e15..2898253f07 100644 --- a/test/features/initial_setting/initial_setting_state_notifier_test.dart +++ b/test/features/initial_setting/initial_setting_state_notifier_test.dart @@ -401,7 +401,7 @@ void main() { when(batchSetPillSheetModifiedHistory(batch, history)).thenReturn(null); const setting = Setting( - pillSheetAppearanceMode: PillSheetAppearanceMode.sequential, + pillSheetAppearanceMode: PillSheetAppearanceMode.cyclicSequential, pillNumberForFromMenstruation: 52, durationMenstruation: 4, isOnReminder: true, diff --git a/test/features/record/announcement_bar/announcement_bar_test.dart b/test/features/record/announcement_bar/announcement_bar_test.dart index 1838483cca..7d61b1b87c 100644 --- a/test/features/record/announcement_bar/announcement_bar_test.dart +++ b/test/features/record/announcement_bar/announcement_bar_test.dart @@ -3,7 +3,6 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/rendering.dart'; import 'package:pilll/entity/remote_config_parameter.codegen.dart'; -import 'package:pilll/entity/setting.codegen.dart'; import 'package:pilll/entity/user.codegen.dart'; import 'package:pilll/features/record/components/announcement_bar/components/admob.dart'; import 'package:pilll/provider/purchase.dart'; diff --git a/test/features/record/components/button/record_page_button_test.dart b/test/features/record/components/button/record_page_button_test.dart index efa32086f5..3a8b2ffc99 100644 --- a/test/features/record/components/button/record_page_button_test.dart +++ b/test/features/record/components/button/record_page_button_test.dart @@ -2,7 +2,6 @@ import 'package:flutter/rendering.dart'; import 'package:pilll/entity/pill_sheet.codegen.dart'; import 'package:pilll/entity/pill_sheet_group.codegen.dart'; import 'package:pilll/entity/pill_sheet_type.dart'; -import 'package:pilll/entity/setting.codegen.dart'; import 'package:pilll/features/record/components/button/cancel_button.dart'; import 'package:pilll/features/record/components/button/record_page_button.dart'; import 'package:pilll/features/record/components/button/rest_duration_button.dart'; diff --git a/test/features/record/components/record_page_pill_sheet_test.dart b/test/features/record/components/record_page_pill_sheet_test.dart index a7816e2bfb..56ca14e04e 100644 --- a/test/features/record/components/record_page_pill_sheet_test.dart +++ b/test/features/record/components/record_page_pill_sheet_test.dart @@ -363,185 +363,6 @@ void main() { pillSheetAppearanceMode: PillSheetAppearanceMode.number, ); - for (int i = 0; i < 28; i++) { - final pillNumberInPillSheet = i + 1; - final widget = PillNumber( - user: FakeUser(fakeIsPremium: true, fakeIsTrial: true), - pillSheetGroup: pillSheetGroup, - pillSheet: pillSheet, - pillNumberInPillSheet: pillNumberInPillSheet, - pageIndex: 0, - setting: setting); - await tester.pumpWidget(MaterialApp(home: widget)); - - if (pillNumberInPillSheet < pillNumberForFromMenstruation) { - expect(find.byWidgetPredicate((widget) => widget is PlainPillNumber), findsWidgets, - reason: "pillNumberInPillSheet: $pillNumberInPillSheet"); - } else if (pillNumberInPillSheet < pillNumberForFromMenstruation + durationMenstruation) { - expect(find.byWidgetPredicate((widget) => widget is PlainPillNumber), findsWidgets, - reason: "pillNumberInPillSheet: $pillNumberInPillSheet"); - } else { - expect(find.byWidgetPredicate((widget) => widget is PlainPillNumber), findsWidgets, - reason: "pillNumberInPillSheet: $pillNumberInPillSheet"); - } - } - }); - }); - group("pillSheetAppearanceMode is sequential", () { - const pillSheetAppearanceMode = PillSheetAppearanceMode.sequential; - testWidgets("it is isPremium or isTrial", (WidgetTester tester) async { - SupportedDeviceType.iPhone5SE2nd.binding(tester.view); - - final originalTodayRepository = todayRepository; - final mockTodayRepository = MockTodayService(); - final mockToday = DateTime.parse("2020-09-01"); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(mockToday); - when(mockTodayRepository.now()).thenReturn(mockToday); - addTearDown(() { - todayRepository = originalTodayRepository; - }); - - const pillNumberForFromMenstruation = 22; - const durationMenstruation = 4; - const setting = Setting( - pillNumberForFromMenstruation: pillNumberForFromMenstruation, - durationMenstruation: durationMenstruation, - isOnReminder: true, - timezoneDatabaseName: null, - pillSheetAppearanceMode: pillSheetAppearanceMode, - ); - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - typeInfo: PillSheetType.pillsheet_21.typeInfo, - beginingDate: mockToday, - lastTakenDate: null, - createdAt: now(), - ); - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["pill_sheet_id"], - pillSheets: [pillSheet], - createdAt: today(), - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - ); - for (int i = 0; i < 28; i++) { - final pillNumberInPillSheet = i + 1; - final widget = PillNumber( - user: FakeUser(fakeIsPremium: true, fakeIsTrial: true), - pillSheetGroup: pillSheetGroup, - pillSheet: pillSheet, - pillNumberInPillSheet: pillNumberInPillSheet, - pageIndex: 0, - setting: setting); - await tester.pumpWidget(MaterialApp(home: widget)); - - if (pillNumberInPillSheet < pillNumberForFromMenstruation) { - expect(find.byWidgetPredicate((widget) => widget is PlainPillNumber), findsWidgets, - reason: "pillNumberInPillSheet: $pillNumberInPillSheet"); - } else if (pillNumberInPillSheet < pillNumberForFromMenstruation + durationMenstruation) { - expect(find.byWidgetPredicate((widget) => widget is MenstruationPillNumber), findsWidgets, - reason: "pillNumberInPillSheet: $pillNumberInPillSheet"); - } else { - expect(find.byWidgetPredicate((widget) => widget is PlainPillNumber), findsWidgets, - reason: "pillNumberInPillSheet: $pillNumberInPillSheet"); - } - } - }); - testWidgets("it is not isPremium and isTrial", (WidgetTester tester) async { - SupportedDeviceType.iPhone5SE2nd.binding(tester.view); - - final originalTodayRepository = todayRepository; - final mockTodayRepository = MockTodayService(); - final mockToday = DateTime.parse("2020-09-01"); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(mockToday); - when(mockTodayRepository.now()).thenReturn(mockToday); - addTearDown(() { - todayRepository = originalTodayRepository; - }); - - const pillNumberForFromMenstruation = 22; - const durationMenstruation = 4; - const setting = Setting( - pillNumberForFromMenstruation: pillNumberForFromMenstruation, - durationMenstruation: durationMenstruation, - isOnReminder: true, - timezoneDatabaseName: null, - pillSheetAppearanceMode: pillSheetAppearanceMode, - ); - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - typeInfo: PillSheetType.pillsheet_21.typeInfo, - beginingDate: mockToday, - lastTakenDate: null, - createdAt: now(), - ); - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["pill_sheet_id"], - pillSheets: [pillSheet], - createdAt: today(), - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - ); - - for (int i = 0; i < 28; i++) { - final pillNumberInPillSheet = i + 1; - final widget = PillNumber( - user: FakeUser(fakeIsPremium: false, fakeIsTrial: false), - pillSheetGroup: pillSheetGroup, - pillSheet: pillSheet, - pillNumberInPillSheet: pillNumberInPillSheet, - pageIndex: 0, - setting: setting); - await tester.pumpWidget(MaterialApp(home: widget)); - - if (pillNumberInPillSheet < pillNumberForFromMenstruation) { - expect(find.byWidgetPredicate((widget) => widget is PlainPillNumber), findsWidgets, - reason: "pillNumberInPillSheet: $pillNumberInPillSheet"); - } else if (pillNumberInPillSheet < pillNumberForFromMenstruation + durationMenstruation) { - expect(find.byWidgetPredicate((widget) => widget is PlainPillNumber), findsWidgets, - reason: "pillNumberInPillSheet: $pillNumberInPillSheet"); - } else { - expect(find.byWidgetPredicate((widget) => widget is PlainPillNumber), findsWidgets, - reason: "pillNumberInPillSheet: $pillNumberInPillSheet"); - } - } - }); - testWidgets("setting.pillNumberForFromMenstruation == 0 || setting.durationMenstruation == 0", (WidgetTester tester) async { - SupportedDeviceType.iPhone5SE2nd.binding(tester.view); - - final originalTodayRepository = todayRepository; - final mockTodayRepository = MockTodayService(); - final mockToday = DateTime.parse("2020-09-01"); - todayRepository = mockTodayRepository; - when(mockTodayRepository.now()).thenReturn(mockToday); - when(mockTodayRepository.now()).thenReturn(mockToday); - addTearDown(() { - todayRepository = originalTodayRepository; - }); - - const pillNumberForFromMenstruation = 0; - const durationMenstruation = 0; - const setting = Setting( - pillNumberForFromMenstruation: pillNumberForFromMenstruation, - durationMenstruation: durationMenstruation, - isOnReminder: true, - timezoneDatabaseName: null, - pillSheetAppearanceMode: pillSheetAppearanceMode, - ); - final pillSheet = PillSheet( - id: firestoreIDGenerator(), - typeInfo: PillSheetType.pillsheet_21.typeInfo, - beginingDate: mockToday, - lastTakenDate: null, - createdAt: now(), - ); - final pillSheetGroup = PillSheetGroup( - pillSheetIDs: ["pill_sheet_id"], - pillSheets: [pillSheet], - createdAt: today(), - pillSheetAppearanceMode: PillSheetAppearanceMode.number, - ); - for (int i = 0; i < 28; i++) { final pillNumberInPillSheet = i + 1; final widget = PillNumber( diff --git a/test/features/record/components/setting/button/provider_test.dart b/test/features/record/components/setting/button/provider_test.dart index 5635c1cfff..59d6ecc4c1 100644 --- a/test/features/record/components/setting/button/provider_test.dart +++ b/test/features/record/components/setting/button/provider_test.dart @@ -5,7 +5,6 @@ import 'package:pilll/entity/pill_sheet_modified_history.codegen.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:pilll/entity/pill_sheet_type.dart'; -import 'package:pilll/entity/setting.codegen.dart'; import 'package:pilll/features/record/components/setting/components/rest_duration/provider.dart'; import 'package:pilll/utils/datetime/date_add.dart'; import 'package:pilll/utils/datetime/date_compare.dart'; diff --git a/test/helper/mock.mocks.dart b/test/helper/mock.mocks.dart index 90e7abae2c..81c5c7b0bf 100644 --- a/test/helper/mock.mocks.dart +++ b/test/helper/mock.mocks.dart @@ -593,11 +593,11 @@ class MockSetting extends _i1.Mock implements _i6.Setting { ) as _i5.ReminderNotificationCustomization); @override - _i6.PillSheetAppearanceMode get pillSheetAppearanceMode => + _i7.PillSheetAppearanceMode get pillSheetAppearanceMode => (super.noSuchMethod( Invocation.getter(#pillSheetAppearanceMode), - returnValue: _i6.PillSheetAppearanceMode.number, - ) as _i6.PillSheetAppearanceMode); + returnValue: _i7.PillSheetAppearanceMode.number, + ) as _i7.PillSheetAppearanceMode); @override _i6.$SettingCopyWith<_i6.Setting> get copyWith => (super.noSuchMethod(