Conversation
This commit adds several unit tests to `config_loader_test.dart` to cover edge cases and error scenarios when loading organization configurations, including handling null repository files and remote loading failures.
### Key Changes:
- **`test/core/config/config_loader_test.dart`**:
- Updated `tearDown` to properly clear the mock message handler for `flutter/assets` and reset `GetIt`.
- Added a test case to verify that an error is set (`setError(true)`) when the GitHub repository content returns a null file.
- Added a test case to verify successful local fallback when `githubItem` is null or missing specific keys.
- Added a test case to verify that an error is set when remote configuration fails to load and local configuration is empty.
- Cleaned up redundant comments and added `rootBundle.clear()` to ensure test isolation.
This commit adds unit tests to `secure_info_test.dart` to verify that `SecureInfo` correctly handles and throws exceptions when storage operations for GitHub tokens fail.
### Key Changes:
- **`test/core/config/secure_info_test.dart`**:
- Added a test case to verify that `saveGithubKey` throws an `Exception` when the underlying storage write operation fails.
- Added a test case to verify that `removeGithubKey` throws an `Exception` when the underlying storage delete operation fails.
- Mocked the `MethodChannel` behavior to simulate failures during storage access.
This commit updates a unit test in `config_loader_test.dart` to explicitly call `ConfigLoader.loadOrganization()`, ensuring the error state verification is correctly triggered during the test execution.
### Key Changes:
- **`test/core/config/config_loader_test.dart`**:
- Added a call to `ConfigLoader.loadOrganization()` within a test case to properly exercise the logic that triggers `mockCheckOrg.setError(true)`.
… routing
This commit introduces a comprehensive test suite for the `Result` utility class to ensure type safety and correct pattern matching. It also simplifies the routing logic for the agenda form by removing a redundant null check.
### Key Changes:
- **`test/core/utils/result_test.dart`**:
- Added unit tests for `Result.ok` and `Result.error` to verify value encapsulation and `toString` output.
- Added tests for pattern matching using Dart 3 switch expressions.
- Added type safety tests to ensure generic integrity between `Result<int>` and `Result<String>`.
- Defined a `TestException` mock class to facilitate error state testing.
- **`lib/core/routing/app_router.dart`**:
- Removed a redundant null check in the `agendaFormPath` builder, as `state.extra` is now expected to be cast directly to `AgendaFormData`.
This commit refactors the `GithubJsonModel.fromJson` factory to use more direct list casting and adds a template JSON file for GitHub items.
### Key Changes:
- **`lib/core/models/github_json_model.dart`**:
- Simplified the parsing logic for `events`, `tracks`, `sessions`, `agendadays`, `sponsors`, and `speakers`.
- Removed redundant null-aware operators (`?` and `?? []`) when casting lists, assuming the existence check `json['key'] != null` is sufficient for a direct `as List` cast.
- **`events/githubItem/githubItem.json`**:
- Added a new JSON file providing a base structure with empty arrays for all major entities.
…es.updateData`
This commit enhances the test suite for `commons_api_services_test.dart` by adding several test cases to verify error handling during the GitHub data update process. It also includes minor cleanup in the `SessionType` model and updates generated mocks.
### Key Changes:
- **`test/data/remote_data/common/commons_api_services_test.dart`**:
- Added tests to verify `GithubException` is thrown when the file `sha` is null during an update.
- Added tests to simulate `GitHubError` (e.g., "Not Found") from the GitHub SDK, covering scenarios where file creation either succeeds or fails.
- Added a test case to ensure an exception is thrown when the GitHub token is missing or null.
- Added a test case to handle scenarios where the repository content response is null.
- Refactored several existing tests to improve readability and ensure consistent mock setups.
- **`lib/core/models/session_type.dart`**:
- Removed the unused `allLabels` static method.
- **`test/mocks.dart`**:
- Added `ContentCreation` to the list of mocked classes.
- **`test/mocks.mocks.dart`**:
- Regenerated mocks to include `MockContentCreation`.
# Conflicts: # events/githubItem/githubItem.json
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #145 +/- ##
==========================================
+ Coverage 89.36% 90.47% +1.10%
==========================================
Files 78 78
Lines 6431 6464 +33
==========================================
+ Hits 5747 5848 +101
+ Misses 684 616 -68 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…vices`
This commit introduces several unit tests to `commons_api_services_test.dart` to verify error handling and specific edge cases for `updateData`, `updateDataList`, and `updateSingleData`.
### Key Changes:
- **`test/data/remote_data/common/commons_api_services_test.dart`**:
- Added a test for `updateData` to verify it throws a `NetworkException` when the HTTP status code is 400.
- Added multiple test cases for `updateDataList` to handle scenarios including:
- Throwing a `GithubException` when the file SHA is null.
- Throwing a `GithubException` when `getContents` fails and the file cannot be created.
- Successful execution when `getContents` fails but `createFile` succeeds.
- Throwing a `GithubException` when the created file content is null.
- Throwing a `NetworkException` when the update results in a 400 status code.
- Updated the error handling test for `updateSingleData` to use an asynchronous expectation for better reliability.
…piServices`
This commit adds several unit tests to `commons_api_services_test.dart` to verify error handling for `updateDataList` and `removeDataList` methods, specifically targeting various GitHub API failure scenarios and HTTP error status codes.
### Key Changes:
- **`test/data/remote_data/common/commons_api_services_test.dart`**:
- Added a test case for `updateDataList` to verify it throws a `NetworkException` when receiving a 409 Conflict status code.
- Added comprehensive test cases for `removeDataList` covering:
- Scenarios where the repository file SHA is null.
- GitHub API "Not Found" errors during content retrieval, including cases where file creation subsequently fails or succeeds.
- Handling of null content in API responses.
- HTTP error responses (400 and 409 status codes) during the data removal process.
- Refactored existing tests for consistent indentation and improved readability.
- Fixed a typo in a test description from `updateData` to `updateDataList`.
…piServices`
This commit adds several unit tests to `commons_api_services_test.dart` to verify error handling and edge cases for the `updateAllData` method, ensuring robust behavior when interacting with the GitHub API.
### Key Changes:
- **`test/data/remote_data/common/commons_api_services_test.dart`**:
- Added tests to verify that `GithubException` is thrown when the file `sha` is null during content retrieval.
- Added a test case for handling `GitHubError` (e.g., "Not Found") from the repository service, covering both successful and failed attempts to create a missing file.
- Added a test case to ensure a `GithubException` is thrown if the file creation response contains null content.
- Added tests for HTTP error responses from the client, verifying that a `NetworkException` is thrown for status codes `400` and `409`.
- Integrated `MockSecureInfo` and dependency injection overrides to simulate various GitHub configuration states during tests.
This commit introduces unit tests to verify the functionality of the room creation dialog and adds necessary keys to the UI components to facilitate testing.
### Key Changes:
- **`lib/presentation/ui/screens/agenda/form/agenda_form_screen.dart`**:
- Added `Key` identifiers to the room name `TextFormField`, "Cancel" button, and "Save" button within the room dialog to enable widget testing.
- **`test/presentation/agenda/form/agenda_form_screen_test.dart`**:
- Added a new test group 'room dialog' with three test cases:
- Verifies that the room dialog opens when the "add room" button is pressed.
- Verifies that the dialog closes correctly when the "cancel" button is tapped.
- Verifies that the dialog saves the input and closes when the "save" button is tapped.
- Cleaned up minor formatting and trailing whitespace in existing tests.
…een`
This commit removes the redundant `isTimeSelected` utility method from `AgendaFormScreen` as it is no longer used within the codebase.
### Key Changes:
- **`lib/presentation/ui/screens/agenda/form/agenda_form_screen.dart`**:
- Deleted the `isTimeSelected` helper method.
…ve `EventCollectionScreen` test coverage
This commit enhances the test suite for event collection and login flows by adding specific widget keys for testing, introducing new test cases for admin interactions, and cleaning up redundant tests in `event_collection_screen_test.dart`.
### Key Changes:
- **`lib/presentation/ui/screens/event_collection/event_collection_screen.dart`**:
- Added `title_key_event_collection` key to the `AppBar` title `GestureDetector` to facilitate targeted tap testing.
- **`lib/presentation/ui/screens/login/admin_login_screen.dart`**:
- Added unique keys (`title_key_event_collection`, `token_key_github`, `login_button`) to UI components for more robust widget testing.
- Refactored GitHub client initialization into a helper method `getGithubUser()`.
- **`test/presentation/event_collection/event_collection_screen_test.dart`**:
- Refactored existing tests for better readability and consistent formatting.
- Added a new test case to verify that tapping the screen title 5 times correctly triggers the `AdminLoginScreen` dialog when an organization error exists.
- Removed several admin-related test cases (visibility toggle, edit/delete event, organization FAB) that were redundant or out of scope for this suite.
- **`test/mocks.dart` & `test/mocks.mocks.dart`**:
- Generated new mocks for `CurrentUser` and `UsersService` to support authentication and user-related test scenarios.
This commit introduces several new localization keys to support option management (adding and deleting) and confirmation dialogs across all supported languages.
### Key Changes:
- **Localization Files (`.arb`, `.dart`)**:
- Added `confirm`: Translation for generic confirmation actions.
- Added `deleteOptionMessage`: Confirmation prompt for deleting an option.
- Added `delete`: Translation for delete actions.
- Added `addOption`: Translation for adding a new option.
- Added `optionHint`: Placeholder text for option input fields.
- Updated English, Basque, Catalan, Spanish, French, Galician, Italian, and Portuguese localizations.
- Fixed a typo in `app_eu.arb` for `tokenHintLabel`.
- **Tests**:
- Updated unit tests for various languages (English, French, Portuguese, Spanish, Catalan, Galician, Italian, Basque) to verify the presence and correctness of the new localized strings.
This commit updates the `tokenHintLabel` string in the Basque localization and its corresponding test to reflect a change in the translation text.
### Key Changes:
- **`lib/l10n/app_localizations_eu.dart`**:
- Updated `tokenHintLabel` from "Sartu zure bezeroaren sekretua jarraitzeko" to "Sartu votre bezeroaren sekretua jarraitzeko".
- **`test/l10n/app_localizations_eu_test.dart`**:
- Updated the test expectation for `tokenHintLabel` to match the new string value.
This commit replaces hardcoded Spanish and English strings with localized alternatives in the `AddRoom` widget to support internationalization.
### Key Changes:
- **`lib/presentation/ui/widgets/add_room.dart`**:
- Imported `AppLocalizations`.
- Updated the `_confirmRemoveOption` dialog to use localized strings for the title (`confirm`), content (`deleteOptionMessage`), and action buttons (`cancel`, `delete`).
- Updated the "Add Option" button label in the `build` method to use the localized `addOption` string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.