From 13086e4ee4b5eff5a420963a0760533697782f70 Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Mon, 16 Dec 2024 22:11:23 +0530 Subject: [PATCH 01/11] test: added test for all files under utils/app_settings --- .../utils/app_settings/app_settings_test.dart | 39 ++++++++++++ .../app_settings/save_tour_status_test.dart | 61 +++++++++++++++++++ .../app_settings/selected_language_test.dart | 21 +++++++ .../app_settings/selected_theme_test.dart | 20 ++++++ 4 files changed, 141 insertions(+) create mode 100644 test/utils/app_settings/app_settings_test.dart create mode 100644 test/utils/app_settings/save_tour_status_test.dart create mode 100644 test/utils/app_settings/selected_language_test.dart create mode 100644 test/utils/app_settings/selected_theme_test.dart diff --git a/test/utils/app_settings/app_settings_test.dart b/test/utils/app_settings/app_settings_test.dart new file mode 100644 index 00000000..592de7a1 --- /dev/null +++ b/test/utils/app_settings/app_settings_test.dart @@ -0,0 +1,39 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/language/supported_language.dart'; + +void main() { + group('AppSettings', () { + setUp(() async { + SharedPreferences.setMockInitialValues({}); + await AppSettings.init(); + }); + + test('should initialize settings correctly', () async { + expect(AppSettings.isDarkMode, true); + expect(AppSettings.selectedLanguage, SupportedLanguage.english); + }); + + test('should save settings correctly', () async { + await AppSettings.saveSettings(false, SupportedLanguage.english); + expect(AppSettings.isDarkMode, true); + expect(AppSettings.selectedLanguage, SupportedLanguage.english); + }); + }); + + group('SelectedTheme', () { + setUp(() async { + SharedPreferences.setMockInitialValues({}); + await SelectedTheme.init(); + }); + + test('should save and retrieve theme mode correctly', () async { + await SelectedTheme.saveMode(false); + expect(SelectedTheme.getMode(), false); + + await SelectedTheme.saveMode(true); + expect(SelectedTheme.getMode(), true); + }); + }); +} diff --git a/test/utils/app_settings/save_tour_status_test.dart b/test/utils/app_settings/save_tour_status_test.dart new file mode 100644 index 00000000..0716a44a --- /dev/null +++ b/test/utils/app_settings/save_tour_status_test.dart @@ -0,0 +1,61 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; + +void main() { + group('SaveTourStatus', () { + setUp(() async { + SharedPreferences.setMockInitialValues({}); + await SaveTourStatus.init(); + }); + + test('should save and retrieve reports tour status correctly', () async { + await SaveTourStatus.saveReportsTourStatus(true); + expect(await SaveTourStatus.getReportsTourStatus(), true); + + await SaveTourStatus.saveReportsTourStatus(false); + expect(await SaveTourStatus.getReportsTourStatus(), false); + }); + + test('should save and retrieve in-app tour status correctly', () async { + await SaveTourStatus.saveInAppTourStatus(true); + expect(await SaveTourStatus.getInAppTourStatus(), true); + + await SaveTourStatus.saveInAppTourStatus(false); + expect(await SaveTourStatus.getInAppTourStatus(), false); + }); + + test('should save and retrieve filter tour status correctly', () async { + await SaveTourStatus.saveFilterTourStatus(true); + expect(await SaveTourStatus.getFilterTourStatus(), true); + + await SaveTourStatus.saveFilterTourStatus(false); + expect(await SaveTourStatus.getFilterTourStatus(), false); + }); + + test('should save and retrieve profile tour status correctly', () async { + await SaveTourStatus.saveProfileTourStatus(true); + expect(await SaveTourStatus.getProfileTourStatus(), true); + + await SaveTourStatus.saveProfileTourStatus(false); + expect(await SaveTourStatus.getProfileTourStatus(), false); + }); + + test('should save and retrieve details tour status correctly', () async { + await SaveTourStatus.saveDetailsTourStatus(true); + expect(await SaveTourStatus.getDetailsTourStatus(), true); + + await SaveTourStatus.saveDetailsTourStatus(false); + expect(await SaveTourStatus.getDetailsTourStatus(), false); + }); + + test('should save and retrieve manage task server tour status correctly', + () async { + await SaveTourStatus.saveManageTaskServerTourStatus(true); + expect(await SaveTourStatus.getManageTaskServerTourStatus(), true); + + await SaveTourStatus.saveManageTaskServerTourStatus(false); + expect(await SaveTourStatus.getManageTaskServerTourStatus(), false); + }); + }); +} diff --git a/test/utils/app_settings/selected_language_test.dart b/test/utils/app_settings/selected_language_test.dart new file mode 100644 index 00000000..a82c227b --- /dev/null +++ b/test/utils/app_settings/selected_language_test.dart @@ -0,0 +1,21 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/language/supported_language.dart'; + +void main() { + group('SelectedLanguage', () { + setUp(() async { + SharedPreferences.setMockInitialValues({}); + await SelectedLanguage.init(); + }); + + test('should save and retrieve selected language correctly', () async { + await SelectedLanguage.saveSelectedLanguage(SupportedLanguage.spanish); + expect(SelectedLanguage.getSelectedLanguage(), SupportedLanguage.spanish); + + await SelectedLanguage.saveSelectedLanguage(SupportedLanguage.english); + expect(SelectedLanguage.getSelectedLanguage(), SupportedLanguage.english); + }); + }); +} diff --git a/test/utils/app_settings/selected_theme_test.dart b/test/utils/app_settings/selected_theme_test.dart new file mode 100644 index 00000000..bd1239e9 --- /dev/null +++ b/test/utils/app_settings/selected_theme_test.dart @@ -0,0 +1,20 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; + +void main() { + group('SelectedTheme', () { + setUp(() async { + SharedPreferences.setMockInitialValues({}); + await SelectedTheme.init(); + }); + + test('should save and retrieve theme mode correctly', () async { + await SelectedTheme.saveMode(false); + expect(SelectedTheme.getMode(), false); + + await SelectedTheme.saveMode(true); + expect(SelectedTheme.getMode(), true); + }); + }); +} From ab77c2aff5a7df65f6dbbe729840a1e8d8ab8625 Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Mon, 16 Dec 2024 22:11:52 +0530 Subject: [PATCH 02/11] test: added test for all files under utils/constants --- .../onboarding_screen_content_test.dart | 26 +++++++ test/utils/constants/pallette_test.dart | 24 +++++++ test/utils/constants/permissions_test.dart | 15 ++++ .../constants/taskwarrior_colors_test.dart | 47 +++++++++++++ .../constants/taskwarrior_fonts_test.dart | 26 +++++++ test/utils/constants/utilities_test.dart | 70 +++++++++++++++++++ 6 files changed, 208 insertions(+) create mode 100644 test/utils/constants/onboarding_screen_content_test.dart create mode 100644 test/utils/constants/pallette_test.dart create mode 100644 test/utils/constants/permissions_test.dart create mode 100644 test/utils/constants/taskwarrior_colors_test.dart create mode 100644 test/utils/constants/taskwarrior_fonts_test.dart create mode 100644 test/utils/constants/utilities_test.dart diff --git a/test/utils/constants/onboarding_screen_content_test.dart b/test/utils/constants/onboarding_screen_content_test.dart new file mode 100644 index 00000000..3023fb43 --- /dev/null +++ b/test/utils/constants/onboarding_screen_content_test.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/constants/onboarding_screen_content.dart'; + +void main() { + group('Onboarding Screen Content', () { + test('should contain three onboarding items', () { + expect(contents.length, 3); + }); + + test('should have valid content for each onboarding item', () { + for (var content in contents) { + expect(content.title.isNotEmpty, true); + expect(content.image.isNotEmpty, true); + expect(content.colors, isA()); + expect(content.desc.isNotEmpty, true); + } + }); + + test('should match the expected titles', () { + expect(contents[0].title, "Welcome to Taskwarrior"); + expect(contents[1].title, "Powerful Reporting"); + expect(contents[2].title, "Sync Across Devices"); + }); + }); +} diff --git a/test/utils/constants/pallette_test.dart b/test/utils/constants/pallette_test.dart new file mode 100644 index 00000000..81a825f2 --- /dev/null +++ b/test/utils/constants/pallette_test.dart @@ -0,0 +1,24 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/constants/palette.dart'; +import 'package:flutter/material.dart'; + +void main() { + group('Palette', () { + test('kToDark should be a MaterialColor', () { + expect(Palette.kToDark, isA()); + }); + + test('kToDark should contain the correct color values', () { + expect(Palette.kToDark[50], const Color(0xff1e1e1e)); + expect(Palette.kToDark[100], const Color(0xff1a1a1a)); + expect(Palette.kToDark[200], const Color(0xff171717)); + expect(Palette.kToDark[300], const Color(0xff141414)); + expect(Palette.kToDark[400], const Color(0xff111111)); + expect(Palette.kToDark[500], const Color(0xff0d0d0d)); + expect(Palette.kToDark[600], const Color(0xff0a0a0a)); + expect(Palette.kToDark[700], const Color(0xff070707)); + expect(Palette.kToDark[800], const Color(0xff030303)); + expect(Palette.kToDark[900], const Color(0xff000000)); + }); + }); +} diff --git a/test/utils/constants/permissions_test.dart b/test/utils/constants/permissions_test.dart new file mode 100644 index 00000000..e1cdabcd --- /dev/null +++ b/test/utils/constants/permissions_test.dart @@ -0,0 +1,15 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:taskwarrior/app/utils/constants/permissions.dart'; + +void main() { + group('Permissions', () { + test('should contain the correct permissions', () { + expect(permissions, [ + Permission.notification, + Permission.storage, + Permission.manageExternalStorage, + ]); + }); + }); +} diff --git a/test/utils/constants/taskwarrior_colors_test.dart b/test/utils/constants/taskwarrior_colors_test.dart new file mode 100644 index 00000000..a7fea38d --- /dev/null +++ b/test/utils/constants/taskwarrior_colors_test.dart @@ -0,0 +1,47 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter/material.dart'; +import 'package:taskwarrior/app/utils/constants/palette.dart'; +import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; + +void main() { + group('TaskWarriorColors', () { + test('should contain the correct normal colors', () { + expect(TaskWarriorColors.red, Colors.red); + expect(TaskWarriorColors.green, Colors.green); + expect(TaskWarriorColors.yellow, Colors.yellow); + expect(TaskWarriorColors.white, Colors.white); + expect(TaskWarriorColors.black, Colors.black); + expect(TaskWarriorColors.grey, Colors.grey); + expect(TaskWarriorColors.lightGrey, Colors.grey[600]); + expect(TaskWarriorColors.purple, Colors.purple); + expect(TaskWarriorColors.borderColor, Colors.grey.shade300); + expect(TaskWarriorColors.deepPurpleAccent, Colors.deepPurpleAccent); + expect(TaskWarriorColors.deepPurple, Colors.deepPurple); + }); + + test('should contain the correct dark theme colors', () { + expect( + TaskWarriorColors.kprimaryBackgroundColor, Palette.kToDark.shade200); + expect(TaskWarriorColors.ksecondaryBackgroundColor, + const Color.fromARGB(255, 48, 46, 46)); + expect(TaskWarriorColors.kprimaryTextColor, Colors.white); + expect(TaskWarriorColors.ksecondaryTextColor, Colors.white); + expect( + TaskWarriorColors.kprimaryDisabledTextColor, const Color(0xff595f6b)); + expect(TaskWarriorColors.kdialogBackGroundColor, + const Color.fromARGB(255, 25, 25, 25)); + }); + + test('should contain the correct light theme colors', () { + expect(TaskWarriorColors.kLightPrimaryBackgroundColor, Colors.white); + expect(TaskWarriorColors.kLightSecondaryBackgroundColor, + const Color.fromARGB(255, 220, 216, 216)); + expect(TaskWarriorColors.kLightPrimaryTextColor, Colors.black); + expect(TaskWarriorColors.kLightSecondaryTextColor, + const Color.fromARGB(255, 48, 46, 46)); + expect(TaskWarriorColors.kLightPrimaryDisabledTextColor, + const Color(0xffACACAB)); + expect(TaskWarriorColors.kLightDialogBackGroundColor, Colors.white); + }); + }); +} diff --git a/test/utils/constants/taskwarrior_fonts_test.dart b/test/utils/constants/taskwarrior_fonts_test.dart new file mode 100644 index 00000000..0dc72d4c --- /dev/null +++ b/test/utils/constants/taskwarrior_fonts_test.dart @@ -0,0 +1,26 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter/material.dart'; +import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; + +void main() { + group('TaskWarriorFonts', () { + test('should contain the correct font weights', () { + expect(TaskWarriorFonts.thin, FontWeight.w100); + expect(TaskWarriorFonts.extraLight, FontWeight.w200); + expect(TaskWarriorFonts.light, FontWeight.w300); + expect(TaskWarriorFonts.regular, FontWeight.w400); + expect(TaskWarriorFonts.medium, FontWeight.w500); + expect(TaskWarriorFonts.semiBold, FontWeight.w600); + expect(TaskWarriorFonts.bold, FontWeight.w700); + expect(TaskWarriorFonts.extraBold, FontWeight.w800); + expect(TaskWarriorFonts.black, FontWeight.w900); + }); + + test('should contain the correct font sizes', () { + expect(TaskWarriorFonts.fontSizeSmall, 12.0); + expect(TaskWarriorFonts.fontSizeMedium, 16.0); + expect(TaskWarriorFonts.fontSizeLarge, 20.0); + expect(TaskWarriorFonts.fontSizeExtraLarge, 24.0); + }); + }); +} diff --git a/test/utils/constants/utilities_test.dart b/test/utils/constants/utilities_test.dart new file mode 100644 index 00000000..c58da03d --- /dev/null +++ b/test/utils/constants/utilities_test.dart @@ -0,0 +1,70 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter/material.dart'; +import 'package:taskwarrior/app/utils/constants/utilites.dart'; + +void main() { + group('Utils', () { + test('should return the correct week number as string', () { + DateTime date = DateTime(2024, 12, 15); + expect(Utils.getWeekNumber(date), '50'); + }); + + test('should return the correct week number as integer', () { + DateTime date = DateTime(2024, 12, 15); + expect(Utils.getWeekNumbertoInt(date), 50); + }); + + test('should format date correctly', () { + DateTime date = DateTime(2024, 12, 15); + String pattern = 'yyyy-MM-dd'; + expect(Utils.formatDate(date, pattern), '2024-12-15'); + }); + + test('should return the correct month name', () { + expect(Utils.getMonthName(1), 'January'); + expect(Utils.getMonthName(2), 'February'); + expect(Utils.getMonthName(3), 'March'); + expect(Utils.getMonthName(4), 'April'); + expect(Utils.getMonthName(5), 'May'); + expect(Utils.getMonthName(6), 'June'); + expect(Utils.getMonthName(7), 'July'); + expect(Utils.getMonthName(8), 'August'); + expect(Utils.getMonthName(9), 'September'); + expect(Utils.getMonthName(10), 'October'); + expect(Utils.getMonthName(11), 'November'); + expect(Utils.getMonthName(12), 'December'); + expect(Utils.getMonthName(0), ''); + }); + + testWidgets('should create an AlertDialog', (WidgetTester tester) async { + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Builder( + builder: (context) { + return ElevatedButton( + onPressed: () { + showDialog( + context: context, + builder: (BuildContext context) { + return Utils.showAlertDialog( + title: const Text('Test Dialog'), + content: const Text('This is a test dialog'), + ); + }, + ); + }, + child: const Text('Show Dialog'), + ); + }, + ), + ), + )); + + await tester.tap(find.text('Show Dialog')); + await tester.pump(); + + expect(find.text('Test Dialog'), findsOneWidget); + expect(find.text('This is a test dialog'), findsOneWidget); + }); + }); +} From 5edb00c3c3eaab9295f34bb916ea84753d456df5 Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Mon, 16 Dec 2024 22:12:19 +0530 Subject: [PATCH 03/11] test: added test for all files under utils/language --- .../language/bengali_sentences_test.dart | 179 +++++++++++++++++ .../language/english_sentences_test.dart | 169 ++++++++++++++++ .../utils/language/french_sentences_test.dart | 181 ++++++++++++++++++ test/utils/language/hindi_sentences_test.dart | 175 +++++++++++++++++ .../language/marathi_sentences_test.dart | 176 +++++++++++++++++ .../utils/language/sentence_manager_test.dart | 48 +++++ test/utils/language/sentences_test.dart | 180 +++++++++++++++++ .../language/spanish_sentences_test.dart | 179 +++++++++++++++++ .../language/supported_language_test.dart | 31 +++ 9 files changed, 1318 insertions(+) create mode 100644 test/utils/language/bengali_sentences_test.dart create mode 100644 test/utils/language/english_sentences_test.dart create mode 100644 test/utils/language/french_sentences_test.dart create mode 100644 test/utils/language/hindi_sentences_test.dart create mode 100644 test/utils/language/marathi_sentences_test.dart create mode 100644 test/utils/language/sentence_manager_test.dart create mode 100644 test/utils/language/sentences_test.dart create mode 100644 test/utils/language/spanish_sentences_test.dart create mode 100644 test/utils/language/supported_language_test.dart diff --git a/test/utils/language/bengali_sentences_test.dart b/test/utils/language/bengali_sentences_test.dart new file mode 100644 index 00000000..a9b86947 --- /dev/null +++ b/test/utils/language/bengali_sentences_test.dart @@ -0,0 +1,179 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/language/bengali_sentences.dart'; + +void main() { + final bengali = BengaliSentences(); + + test('should provide correct Bengali translations', () { + expect(bengali.helloWorld, 'হ্যালো বিশ্ব!'); + expect(bengali.homePageTitle, 'হোম পেজ'); + expect(bengali.homePageLastModified, 'শেষবার পরিবর্তিত'); + expect(bengali.homePageDue, 'জরুরি'); + expect(bengali.homePageTaskWarriorNotConfigured, + 'TaskServer কনফিগার করা হয়নি'); + expect(bengali.homePageSetup, 'সেটআপ'); + expect(bengali.homePageFilter, 'ফিল্টার'); + expect(bengali.homePageMenu, 'মেনু'); + expect(bengali.homePageExitApp, 'অ্যাপ বন্ধ করুন'); + expect(bengali.homePageAreYouSureYouWantToExit, + 'আপনি কি সত্যিই অ্যাপ বন্ধ করতে চান?'); + expect(bengali.homePageExit, 'বাহির যান'); + expect(bengali.homePageCancel, 'বাতিল করুন'); + expect(bengali.homePageClickOnTheBottomRightButtonToStartAddingTasks, + 'টাস্ক যোগ করা শুরু করতে নিচে ডানদিকে বোতামে ক্লিক করুন'); + expect(bengali.homePageSearchNotFound, 'অনুসন্ধানে কিছু পাওয়া যায়নি'); + expect(bengali.settingsPageTitle, 'সেটিংস পেজ'); + expect(bengali.settingsPageSubtitle, 'আপনার পছন্দ সেট করুন'); + expect(bengali.settingsPageMovingDataToNewDirectory, + 'নতুন ডিরেক্টরিতে ডেটা স্থানান্তর করা হচ্ছে'); + expect(bengali.settingsPageSyncOnStartTitle, + 'অ্যাপ শুরুতে ডেটা স্বয়ংক্রিয়ভাবে সিঙ্ক করুন'); + expect(bengali.settingsPageSyncOnStartDescription, 'শুরুতে সিঙ্ক করুন'); + expect(bengali.settingsPageEnableSyncOnTaskCreateTitle, + 'নতুন টাস্ক তৈরি করার সময় স্বয়ংক্রিয় সিঙ্কিং সক্ষম করুন'); + expect(bengali.settingsPageEnableSyncOnTaskCreateDescription, + 'নতুন টাস্ক তৈরি করার সময় স্বয়ংক্রিয় সিঙ্কিং সক্ষম করুন'); + expect(bengali.settingsPageHighlightTaskTitle, + 'শুধু 1 দিন বাকি থাকলে টাস্ক হাইলাইট করুন'); + expect(bengali.settingsPageHighlightTaskDescription, + 'শুধু 1 দিন বাকি থাকলে টাস্ক হাইলাইট করুন'); + expect(bengali.settingsPageEnable24hrFormatTitle, + '24 ঘণ্টার ফর্ম্যাট সক্রিয় করুন'); + expect(bengali.settingsPageEnable24hrFormatDescription, + '24 ঘণ্টার ফর্ম্যাট সক্রিয় করুন'); + expect(bengali.settingsPageSelectLanguage, 'ভাষা নির্বাচন করুন'); + expect(bengali.settingsPageToggleNativeLanguage, + 'আপনার মাতৃভাষার মধ্যে টগল করুন'); + expect(bengali.settingsPageSelectDirectoryTitle, 'ডিরেক্টরি নির্বাচন করুন'); + expect(bengali.settingsPageSelectDirectoryDescription, + 'টাস্কওয়ারিয়র ডেটা যেখানে সংরক্ষিত হয় সেই ডিরেক্টরি নির্বাচন করুন\nবর্তমান ডিরেক্টরি: '); + expect(bengali.settingsPageChangeDirectory, 'ডিরেক্টরি পরিবর্তন করুন'); + expect(bengali.settingsPageSetToDefault, 'ডিফল্টে সেট করুন'); + expect(bengali.navDrawerProfile, 'প্রোফাইল'); + expect(bengali.navDrawerReports, 'রিপোর্টস'); + expect(bengali.navDrawerAbout, 'সম্পর্কে'); + expect(bengali.navDrawerSettings, 'সেটিংস'); + expect(bengali.navDrawerExit, 'বাহির যান'); + expect(bengali.detailPageDescription, 'বর্ণনা'); + expect(bengali.detailPageStatus, 'অবস্থা'); + expect(bengali.detailPageEntry, 'এন্ট্রি'); + expect(bengali.detailPageModified, 'পরিবর্তিত'); + expect(bengali.detailPageStart, 'শুরু'); + expect(bengali.detailPageEnd, 'শেষ'); + expect(bengali.detailPageDue, 'জরুরি'); + expect(bengali.detailPageWait, 'অপেক্ষা করুন'); + expect(bengali.detailPageUntil, 'পর্যন্ত'); + expect(bengali.detailPagePriority, 'প্রাধান্য'); + expect(bengali.detailPageProject, 'প্রকল্প'); + expect(bengali.detailPageTags, 'ট্যাগ'); + expect(bengali.detailPageUrgency, 'জরুরি'); + expect(bengali.detailPageID, 'আইডি'); + expect(bengali.filterDrawerApplyFilters, 'ফিল্টার প্রয়োগ করুন'); + expect(bengali.filterDrawerHideWaiting, 'অপেক্ষা লুকান'); + expect(bengali.filterDrawerShowWaiting, 'অপেক্ষা প্রদর্শন করুন'); + expect(bengali.filterDrawerPending, 'মুলতুবি'); + expect(bengali.filterDrawerCompleted, 'সম্পন্ন'); + expect(bengali.filterDrawerFilterTagBy, 'ট্যাগ দ্বারা ফিল্টার করুন'); + expect(bengali.filterDrawerAND, 'এবং'); + expect(bengali.filterDrawerOR, 'অথবা'); + expect(bengali.filterDrawerSortBy, 'এর দ্বারা সাজান'); + expect(bengali.filterDrawerCreated, 'সৃষ্ট'); + expect(bengali.filterDrawerModified, 'পরিবর্তিত'); + expect(bengali.filterDrawerStartTime, 'শুরুর সময়'); + expect(bengali.filterDrawerDueTill, 'জরুরি পর্যন্ত'); + expect(bengali.filterDrawerPriority, 'প্রাধান্য'); + expect(bengali.filterDrawerProject, 'প্রকল্প'); + expect(bengali.filterDrawerTags, 'ট্যাগস'); + expect(bengali.filterDrawerUrgency, 'জরুরি'); + expect(bengali.filterDrawerResetSort, 'সাজানো রিসেট করুন'); + expect(bengali.filterDrawerStatus, 'অবস্থা'); + expect(bengali.reportsPageTitle, 'রিপোর্টস'); + expect(bengali.reportsPageCompleted, 'সম্পন্ন'); + expect(bengali.reportsPagePending, 'মুলতুবি'); + expect(bengali.reportsPageTasks, 'টাস্ক'); + expect(bengali.reportsPageDaily, 'দৈনিক'); + expect(bengali.reportsPageDailyBurnDownChart, 'দৈনিক বার্নডাউন চার্ট'); + expect(bengali.reportsPageDailyDayMonth, 'দিন - মাস'); + expect(bengali.reportsPageWeekly, 'সাপ্তাহিক'); + expect(bengali.reportsPageWeeklyBurnDownChart, 'সাপ্তাহিক বার্নডাউন চার্ট'); + expect(bengali.reportsPageWeeklyWeeksYear, 'সপ্তাহ - বছর'); + expect(bengali.reportsPageMonthly, 'মাসিক'); + expect(bengali.reportsPageMonthlyBurnDownChart, 'মাসিক বার্নডাউন চার্ট'); + expect(bengali.reportsPageMonthlyMonthYear, 'মাস - বছর'); + expect(bengali.reportsPageNoTasksFound, 'কোনও টাস্ক পাওয়া যায়নি'); + expect(bengali.reportsPageAddTasksToSeeReports, + 'রিপোর্ট দেখতে টাস্ক যোগ করুন'); + expect(bengali.taskchampionTileDescription, + 'TaskWarrior সিঙ্কিং CCSync বা Taskchampion সিঙ্ক সার্ভারে পরিবর্তন করুন'); + expect(bengali.taskchampionTileTitle, 'Taskchampion সিঙ্ক'); + expect(bengali.ccsyncCredentials, 'CCSync ক্রেডেনশিয়াল'); + expect(bengali.deleteTaskConfirmation, 'টাস্ক মুছুন'); + expect(bengali.deleteTaskTitle, 'সব টাস্ক মুছুন?'); + expect(bengali.deleteTaskWarning, + 'এই পদক্ষেপটি অপরিবর্তনীয় এবং সমস্ত স্থানীয়ভাবে সংরক্ষিত টাস্ক মুছে ফেলবে।'); + expect(bengali.profilePageProfile, 'প্রোফাইল'); + expect(bengali.profilePageProfiles, 'প্রোফাইলস'); + expect(bengali.profilePageCurrentProfile, 'বর্তমান প্রোফাইল'); + expect(bengali.profilePageManageSelectedProfile, + 'নির্বাচিত প্রোফাইল পরিচালনা করুন'); + expect(bengali.profilePageRenameAlias, 'অ্যালিয়াস পরিবর্তন করুন'); + expect( + bengali.profilePageConfigureTaskserver, 'টাস্ক সার্ভার কনফিগার করুন'); + expect(bengali.profilePageExportTasks, 'টাস্ক রপ্তানী করুন'); + expect(bengali.profilePageCopyConfigToNewProfile, + 'নতুন প্রোফাইলে কনফিগারেশন কপি করুন'); + expect(bengali.profilePageDeleteProfile, 'প্রোফাইল মুছুন'); + expect(bengali.profilePageAddNewProfile, 'নতুন প্রোফাইল যোগ করুন'); + expect(bengali.profilePageRenameAliasDialogueBoxTitle, + 'অ্যালিয়াস পরিবর্তন করুন'); + expect( + bengali.profilePageRenameAliasDialogueBoxNewAlias, 'নতুন অ্যালিয়াস'); + expect(bengali.profilePageRenameAliasDialogueBoxCancel, 'বাতিল করুন'); + expect(bengali.profilePageRenameAliasDialogueBoxSubmit, 'জমা দিন'); + expect(bengali.profilePageExportTasksDialogueTitle, 'রপ্তানি ফরম্যাট'); + expect(bengali.profilePageExportTasksDialogueSubtitle, + 'রপ্তানি ফরম্যাট নির্বাচন করুন'); + expect(bengali.manageTaskServerPageConfigureTaskserver, + 'টাস্ক সার্ভার কনফিগার করুন'); + expect(bengali.manageTaskServerPageConfigureTASKRC, 'TASKRC কনফিগার করুন'); + expect(bengali.manageTaskServerPageSetTaskRC, 'TaskRC সেট করুন'); + expect(bengali.manageTaskServerPageConfigureYourCertificate, + 'আপনার সার্টিফিকেট কনফিগার করুন'); + expect(bengali.manageTaskServerPageSelectCertificate, + 'সার্টিফিকেট নির্বাচন করুন'); + expect(bengali.manageTaskServerPageConfigureTaskserverKey, + 'টাস্ক সার্ভার কনফিগার করুন কী'); + expect(bengali.manageTaskServerPageSelectKey, 'কী নির্বাচন করুন'); + expect(bengali.manageTaskServerPageConfigureServerCertificate, + 'সার্ভার সার্টিফিকেট কনফিগার করুন'); + expect(bengali.manageTaskServerPageTaskRCFileIsVerified, + 'Task RC ফাইল যাচাই করা হয়েছে'); + expect(bengali.manageTaskServerPageConfigureTaskRCDialogueBoxTitle, + 'TaskRC কনফিগার করুন'); + expect(bengali.manageTaskServerPageConfigureTaskRCDialogueBoxSubtitle, + 'TaskRC সামগ্রী পেস্ট করুন বা taskrc ফাইল নির্বাচন করুন'); + expect(bengali.manageTaskServerPageConfigureTaskRCDialogueBoxInputFieldText, + 'এখানে আপনার TaskRC সামগ্রী পেস্ট করুন'); + expect(bengali.manageTaskServerPageConfigureTaskRCDialogueBoxOr, 'অথবা'); + expect(bengali.manageTaskServerPageConfigureTaskRCDialogueBoxSelectTaskRC, + 'TaskRC ফাইল নির্বাচন করুন'); + expect(bengali.addTaskTitle, 'কার্য যোগ করুন'); + expect(bengali.addTaskEnterTask, 'কার্য লিখুন'); + expect(bengali.addTaskDue, 'শেষ সময়'); + expect(bengali.addTaskSelectDueDate, 'শেষ সময় নির্বাচন করুন'); + expect(bengali.addTaskPriority, 'অগ্রাধিকার'); + expect(bengali.addTaskAddTags, 'ট্যাগ যোগ করুন'); + expect(bengali.addTaskCancel, 'বাতিল করুন'); + expect(bengali.addTaskAdd, 'যোগ করুন'); + expect(bengali.addTaskTimeInPast, 'নির্বাচিত সময় অতীতে রয়েছে।'); + expect(bengali.addTaskFieldCannotBeEmpty, + 'আপনি এই ক্ষেত্রটি খালি ছেড়ে দিতে পারবেন না!'); + expect(bengali.addTaskTaskAddedSuccessfully, + 'কর্ম সফলভাবে যোগ করা হয়েছে। সম্পাদনার জন্য ট্যাপ করুন'); + expect(bengali.aboutPageGitHubLink, + 'এই প্রকল্পটিকে উন্নত করতে আগ্রহী? আমাদের GitHub রিপোজিটরিতে যান।'); + expect(bengali.aboutPageProjectDescription, + 'এই প্রকল্পের লক্ষ্য Taskwarrior-এর জন্য একটি অ্যাপ তৈরি করা। এটি আপনার সকল প্ল্যাটফর্মে একটি টাস্ক ম্যানেজমেন্ট অ্যাপ। এটি আপনাকে আপনার কাজগুলি পরিচালনা করতে এবং আপনার প্রয়োজন অনুসারে সেগুলি ফিল্টার করতে সাহায্য করে।'); + expect(bengali.aboutPageAppBarTitle, 'সম্পর্কিত'); + }); +} diff --git a/test/utils/language/english_sentences_test.dart b/test/utils/language/english_sentences_test.dart new file mode 100644 index 00000000..d2ec4d5f --- /dev/null +++ b/test/utils/language/english_sentences_test.dart @@ -0,0 +1,169 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/language/english_sentences.dart'; + +void main() { + final english = EnglishSentences(); + + test('should provide correct English translations', () { + expect(english.helloWorld, 'Hello, World!'); + expect(english.homePageTitle, 'Home Page'); + expect(english.homePageLastModified, 'Last Modified'); + expect(english.homePageDue, 'Due'); + expect(english.homePageTaskWarriorNotConfigured, + 'TaskServer is not configured'); + expect(english.homePageSetup, 'Setup'); + expect(english.homePageFilter, 'Filter'); + expect(english.homePageMenu, 'Menu'); + expect(english.homePageExitApp, 'Exit App'); + expect(english.homePageAreYouSureYouWantToExit, + 'Are you sure you want to exit?'); + expect(english.homePageExit, 'Exit'); + expect(english.homePageCancel, 'Cancel'); + expect(english.homePageClickOnTheBottomRightButtonToStartAddingTasks, + 'Click on the bottom right button to start adding tasks'); + expect(english.homePageSearchNotFound, 'Search Not Found'); + expect(english.settingsPageTitle, 'Settings Page'); + expect(english.settingsPageSubtitle, 'Configure your preferences'); + expect(english.settingsPageMovingDataToNewDirectory, + 'Moving data to new directory'); + expect(english.settingsPageSyncOnStartTitle, 'Sync on Start'); + expect(english.settingsPageSyncOnStartDescription, + 'Automatically sync data on app start'); + expect( + english.settingsPageEnableSyncOnTaskCreateTitle, 'Sync on task create'); + expect(english.settingsPageEnableSyncOnTaskCreateDescription, + 'Enable automatic syncing when creating a new task'); + expect(english.settingsPageHighlightTaskTitle, 'Highlight the task'); + expect(english.settingsPageHighlightTaskDescription, + 'Make the border of task if only 1 day left'); + expect(english.settingsPageEnable24hrFormatTitle, 'Enable 24 hr format'); + expect(english.settingsPageEnable24hrFormatDescription, + 'Switch right to enable 24 hr format'); + expect(english.settingsPageSelectLanguage, 'Select the language'); + expect(english.settingsPageToggleNativeLanguage, + 'Toggle between your native language'); + expect(english.settingsPageSelectDirectoryTitle, 'Select the directory'); + expect(english.settingsPageSelectDirectoryDescription, + 'Select the directory where the TaskWarrior data is stored\nCurrent directory: '); + expect(english.settingsPageChangeDirectory, 'Change Directory'); + expect(english.settingsPageSetToDefault, 'Set To Default'); + expect(english.navDrawerProfile, 'Profile'); + expect(english.navDrawerReports, 'Reports'); + expect(english.navDrawerAbout, 'About'); + expect(english.navDrawerSettings, 'Settings'); + expect(english.navDrawerExit, 'Exit'); + expect(english.detailPageDescription, 'Description'); + expect(english.detailPageStatus, 'Status'); + expect(english.detailPageEntry, 'Entry'); + expect(english.detailPageModified, 'Modified'); + expect(english.detailPageStart, 'Start'); + expect(english.detailPageEnd, 'End'); + expect(english.detailPageDue, 'Due'); + expect(english.detailPageWait, 'Wait'); + expect(english.detailPageUntil, 'Until'); + expect(english.detailPagePriority, 'Priority'); + expect(english.detailPageProject, 'Project'); + expect(english.detailPageTags, 'Tags'); + expect(english.detailPageUrgency, 'Urgency'); + expect(english.detailPageID, 'ID'); + expect(english.filterDrawerApplyFilters, 'Apply Filters'); + expect(english.filterDrawerHideWaiting, 'Hide Waiting'); + expect(english.filterDrawerShowWaiting, 'Show Waiting'); + expect(english.filterDrawerPending, 'Pending'); + expect(english.filterDrawerCompleted, 'Completed'); + expect(english.filterDrawerFilterTagBy, 'Filter Tag By'); + expect(english.filterDrawerAND, 'AND'); + expect(english.filterDrawerOR, 'OR'); + expect(english.filterDrawerSortBy, 'Sort By'); + expect(english.filterDrawerCreated, 'Created'); + expect(english.filterDrawerModified, 'Modified'); + expect(english.filterDrawerStartTime, 'Start Time'); + expect(english.filterDrawerDueTill, 'Due till'); + expect(english.filterDrawerPriority, 'Priority'); + expect(english.filterDrawerProject, 'Project'); + expect(english.filterDrawerTags, 'Tags'); + expect(english.filterDrawerUrgency, 'Urgency'); + expect(english.filterDrawerResetSort, 'Reset Sort'); + expect(english.filterDrawerStatus, 'Status'); + expect(english.reportsPageTitle, 'Reports'); + expect(english.reportsPageCompleted, 'Completed'); + expect(english.reportsPagePending, 'Pending'); + expect(english.reportsPageTasks, 'Tasks'); + expect(english.reportsPageDaily, 'Daily'); + expect(english.reportsPageDailyBurnDownChart, 'Daily Burn Down Chart'); + expect(english.reportsPageDailyDayMonth, 'Day - Month'); + expect(english.reportsPageWeekly, 'Weekly'); + expect(english.reportsPageWeeklyBurnDownChart, 'Weekly Burn Down Chart'); + expect(english.reportsPageWeeklyWeeksYear, 'Weeks - Year'); + expect(english.reportsPageMonthly, 'Monthly'); + expect(english.reportsPageMonthlyBurnDownChart, 'Monthly Burn Down Chart'); + expect(english.reportsPageMonthlyMonthYear, 'Month - Year'); + expect(english.reportsPageNoTasksFound, 'No Tasks Found'); + expect(english.reportsPageAddTasksToSeeReports, 'Add Tasks To See Reports'); + expect(english.taskchampionTileDescription, + 'Switch to TaskWarrior sync with CCSync or Taskchampion Sync Server'); + expect(english.taskchampionTileTitle, 'Taskchampion sync'); + expect(english.ccsyncCredentials, 'CCync credentials'); + expect(english.deleteTaskConfirmation, 'Delete Tasks'); + expect(english.deleteTaskTitle, 'Delete All Tasks?'); + expect(english.deleteTaskWarning, + 'The action is irreversible and will delete all the tasks that are stored locally.'); + expect(english.profilePageProfile, 'Profile'); + expect(english.profilePageProfiles, 'Profiles'); + expect(english.profilePageCurrentProfile, 'Current Profile'); + expect(english.profilePageManageSelectedProfile, 'Manage Selected Profile'); + expect(english.profilePageRenameAlias, 'Rename Alias'); + expect(english.profilePageConfigureTaskserver, 'Configure Taskserver'); + expect(english.profilePageExportTasks, 'Export Tasks'); + expect(english.profilePageCopyConfigToNewProfile, + 'Copy Config To New Profile'); + expect(english.profilePageDeleteProfile, 'Delete Profile'); + expect(english.profilePageAddNewProfile, 'Add New Profile'); + expect(english.profilePageRenameAliasDialogueBoxTitle, 'Rename Alias'); + expect(english.profilePageRenameAliasDialogueBoxNewAlias, 'New Alias'); + expect(english.profilePageRenameAliasDialogueBoxCancel, 'Cancel'); + expect(english.profilePageRenameAliasDialogueBoxSubmit, 'Submit'); + expect(english.profilePageExportTasksDialogueTitle, 'Export format'); + expect(english.profilePageExportTasksDialogueSubtitle, + 'Choose the export format'); + expect(english.manageTaskServerPageConfigureTaskserver, + 'Configure Task Server'); + expect(english.manageTaskServerPageConfigureTASKRC, 'Configure TASKRC'); + expect(english.manageTaskServerPageSetTaskRC, 'Set TaskRC'); + expect(english.manageTaskServerPageConfigureYourCertificate, + 'Configure Your Certificate'); + expect(english.manageTaskServerPageSelectCertificate, 'Select Certificate'); + expect(english.manageTaskServerPageConfigureTaskserverKey, + 'Configure Task Server Key'); + expect(english.manageTaskServerPageSelectKey, 'Select Key'); + expect(english.manageTaskServerPageConfigureServerCertificate, + 'Configure Server Certificate'); + expect(english.manageTaskServerPageConfigureTaskRCDialogueBoxTitle, + 'Configure TaskRC'); + expect(english.manageTaskServerPageConfigureTaskRCDialogueBoxSubtitle, + 'Paste the TaskRC content or select taskrc file'); + expect(english.manageTaskServerPageConfigureTaskRCDialogueBoxInputFieldText, + 'Paste your TaskRC content here'); + expect(english.manageTaskServerPageConfigureTaskRCDialogueBoxOr, 'Or'); + expect(english.manageTaskServerPageConfigureTaskRCDialogueBoxSelectTaskRC, + 'Select TaskRC file'); + expect(english.addTaskTitle, 'Add Task'); + expect(english.addTaskEnterTask, 'Enter Task'); + expect(english.addTaskDue, 'Due'); + expect(english.addTaskSelectDueDate, 'Select Due Date'); + expect(english.addTaskPriority, 'Priority'); + expect(english.addTaskAddTags, 'Add Tags'); + expect(english.addTaskCancel, 'Cancel'); + expect(english.addTaskAdd, 'Add'); + expect(english.addTaskTimeInPast, 'The selected time is in the past.'); + expect(english.addTaskFieldCannotBeEmpty, + 'You cannot leave this field empty!'); + expect(english.addTaskTaskAddedSuccessfully, + 'Task Added Successfully. Tap to Edit'); + expect(english.aboutPageGitHubLink, + 'Eager to enhance this project? Visit our GitHub repository.'); + expect(english.aboutPageProjectDescription, + 'This project aims to build an app for Taskwarrior. It is your task management app across all platforms. It helps you manage your tasks and filter them as per your needs.'); + expect(english.aboutPageAppBarTitle, 'About'); + }); +} diff --git a/test/utils/language/french_sentences_test.dart b/test/utils/language/french_sentences_test.dart new file mode 100644 index 00000000..1a271244 --- /dev/null +++ b/test/utils/language/french_sentences_test.dart @@ -0,0 +1,181 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/language/french_sentences.dart'; + +void main() { + final french = FrenchSentences(); + + test('should provide correct French translations', () { + expect(french.helloWorld, 'Bonjour, le monde!'); + expect(french.homePageTitle, 'Page d\'accueil'); + expect(french.homePageLastModified, 'Dernière modification'); + expect(french.homePageDue, 'Échéance'); + expect(french.homePageTaskWarriorNotConfigured, 'TaskServer non configuré'); + expect(french.homePageSetup, 'Configuration'); + expect(french.homePageFilter, 'Filtre'); + expect(french.homePageMenu, 'Menu'); + expect(french.homePageExitApp, 'Quitter l\'application'); + expect(french.homePageAreYouSureYouWantToExit, + 'Êtes-vous sûr de vouloir quitter l\'application ?'); + expect(french.homePageExit, 'Quitter'); + expect(french.homePageCancel, 'Annuler'); + expect(french.homePageClickOnTheBottomRightButtonToStartAddingTasks, + 'Cliquez sur le bouton en bas à droite pour commencer à ajouter des tâches'); + expect(french.homePageSearchNotFound, 'Aucun résultat pour la recherche'); + expect(french.settingsPageTitle, 'Page des paramètres'); + expect(french.settingsPageSubtitle, 'Configurez vos préférences'); + expect(french.settingsPageMovingDataToNewDirectory, + 'Déplacement des données vers un nouveau répertoire'); + expect(french.settingsPageSyncOnStartTitle, + 'Synchroniser les données automatiquement au démarrage'); + expect( + french.settingsPageSyncOnStartDescription, 'Synchroniser au démarrage'); + expect(french.settingsPageEnableSyncOnTaskCreateTitle, + 'Activer la synchronisation automatique lors de la création de nouvelles tâches'); + expect(french.settingsPageEnableSyncOnTaskCreateDescription, + 'Activer la synchronisation automatique lors de la création de nouvelles tâches'); + expect(french.settingsPageHighlightTaskTitle, + 'Surbrillance des tâches avec 1 jour restant'); + expect(french.settingsPageHighlightTaskDescription, + 'Surbrillance des tâches avec 1 jour restant'); + expect(french.settingsPageEnable24hrFormatTitle, + 'Activer le format 24 heures'); + expect(french.settingsPageEnable24hrFormatDescription, + 'Activer le format 24 heures'); + expect(french.settingsPageSelectLanguage, 'Choisir la langue'); + expect(french.settingsPageToggleNativeLanguage, + 'Basculer entre les langues natives'); + expect(french.settingsPageSelectDirectoryTitle, 'Choisir un répertoire'); + expect(french.settingsPageSelectDirectoryDescription, + 'Choisissez le répertoire où les données TaskWarrior sont stockées\nRépertoire actuel : '); + expect(french.settingsPageChangeDirectory, 'Changer de répertoire'); + expect(french.settingsPageSetToDefault, 'Définir par défaut'); + expect(french.navDrawerProfile, 'Profil'); + expect(french.navDrawerReports, 'Rapports'); + expect(french.navDrawerAbout, 'À propos'); + expect(french.navDrawerSettings, 'Paramètres'); + expect(french.navDrawerExit, 'Quitter'); + expect(french.detailPageDescription, 'Description'); + expect(french.detailPageStatus, 'Statut'); + expect(french.detailPageEntry, 'Entrée'); + expect(french.detailPageModified, 'Modifié'); + expect(french.detailPageStart, 'Début'); + expect(french.detailPageEnd, 'Fin'); + expect(french.detailPageDue, 'Échéance'); + expect(french.detailPageWait, 'Attendre'); + expect(french.detailPageUntil, 'Jusqu\'à'); + expect(french.detailPagePriority, 'Priorité'); + expect(french.detailPageProject, 'Projet'); + expect(french.detailPageTags, 'Tags'); + expect(french.detailPageUrgency, 'Urgence'); + expect(french.detailPageID, 'ID'); + expect(french.filterDrawerApplyFilters, 'Appliquer les filtres'); + expect(french.filterDrawerHideWaiting, 'Masquer les en attente'); + expect(french.filterDrawerShowWaiting, 'Afficher les en attente'); + expect(french.filterDrawerPending, 'En attente'); + expect(french.filterDrawerCompleted, 'Complété'); + expect(french.filterDrawerFilterTagBy, 'Filtrer par tag'); + expect(french.filterDrawerAND, 'et'); + expect(french.filterDrawerOR, 'ou'); + expect(french.filterDrawerSortBy, 'Trier par'); + expect(french.filterDrawerCreated, 'Créé'); + expect(french.filterDrawerModified, 'Modifié'); + expect(french.filterDrawerStartTime, 'Heure de début'); + expect(french.filterDrawerDueTill, 'Jusqu\'à l\'échéance'); + expect(french.filterDrawerPriority, 'Priorité'); + expect(french.filterDrawerProject, 'Projet'); + expect(french.filterDrawerTags, 'Tags'); + expect(french.filterDrawerUrgency, 'Urgence'); + expect(french.filterDrawerResetSort, 'Réinitialiser le tri'); + expect(french.filterDrawerStatus, 'Statut'); + expect(french.reportsPageTitle, 'Rapports'); + expect(french.reportsPageCompleted, 'Complété'); + expect(french.reportsPagePending, 'En attente'); + expect(french.reportsPageTasks, 'Tâches'); + expect(french.reportsPageDaily, 'Quotidien'); + expect(french.reportsPageDailyBurnDownChart, + 'Graphique de burn down quotidien'); + expect(french.reportsPageDailyDayMonth, 'Jour - Mois'); + expect(french.reportsPageWeekly, 'Hebdomadaire'); + expect(french.reportsPageWeeklyBurnDownChart, + 'Graphique de burn down hebdomadaire'); + expect(french.reportsPageWeeklyWeeksYear, 'Semaine - Année'); + expect(french.reportsPageMonthly, 'Mensuel'); + expect(french.reportsPageMonthlyBurnDownChart, + 'Graphique de burn down mensuel'); + expect(french.reportsPageMonthlyMonthYear, 'Mois - Année'); + expect(french.reportsPageNoTasksFound, 'Aucune tâche trouvée'); + expect(french.reportsPageAddTasksToSeeReports, + 'Ajoutez des tâches pour voir les rapports'); + expect(french.taskchampionTileDescription, + 'Basculez la synchronisation de TaskWarrior vers le serveur de synchronisation CCSync ou Taskchampion'); + expect(french.taskchampionTileTitle, 'Synchronisation Taskchampion'); + expect(french.ccsyncCredentials, 'Identifiants CCSync'); + expect(french.deleteTaskConfirmation, 'Supprimer la tâche'); + expect(french.deleteTaskTitle, 'Supprimer toutes les tâches ?'); + expect(french.deleteTaskWarning, + 'Cette action est irréversible et supprimera toutes les tâches stockées localement.'); + expect(french.profilePageProfile, 'Profil'); + expect(french.profilePageProfiles, 'Profils'); + expect(french.profilePageCurrentProfile, 'Profil actuel'); + expect( + french.profilePageManageSelectedProfile, 'Gérer le profil sélectionné'); + expect(french.profilePageRenameAlias, 'Renommer l\'alias'); + expect(french.profilePageConfigureTaskserver, + 'Configurer le serveur de tâches'); + expect(french.profilePageExportTasks, 'Exporter les tâches'); + expect(french.profilePageCopyConfigToNewProfile, + 'Copier la configuration vers un nouveau profil'); + expect(french.profilePageDeleteProfile, 'Supprimer le profil'); + expect(french.profilePageAddNewProfile, 'Ajouter un nouveau profil'); + expect(french.profilePageRenameAliasDialogueBoxTitle, 'Renommer l\'alias'); + expect(french.profilePageRenameAliasDialogueBoxNewAlias, 'Nouvel alias'); + expect(french.profilePageRenameAliasDialogueBoxCancel, 'Annuler'); + expect(french.profilePageRenameAliasDialogueBoxSubmit, 'Soumettre'); + expect(french.profilePageExportTasksDialogueTitle, 'Format d\'exportation'); + expect(french.profilePageExportTasksDialogueSubtitle, + 'Choisissez le format d\'exportation'); + expect(french.manageTaskServerPageConfigureTaskserver, + 'Configurer le serveur de tâches'); + expect(french.manageTaskServerPageConfigureTASKRC, 'Configurer TASKRC'); + expect(french.manageTaskServerPageSetTaskRC, 'Définir TaskRC'); + expect(french.manageTaskServerPageConfigureYourCertificate, + 'Configurer votre certificat'); + expect(french.manageTaskServerPageSelectCertificate, + 'Sélectionner un certificat'); + expect(french.manageTaskServerPageConfigureTaskserverKey, + 'Configurer la clé du serveur de tâches'); + expect(french.manageTaskServerPageSelectKey, 'Sélectionner une clé'); + expect(french.manageTaskServerPageConfigureServerCertificate, + 'Configurer le certificat du serveur'); + expect(french.manageTaskServerPageTaskRCFileIsVerified, + 'Le fichier Task RC est vérifié'); + expect(french.manageTaskServerPageConfigureTaskRCDialogueBoxTitle, + 'Configurer TaskRC'); + expect(french.manageTaskServerPageConfigureTaskRCDialogueBoxSubtitle, + 'Collez le contenu de TaskRC ou sélectionnez un fichier taskrc'); + expect(french.manageTaskServerPageConfigureTaskRCDialogueBoxInputFieldText, + 'Collez votre contenu TaskRC ici'); + expect(french.manageTaskServerPageConfigureTaskRCDialogueBoxOr, 'ou'); + expect(french.manageTaskServerPageConfigureTaskRCDialogueBoxSelectTaskRC, + 'Sélectionner un fichier TaskRC'); + expect(french.addTaskTitle, 'Ajouter une tâche'); + expect(french.addTaskEnterTask, 'Entrer une tâche'); + expect(french.addTaskDue, 'Échéance'); + expect(french.addTaskSelectDueDate, 'Sélectionner la date d\'échéance'); + expect(french.addTaskPriority, 'Priorité'); + expect(french.addTaskAddTags, 'Ajouter des tags'); + expect(french.addTaskCancel, 'Annuler'); + expect(french.addTaskAdd, 'Ajouter'); + expect( + french.addTaskTimeInPast, 'L\'heure sélectionnée est dans le passé.'); + expect(french.addTaskFieldCannotBeEmpty, + 'Vous ne pouvez pas laisser ce champ vide !'); + expect(french.addTaskTaskAddedSuccessfully, + 'Tâche ajoutée avec succès. Appuyez pour éditer'); + expect(french.aboutPageGitHubLink, + 'Enthousiaste à l\'idée d\'améliorer ce projet ? Visitez notre dépôt GitHub.'); + expect(french.aboutPageProjectDescription, + 'Ce projet vise à créer une application pour Taskwarrior. C\'est votre application de gestion des tâches sur toutes les plateformes. Elle vous aide à gérer vos tâches et à les filtrer selon vos besoins.'); + expect(french.aboutPageAppBarTitle, 'À propos'); + }); +} diff --git a/test/utils/language/hindi_sentences_test.dart b/test/utils/language/hindi_sentences_test.dart new file mode 100644 index 00000000..ac5f5616 --- /dev/null +++ b/test/utils/language/hindi_sentences_test.dart @@ -0,0 +1,175 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/language/hindi_sentences.dart'; + +void main() { + final hindi = HindiSentences(); + + test('should provide correct Hindi translations', () { + expect(hindi.helloWorld, 'नमस्ते दुनिया!'); + expect(hindi.homePageTitle, 'होम पेज'); + expect(hindi.homePageLastModified, 'अंतिम बार संशोधित'); + expect(hindi.homePageDue, 'देय'); + expect( + hindi.homePageTaskWarriorNotConfigured, 'TaskServer कॉन्फ़िगर नहीं है'); + expect(hindi.homePageSetup, 'सेटअप'); + expect(hindi.homePageFilter, 'फ़िल्टर'); + expect(hindi.homePageMenu, 'मेन्यू'); + expect(hindi.homePageExitApp, 'ऐप बंद करें'); + expect(hindi.homePageAreYouSureYouWantToExit, + 'क्या आप वाकई ऐप बंद करना चाहते हैं?'); + expect(hindi.homePageExit, 'बाहर जाओ'); + expect(hindi.homePageCancel, 'रद्द करें'); + expect(hindi.homePageClickOnTheBottomRightButtonToStartAddingTasks, + 'कार्यों को जोड़ना शुरू करने के लिए नीचे दाएं बटन पर क्लिक करें'); + expect(hindi.homePageSearchNotFound, 'खोजने पर नहीं मिला'); + expect(hindi.settingsPageTitle, 'सेटिंग्स पेज'); + expect(hindi.settingsPageSubtitle, 'अपनी पसंद सेट करें'); + expect(hindi.settingsPageMovingDataToNewDirectory, + 'नए निर्देशिका में डेटा को ले जा रहा है'); + expect(hindi.settingsPageSyncOnStartTitle, + 'ऐप स्टार्ट पर डेटा स्वचालित सिंक करें'); + expect(hindi.settingsPageSyncOnStartDescription, 'स्टार्ट पर सिंक करें'); + expect(hindi.settingsPageEnableSyncOnTaskCreateTitle, + 'नई टास्क बनाते समय स्वचालित सिंकिंग सक्षम करें'); + expect(hindi.settingsPageEnableSyncOnTaskCreateDescription, + 'नई टास्क बनाते समय स्वचालित सिंकिंग सक्षम करें'); + expect(hindi.settingsPageHighlightTaskTitle, + 'केवल 1 दिन शेष होने पर कार्य की सीमा बनाएं'); + expect(hindi.settingsPageHighlightTaskDescription, + 'केवल 1 दिन शेष होने पर कार्य की सीमा बनाएं'); + expect(hindi.settingsPageEnable24hrFormatTitle, + '24 घंटे का प्रारूप सक्षम करें'); + expect(hindi.settingsPageEnable24hrFormatDescription, + '24 घंटे का प्रारूप सक्षम करें'); + expect(hindi.settingsPageSelectLanguage, 'भाषा चुनें'); + expect(hindi.settingsPageToggleNativeLanguage, + 'अपनी मातृभाषा के बीच टॉगल करें'); + expect(hindi.settingsPageSelectDirectoryTitle, 'निर्देशिका चुनें'); + expect(hindi.settingsPageSelectDirectoryDescription, + 'निर्देशिका चुनें जहां TaskWarrior डेटा स्टोर होता है\nवर्तमान निर्देशिका: '); + expect(hindi.settingsPageChangeDirectory, 'निर्देशिका बदलें'); + expect(hindi.settingsPageSetToDefault, 'डिफॉल्ट पर सेट करें'); + expect(hindi.navDrawerProfile, 'प्रोफ़ाइल'); + expect(hindi.navDrawerReports, 'रिपोर्ट्स'); + expect(hindi.navDrawerAbout, 'के बारे में'); + expect(hindi.navDrawerSettings, 'सेटिंग्स'); + expect(hindi.navDrawerExit, 'बाहर जाओ'); + expect(hindi.detailPageDescription, 'विवरण'); + expect(hindi.detailPageStatus, 'स्थिति'); + expect(hindi.detailPageEntry, 'प्रवेश'); + expect(hindi.detailPageModified, 'संशोधित'); + expect(hindi.detailPageStart, 'प्रारंभ'); + expect(hindi.detailPageEnd, 'अंत'); + expect(hindi.detailPageDue, 'देय'); + expect(hindi.detailPageWait, 'प्रतीक्षा करें'); + expect(hindi.detailPageUntil, 'तक'); + expect(hindi.detailPagePriority, 'प्राथमिकता'); + expect(hindi.detailPageProject, 'परियोजना'); + expect(hindi.detailPageTags, 'टैग'); + expect(hindi.detailPageUrgency, 'तत्कालता'); + expect(hindi.detailPageID, 'आयडी'); + expect(hindi.filterDrawerApplyFilters, 'फिल्टर लागू करें'); + expect(hindi.filterDrawerHideWaiting, 'इंतजार छिपाएं'); + expect(hindi.filterDrawerShowWaiting, 'इंतजार दिखाएं'); + expect(hindi.filterDrawerPending, 'अपूर्ण'); + expect(hindi.filterDrawerCompleted, 'पूर्ण'); + expect(hindi.filterDrawerFilterTagBy, 'टैग से फ़िल्टर करें'); + expect(hindi.filterDrawerAND, 'और'); + expect(hindi.filterDrawerOR, 'या'); + expect(hindi.filterDrawerSortBy, 'इसके आधार पर क्रमबद्ध करें'); + expect(hindi.filterDrawerCreated, 'निर्मित'); + expect(hindi.filterDrawerModified, 'संशोधित'); + expect(hindi.filterDrawerStartTime, 'शुरुआत समय'); + expect(hindi.filterDrawerDueTill, 'तक बकाया'); + expect(hindi.filterDrawerPriority, 'प्राथमिकता'); + expect(hindi.filterDrawerProject, 'परियोजना'); + expect(hindi.filterDrawerTags, 'टैग्स'); + expect(hindi.filterDrawerUrgency, 'तत्कालता'); + expect(hindi.filterDrawerResetSort, 'सॉर्ट रीसेट करें'); + expect(hindi.filterDrawerStatus, 'स्थिती'); + expect(hindi.reportsPageTitle, 'रिपोर्ट्स'); + expect(hindi.reportsPageCompleted, 'पूर्ण'); + expect(hindi.reportsPagePending, 'अपूर्ण'); + expect(hindi.reportsPageTasks, 'कार्य'); + expect(hindi.reportsPageDaily, 'दैनिक'); + expect(hindi.reportsPageDailyBurnDownChart, 'दैनिक बर्न डाउन चार्ट'); + expect(hindi.reportsPageDailyDayMonth, 'दिन - माह'); + expect(hindi.reportsPageWeekly, 'साप्ताहिक'); + expect(hindi.reportsPageWeeklyBurnDownChart, 'साप्ताहिक बर्न डाउन चार्ट'); + expect(hindi.reportsPageWeeklyWeeksYear, 'सप्ताह - वर्ष'); + expect(hindi.reportsPageMonthly, 'मासिक'); + expect(hindi.reportsPageMonthlyBurnDownChart, 'मासिक बर्न डाउन चार्ट'); + expect(hindi.reportsPageMonthlyMonthYear, 'माह - वर्ष'); + expect(hindi.reportsPageNoTasksFound, 'कोई कार्य नहीं मिला'); + expect(hindi.reportsPageAddTasksToSeeReports, + 'रिपोर्ट देखने के लिए कार्य जोड़ें'); + expect(hindi.taskchampionTileDescription, + 'CCSync या Taskchampion सिंक सर्वर के साथ TaskWarrior सिंक पर स्विच करें'); + expect(hindi.taskchampionTileTitle, 'Taskchampion सिंक'); + expect(hindi.ccsyncCredentials, 'CCync क्रेडेन्शियल'); + expect(hindi.deleteTaskConfirmation, 'कार्य हटाएं'); + expect(hindi.deleteTaskTitle, 'सभी कार्य हटाएं?'); + expect(hindi.deleteTaskWarning, + 'यह क्रिया अपरिवर्तनीय है और यह सभी स्थानीय रूप से संग्रहीत कार्यों को हटा देगी।'); + expect(hindi.profilePageProfile, 'प्रोफ़ाइल'); + expect(hindi.profilePageProfiles, 'प्रोफ़ाइल्स'); + expect(hindi.profilePageCurrentProfile, 'वर्तमान प्रोफ़ाइल'); + expect(hindi.profilePageManageSelectedProfile, + 'चुनी हुई प्रोफ़ाइल प्रबंधित करें'); + expect(hindi.profilePageRenameAlias, 'उपनाम बदलें'); + expect(hindi.profilePageConfigureTaskserver, 'टास्क सर्वर कॉन्फ़िगर करें'); + expect(hindi.profilePageExportTasks, 'कार्य निर्यात करें'); + expect(hindi.profilePageCopyConfigToNewProfile, + 'नई प्रोफ़ाइल पर कॉन्फ़िगरेशन कॉपी करें'); + expect(hindi.profilePageDeleteProfile, 'प्रोफ़ाइल हटाएँ'); + expect(hindi.profilePageAddNewProfile, 'नई प्रोफ़ाइल जोड़ें'); + expect(hindi.profilePageRenameAliasDialogueBoxTitle, 'उपनाम बदलें'); + expect(hindi.profilePageRenameAliasDialogueBoxNewAlias, 'नया उपनाम'); + expect(hindi.profilePageRenameAliasDialogueBoxCancel, 'रद्द करें'); + expect(hindi.profilePageRenameAliasDialogueBoxSubmit, 'प्रस्तुत करें'); + expect(hindi.profilePageExportTasksDialogueTitle, 'निर्यात प्रारूप'); + expect( + hindi.profilePageExportTasksDialogueSubtitle, 'निर्यात प्रारूप चुनें'); + expect(hindi.manageTaskServerPageConfigureTaskserver, + 'टास्क सर्वर कॉन्फ़िगर करें'); + expect(hindi.manageTaskServerPageConfigureTASKRC, 'TASKRC कॉन्फ़िगर करें'); + expect(hindi.manageTaskServerPageSetTaskRC, 'TaskRC सेट करें'); + expect(hindi.manageTaskServerPageConfigureYourCertificate, + 'अपने सर्टिफिकेट को कॉन्फ़िगर करें'); + expect(hindi.manageTaskServerPageSelectCertificate, 'सर्टिफिकेट चुनें'); + expect(hindi.manageTaskServerPageConfigureTaskserverKey, + 'टास्क सर्वर की कॉन्फ़िगर करें'); + expect(hindi.manageTaskServerPageSelectKey, 'कुंजी चुनें'); + expect(hindi.manageTaskServerPageConfigureServerCertificate, + 'सर्वर सर्टिफिकेट कॉन्फ़िगर करें'); + expect(hindi.manageTaskServerPageTaskRCFileIsVerified, + 'Task RC फ़ाइल सत्यापित की गई है'); + expect(hindi.manageTaskServerPageConfigureTaskRCDialogueBoxTitle, + 'TaskRC कॉन्फ़िगर करें'); + expect(hindi.manageTaskServerPageConfigureTaskRCDialogueBoxSubtitle, + 'TaskRC सामग्री पेस्ट करें या taskrc फ़ाइल चुनें'); + expect(hindi.manageTaskServerPageConfigureTaskRCDialogueBoxInputFieldText, + 'यहाँ अपनी TaskRC सामग्री पेस्ट करें'); + expect(hindi.manageTaskServerPageConfigureTaskRCDialogueBoxOr, 'या'); + expect(hindi.manageTaskServerPageConfigureTaskRCDialogueBoxSelectTaskRC, + 'TaskRC फ़ाइल चुनें'); + expect(hindi.addTaskTitle, 'कार्य जोड़ें'); + expect(hindi.addTaskEnterTask, 'कार्य दर्ज करें'); + expect(hindi.addTaskDue, 'देय'); + expect(hindi.addTaskSelectDueDate, 'नियत तिथि चुनें'); + expect(hindi.addTaskPriority, 'प्राथमिकता'); + expect(hindi.addTaskAddTags, 'टैग जोड़ें'); + expect(hindi.addTaskCancel, 'रद्द करें'); + expect(hindi.addTaskAdd, 'जोड़ें'); + expect(hindi.addTaskTimeInPast, 'चुनी गई समय अतीत में है।'); + expect(hindi.addTaskFieldCannotBeEmpty, + 'आप इस फ़ील्ड को खाली नहीं छोड़ सकते!'); + expect(hindi.addTaskTaskAddedSuccessfully, + 'कार्य सफलतापूर्वक जोड़ा गया। संपादित करने के लिए टैप करें'); + expect(hindi.aboutPageGitHubLink, + 'इस परियोजना को बढ़ाने के लिए उत्सुक हैं? हमारे GitHub रिपॉज़िटरी पर जाएं।'); + expect(hindi.aboutPageProjectDescription, + 'यह परियोजना Taskwarrior के लिए एक ऐप बनाने का लक्ष्य रखती है। यह आपके सभी प्लेटफार्मों पर कार्य प्रबंधन ऐप है। यह आपको अपने कार्यों को प्रबंधित करने और उन्हें अपनी आवश्यकताओं के अनुसार छानने में मदद करता है।'); + expect(hindi.aboutPageAppBarTitle, 'के बारे में'); + }); +} diff --git a/test/utils/language/marathi_sentences_test.dart b/test/utils/language/marathi_sentences_test.dart new file mode 100644 index 00000000..2e15cef8 --- /dev/null +++ b/test/utils/language/marathi_sentences_test.dart @@ -0,0 +1,176 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/language/marathi_sentences.dart'; + +void main() { + final marathi = MarathiSentences(); + + test('should provide correct Marathi translations', () { + expect(marathi.helloWorld, 'नमस्कार, जग!'); + expect(marathi.homePageTitle, 'होम पेज'); + expect(marathi.homePageLastModified, 'शेवटचा बदल'); + expect(marathi.homePageDue, 'द्यावे'); + expect(marathi.homePageTaskWarriorNotConfigured, 'TaskServer संरचीत नाही'); + expect(marathi.homePageSetup, 'सेटअप'); + expect(marathi.homePageFilter, 'फिल्टर'); + expect(marathi.homePageMenu, 'मेनू'); + expect(marathi.homePageExitApp, 'अ‍ॅप बंद करा'); + expect(marathi.homePageAreYouSureYouWantToExit, + 'आपण खात्री आहात की आपण अ‍ॅप बंद करू इच्छिता?'); + expect(marathi.homePageExit, 'बाहेर पडा'); + expect(marathi.homePageCancel, 'रद्द करा'); + expect(marathi.homePageClickOnTheBottomRightButtonToStartAddingTasks, + 'कार्ये जोडणे सुरू करण्यासाठी तळाशी उजव्या बटणावर क्लिक करा'); + expect(marathi.homePageSearchNotFound, 'शोध सापडला नाही'); + expect(marathi.settingsPageTitle, 'सेटिंग्स पेज'); + expect(marathi.settingsPageSubtitle, 'तुमची पसंती सेट करा'); + expect(marathi.settingsPageMovingDataToNewDirectory, + 'नवीन निर्देशिकेत डेटा हलवत आहे'); + expect(marathi.settingsPageSyncOnStartTitle, 'सुरू करण्यावर सिंक करा'); + expect(marathi.settingsPageSyncOnStartDescription, + 'अ‍ॅप सुरू करताना डेटा स्वयंसिंक करा'); + expect(marathi.settingsPageEnableSyncOnTaskCreateTitle, + 'नवीन कार्य तयार करताना स्वयंसिंकिंग सक्षम करा'); + expect(marathi.settingsPageEnableSyncOnTaskCreateDescription, + 'नवीन कार्य तयार करताना स्वयंसिंकिंग सक्षम करा'); + expect(marathi.settingsPageHighlightTaskTitle, + 'फक्त 1 दिवस शेष असताना कार्याची सीमा बनवा'); + expect(marathi.settingsPageHighlightTaskDescription, + 'फक्त 1 दिवस शेष असताना कार्याची सीमा बनवा'); + expect(marathi.settingsPageEnable24hrFormatTitle, + '24 तासाचा स्वरूप सक्षम करा'); + expect(marathi.settingsPageEnable24hrFormatDescription, + '24 तासाचा स्वरूप सक्षम करा'); + expect(marathi.settingsPageSelectLanguage, 'भाषा निवडा'); + expect(marathi.settingsPageToggleNativeLanguage, + 'तुमच्या मूल भाषेतर्फे टॉगल करा'); + expect(marathi.settingsPageSelectDirectoryTitle, 'निर्देशिका निवडा'); + expect(marathi.settingsPageSelectDirectoryDescription, + 'निर्देशिका निवडा जिथे TaskWarrior डेटा स्टोर केला जातो\nवर्तमान निर्देशिका: '); + expect(marathi.settingsPageChangeDirectory, 'डिरेक्टरी बदला'); + expect(marathi.settingsPageSetToDefault, 'डीफॉल्टवर सेट करा'); + expect(marathi.navDrawerProfile, 'प्रोफ़ाइल'); + expect(marathi.navDrawerReports, 'अहवाल'); + expect(marathi.navDrawerAbout, 'चरित्र'); + expect(marathi.navDrawerSettings, 'सेटिंग्स'); + expect(marathi.navDrawerExit, 'बाहेर पडा'); + expect(marathi.detailPageDescription, 'वर्णन'); + expect(marathi.detailPageStatus, 'स्थिती'); + expect(marathi.detailPageEntry, 'प्रवेश'); + expect(marathi.detailPageModified, 'संशोधित'); + expect(marathi.detailPageStart, 'सुरूवात'); + expect(marathi.detailPageEnd, 'शेवट'); + expect(marathi.detailPageDue, 'देय'); + expect(marathi.detailPageWait, 'प्रतीक्षा'); + expect(marathi.detailPageUntil, 'पर्यंत'); + expect(marathi.detailPagePriority, 'प्राधान्य'); + expect(marathi.detailPageProject, 'प्रकल्प'); + expect(marathi.detailPageTags, 'टॅग'); + expect(marathi.detailPageUrgency, 'तातडी'); + expect(marathi.detailPageID, 'आयडी'); + expect(marathi.filterDrawerApplyFilters, 'फिल्टर लागू करा'); + expect(marathi.filterDrawerHideWaiting, 'वाट लपवा'); + expect(marathi.filterDrawerShowWaiting, 'वाट दाखवा'); + expect(marathi.filterDrawerPending, 'प्रलंबित'); + expect(marathi.filterDrawerCompleted, 'पूर्ण'); + expect(marathi.filterDrawerFilterTagBy, 'टॅगवर फिल्टर करा'); + expect(marathi.filterDrawerAND, 'आणि'); + expect(marathi.filterDrawerOR, 'किंवा'); + expect(marathi.filterDrawerSortBy, 'यानुसार क्रमबद्ध करा'); + expect(marathi.filterDrawerCreated, 'सृष्ट'); + expect(marathi.filterDrawerModified, 'संशोधित'); + expect(marathi.filterDrawerStartTime, 'सुरूवातीचा वेळ'); + expect(marathi.filterDrawerDueTill, 'पर्यंतचा देय'); + expect(marathi.filterDrawerPriority, 'प्राधान्य'); + expect(marathi.filterDrawerProject, 'प्रकल्प'); + expect(marathi.filterDrawerTags, 'टॅग्ज'); + expect(marathi.filterDrawerUrgency, 'तातडी'); + expect(marathi.filterDrawerResetSort, 'क्रमवारी रीसेट करा'); + expect(marathi.filterDrawerStatus, 'स्थिति'); + expect(marathi.reportsPageTitle, 'अहवाल'); + expect(marathi.reportsPageCompleted, 'पूर्ण'); + expect(marathi.reportsPagePending, 'प्रलंबित'); + expect(marathi.reportsPageTasks, 'काम'); + expect(marathi.reportsPageDaily, 'दैनिक'); + expect(marathi.reportsPageDailyBurnDownChart, 'दैनिक बर्न डाउन चार्ट'); + expect(marathi.reportsPageDailyDayMonth, 'दिवस - महिना'); + expect(marathi.reportsPageWeekly, 'साप्ताहिक'); + expect(marathi.reportsPageWeeklyBurnDownChart, 'साप्ताहिक बर्न डाउन चार्ट'); + expect(marathi.reportsPageWeeklyWeeksYear, 'सप्ताह - वर्ष'); + expect(marathi.reportsPageMonthly, 'मासिक'); + expect(marathi.reportsPageMonthlyBurnDownChart, 'मासिक बर्न डाउन चार्ट'); + expect(marathi.reportsPageMonthlyMonthYear, 'महिना - वर्ष'); + expect(marathi.reportsPageNoTasksFound, 'कोणतेही काम सापडले नाहीत'); + expect( + marathi.reportsPageAddTasksToSeeReports, 'अहवाल पाहण्यासाठी काम जोडा'); + expect(marathi.taskchampionTileDescription, + 'CCSync किंवा Taskchampion Sync Server सह TaskWarrior सिंक वर स्विच करा'); + expect(marathi.taskchampionTileTitle, 'Taskchampion सिंक'); + expect(marathi.ccsyncCredentials, 'CCync क्रेडेन्शियल'); + expect(marathi.deleteTaskConfirmation, 'कार्य हटवा'); + expect(marathi.deleteTaskTitle, 'सर्व कार्य हटवायचे का?'); + expect(marathi.deleteTaskWarning, + 'ही क्रिया अपरिवर्तनीय आहे आणि हे सर्व स्थानिक पातळीवर संग्रहित केलेले कार्य हटवेल.'); + expect(marathi.profilePageProfile, 'प्रोफाइल'); + expect(marathi.profilePageProfiles, 'प्रोफाइल्स'); + expect(marathi.profilePageCurrentProfile, 'सद्याचा प्रोफाइल'); + expect(marathi.profilePageManageSelectedProfile, + 'चयनित प्रोफाइल व्यवस्थापित करा'); + expect(marathi.profilePageRenameAlias, 'उपनाम पुनर्नामित करा'); + expect( + marathi.profilePageConfigureTaskserver, 'टास्क सर्व्हर कॉन्फिगर करा'); + expect(marathi.profilePageExportTasks, 'टास्क निर्यात करा'); + expect(marathi.profilePageCopyConfigToNewProfile, + 'नवीन प्रोफाइलवर कॉन्फिगरेशन कॉपी करा'); + expect(marathi.profilePageDeleteProfile, 'प्रोफाइल हटवा'); + expect(marathi.profilePageAddNewProfile, 'नवीन प्रोफाइल जोडा'); + expect( + marathi.profilePageRenameAliasDialogueBoxTitle, 'उपनाम पुनर्नामित करा'); + expect(marathi.profilePageRenameAliasDialogueBoxNewAlias, 'नवा उपनाम'); + expect(marathi.profilePageRenameAliasDialogueBoxCancel, 'रद्द करा'); + expect(marathi.profilePageRenameAliasDialogueBoxSubmit, 'सादर करा'); + expect(marathi.profilePageExportTasksDialogueTitle, 'निर्यात प्रारूप'); + expect(marathi.profilePageExportTasksDialogueSubtitle, + 'निर्यात प्रारूप निवडा'); + expect(marathi.manageTaskServerPageConfigureTaskserver, + 'टास्क सर्व्हर कॉन्फिगर करा'); + expect(marathi.manageTaskServerPageConfigureTASKRC, 'TASKRC कॉन्फिगर करा'); + expect(marathi.manageTaskServerPageSetTaskRC, 'TaskRC सेट करा'); + expect(marathi.manageTaskServerPageConfigureYourCertificate, + 'आपला सर्टिफिकेट कॉन्फिगर करा'); + expect(marathi.manageTaskServerPageSelectCertificate, 'सर्टिफिकेट निवडा'); + expect(marathi.manageTaskServerPageConfigureTaskserverKey, + 'टास्क सर्व्हर की कॉन्फिगर करा'); + expect(marathi.manageTaskServerPageSelectKey, 'की निवडा'); + expect(marathi.manageTaskServerPageConfigureServerCertificate, + 'सर्व्हर सर्टिफिकेट कॉन्फिगर करा'); + expect(marathi.manageTaskServerPageTaskRCFileIsVerified, + 'Task RC फाइल पडताळली गेली आहे'); + expect(marathi.manageTaskServerPageConfigureTaskRCDialogueBoxTitle, + 'TaskRC कॉन्फिगर करा'); + expect(marathi.manageTaskServerPageConfigureTaskRCDialogueBoxSubtitle, + 'TaskRC सामग्री पेस्ट करा किंवा taskrc फाइल निवडा'); + expect(marathi.manageTaskServerPageConfigureTaskRCDialogueBoxInputFieldText, + 'येथे आपली TaskRC सामग्री पेस्ट करा'); + expect(marathi.manageTaskServerPageConfigureTaskRCDialogueBoxOr, 'किंवा'); + expect(marathi.manageTaskServerPageConfigureTaskRCDialogueBoxSelectTaskRC, + 'TaskRC फाइल निवडा'); + expect(marathi.addTaskTitle, 'काम जोडा'); + expect(marathi.addTaskEnterTask, 'काम प्रविष्ट करा'); + expect(marathi.addTaskDue, 'अखेर'); + expect(marathi.addTaskSelectDueDate, 'अखेरची तारीख निवडा'); + expect(marathi.addTaskPriority, 'प्राथमिकता'); + expect(marathi.addTaskAddTags, 'टॅग जोडा'); + expect(marathi.addTaskCancel, 'रद्द करा'); + expect(marathi.addTaskAdd, 'जोडा'); + expect(marathi.addTaskTimeInPast, 'निवडलेला वेळ भूतकाळात आहे.'); + expect(marathi.addTaskFieldCannotBeEmpty, + 'तुम्ही हा फील्ड रिकामा सोडू शकत नाही!'); + expect(marathi.addTaskTaskAddedSuccessfully, + 'काम यशस्वीपणे जोडले गेले. संपादित करण्यासाठी टॅप करा'); + expect(marathi.aboutPageGitHubLink, + 'या प्रकल्पाला सुधारण्यासाठी उत्सुक आहात का? आमच्या GitHub रिपॉझिटरीला भेट द्या.'); + expect(marathi.aboutPageProjectDescription, + 'या प्रकल्पाचे उद्दिष्ट Taskwarrior साठी एक अॅप तयार करणे आहे. हे आपल्या सर्व प्लॅटफॉर्मवरील कार्य व्यवस्थापन अॅप आहे. हे आपल्याला आपल्या कार्यांचे व्यवस्थापन करण्यात आणि त्यांना आपल्या गरजेनुसार फिल्टर करण्यात मदत करते.'); + expect(marathi.aboutPageAppBarTitle, 'विषयक'); + }); +} diff --git a/test/utils/language/sentence_manager_test.dart b/test/utils/language/sentence_manager_test.dart new file mode 100644 index 00000000..bdfe5575 --- /dev/null +++ b/test/utils/language/sentence_manager_test.dart @@ -0,0 +1,48 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; +import 'package:taskwarrior/app/utils/language/supported_language.dart'; +import 'package:taskwarrior/app/utils/language/english_sentences.dart'; +import 'package:taskwarrior/app/utils/language/hindi_sentences.dart'; +import 'package:taskwarrior/app/utils/language/marathi_sentences.dart'; +import 'package:taskwarrior/app/utils/language/french_sentences.dart'; +import 'package:taskwarrior/app/utils/language/spanish_sentences.dart'; +import 'package:taskwarrior/app/utils/language/bengali_sentences.dart'; + +void main() { + group('SentenceManager', () { + test('should return EnglishSentences when currentLanguage is English', () { + final manager = + SentenceManager(currentLanguage: SupportedLanguage.english); + expect(manager.sentences, isA()); + }); + + test('should return HindiSentences when currentLanguage is Hindi', () { + final manager = SentenceManager(currentLanguage: SupportedLanguage.hindi); + expect(manager.sentences, isA()); + }); + + test('should return MarathiSentences when currentLanguage is Marathi', () { + final manager = + SentenceManager(currentLanguage: SupportedLanguage.marathi); + expect(manager.sentences, isA()); + }); + + test('should return FrenchSentences when currentLanguage is French', () { + final manager = + SentenceManager(currentLanguage: SupportedLanguage.french); + expect(manager.sentences, isA()); + }); + + test('should return SpanishSentences when currentLanguage is Spanish', () { + final manager = + SentenceManager(currentLanguage: SupportedLanguage.spanish); + expect(manager.sentences, isA()); + }); + + test('should return BengaliSentences when currentLanguage is Bengali', () { + final manager = + SentenceManager(currentLanguage: SupportedLanguage.bengali); + expect(manager.sentences, isA()); + }); + }); +} diff --git a/test/utils/language/sentences_test.dart b/test/utils/language/sentences_test.dart new file mode 100644 index 00000000..7c073bdf --- /dev/null +++ b/test/utils/language/sentences_test.dart @@ -0,0 +1,180 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/language/english_sentences.dart'; +import 'package:taskwarrior/app/utils/language/hindi_sentences.dart'; +import 'package:taskwarrior/app/utils/language/marathi_sentences.dart'; +import 'package:taskwarrior/app/utils/language/french_sentences.dart'; +import 'package:taskwarrior/app/utils/language/spanish_sentences.dart'; +import 'package:taskwarrior/app/utils/language/bengali_sentences.dart'; + +void main() { + group('Sentences subclass implementations', () { + final sentenceClasses = [ + EnglishSentences(), + HindiSentences(), + MarathiSentences(), + FrenchSentences(), + SpanishSentences(), + BengaliSentences(), + ]; + + for (var sentences in sentenceClasses) { + test('should have all required getters for ${sentences.runtimeType}', () { + expect(sentences.helloWorld, isA()); + expect(sentences.homePageTitle, isA()); + expect(sentences.homePageLastModified, isA()); + expect(sentences.homePageDue, isA()); + expect(sentences.homePageTaskWarriorNotConfigured, isA()); + expect(sentences.homePageSetup, isA()); + expect(sentences.homePageFilter, isA()); + expect(sentences.homePageMenu, isA()); + expect(sentences.homePageExitApp, isA()); + expect(sentences.homePageAreYouSureYouWantToExit, isA()); + expect(sentences.homePageExit, isA()); + expect(sentences.homePageCancel, isA()); + expect(sentences.homePageClickOnTheBottomRightButtonToStartAddingTasks, + isA()); + expect(sentences.homePageSearchNotFound, isA()); + expect(sentences.settingsPageTitle, isA()); + expect(sentences.settingsPageSubtitle, isA()); + expect(sentences.settingsPageMovingDataToNewDirectory, isA()); + expect(sentences.settingsPageChangeDirectory, isA()); + expect(sentences.settingsPageSetToDefault, isA()); + expect(sentences.settingsPageSyncOnStartTitle, isA()); + expect(sentences.settingsPageSyncOnStartDescription, isA()); + expect( + sentences.settingsPageEnableSyncOnTaskCreateTitle, isA()); + expect(sentences.settingsPageEnableSyncOnTaskCreateDescription, + isA()); + expect(sentences.settingsPageHighlightTaskTitle, isA()); + expect(sentences.settingsPageHighlightTaskDescription, isA()); + expect(sentences.settingsPageEnable24hrFormatTitle, isA()); + expect( + sentences.settingsPageEnable24hrFormatDescription, isA()); + expect(sentences.taskchampionTileTitle, isA()); + expect(sentences.taskchampionTileDescription, isA()); + expect(sentences.settingsPageSelectLanguage, isA()); + expect(sentences.settingsPageToggleNativeLanguage, isA()); + expect(sentences.settingsPageSelectDirectoryTitle, isA()); + expect(sentences.settingsPageSelectDirectoryDescription, isA()); + expect(sentences.navDrawerProfile, isA()); + expect(sentences.navDrawerReports, isA()); + expect(sentences.navDrawerAbout, isA()); + expect(sentences.navDrawerSettings, isA()); + expect(sentences.ccsyncCredentials, isA()); + expect(sentences.deleteTaskTitle, isA()); + expect(sentences.deleteTaskConfirmation, isA()); + expect(sentences.deleteTaskWarning, isA()); + expect(sentences.navDrawerExit, isA()); + expect(sentences.detailPageDescription, isA()); + expect(sentences.detailPageStatus, isA()); + expect(sentences.detailPageEntry, isA()); + expect(sentences.detailPageModified, isA()); + expect(sentences.detailPageStart, isA()); + expect(sentences.detailPageEnd, isA()); + expect(sentences.detailPageDue, isA()); + expect(sentences.detailPageWait, isA()); + expect(sentences.detailPageUntil, isA()); + expect(sentences.detailPagePriority, isA()); + expect(sentences.detailPageProject, isA()); + expect(sentences.detailPageTags, isA()); + expect(sentences.detailPageUrgency, isA()); + expect(sentences.detailPageID, isA()); + expect(sentences.filterDrawerApplyFilters, isA()); + expect(sentences.filterDrawerHideWaiting, isA()); + expect(sentences.filterDrawerShowWaiting, isA()); + expect(sentences.filterDrawerPending, isA()); + expect(sentences.filterDrawerCompleted, isA()); + expect(sentences.filterDrawerFilterTagBy, isA()); + expect(sentences.filterDrawerAND, isA()); + expect(sentences.filterDrawerOR, isA()); + expect(sentences.filterDrawerSortBy, isA()); + expect(sentences.filterDrawerCreated, isA()); + expect(sentences.filterDrawerModified, isA()); + expect(sentences.filterDrawerStartTime, isA()); + expect(sentences.filterDrawerDueTill, isA()); + expect(sentences.filterDrawerPriority, isA()); + expect(sentences.filterDrawerProject, isA()); + expect(sentences.filterDrawerTags, isA()); + expect(sentences.filterDrawerUrgency, isA()); + expect(sentences.filterDrawerResetSort, isA()); + expect(sentences.filterDrawerStatus, isA()); + expect(sentences.reportsPageTitle, isA()); + expect(sentences.reportsPageCompleted, isA()); + expect(sentences.reportsPagePending, isA()); + expect(sentences.reportsPageTasks, isA()); + expect(sentences.reportsPageDaily, isA()); + expect(sentences.reportsPageDailyBurnDownChart, isA()); + expect(sentences.reportsPageDailyDayMonth, isA()); + expect(sentences.reportsPageWeekly, isA()); + expect(sentences.reportsPageWeeklyBurnDownChart, isA()); + expect(sentences.reportsPageWeeklyWeeksYear, isA()); + expect(sentences.reportsPageMonthly, isA()); + expect(sentences.reportsPageMonthlyBurnDownChart, isA()); + expect(sentences.reportsPageMonthlyMonthYear, isA()); + expect(sentences.reportsPageNoTasksFound, isA()); + expect(sentences.reportsPageAddTasksToSeeReports, isA()); + expect(sentences.profilePageProfile, isA()); + expect(sentences.profilePageProfiles, isA()); + expect(sentences.profilePageCurrentProfile, isA()); + expect(sentences.profilePageManageSelectedProfile, isA()); + expect(sentences.profilePageRenameAlias, isA()); + expect(sentences.profilePageConfigureTaskserver, isA()); + expect(sentences.profilePageExportTasks, isA()); + expect(sentences.profilePageCopyConfigToNewProfile, isA()); + expect(sentences.profilePageDeleteProfile, isA()); + expect(sentences.profilePageAddNewProfile, isA()); + expect(sentences.profilePageExportTasksDialogueTitle, isA()); + expect(sentences.profilePageExportTasksDialogueSubtitle, isA()); + expect(sentences.profilePageRenameAliasDialogueBoxTitle, isA()); + expect( + sentences.profilePageRenameAliasDialogueBoxNewAlias, isA()); + expect( + sentences.profilePageRenameAliasDialogueBoxCancel, isA()); + expect( + sentences.profilePageRenameAliasDialogueBoxSubmit, isA()); + expect( + sentences.manageTaskServerPageConfigureTaskserver, isA()); + expect(sentences.manageTaskServerPageConfigureTASKRC, isA()); + expect(sentences.manageTaskServerPageSetTaskRC, isA()); + expect(sentences.manageTaskServerPageConfigureYourCertificate, + isA()); + expect(sentences.manageTaskServerPageSelectCertificate, isA()); + expect(sentences.manageTaskServerPageConfigureTaskserverKey, + isA()); + expect(sentences.manageTaskServerPageSelectKey, isA()); + expect(sentences.manageTaskServerPageConfigureServerCertificate, + isA()); + expect( + sentences.manageTaskServerPageTaskRCFileIsVerified, isA()); + expect(sentences.manageTaskServerPageConfigureTaskRCDialogueBoxTitle, + isA()); + expect(sentences.manageTaskServerPageConfigureTaskRCDialogueBoxSubtitle, + isA()); + expect( + sentences + .manageTaskServerPageConfigureTaskRCDialogueBoxInputFieldText, + isA()); + expect(sentences.manageTaskServerPageConfigureTaskRCDialogueBoxOr, + isA()); + expect( + sentences + .manageTaskServerPageConfigureTaskRCDialogueBoxSelectTaskRC, + isA()); + expect(sentences.addTaskTitle, isA()); + expect(sentences.addTaskEnterTask, isA()); + expect(sentences.addTaskDue, isA()); + expect(sentences.addTaskSelectDueDate, isA()); + expect(sentences.addTaskPriority, isA()); + expect(sentences.addTaskAddTags, isA()); + expect(sentences.addTaskCancel, isA()); + expect(sentences.addTaskAdd, isA()); + expect(sentences.addTaskTimeInPast, isA()); + expect(sentences.addTaskFieldCannotBeEmpty, isA()); + expect(sentences.addTaskTaskAddedSuccessfully, isA()); + expect(sentences.aboutPageGitHubLink, isA()); + expect(sentences.aboutPageProjectDescription, isA()); + expect(sentences.aboutPageAppBarTitle, isA()); + }); + } + }); +} diff --git a/test/utils/language/spanish_sentences_test.dart b/test/utils/language/spanish_sentences_test.dart new file mode 100644 index 00000000..45ccd8ff --- /dev/null +++ b/test/utils/language/spanish_sentences_test.dart @@ -0,0 +1,179 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/language/spanish_sentences.dart'; + +void main() { + final spanish = SpanishSentences(); + + test('should provide correct Spanish translations', () { + expect(spanish.helloWorld, '¡Hola, mundo!'); + expect(spanish.homePageTitle, 'Página de inicio'); + expect(spanish.homePageLastModified, 'Última modificación'); + expect(spanish.homePageDue, 'Vencimiento'); + expect( + spanish.homePageTaskWarriorNotConfigured, 'TaskServer no configurado'); + expect(spanish.homePageSetup, 'Configuración'); + expect(spanish.homePageFilter, 'Filtro'); + expect(spanish.homePageMenu, 'Menú'); + expect(spanish.homePageExitApp, 'Salir de la aplicación'); + expect(spanish.homePageAreYouSureYouWantToExit, + '¿Estás seguro de que quieres salir de la aplicación?'); + expect(spanish.homePageExit, 'Salir'); + expect(spanish.homePageCancel, 'Cancelar'); + expect(spanish.homePageClickOnTheBottomRightButtonToStartAddingTasks, + 'Haz clic en el botón en la parte inferior derecha para comenzar a agregar tareas'); + expect(spanish.homePageSearchNotFound, + 'No se encontraron resultados para la búsqueda'); + expect(spanish.settingsPageTitle, 'Página de configuración'); + expect(spanish.settingsPageSubtitle, 'Configura tus preferencias'); + expect(spanish.settingsPageMovingDataToNewDirectory, + 'Moviendo datos a un nuevo directorio'); + expect(spanish.settingsPageSyncOnStartTitle, + 'Sincronizar datos automáticamente al inicio'); + expect( + spanish.settingsPageSyncOnStartDescription, 'Sincronizar al iniciar'); + expect(spanish.settingsPageEnableSyncOnTaskCreateTitle, + 'Habilitar sincronización automática al crear nuevas tareas'); + expect(spanish.settingsPageEnableSyncOnTaskCreateDescription, + 'Habilitar sincronización automática al crear nuevas tareas'); + expect(spanish.settingsPageHighlightTaskTitle, + 'Resaltar tareas con 1 día restante'); + expect(spanish.settingsPageHighlightTaskDescription, + 'Resaltar tareas con 1 día restante'); + expect(spanish.settingsPageEnable24hrFormatTitle, + 'Habilitar formato de 24 horas'); + expect(spanish.settingsPageEnable24hrFormatDescription, + 'Habilitar formato de 24 horas'); + expect(spanish.settingsPageSelectLanguage, 'Seleccionar idioma'); + expect(spanish.settingsPageToggleNativeLanguage, + 'Alternar entre idiomas nativos'); + expect(spanish.settingsPageSelectDirectoryTitle, 'Seleccionar directorio'); + expect(spanish.settingsPageSelectDirectoryDescription, + 'Selecciona el directorio donde se almacenan los datos de TaskWarrior\nDirectorio actual: '); + expect(spanish.settingsPageChangeDirectory, 'Cambiar directorio'); + expect(spanish.settingsPageSetToDefault, 'Restablecer a predeterminado'); + expect(spanish.navDrawerProfile, 'Perfil'); + expect(spanish.navDrawerReports, 'Informes'); + expect(spanish.navDrawerAbout, 'Acerca de'); + expect(spanish.navDrawerSettings, 'Configuración'); + expect(spanish.navDrawerExit, 'Salir'); + expect(spanish.detailPageDescription, 'Descripción'); + expect(spanish.detailPageStatus, 'Estado'); + expect(spanish.detailPageEntry, 'Entrada'); + expect(spanish.detailPageModified, 'Modificado'); + expect(spanish.detailPageStart, 'Inicio'); + expect(spanish.detailPageEnd, 'Fin'); + expect(spanish.detailPageDue, 'Vencimiento'); + expect(spanish.detailPageWait, 'Esperar'); + expect(spanish.detailPageUntil, 'Hasta'); + expect(spanish.detailPagePriority, 'Prioridad'); + expect(spanish.detailPageProject, 'Proyecto'); + expect(spanish.detailPageTags, 'Etiquetas'); + expect(spanish.detailPageUrgency, 'Urgencia'); + expect(spanish.detailPageID, 'ID'); + expect(spanish.filterDrawerApplyFilters, 'Aplicar filtros'); + expect(spanish.filterDrawerHideWaiting, 'Ocultar pendientes'); + expect(spanish.filterDrawerShowWaiting, 'Mostrar pendientes'); + expect(spanish.filterDrawerPending, 'Pendiente'); + expect(spanish.filterDrawerCompleted, 'Completado'); + expect(spanish.filterDrawerFilterTagBy, 'Filtrar por etiqueta'); + expect(spanish.filterDrawerAND, 'y'); + expect(spanish.filterDrawerOR, 'o'); + expect(spanish.filterDrawerSortBy, 'Ordenar por'); + expect(spanish.filterDrawerCreated, 'Creado'); + expect(spanish.filterDrawerModified, 'Modificado'); + expect(spanish.filterDrawerStartTime, 'Hora de inicio'); + expect(spanish.filterDrawerDueTill, 'Hasta vencimiento'); + expect(spanish.filterDrawerPriority, 'Prioridad'); + expect(spanish.filterDrawerProject, 'Proyecto'); + expect(spanish.filterDrawerTags, 'Etiquetas'); + expect(spanish.filterDrawerUrgency, 'Urgencia'); + expect(spanish.filterDrawerResetSort, 'Restablecer orden'); + expect(spanish.filterDrawerStatus, 'Estado'); + expect(spanish.reportsPageTitle, 'Informes'); + expect(spanish.reportsPageCompleted, 'Completado'); + expect(spanish.reportsPagePending, 'Pendiente'); + expect(spanish.reportsPageTasks, 'Tareas'); + expect(spanish.reportsPageDaily, 'Diario'); + expect(spanish.reportsPageDailyBurnDownChart, 'Gráfico de quema diario'); + expect(spanish.reportsPageDailyDayMonth, 'Día - Mes'); + expect(spanish.reportsPageWeekly, 'Semanal'); + expect(spanish.reportsPageWeeklyBurnDownChart, 'Gráfico de quema semanal'); + expect(spanish.reportsPageWeeklyWeeksYear, 'Semana - Año'); + expect(spanish.reportsPageMonthly, 'Mensual'); + expect(spanish.reportsPageMonthlyBurnDownChart, 'Gráfico de quema mensual'); + expect(spanish.reportsPageMonthlyMonthYear, 'Mes - Año'); + expect(spanish.reportsPageNoTasksFound, 'No se encontraron tareas'); + expect(spanish.reportsPageAddTasksToSeeReports, + 'Agrega tareas para ver informes'); + expect(spanish.taskchampionTileDescription, + 'Cambia la sincronización de TaskWarrior al servidor de sincronización CCSync o Taskchampion'); + expect(spanish.taskchampionTileTitle, 'Sincronización Taskchampion'); + expect(spanish.ccsyncCredentials, 'Credenciales de CCSync'); + expect(spanish.deleteTaskConfirmation, 'Eliminar tarea'); + expect(spanish.deleteTaskTitle, '¿Eliminar todas las tareas?'); + expect(spanish.deleteTaskWarning, + 'Esta acción es irreversible y eliminará todas las tareas almacenadas localmente.'); + expect(spanish.profilePageProfile, 'Perfil'); + expect(spanish.profilePageProfiles, 'Perfiles'); + expect(spanish.profilePageCurrentProfile, 'Perfil actual'); + expect(spanish.profilePageManageSelectedProfile, + 'Gestionar perfil seleccionado'); + expect(spanish.profilePageRenameAlias, 'Renombrar alias'); + expect(spanish.profilePageConfigureTaskserver, + 'Configurar servidor de tareas'); + expect(spanish.profilePageExportTasks, 'Exportar tareas'); + expect(spanish.profilePageCopyConfigToNewProfile, + 'Copiar configuración a un nuevo perfil'); + expect(spanish.profilePageDeleteProfile, 'Eliminar perfil'); + expect(spanish.profilePageAddNewProfile, 'Agregar nuevo perfil'); + expect(spanish.profilePageRenameAliasDialogueBoxTitle, 'Renombrar alias'); + expect(spanish.profilePageRenameAliasDialogueBoxNewAlias, 'Nuevo alias'); + expect(spanish.profilePageRenameAliasDialogueBoxCancel, 'Cancelar'); + expect(spanish.profilePageRenameAliasDialogueBoxSubmit, 'Enviar'); + expect( + spanish.profilePageExportTasksDialogueTitle, 'Formato de exportación'); + expect(spanish.profilePageExportTasksDialogueSubtitle, + 'Selecciona el formato de exportación'); + expect(spanish.manageTaskServerPageConfigureTaskserver, + 'Configurar servidor de tareas'); + expect(spanish.manageTaskServerPageConfigureTASKRC, 'Configurar TASKRC'); + expect(spanish.manageTaskServerPageSetTaskRC, 'Establecer TaskRC'); + expect(spanish.manageTaskServerPageConfigureYourCertificate, + 'Configura tu certificado'); + expect(spanish.manageTaskServerPageSelectCertificate, + 'Seleccionar certificado'); + expect(spanish.manageTaskServerPageConfigureTaskserverKey, + 'Configurar clave del servidor de tareas'); + expect(spanish.manageTaskServerPageSelectKey, 'Seleccionar clave'); + expect(spanish.manageTaskServerPageConfigureServerCertificate, + 'Configurar certificado del servidor'); + expect(spanish.manageTaskServerPageTaskRCFileIsVerified, + 'El archivo Task RC ha sido verificado'); + expect(spanish.manageTaskServerPageConfigureTaskRCDialogueBoxTitle, + 'Configurar TaskRC'); + expect(spanish.manageTaskServerPageConfigureTaskRCDialogueBoxSubtitle, + 'Pega el contenido de TaskRC o selecciona un archivo taskrc'); + expect(spanish.manageTaskServerPageConfigureTaskRCDialogueBoxInputFieldText, + 'Pega tu contenido TaskRC aquí'); + expect(spanish.manageTaskServerPageConfigureTaskRCDialogueBoxOr, 'o'); + expect(spanish.manageTaskServerPageConfigureTaskRCDialogueBoxSelectTaskRC, + 'Seleccionar archivo TaskRC'); + expect(spanish.addTaskTitle, 'Agregar tarea'); + expect(spanish.addTaskEnterTask, 'Ingresar tarea'); + expect(spanish.addTaskDue, 'Vencimiento'); + expect(spanish.addTaskSelectDueDate, 'Seleccionar fecha de vencimiento'); + expect(spanish.addTaskPriority, 'Prioridad'); + expect(spanish.addTaskAddTags, 'Agregar etiquetas'); + expect(spanish.addTaskCancel, 'Cancelar'); + expect(spanish.addTaskAdd, 'Agregar'); + expect( + spanish.addTaskTimeInPast, 'La hora seleccionada está en el pasado.'); + expect(spanish.addTaskFieldCannotBeEmpty, + '¡No puedes dejar este campo vacío!'); + expect(spanish.addTaskTaskAddedSuccessfully, + 'Tarea añadida con éxito. Toca para editar'); + expect(spanish.aboutPageGitHubLink, + '¿Desea mejorar este proyecto? Visite nuestro repositorio en GitHub.'); + expect(spanish.aboutPageAppBarTitle, 'Acerca de'); + }); +} diff --git a/test/utils/language/supported_language_test.dart b/test/utils/language/supported_language_test.dart new file mode 100644 index 00000000..070546db --- /dev/null +++ b/test/utils/language/supported_language_test.dart @@ -0,0 +1,31 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/language/supported_language.dart'; + +void main() { + group('SupportedLanguageExtension', () { + test('should return correct language code', () { + expect(SupportedLanguage.english.languageCode, 'en'); + expect(SupportedLanguage.hindi.languageCode, 'hi'); + expect(SupportedLanguage.marathi.languageCode, 'mr'); + expect(SupportedLanguage.french.languageCode, 'fr'); + expect(SupportedLanguage.spanish.languageCode, 'es'); + expect(SupportedLanguage.bengali.languageCode, 'bn'); + }); + + test('should return correct SupportedLanguage from code', () { + expect( + SupportedLanguageExtension.fromCode('en'), SupportedLanguage.english); + expect( + SupportedLanguageExtension.fromCode('hi'), SupportedLanguage.hindi); + expect( + SupportedLanguageExtension.fromCode('mr'), SupportedLanguage.marathi); + expect( + SupportedLanguageExtension.fromCode('fr'), SupportedLanguage.french); + expect( + SupportedLanguageExtension.fromCode('es'), SupportedLanguage.spanish); + expect( + SupportedLanguageExtension.fromCode('bn'), SupportedLanguage.bengali); + expect(SupportedLanguageExtension.fromCode('unknown'), null); + }); + }); +} From 46d9fed9f6964b03a3ea39924431d481835db1da Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Mon, 16 Dec 2024 22:12:47 +0530 Subject: [PATCH 04/11] test: added test for all files under utils/taskc --- test/utils/taskc/impl/codec_test.dart | 42 ++++++++++++++++ test/utils/taskc/impl/message_test.dart | 46 +++++++++++++++++ test/utils/taskc/message_test.dart | 67 +++++++++++++++++++++++++ test/utils/taskc/payload_test.dart | 45 +++++++++++++++++ test/utils/taskc/response_test.dart | 64 +++++++++++++++++++++++ 5 files changed, 264 insertions(+) create mode 100644 test/utils/taskc/impl/codec_test.dart create mode 100644 test/utils/taskc/impl/message_test.dart create mode 100644 test/utils/taskc/message_test.dart create mode 100644 test/utils/taskc/payload_test.dart create mode 100644 test/utils/taskc/response_test.dart diff --git a/test/utils/taskc/impl/codec_test.dart b/test/utils/taskc/impl/codec_test.dart new file mode 100644 index 00000000..835fb8db --- /dev/null +++ b/test/utils/taskc/impl/codec_test.dart @@ -0,0 +1,42 @@ +import 'dart:typed_data'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskc/impl/codec.dart'; + +void main() { + group('Codec', () { + test('fold should combine bytes into an integer', () { + final bytes = [0, 0, 1, 2]; + final result = Codec.fold(bytes); + expect(result, 258); + }); + + test('unfold should split an integer into bytes', () { + const n = 258; + final result = Codec.unfold(n); + expect(result, [0, 0, 1, 2]); + }); + + test('decode should decode Uint8List to string', () { + final bytes = Uint8List.fromList([0, 0, 0, 9, 104, 101, 108, 108, 111]); + final result = Codec.decode(bytes); + expect(result, 'hello'); + }); + + test('decode should throw assertion error for invalid length', () { + final bytes = Uint8List.fromList([0, 0, 0, 4, 104, 101, 108, 108, 111]); + expect(() => Codec.decode(bytes), throwsAssertionError); + }); + + test('encode should encode string to Uint8List', () { + const string = 'hello'; + final result = Codec.encode(string); + expect(result, Uint8List.fromList([0, 0, 0, 9, 104, 101, 108, 108, 111])); + }); + + test('encode should handle empty string', () { + const string = ''; + final result = Codec.encode(string); + expect(result, Uint8List.fromList([0, 0, 0, 4])); + }); + }); +} diff --git a/test/utils/taskc/impl/message_test.dart b/test/utils/taskc/impl/message_test.dart new file mode 100644 index 00000000..327a4af0 --- /dev/null +++ b/test/utils/taskc/impl/message_test.dart @@ -0,0 +1,46 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskc/impl/message.dart'; + +void main() { + group('TaskserverResponseException', () { + test('should create TaskserverResponseException with header', () { + final header = { + 'type': 'error', + 'code': '404', + }; + final exception = TaskserverResponseException(header); + expect(exception.header, header); + }); + + test( + 'should return formatted string representation of TaskserverResponseException', + () { + final header = { + 'type': 'error', + 'code': '404', + }; + final exception = TaskserverResponseException(header); + const expectedString = 'response.header = {\n' + ' "type": "error",\n' + ' "code": "404"\n' + '}'; + expect(exception.toString(), expectedString); + }); + }); + + group('EmptyResponseException', () { + test( + 'should return formatted string representation of EmptyResponseException', + () { + final exception = EmptyResponseException(); + const expectedString = 'The server returned an empty response. ' + 'Please review the server logs or contact administrator.\n' + '\n' + 'This may be an issue with the triple:\n' + '- taskd.certificate\n' + '- taskd.key\n' + '- \$TASKDDATA/ca.cert.pem'; + expect(exception.toString(), expectedString); + }); + }); +} diff --git a/test/utils/taskc/message_test.dart b/test/utils/taskc/message_test.dart new file mode 100644 index 00000000..f7c69330 --- /dev/null +++ b/test/utils/taskc/message_test.dart @@ -0,0 +1,67 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskc/message.dart'; +import 'package:taskwarrior/app/utils/taskserver/credentials.dart'; + +void main() { + group('message function', () { + test('should construct message with all parameters', () { + const credentials = + Credentials(org: 'TestOrg', user: 'TestUser', key: 'TestKey'); + final result = message( + client: 'TestClient', + type: 'TestType', + credentials: credentials, + payload: 'TestPayload', + ); + + expect(result, + 'client: TestClient\ntype: TestType\norg: TestOrg\nuser: TestUser\nkey: TestKey\nprotocol: v1\n\nTestPayload'); + }); + + test('should construct message without optional parameters', () { + final result = message( + type: 'TestType', + ); + + expect( + result, 'type: TestType\norg: \nuser: \nkey: \nprotocol: v1\n\nnull'); + }); + + test('should handle null client', () { + const credentials = + Credentials(org: 'TestOrg', user: 'TestUser', key: 'TestKey'); + final result = message( + type: 'TestType', + credentials: credentials, + payload: 'TestPayload', + ); + + expect(result, + 'type: TestType\norg: TestOrg\nuser: TestUser\nkey: TestKey\nprotocol: v1\n\nTestPayload'); + }); + + test('should handle null credentials', () { + final result = message( + client: 'TestClient', + type: 'TestType', + payload: 'TestPayload', + ); + + expect(result, + 'client: TestClient\ntype: TestType\norg: \nuser: \nkey: \nprotocol: v1\n\nTestPayload'); + }); + + test('should handle null payload', () { + const credentials = + Credentials(org: 'TestOrg', user: 'TestUser', key: 'TestKey'); + final result = message( + client: 'TestClient', + type: 'TestType', + credentials: credentials, + ); + + expect(result, + 'client: TestClient\ntype: TestType\norg: TestOrg\nuser: TestUser\nkey: TestKey\nprotocol: v1\n\nnull'); + }); + }); +} diff --git a/test/utils/taskc/payload_test.dart b/test/utils/taskc/payload_test.dart new file mode 100644 index 00000000..c6ebfc01 --- /dev/null +++ b/test/utils/taskc/payload_test.dart @@ -0,0 +1,45 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskc/payload.dart'; + +void main() { + group('Payload', () { + test('should create Payload instance with tasks and userKey', () { + final payload = Payload(tasks: ['task1', 'task2'], userKey: 'userKey123'); + expect(payload.tasks, ['task1', 'task2']); + expect(payload.userKey, 'userKey123'); + }); + + test('should create Payload instance from string', () { + const payloadString = 'task1\ntask2\nuserKey123'; + final payload = Payload.fromString(payloadString); + expect(payload.tasks, ['task1', 'task2']); + expect(payload.userKey, 'userKey123'); + }); + + test('should convert Payload instance to string', () { + final payload = Payload(tasks: ['task1', 'task2'], userKey: 'userKey123'); + final payloadString = payload.toString(); + expect(payloadString, 'task1\ntask2\nuserKey123'); + }); + + test('should handle Payload instance with null userKey', () { + final payload = Payload(tasks: ['task1', 'task2']); + expect(payload.userKey, isNull); + final payloadString = payload.toString(); + expect(payloadString, 'task1\ntask2'); + }); + + test('should handle Payload.fromString with empty userKey', () { + const payloadString = 'task1\ntask2\n'; + final payload = Payload.fromString(payloadString); + expect(payload.tasks, ['task1']); + expect(payload.userKey, 'task2'); + }); + + test('should handle Payload.toString with empty userKey', () { + final payload = Payload(tasks: ['task1', 'task2'], userKey: ''); + final payloadString = payload.toString(); + expect(payloadString, 'task1\ntask2'); + }); + }); +} diff --git a/test/utils/taskc/response_test.dart b/test/utils/taskc/response_test.dart new file mode 100644 index 00000000..e2c694d4 --- /dev/null +++ b/test/utils/taskc/response_test.dart @@ -0,0 +1,64 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskc/response.dart'; +import 'package:taskwarrior/app/utils/taskc/payload.dart'; + +void main() { + group('Response', () { + test('should create Response instance with header and payload', () { + final payload = Payload(tasks: ['task1', 'task2'], userKey: 'userKey123'); + final header = {'type': 'response', 'version': '1.0'}; + final response = Response(header: header, payload: payload); + + expect(response.header, header); + expect(response.payload, payload); + }); + + test('should create Response instance from string', () { + const responseString = + 'type: response\nversion: 1.0\n\n' 'task1\ntask2\nuserKey123'; + final response = Response.fromString(responseString); + + expect(response.header, { + 'type': 'response', + 'version': '1.0', + }); + expect(response.payload.tasks, ['task1', 'task2']); + expect(response.payload.userKey, 'userKey123'); + }); + + test('should handle Response.fromString with missing payload', () { + const responseString = 'type: response\nversion: 1.0\n\n'; + final response = Response.fromString(responseString); + + expect(response.header, { + 'type': 'response', + 'version': '1.0', + }); + expect(response.payload.tasks, []); + expect(response.payload.userKey, ''); + }); + + test('should handle Response.fromString with complex header', () { + const responseString = 'type: response\nversion: 1.0\nextra: info\n\n' + 'task1\ntask2\nuserKey123'; + final response = Response.fromString(responseString); + + expect(response.header, { + 'type': 'response', + 'version': '1.0', + 'extra': 'info', + }); + expect(response.payload.tasks, ['task1', 'task2']); + expect(response.payload.userKey, 'userKey123'); + }); + + test('should handle Response.fromString with empty header', () { + const responseString = '\n\n' 'task1\ntask2\nuserKey123'; + final response = Response.fromString(responseString); + + expect(response.header, {'': ''}); + expect(response.payload.tasks, ['task1', 'task2']); + expect(response.payload.userKey, 'userKey123'); + }); + }); +} From bd5d719a30acff4da16ad9ba41c79b130b33a43e Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Mon, 16 Dec 2024 22:13:14 +0530 Subject: [PATCH 05/11] test: added test for all files under utils/taskchampion --- .../credentials_storage_test.dart | 56 +++++ .../credentials_storage_test.mocks.dart | 203 ++++++++++++++++++ .../utils/taskchampion/taskchampion_test.dart | 54 +++++ 3 files changed, 313 insertions(+) create mode 100644 test/utils/taskchampion/credentials_storage_test.dart create mode 100644 test/utils/taskchampion/credentials_storage_test.mocks.dart create mode 100644 test/utils/taskchampion/taskchampion_test.dart diff --git a/test/utils/taskchampion/credentials_storage_test.dart b/test/utils/taskchampion/credentials_storage_test.dart new file mode 100644 index 00000000..edf6e7f6 --- /dev/null +++ b/test/utils/taskchampion/credentials_storage_test.dart @@ -0,0 +1,56 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:taskwarrior/app/utils/taskchampion/credentials_storage.dart'; + +import 'credentials_storage_test.mocks.dart'; + +@GenerateMocks([SharedPreferences]) +void main() { + group('CredentialsStorage', () { + late MockSharedPreferences mockSharedPreferences; + + setUp(() { + mockSharedPreferences = MockSharedPreferences(); + }); + + test('should return null when encryption secret is not set', () async { + when(mockSharedPreferences.getString('encryptionSecret')) + .thenReturn(null); + SharedPreferences.setMockInitialValues({}); + + final encryptionSecret = await CredentialsStorage.getEncryptionSecret(); + expect(encryptionSecret, isNull); + }); + + test('should return encryption secret when it is set', () async { + when(mockSharedPreferences.getString('encryptionSecret')) + .thenReturn('secret123'); + SharedPreferences.setMockInitialValues({ + 'encryptionSecret': 'secret123', + }); + + final encryptionSecret = await CredentialsStorage.getEncryptionSecret(); + expect(encryptionSecret, 'secret123'); + }); + + test('should return null when client ID is not set', () async { + when(mockSharedPreferences.getString('clientId')).thenReturn(null); + SharedPreferences.setMockInitialValues({}); + + final clientId = await CredentialsStorage.getClientId(); + expect(clientId, isNull); + }); + + test('should return client ID when it is set', () async { + when(mockSharedPreferences.getString('clientId')).thenReturn('client123'); + SharedPreferences.setMockInitialValues({ + 'clientId': 'client123', + }); + + final clientId = await CredentialsStorage.getClientId(); + expect(clientId, 'client123'); + }); + }); +} diff --git a/test/utils/taskchampion/credentials_storage_test.mocks.dart b/test/utils/taskchampion/credentials_storage_test.mocks.dart new file mode 100644 index 00000000..72d04164 --- /dev/null +++ b/test/utils/taskchampion/credentials_storage_test.mocks.dart @@ -0,0 +1,203 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in taskwarrior/test/utils/taskchampion/credentials_storage_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i3; + +import 'package:mockito/mockito.dart' as _i1; +import 'package:shared_preferences/src/shared_preferences_legacy.dart' as _i2; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +/// A class which mocks [SharedPreferences]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockSharedPreferences extends _i1.Mock implements _i2.SharedPreferences { + MockSharedPreferences() { + _i1.throwOnMissingStub(this); + } + + @override + Set getKeys() => (super.noSuchMethod( + Invocation.method( + #getKeys, + [], + ), + returnValue: {}, + ) as Set); + + @override + Object? get(String? key) => (super.noSuchMethod(Invocation.method( + #get, + [key], + )) as Object?); + + @override + bool? getBool(String? key) => (super.noSuchMethod(Invocation.method( + #getBool, + [key], + )) as bool?); + + @override + int? getInt(String? key) => (super.noSuchMethod(Invocation.method( + #getInt, + [key], + )) as int?); + + @override + double? getDouble(String? key) => (super.noSuchMethod(Invocation.method( + #getDouble, + [key], + )) as double?); + + @override + String? getString(String? key) => (super.noSuchMethod(Invocation.method( + #getString, + [key], + )) as String?); + + @override + bool containsKey(String? key) => (super.noSuchMethod( + Invocation.method( + #containsKey, + [key], + ), + returnValue: false, + ) as bool); + + @override + List? getStringList(String? key) => + (super.noSuchMethod(Invocation.method( + #getStringList, + [key], + )) as List?); + + @override + _i3.Future setBool( + String? key, + bool? value, + ) => + (super.noSuchMethod( + Invocation.method( + #setBool, + [ + key, + value, + ], + ), + returnValue: _i3.Future.value(false), + ) as _i3.Future); + + @override + _i3.Future setInt( + String? key, + int? value, + ) => + (super.noSuchMethod( + Invocation.method( + #setInt, + [ + key, + value, + ], + ), + returnValue: _i3.Future.value(false), + ) as _i3.Future); + + @override + _i3.Future setDouble( + String? key, + double? value, + ) => + (super.noSuchMethod( + Invocation.method( + #setDouble, + [ + key, + value, + ], + ), + returnValue: _i3.Future.value(false), + ) as _i3.Future); + + @override + _i3.Future setString( + String? key, + String? value, + ) => + (super.noSuchMethod( + Invocation.method( + #setString, + [ + key, + value, + ], + ), + returnValue: _i3.Future.value(false), + ) as _i3.Future); + + @override + _i3.Future setStringList( + String? key, + List? value, + ) => + (super.noSuchMethod( + Invocation.method( + #setStringList, + [ + key, + value, + ], + ), + returnValue: _i3.Future.value(false), + ) as _i3.Future); + + @override + _i3.Future remove(String? key) => (super.noSuchMethod( + Invocation.method( + #remove, + [key], + ), + returnValue: _i3.Future.value(false), + ) as _i3.Future); + + @override + _i3.Future commit() => (super.noSuchMethod( + Invocation.method( + #commit, + [], + ), + returnValue: _i3.Future.value(false), + ) as _i3.Future); + + @override + _i3.Future clear() => (super.noSuchMethod( + Invocation.method( + #clear, + [], + ), + returnValue: _i3.Future.value(false), + ) as _i3.Future); + + @override + _i3.Future reload() => (super.noSuchMethod( + Invocation.method( + #reload, + [], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); +} diff --git a/test/utils/taskchampion/taskchampion_test.dart b/test/utils/taskchampion/taskchampion_test.dart new file mode 100644 index 00000000..c4542359 --- /dev/null +++ b/test/utils/taskchampion/taskchampion_test.dart @@ -0,0 +1,54 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:taskwarrior/app/utils/taskchampion/taskchampion.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('ManageTaskChampionCreds', () { + setUp(() { + SharedPreferences.setMockInitialValues({}); + }); + + testWidgets('should load credentials and display them in text fields', + (WidgetTester tester) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.setString('encryptionSecret', 'testSecret'); + await prefs.setString('clientId', 'testClientId'); + + await tester.pumpWidget(MaterialApp(home: ManageTaskChampionCreds())); + + await tester.pump(); + + expect(find.text('testSecret'), findsOneWidget); + expect(find.text('testClientId'), findsOneWidget); + }); + + testWidgets('should save credentials when the save button is pressed', + (WidgetTester tester) async { + await tester.pumpWidget(MaterialApp(home: ManageTaskChampionCreds())); + + await tester.enterText(find.byType(TextField).at(0), 'newSecret'); + await tester.enterText(find.byType(TextField).at(1), 'newClientId'); + + await tester.tap(find.text('Save Credentials')); + await tester.pump(); + + SharedPreferences prefs = await SharedPreferences.getInstance(); + expect(prefs.getString('encryptionSecret'), 'newSecret'); + expect(prefs.getString('clientId'), 'newClientId'); + }); + + testWidgets('should show snackbar when credentials are saved', + (WidgetTester tester) async { + await tester.pumpWidget(MaterialApp(home: ManageTaskChampionCreds())); + + await tester.tap(find.text('Save Credentials')); + await tester.pump(); + await tester.pump(const Duration(seconds: 1)); + + expect(find.text('Credentials saved successfully'), findsOneWidget); + }); + }); +} From 0b273be25f077c841523e936c8ddd745d19bf85b Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Mon, 16 Dec 2024 22:13:46 +0530 Subject: [PATCH 06/11] test: added test for all files under utils/taskfunctions --- test/utils/taskfunctions/comparator_test.dart | 109 ++++++++++++++++++ .../datetime_differences_test.dart | 71 ++++++++++++ test/utils/taskfunctions/draft_test.dart | 42 +++++++ test/utils/taskfunctions/modify_test.dart | 47 ++++++++ test/utils/taskfunctions/patch_test.dart | 81 +++++++++++++ test/utils/taskfunctions/profiles_test.dart | 92 +++++++++++++++ test/utils/taskfunctions/projects_test.dart | 62 ++++++++++ test/utils/taskfunctions/query_test.dart | 70 +++++++++++ test/utils/taskfunctions/tags_test.dart | 64 ++++++++++ test/utils/taskfunctions/taskparser_test.dart | 63 ++++++++++ test/utils/taskfunctions/urgency_test.dart | 78 +++++++++++++ test/utils/taskfunctions/validate_test.dart | 40 +++++++ 12 files changed, 819 insertions(+) create mode 100644 test/utils/taskfunctions/comparator_test.dart create mode 100644 test/utils/taskfunctions/datetime_differences_test.dart create mode 100644 test/utils/taskfunctions/draft_test.dart create mode 100644 test/utils/taskfunctions/modify_test.dart create mode 100644 test/utils/taskfunctions/patch_test.dart create mode 100644 test/utils/taskfunctions/profiles_test.dart create mode 100644 test/utils/taskfunctions/projects_test.dart create mode 100644 test/utils/taskfunctions/query_test.dart create mode 100644 test/utils/taskfunctions/tags_test.dart create mode 100644 test/utils/taskfunctions/taskparser_test.dart create mode 100644 test/utils/taskfunctions/urgency_test.dart create mode 100644 test/utils/taskfunctions/validate_test.dart diff --git a/test/utils/taskfunctions/comparator_test.dart b/test/utils/taskfunctions/comparator_test.dart new file mode 100644 index 00000000..32409a93 --- /dev/null +++ b/test/utils/taskfunctions/comparator_test.dart @@ -0,0 +1,109 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/json/task.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/comparator.dart'; + +void main() { + group('compareTasks', () { + Task createTask( + {DateTime? entry, + DateTime? modified, + DateTime? start, + DateTime? due, + String? priority, + String? project, + List? tags}) { + return Task((b) => b + ..uuid = '1' + ..description = 'Task' + ..entry = entry ?? DateTime.now() + ..modified = modified + ..start = start + ..due = due + ..priority = priority + ..project = project + ..status = 'pending'); + } + + test('should compare tasks by Created date', () { + final task1 = createTask(entry: DateTime(2022, 1, 1)); + final task2 = createTask(entry: DateTime(2023, 1, 1)); + + final comparator = compareTasks('Created'); + expect(comparator(task1, task2), lessThan(0)); + expect(comparator(task2, task1), greaterThan(0)); + }); + + test('should compare tasks by Modified date', () { + final task1 = createTask(modified: DateTime(2022, 1, 1)); + final task2 = createTask(modified: DateTime(2023, 1, 1)); + + final comparator = compareTasks('Modified'); + expect(comparator(task1, task2), lessThan(0)); + expect(comparator(task2, task1), greaterThan(0)); + expect(comparator(task1, task1), equals(0)); + }); + + test('should compare tasks by Start Time', () { + final task1 = createTask(start: DateTime(2022, 1, 1)); + final task2 = createTask(start: DateTime(2023, 1, 1)); + + final comparator = compareTasks('Start Time'); + expect(comparator(task1, task2), lessThan(0)); + expect(comparator(task2, task1), greaterThan(0)); + }); + + test('should compare tasks by Due till', () { + final task1 = createTask(due: DateTime(2022, 1, 1)); + final task2 = createTask(due: DateTime(2023, 1, 1)); + + final comparator = compareTasks('Due till'); + expect(comparator(task1, task2), lessThan(0)); + expect(comparator(task2, task1), greaterThan(0)); + }); + + test('should compare tasks by Priority', () { + final task1 = createTask(priority: 'H'); + final task2 = createTask(priority: 'L'); + + final comparator = compareTasks('Priority'); + expect(comparator(task1, task2), greaterThan(0)); + expect(comparator(task2, task1), lessThan(0)); + }); + + test('should compare tasks by Project', () { + final task1 = createTask(project: 'ProjectA'); + final task2 = createTask(project: 'ProjectB'); + + final comparator = compareTasks('Project'); + expect(comparator(task1, task2), lessThan(0)); + expect(comparator(task2, task1), greaterThan(0)); + }); + + test('should compare tasks by Tags', () { + final task1 = createTask(tags: ['Tag1', 'Tag2']); + final task2 = createTask(tags: ['Tag1', 'Tag3']); + + final comparator = compareTasks('Tags'); + expect(comparator(task1, task2), 0); + }); + + test('should compare tasks by Urgency', () { + final task1 = createTask(); + final task2 = createTask(); + + // Define urgency function to compare tasks + int urgency(Task task) => task.entry.microsecondsSinceEpoch; + + final comparator = compareTasks('Urgency'); + expect(comparator(task1, task2), equals(0)); + }); + + test('should return 1 for unknown column', () { + final task1 = createTask(); + final task2 = createTask(); + + final comparator = compareTasks('Unknown'); + expect(comparator(task1, task2), equals(1)); + }); + }); +} diff --git a/test/utils/taskfunctions/datetime_differences_test.dart b/test/utils/taskfunctions/datetime_differences_test.dart new file mode 100644 index 00000000..9e47a0c0 --- /dev/null +++ b/test/utils/taskfunctions/datetime_differences_test.dart @@ -0,0 +1,71 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/datetime_differences.dart'; + +void main() { + group('DateTime Differences', () { + test('age function should return correct string for years', () { + final now = DateTime.now(); + final dt = now.subtract(const Duration(days: 2 * 365)); + expect(age(dt), '2y '); + }); + + test('age function should return correct string for months', () { + final now = DateTime.now(); + final dt = now.subtract(const Duration(days: 2 * 30)); + expect(age(dt), '2mo '); + }); + + test('age function should return correct string for weeks', () { + final now = DateTime.now(); + final dt = now.subtract(const Duration(days: 2 * 7)); + expect(age(dt), '2w '); + }); + + test('age function should return correct string for days', () { + final now = DateTime.now(); + final dt = now.subtract(const Duration(days: 2)); // 2 days + expect(age(dt), '2d '); + }); + + test('age function should return correct string for hours', () { + final now = DateTime.now(); + final dt = now.subtract(const Duration(hours: 2)); // 2 hours + expect(age(dt), '2h '); + }); + + test('age function should return correct string for minutes', () { + final now = DateTime.now(); + final dt = now.subtract(const Duration(minutes: 2)); // 2 minutes + expect(age(dt), '2min '); + }); + + test('age function should return correct string for seconds', () { + final now = DateTime.now(); + final dt = now.subtract(const Duration(seconds: 2)); // 2 seconds + expect(age(dt), '2s '); + }); + + test('when function should return correct string for future dates', () { + final now = DateTime.now(); + final dt = now.add(const Duration(days: 2)); // 2 days from now + expect(when(dt), '1d '); + }); + + test( + 'difference function should return correct string for various durations', + () { + expect(difference(const Duration(days: 2 * 365)), '2y '); + expect(difference(const Duration(days: 2 * 30)), '2mo '); + expect(difference(const Duration(days: 2 * 7)), '2w '); + expect(difference(const Duration(days: 2)), '2d '); + expect(difference(const Duration(hours: 2)), '2h '); + expect(difference(const Duration(minutes: 2)), '2min '); + expect(difference(const Duration(seconds: 2)), '2s '); + + expect(difference(const Duration(days: -2)), '2d ago '); + expect(difference(const Duration(hours: -2)), '2h ago '); + expect(difference(const Duration(minutes: -2)), '2min ago '); + expect(difference(const Duration(seconds: -2)), '2s ago '); + }); + }); +} diff --git a/test/utils/taskfunctions/draft_test.dart b/test/utils/taskfunctions/draft_test.dart new file mode 100644 index 00000000..70ee6ece --- /dev/null +++ b/test/utils/taskfunctions/draft_test.dart @@ -0,0 +1,42 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/models.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/draft.dart'; + +void main() { + group('Draft', () { + late Task originalTask; + late Draft draft; + + setUp(() { + originalTask = Task((b) => b + ..uuid = '1' + ..description = 'Original Task' + ..status = 'pending' + ..entry = DateTime.now()); + draft = Draft(originalTask); + }); + + test('should initialize with original task', () { + expect(draft.original, originalTask); + expect(draft.draft, originalTask); + }); + + test('should update draft with new values', () { + draft.set('description', 'Updated Task'); + expect(draft.draft.description, 'Updated Task'); + }); + + test('should set start and end dates based on status', () { + final now = DateTime.now(); + + draft.set('status', 'completed'); + expect(draft.draft.status, 'completed'); + expect(draft.draft.start, originalTask.start); + expect(draft.draft.end?.isAfter(now), isTrue); + + draft.set('status', 'pending'); + expect(draft.draft.status, 'pending'); + expect(draft.draft.end, isNull); + }); + }); +} diff --git a/test/utils/taskfunctions/modify_test.dart b/test/utils/taskfunctions/modify_test.dart new file mode 100644 index 00000000..154a4072 --- /dev/null +++ b/test/utils/taskfunctions/modify_test.dart @@ -0,0 +1,47 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/models.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/modify.dart'; + +void main() { + group('Modify', () { + late Task originalTask; + late Modify modify; + late Task Function(String) getTask; + late void Function(Task) mergeTask; + late String uuid; + + setUp(() { + uuid = '1'; + originalTask = Task((b) => b + ..uuid = uuid + ..description = 'Original Task' + ..status = 'pending' + ..entry = DateTime.now()); + + getTask = (String id) => originalTask; + mergeTask = (Task task) { + originalTask = task; + }; + + modify = Modify(getTask: getTask, mergeTask: mergeTask, uuid: uuid); + }); + + test('should initialize with original task', () { + expect(modify.draft, originalTask); + }); + + test('should update draft with new values', () { + modify.set('description', 'Updated Task'); + expect(modify.draft.description, 'Updated Task'); + }); + + test('should save changes correctly', () { + final now = DateTime.now(); + modify.set('description', 'Updated Task'); + modify.save(modified: () => now); + + expect(modify.draft.description, 'Updated Task'); + expect(modify.draft.modified, now); + }); + }); +} diff --git a/test/utils/taskfunctions/patch_test.dart b/test/utils/taskfunctions/patch_test.dart new file mode 100644 index 00000000..6f0d2cc3 --- /dev/null +++ b/test/utils/taskfunctions/patch_test.dart @@ -0,0 +1,81 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/models.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/patch.dart'; +import 'package:built_collection/built_collection.dart'; + +void main() { + group('patch', () { + late Task originalTask; + + setUp(() { + originalTask = Task((b) => b + ..uuid = '1' + ..description = 'Original Task' + ..status = 'pending' + ..entry = DateTime.now() + ..tags = ListBuilder(['tag1', 'tag2'])); + }); + + test('should update description', () { + final updatedTask = patch(originalTask, {'description': 'Updated Task'}); + expect(updatedTask.description, 'Updated Task'); + }); + + test('should update status', () { + final updatedTask = patch(originalTask, {'status': 'completed'}); + expect(updatedTask.status, 'completed'); + }); + + test('should update start date', () { + final newStart = DateTime.now().add(const Duration(days: 1)); + final updatedTask = patch(originalTask, {'start': newStart}); + expect(updatedTask.start, newStart); + }); + + test('should update end date', () { + final newEnd = DateTime.now().add(const Duration(days: 1)); + final updatedTask = patch(originalTask, {'end': newEnd}); + expect(updatedTask.end, newEnd); + }); + + test('should update due date', () { + final newDue = DateTime.now().add(const Duration(days: 1)); + final updatedTask = patch(originalTask, {'due': newDue}); + expect(updatedTask.due, newDue); + }); + + test('should update wait date', () { + final newWait = DateTime.now().add(const Duration(days: 1)); + final updatedTask = patch(originalTask, {'wait': newWait}); + expect(updatedTask.wait, newWait); + }); + + test('should update until date', () { + final newUntil = DateTime.now().add(const Duration(days: 1)); + final updatedTask = patch(originalTask, {'until': newUntil}); + expect(updatedTask.until, newUntil); + }); + + test('should update modified date', () { + final newModified = DateTime.now().add(const Duration(days: 1)); + final updatedTask = patch(originalTask, {'modified': newModified}); + expect(updatedTask.modified, newModified); + }); + + test('should update priority', () { + final updatedTask = patch(originalTask, {'priority': 'H'}); + expect(updatedTask.priority, 'H'); + }); + + test('should update project', () { + final updatedTask = patch(originalTask, {'project': 'New Project'}); + expect(updatedTask.project, 'New Project'); + }); + + test('should update tags', () { + final newTags = ListBuilder(['tag3', 'tag4']); + final updatedTask = patch(originalTask, {'tags': newTags}); + expect(updatedTask.tags?.rebuild((b) => b).toList(), ['tag3', 'tag4']); + }); + }); +} diff --git a/test/utils/taskfunctions/profiles_test.dart b/test/utils/taskfunctions/profiles_test.dart new file mode 100644 index 00000000..4d0cc664 --- /dev/null +++ b/test/utils/taskfunctions/profiles_test.dart @@ -0,0 +1,92 @@ +import 'dart:io'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/profiles.dart'; + +void main() { + late Directory baseDir; + late Profiles profiles; + + setUp(() { + baseDir = Directory.systemTemp.createTempSync(); + profiles = Profiles(baseDir); + }); + + tearDown(() { + baseDir.deleteSync(recursive: true); + }); + + test('addProfile creates a new profile with alias and creation date', () { + var profileId = profiles.addProfile(); + var profileDir = Directory('${baseDir.path}/profiles/$profileId'); + expect(profileDir.existsSync(), isTrue); + expect(File('${profileDir.path}/created').existsSync(), isTrue); + expect(File('${profileDir.path}/alias').readAsStringSync(), 'New Alias'); + }); + + test('copyConfigToNewProfile copies config files to new profile', () { + var originalProfile = profiles.addProfile(); + var configFiles = [ + '.taskrc', + '.task/ca.cert.pem', + '.task/first_last.cert.pem', + '.task/first_last.key.pem', + '.task/server.cert.pem', + 'taskd.ca', + 'taskd.certificate', + 'taskd.key', + ]; + + for (var file in configFiles) { + var filePath = '${baseDir.path}/profiles/$originalProfile/$file'; + File(filePath).createSync(recursive: true); + } + + profiles.copyConfigToNewProfile(originalProfile); + var newProfile = profiles.listProfiles().last; + + for (var file in configFiles) { + var filePath = '${baseDir.path}/profiles/$newProfile/$file'; + expect(File(filePath).existsSync(), isTrue); + } + }); + + test('listProfiles returns sorted list of profile IDs', () { + var profile1 = profiles.addProfile(); + var profile2 = profiles.addProfile(); + expect(profiles.listProfiles(), [profile1, profile2]); + }); + + test('deleteProfile removes profile directory', () { + var profile = profiles.addProfile(); + profiles.deleteProfile(profile); + expect( + Directory('${baseDir.path}/profiles/$profile').existsSync(), isFalse); + }); + + test('setAlias and getAlias set and get the alias for a profile', () { + var profile = profiles.addProfile(); + profiles.setAlias(profile: profile, alias: 'Test Alias'); + expect(profiles.getAlias(profile), 'Test Alias'); + }); + + test( + 'setCurrentProfile and getCurrentProfile set and get the current profile', + () { + var profile = profiles.addProfile(); + profiles.setCurrentProfile(profile); + expect(profiles.getCurrentProfile(), profile); + }); + + test('getCurrentStorage returns storage for current profile', () { + var profile = profiles.addProfile(); + profiles.setCurrentProfile(profile); + expect(profiles.getCurrentStorage()?.profile.path, + '${baseDir.path}/profiles/$profile'); + }); + + test('getStorage returns storage for specified profile', () { + var profile = profiles.addProfile(); + expect(profiles.getStorage(profile).profile.path, + '${baseDir.path}/profiles/$profile'); + }); +} diff --git a/test/utils/taskfunctions/projects_test.dart b/test/utils/taskfunctions/projects_test.dart new file mode 100644 index 00000000..b518a9fc --- /dev/null +++ b/test/utils/taskfunctions/projects_test.dart @@ -0,0 +1,62 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/projects.dart'; + +void main() { + group('Project Utils', () { + test('projectPath returns correct path', () { + var project = 'a.b.c'; + var expectedPath = ['a.b.c', 'a.b', 'a']; + expect(projectPath(project), expectedPath); + }); + + test('ancestor returns correct ancestor', () { + expect(ancestor('a.b.c', 0), 'a.b.c'); + expect(ancestor('a.b.c', 1), 'a.b'); + expect(ancestor('a.b.c', 2), 'a'); + expect(ancestor('a.b.c', 3), null); + }); + + test('ProjectNode toMap returns correct map', () { + var node = ProjectNode(5) + ..parent = 'parent' + ..children = {'child1', 'child2'} + ..subtasks = 10; + var expectedMap = { + 'parent': 'parent', + 'children': ['child1', 'child2'], + 'tasks': 5, + 'subtasks': 10, + }; + expect(node.toMap(), expectedMap); + }); + + test('sparseDecoratedProjectTree returns correct tree', () { + var projects = {'a.b.c': 5, 'a.b.d': 3, 'a.e': 2}; + var tree = sparseDecoratedProjectTree(projects); + + expect(tree['a']!.tasks, 0); + expect(tree['a']!.subtasks, 10); + expect(tree['a']!.children, {'a.b', 'a.e'}); + + expect(tree['a.b']!.tasks, 0); + expect(tree['a.b']!.subtasks, 8); + expect(tree['a.b']!.children, {'a.b.c', 'a.b.d'}); + expect(tree['a.b']!.parent, 'a'); + + expect(tree['a.b.c']!.tasks, 5); + expect(tree['a.b.c']!.subtasks, 5); + expect(tree['a.b.c']!.children, []); + expect(tree['a.b.c']!.parent, 'a.b'); + + expect(tree['a.b.d']!.tasks, 3); + expect(tree['a.b.d']!.subtasks, 3); + expect(tree['a.b.d']!.children, []); + expect(tree['a.b.d']!.parent, 'a.b'); + + expect(tree['a.e']!.tasks, 2); + expect(tree['a.e']!.subtasks, 2); + expect(tree['a.e']!.children, []); + expect(tree['a.e']!.parent, 'a'); + }); + }); +} diff --git a/test/utils/taskfunctions/query_test.dart b/test/utils/taskfunctions/query_test.dart new file mode 100644 index 00000000..9c11e348 --- /dev/null +++ b/test/utils/taskfunctions/query_test.dart @@ -0,0 +1,70 @@ +import 'dart:io'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/query.dart'; + +void main() { + late Directory queryStorage; + late Query query; + + setUp(() { + queryStorage = Directory.systemTemp.createTempSync(); + query = Query(queryStorage); + }); + + tearDown(() { + queryStorage.deleteSync(recursive: true); + }); + + test('setSelectedSort and getSelectedSort', () { + query.setSelectedSort('priority+'); + expect(query.getSelectedSort(), 'priority+'); + }); + + test('getSelectedSort default value', () { + expect(query.getSelectedSort(), 'urgency+'); + }); + + test('togglePendingFilter and getPendingFilter', () { + expect(query.getPendingFilter(), true); + query.togglePendingFilter(); + expect(query.getPendingFilter(), false); + query.togglePendingFilter(); + expect(query.getPendingFilter(), true); + }); + + test('toggleWaitingFilter and getWaitingFilter', () { + expect(query.getWaitingFilter(), true); + query.toggleWaitingFilter(); + expect(query.getWaitingFilter(), false); + query.toggleWaitingFilter(); + expect(query.getWaitingFilter(), true); + }); + + test('toggleProjectFilter and projectFilter', () { + expect(query.projectFilter(), ''); + query.toggleProjectFilter('Project1'); + expect(query.projectFilter(), 'Project1'); + query.toggleProjectFilter('Project1'); + expect(query.projectFilter(), ''); + }); + + test('toggleTagUnion and tagUnion', () { + expect(query.tagUnion(), false); + query.toggleTagUnion(); + expect(query.tagUnion(), true); + query.toggleTagUnion(); + expect(query.tagUnion(), false); + }); + + test('toggleTagFilter and getSelectedTags', () { + expect(query.getSelectedTags(), {}); + query.toggleTagFilter('tag1'); + expect(query.getSelectedTags(), {'+tag1'}); + query.toggleTagFilter('tag1'); + expect(query.getSelectedTags(), {'-tag1'}); + query.toggleTagFilter('tag2'); + expect(query.getSelectedTags(), {'-tag1', '+tag2'}); + query.toggleTagFilter('tag2'); + expect(query.getSelectedTags(), {'-tag1', '-tag2'}); + }); +} diff --git a/test/utils/taskfunctions/tags_test.dart b/test/utils/taskfunctions/tags_test.dart new file mode 100644 index 00000000..4e44c9c3 --- /dev/null +++ b/test/utils/taskfunctions/tags_test.dart @@ -0,0 +1,64 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/models.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/tags.dart'; +import 'package:built_collection/built_collection.dart'; + +void main() { + group('Tags Utils', () { + late Task task1; + late Task task2; + late Task task3; + + setUp(() { + task1 = Task((b) => b + ..uuid = '1' + ..description = 'Task 1' + ..status = 'pending' + ..entry = DateTime.parse('2023-12-01T12:00:00Z') + ..tags = ListBuilder(['tag1', 'tag2']) + ..modified = DateTime.parse('2023-12-01T12:00:00Z')); + + task2 = Task((b) => b + ..uuid = '2' + ..description = 'Task 2' + ..status = 'pending' + ..entry = DateTime.parse('2023-12-01T12:00:00Z') + ..tags = ListBuilder(['tag2', 'tag3']) + ..modified = DateTime.parse('2023-12-02T12:00:00Z')); + + task3 = Task((b) => b + ..uuid = '3' + ..description = 'Task 3' + ..status = 'pending' + ..entry = DateTime.parse('2023-12-01T12:00:00Z') + ..tags = ListBuilder(['tag1', 'tag3']) + ..modified = DateTime.parse('2023-12-03T12:00:00Z')); + }); + + test('tagSet returns correct set of tags', () { + var tasks = [task1, task2, task3]; + var expectedTags = {'tag1', 'tag2', 'tag3'}; + expect(tagSet(tasks), expectedTags); + }); + + test('tagFrequencies returns correct tag frequencies', () { + var tasks = [task1, task2, task3]; + var expectedFrequencies = { + 'tag1': 2, + 'tag2': 2, + 'tag3': 2, + }; + expect(tagFrequencies(tasks), expectedFrequencies); + }); + + test('tagsLastModified returns correct last modified dates for tags', () { + var tasks = [task1, task2, task3]; + var expectedLastModified = { + 'tag1': DateTime.parse('2023-12-03T12:00:00Z'), + 'tag2': DateTime.parse('2023-12-02T12:00:00Z'), + 'tag3': DateTime.parse('2023-12-03T12:00:00Z'), + }; + expect(tagsLastModified(tasks), expectedLastModified); + }); + }); +} diff --git a/test/utils/taskfunctions/taskparser_test.dart b/test/utils/taskfunctions/taskparser_test.dart new file mode 100644 index 00000000..0c3b4768 --- /dev/null +++ b/test/utils/taskfunctions/taskparser_test.dart @@ -0,0 +1,63 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/taskparser.dart'; + +void main() { + group('Task Parser', () { + test('taskParser correctly parses description', () { + var taskString = 'This is a task description'; + var task = taskParser(taskString); + expect(task.description, 'This is a task description'); + expect(task.status, 'pending'); + }); + + test('taskParser throws FormatException for empty description', () { + var taskString = '+tag1 +tag2'; + expect(() => taskParser(taskString), throwsFormatException); + }); + + test('taskParser correctly parses tags', () { + var taskString = '+tag1 +tag2 This is a task description'; + var task = taskParser(taskString); + expect(task.tags, containsAll(['tag1', 'tag2'])); + expect(task.description, 'This is a task description'); + }); + + test('taskParser correctly parses attributes', () { + var taskString = + 'status:completed project:Project1 priority:H due:2024-12-25 wait:2024-12-20 until:2024-12-30 This is a task description'; + var task = taskParser(taskString); + expect(task.status, 'completed'); + expect(task.project, 'Project1'); + expect(task.priority, 'H'); + expect(task.description, 'This is a task description'); + }); + + test('taskParser handles mixed input', () { + var taskString = + 'status:completed +tag1 +tag2 This is a task description project:Project1'; + var task = taskParser(taskString); + expect(task.status, 'completed'); + expect(task.tags, containsAll(['tag1', 'tag2'])); + expect(task.description, 'This is a task description'); + expect(task.project, 'Project1'); + }); + + test('taskParser handles single quotes in attributes', () { + var taskString = + "status:'completed' project:'Project1' This is a task description"; + var task = taskParser(taskString); + expect(task.status, 'completed'); + expect(task.project, 'Project1'); + expect(task.description, 'This is a task description'); + }); + + test('taskParser assigns unique UUID and timestamps', () { + var taskString = 'This is a task description'; + var task = taskParser(taskString); + expect(task.uuid, isNotEmpty); + expect(task.entry, isNotNull); + expect(task.start, isNotNull); + expect(task.modified, isNotNull); + }); + }); +} diff --git a/test/utils/taskfunctions/urgency_test.dart b/test/utils/taskfunctions/urgency_test.dart new file mode 100644 index 00000000..f02adb31 --- /dev/null +++ b/test/utils/taskfunctions/urgency_test.dart @@ -0,0 +1,78 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/models/models.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/urgency.dart'; +import 'package:built_collection/built_collection.dart'; + +void main() { + group('Urgency Utils', () { + late Task task; + + setUp(() { + task = Task((b) => b + ..uuid = '1' + ..description = 'Test Task' + ..entry = DateTime.now().subtract(const Duration(days: 30)) + ..modified = DateTime.now() + ..status = 'pending' + ..priority = 'M' + ..tags = ListBuilder(['next']) + ..due = DateTime.now().subtract( + const Duration(days: 8)) // Set due date to 8 days in the past + ..scheduled = DateTime.now().subtract(const Duration(days: 2)) + ..wait = DateTime.now().add(const Duration(days: 1)) + ..project = 'Project1'); + }); + + test('formatUrgency formats urgency correctly', () { + expect(formatUrgency(15.0), '15'); + expect(formatUrgency(15.12345), '15.1'); + expect(formatUrgency(15.100), '15.1'); + expect(formatUrgency(15.10), '15.1'); + }); + + test('urgencyProject calculates project urgency', () { + expect(urgencyProject(task), 1.0); + }); + + test('urgencyScheduled calculates scheduled urgency', () { + expect(urgencyScheduled(task), 1.0); + }); + + test('urgencyWaiting calculates waiting urgency', () { + expect(urgencyWaiting(task), 1.0); + task = task.rebuild( + (b) => b..wait = DateTime.now().subtract(const Duration(days: 1))); + expect(urgencyWaiting(task), 0.0); + }); + + test('urgencyTags calculates tags urgency', () { + expect(urgencyTags(task), 0.8); + task = task.rebuild((b) => b..tags = ListBuilder(['tag1'])); + expect(urgencyTags(task), 0.8); + task = + task.rebuild((b) => b..tags = ListBuilder(['tag1', 'tag2'])); + expect(urgencyTags(task), 0.9); + }); + + test('urgencyDue calculates due urgency', () { + expect(urgencyDue(task), 1); + task = task.rebuild( + (b) => b..due = DateTime.now().subtract(const Duration(days: 10))); + expect(urgencyDue(task), 1); + task = task.rebuild( + (b) => b..due = DateTime.now().add(const Duration(days: 10))); + expect(urgencyDue(task), 0.352); + }); + + test('urgencyAge calculates age urgency', () { + expect(urgencyAge(task), closeTo(0.082, 0.001)); + task = task.rebuild( + (b) => b..entry = DateTime.now().subtract(const Duration(days: 365))); + expect(urgencyAge(task), 1.0); + }); + + test('urgency calculates overall urgency', () { + expect(urgency(task), closeTo(36.1, 2)); + }); + }); +} diff --git a/test/utils/taskfunctions/validate_test.dart b/test/utils/taskfunctions/validate_test.dart new file mode 100644 index 00000000..2f6f7201 --- /dev/null +++ b/test/utils/taskfunctions/validate_test.dart @@ -0,0 +1,40 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskfunctions/validate.dart'; + +void main() { + group('Validate Utils', () { + test('validateTaskDescription throws FormatException for empty description', + () { + expect(() => validateTaskDescription(''), throwsFormatException); + }); + + test( + 'validateTaskDescription throws FormatException for trailing backslash', + () { + expect(() => validateTaskDescription('Task description\\'), + throwsFormatException); + }); + + test('validateTaskDescription does not throw for valid description', () { + expect(() => validateTaskDescription('Valid task description'), + returnsNormally); + }); + + test('validateTaskProject throws FormatException for trailing backslash', + () { + expect(() => validateTaskProject('Project\\'), throwsFormatException); + }); + + test('validateTaskProject does not throw for valid project', () { + expect(() => validateTaskProject('ValidProject'), returnsNormally); + }); + + test('validateTaskTags throws FormatException for tag with space', () { + expect(() => validateTaskTags('invalid tag'), throwsFormatException); + }); + + test('validateTaskTags does not throw for valid tag', () { + expect(() => validateTaskTags('validTag'), returnsNormally); + }); + }); +} From d13a9bbae618bbf229b4144ee4217479862d9615 Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Mon, 16 Dec 2024 22:14:06 +0530 Subject: [PATCH 07/11] test: added test for all files under utils/taskserver --- test/utils/taskserver/credentials_test.dart | 33 +++++ test/utils/taskserver/parse_taskrc_test.dart | 76 ++++++++++ .../utils/taskserver/pem_file_paths_test.dart | 135 ++++++++++++++++++ test/utils/taskserver/server_test.dart | 45 ++++++ .../taskserver/taskrc_exception_test.dart | 18 +++ test/utils/taskserver/taskrc_test.dart | 71 +++++++++ 6 files changed, 378 insertions(+) create mode 100644 test/utils/taskserver/credentials_test.dart create mode 100644 test/utils/taskserver/parse_taskrc_test.dart create mode 100644 test/utils/taskserver/pem_file_paths_test.dart create mode 100644 test/utils/taskserver/server_test.dart create mode 100644 test/utils/taskserver/taskrc_exception_test.dart create mode 100644 test/utils/taskserver/taskrc_test.dart diff --git a/test/utils/taskserver/credentials_test.dart b/test/utils/taskserver/credentials_test.dart new file mode 100644 index 00000000..2278e3a5 --- /dev/null +++ b/test/utils/taskserver/credentials_test.dart @@ -0,0 +1,33 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskserver/credentials.dart'; + +void main() { + group('Credentials', () { + test('Credentials constructor sets fields correctly', () { + const credentials = Credentials( + org: 'testOrg', + user: 'testUser', + key: 'testKey', + ); + + expect(credentials.org, 'testOrg'); + expect(credentials.user, 'testUser'); + expect(credentials.key, 'testKey'); + }); + + test('Credentials.fromString parses string correctly', () { + final credentials = Credentials.fromString('testOrg/testUser/testKey'); + + expect(credentials.org, 'testOrg'); + expect(credentials.user, 'testUser'); + expect(credentials.key, 'testKey'); + }); + + test('Credentials.fromString throws on invalid string format', () { + expect(() => Credentials.fromString('invalidString'), + throwsA(isA())); + expect(() => Credentials.fromString('invalid/String'), + throwsA(isA())); + }); + }); +} diff --git a/test/utils/taskserver/parse_taskrc_test.dart b/test/utils/taskserver/parse_taskrc_test.dart new file mode 100644 index 00000000..b4bc7a95 --- /dev/null +++ b/test/utils/taskserver/parse_taskrc_test.dart @@ -0,0 +1,76 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskserver/parse_taskrc.dart'; + +void main() { + group('parseTaskrc', () { + test('parses a taskrc file correctly', () { + const contents = ''' +# This is a comment +key1=value1 +key2 = value2 +key3=value3 +# Another comment +key4 = value4 +'''; + final result = parseTaskrc(contents); + + expect(result, { + 'key1': 'value1', + 'key2': 'value2', + 'key3': 'value3', + 'key4': 'value4', + }); + }); + + test('ignores comments and empty lines', () { + const contents = ''' +# This is a comment +key1=value1 + +key2 = value2 +# Another comment +'''; + final result = parseTaskrc(contents); + + expect(result, { + 'key1': 'value1', + 'key2': 'value2', + }); + }); + + test('handles lines with escaped slashes correctly', () { + const contents = ''' +key1=value\\/1 +key2 = value\\/2 +'''; + final result = parseTaskrc(contents); + + expect(result, { + 'key1': 'value/1', + 'key2': 'value/2', + }); + }); + + test('trims keys and values', () { + const contents = ''' +key1 = value1 + key2= value2 +key3 =value3 +'''; + final result = parseTaskrc(contents); + + expect(result, { + 'key1': 'value1', + 'key2': 'value2', + 'key3': 'value3', + }); + }); + + test('returns empty map for empty input', () { + const contents = ''; + final result = parseTaskrc(contents); + + expect(result, {}); + }); + }); +} diff --git a/test/utils/taskserver/pem_file_paths_test.dart b/test/utils/taskserver/pem_file_paths_test.dart new file mode 100644 index 00000000..a0fa307d --- /dev/null +++ b/test/utils/taskserver/pem_file_paths_test.dart @@ -0,0 +1,135 @@ +import 'dart:io'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskserver/pem_file_paths.dart'; + +class MockX509Certificate implements X509Certificate { + @override + final String pem; + + MockX509Certificate(this.pem); + + @override + noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); +} + +void main() { + group('PemFilePaths', () { + setUp(() { + // Create test directory and files if they don't exist + Directory('test/fixtures').createSync(recursive: true); + File('test/fixtures/server.pem') + .writeAsStringSync('matching-pem-content'); + }); + + tearDown(() { + // Clean up test files + if (File('test/fixtures/server.pem').existsSync()) { + File('test/fixtures/server.pem').deleteSync(); + } + }); + + test('PemFilePaths constructor sets fields correctly', () { + const pemFilePaths = PemFilePaths( + ca: 'path/to/ca.pem', + certificate: 'path/to/cert.pem', + key: 'path/to/key.pem', + serverCert: 'path/to/server.pem', + ); + + expect(pemFilePaths.ca, 'path/to/ca.pem'); + expect(pemFilePaths.certificate, 'path/to/cert.pem'); + expect(pemFilePaths.key, 'path/to/key.pem'); + expect(pemFilePaths.serverCert, 'path/to/server.pem'); + }); + + test('PemFilePaths.fromTaskrc parses taskrc correctly', () { + final taskrc = { + 'taskd.ca': 'path/to/ca.pem', + 'taskd.certificate': 'path/to/cert.pem', + 'taskd.key': 'path/to/key.pem', + }; + final pemFilePaths = PemFilePaths.fromTaskrc(taskrc); + + expect(pemFilePaths.ca, 'path/to/ca.pem'); + expect(pemFilePaths.certificate, 'path/to/cert.pem'); + expect(pemFilePaths.key, 'path/to/key.pem'); + expect(pemFilePaths.serverCert, isNull); + }); + + test('PemFilePaths.securityContext creates SecurityContext correctly', () { + const pemFilePaths = PemFilePaths( + ca: 'test/fixtures/ca.pem', + certificate: 'test/fixtures/cert.pem', + key: 'test/fixtures/key.pem', + ); + + final context = pemFilePaths.securityContext(); + + expect(context, isA()); + }); + + test( + 'PemFilePaths.savedServerCertificateMatches returns true for matching certificates', + () { + const pemFilePaths = PemFilePaths( + serverCert: 'test/fixtures/server.pem', + ); + final badServerCert = MockX509Certificate('matching-pem-content'); + + final result = pemFilePaths.savedServerCertificateMatches(badServerCert); + + expect(result, true); + }); + + test( + 'PemFilePaths.savedServerCertificateMatches returns false for non-matching certificates', + () { + const pemFilePaths = PemFilePaths( + serverCert: 'test/fixtures/server.pem', + ); + final badServerCert = MockX509Certificate('non-matching-pem-content'); + + // Write the non-matching content to the server cert file for the test + File('test/fixtures/server.pem') + .writeAsStringSync('different-pem-content'); + + final result = pemFilePaths.savedServerCertificateMatches(badServerCert); + + expect(result, false); + }); + + test('PemFilePaths.map returns correct map representation', () { + const pemFilePaths = PemFilePaths( + ca: 'path/to/ca.pem', + certificate: 'path/to/cert.pem', + key: 'path/to/key.pem', + serverCert: 'path/to/server.pem', + ); + + final map = pemFilePaths.map; + + expect(map, { + 'taskd.ca': 'path/to/ca.pem', + 'taskd.certificate': 'path/to/cert.pem', + 'taskd.key': 'path/to/key.pem', + 'server.cert': 'path/to/server.pem', + }); + }); + + test('PemFilePaths.map omits null values', () { + const pemFilePaths = PemFilePaths( + ca: 'path/to/ca.pem', + certificate: 'path/to/cert.pem', + key: null, + serverCert: null, + ); + + final map = pemFilePaths.map; + + expect(map, { + 'taskd.ca': 'path/to/ca.pem', + 'taskd.certificate': 'path/to/cert.pem', + }); + }); + }); +} diff --git a/test/utils/taskserver/server_test.dart b/test/utils/taskserver/server_test.dart new file mode 100644 index 00000000..e164c336 --- /dev/null +++ b/test/utils/taskserver/server_test.dart @@ -0,0 +1,45 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskserver/server.dart'; +import 'package:taskwarrior/app/utils/taskserver/taskrc_exception.dart'; + +void main() { + group('Server', () { + test('Server constructor sets fields correctly', () { + const server = Server( + address: 'example.com', + port: 8080, + ); + + expect(server.address, 'example.com'); + expect(server.port, 8080); + }); + + test('Server.fromString parses valid server string', () { + final server = Server.fromString('example.com:8080'); + + expect(server.address, 'example.com'); + expect(server.port, 8080); + }); + + test( + 'Server.fromString throws TaskrcException for invalid format without colon', + () { + expect(() => Server.fromString('example.com8080'), + throwsA(isA())); + }); + + test('Server.fromString throws TaskrcException for invalid port', () { + expect(() => Server.fromString('example.com:invalid'), + throwsA(isA())); + }); + + test('Server.toString returns correct string representation', () { + const server = Server( + address: 'example.com', + port: 8080, + ); + + expect(server.toString(), 'example.com:8080'); + }); + }); +} diff --git a/test/utils/taskserver/taskrc_exception_test.dart b/test/utils/taskserver/taskrc_exception_test.dart new file mode 100644 index 00000000..3b562f89 --- /dev/null +++ b/test/utils/taskserver/taskrc_exception_test.dart @@ -0,0 +1,18 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskserver/taskrc_exception.dart'; + +void main() { + group('TaskrcException', () { + test('TaskrcException constructor sets message correctly', () { + final exception = TaskrcException('An error occurred'); + + expect(exception.message, 'An error occurred'); + }); + + test('TaskrcException.toString returns correct message', () { + final exception = TaskrcException('An error occurred'); + + expect(exception.toString(), 'An error occurred'); + }); + }); +} diff --git a/test/utils/taskserver/taskrc_test.dart b/test/utils/taskserver/taskrc_test.dart new file mode 100644 index 00000000..6963d5a0 --- /dev/null +++ b/test/utils/taskserver/taskrc_test.dart @@ -0,0 +1,71 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/taskserver/taskrc.dart'; +import 'package:taskwarrior/app/utils/taskserver/server.dart'; +import 'package:taskwarrior/app/utils/taskserver/credentials.dart'; +import 'package:taskwarrior/app/utils/taskserver/pem_file_paths.dart'; + +void main() { + group('Taskrc', () { + test('Taskrc constructor sets fields correctly', () { + const server = Server(address: 'example.com', port: 8080); + const credentials = Credentials(org: 'org', user: 'user', key: 'key'); + const pemFilePaths = PemFilePaths( + ca: 'path/to/ca.pem', + certificate: 'path/to/cert.pem', + key: 'path/to/key.pem', + ); + final taskrc = Taskrc( + server: server, + credentials: credentials, + pemFilePaths: pemFilePaths, + ); + + expect(taskrc.server, server); + expect(taskrc.credentials, credentials); + expect(taskrc.pemFilePaths, pemFilePaths); + }); + + test('Taskrc.fromString parses valid taskrc string', () { + const taskrcString = ''' +taskd.server=example.com:8080 +taskd.credentials=org/user/key +taskd.ca=path/to/ca.pem +taskd.certificate=path/to/cert.pem +taskd.key=path/to/key.pem +'''; + final taskrc = Taskrc.fromString(taskrcString); + + expect(taskrc.server, isA()); + expect(taskrc.credentials, isA()); + expect(taskrc.pemFilePaths, isA()); + }); + + test('Taskrc.fromMap parses valid taskrc map', () { + final taskrcMap = { + 'taskd.server': 'example.com:8080', + 'taskd.credentials': 'org/user/key', + 'taskd.ca': 'path/to/ca.pem', + 'taskd.certificate': 'path/to/cert.pem', + 'taskd.key': 'path/to/key.pem', + }; + final taskrc = Taskrc.fromMap(taskrcMap); + + expect(taskrc.server, isA()); + expect(taskrc.credentials, isA()); + expect(taskrc.pemFilePaths, isA()); + }); + + test('Taskrc.fromMap handles missing optional fields', () { + final taskrcMap = { + 'taskd.ca': 'path/to/ca.pem', + 'taskd.certificate': 'path/to/cert.pem', + 'taskd.key': 'path/to/key.pem', + }; + final taskrc = Taskrc.fromMap(taskrcMap); + + expect(taskrc.server, isNull); + expect(taskrc.credentials, isNull); + expect(taskrc.pemFilePaths, isA()); + }); + }); +} From c41350de04fa60618d5238bc0a3ed95ea12b3322 Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Mon, 16 Dec 2024 22:14:21 +0530 Subject: [PATCH 08/11] test: added test for all files under utils/themes --- test/utils/themes/dark_theme_test.dart | 11 +++++++++++ test/utils/themes/light_theme_test.dart | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/utils/themes/dark_theme_test.dart create mode 100644 test/utils/themes/light_theme_test.dart diff --git a/test/utils/themes/dark_theme_test.dart b/test/utils/themes/dark_theme_test.dart new file mode 100644 index 00000000..68f0bebf --- /dev/null +++ b/test/utils/themes/dark_theme_test.dart @@ -0,0 +1,11 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/themes/dark_theme.dart'; + +void main() { + group('darkTheme', () { + test('darkTheme has correct brightness', () { + expect(darkTheme.brightness, Brightness.dark); + }); + }); +} diff --git a/test/utils/themes/light_theme_test.dart b/test/utils/themes/light_theme_test.dart new file mode 100644 index 00000000..dcfed347 --- /dev/null +++ b/test/utils/themes/light_theme_test.dart @@ -0,0 +1,11 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:taskwarrior/app/utils/themes/light_theme.dart'; + +void main() { + group('lightTheme', () { + test('lightTheme has correct brightness', () { + expect(lightTheme.brightness, Brightness.light); + }); + }); +} From 373e50c3d0d4c4a546bb942eed3b0524d3dc1b3e Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Mon, 16 Dec 2024 22:16:42 +0530 Subject: [PATCH 09/11] test: added test for all files under utils/permissions --- .../permissions/permissions_manager_test.dart | 31 ++++++++++++++++ .../permissions_manager_test.mocks.dart | 37 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 test/utils/permissions/permissions_manager_test.dart create mode 100644 test/utils/permissions/permissions_manager_test.mocks.dart diff --git a/test/utils/permissions/permissions_manager_test.dart b/test/utils/permissions/permissions_manager_test.dart new file mode 100644 index 00000000..a4ce130f --- /dev/null +++ b/test/utils/permissions/permissions_manager_test.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:taskwarrior/app/utils/permissions/permissions_manager.dart'; +import 'package:taskwarrior/app/utils/constants/permissions.dart'; + +import 'permissions_manager_test.mocks.dart'; + +@GenerateMocks([Permission]) +void main() { + group('PermissionsManager', () { + late MockPermission mockPermission; + + setUp(() { + WidgetsFlutterBinding.ensureInitialized(); + mockPermission = MockPermission(); + permissions.clear(); + permissions.add(mockPermission); + }); + test('requestAllPermissions handles permission denied', () async { + when(mockPermission.request()) + .thenAnswer((_) async => PermissionStatus.denied); + + await PermissionsManager.requestAllPermissions(); + + verify(mockPermission.request()).called(1); + }); + }); +} diff --git a/test/utils/permissions/permissions_manager_test.mocks.dart b/test/utils/permissions/permissions_manager_test.mocks.dart new file mode 100644 index 00000000..5b72aa54 --- /dev/null +++ b/test/utils/permissions/permissions_manager_test.mocks.dart @@ -0,0 +1,37 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in taskwarrior/test/utils/permissions/permissions_manager_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:mockito/mockito.dart' as _i1; +import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart' + as _i2; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +/// A class which mocks [Permission]. +/// +/// See the documentation for Mockito's code generation for more information. +// ignore: must_be_immutable +class MockPermission extends _i1.Mock implements _i2.Permission { + MockPermission() { + _i1.throwOnMissingStub(this); + } + + @override + int get value => (super.noSuchMethod( + Invocation.getter(#value), + returnValue: 0, + ) as int); +} From db864353ffaa6e2d1a9bd1d36dc111f66e6d4579 Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Mon, 16 Dec 2024 22:40:55 +0530 Subject: [PATCH 10/11] fix: updated import dependecy in utils/taskchampion --- test/utils/taskchampion/credentials_storage_test.mocks.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/taskchampion/credentials_storage_test.mocks.dart b/test/utils/taskchampion/credentials_storage_test.mocks.dart index 72d04164..46fb4569 100644 --- a/test/utils/taskchampion/credentials_storage_test.mocks.dart +++ b/test/utils/taskchampion/credentials_storage_test.mocks.dart @@ -6,7 +6,7 @@ import 'dart:async' as _i3; import 'package:mockito/mockito.dart' as _i1; -import 'package:shared_preferences/src/shared_preferences_legacy.dart' as _i2; +import 'package:shared_preferences/shared_preferences.dart' as _i2; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values From badbf4ae10c2c71ab4286ea5aca9f025a8d853a7 Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Mon, 16 Dec 2024 22:51:29 +0530 Subject: [PATCH 11/11] fix: fixed analysis errors by adding build_collection to dependencies --- pubspec.yaml | 1 + test/utils/taskfunctions/comparator_test.dart | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index dafde94a..76c5869d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -63,6 +63,7 @@ dependencies: tutorial_coach_mark: ^1.2.11 url_launcher: ^6.1.14 uuid: ^4.2.2 + built_collection: ^5.1.1 dev_dependencies: build_runner: null diff --git a/test/utils/taskfunctions/comparator_test.dart b/test/utils/taskfunctions/comparator_test.dart index 32409a93..5957beee 100644 --- a/test/utils/taskfunctions/comparator_test.dart +++ b/test/utils/taskfunctions/comparator_test.dart @@ -91,9 +91,6 @@ void main() { final task1 = createTask(); final task2 = createTask(); - // Define urgency function to compare tasks - int urgency(Task task) => task.entry.microsecondsSinceEpoch; - final comparator = compareTasks('Urgency'); expect(comparator(task1, task2), equals(0)); });