Conversation
This commit will be effectively rolled back, it's just to test Prettier in action
Add back husky install script in package.json
Add back lint-staged
Add xml formatting, remove JS test file. Tested use of Prettier Kotlin plugin, but it's ill-maintained and errors on many files so will try to use ktlint to handle kotlin formatting
XML plugin causes errors in Super-Linter action flow. This is a known problem and is unlikely to be resolved
Kover report can't function without build
Only significant change is to specify a Java toolchain (17) in the top-level build.gradle.kts file, so it doesn't implicitly use your local version
- Localize "log" to "Registre" in French - Add constraints to activity crash screen textview
KoverReport failed because path to report.xml was invalid. Hopefully this commit will allow me to see the correct path so I can change the action
Original workflow did not account for app folder nesting
- Adjust path printing - Add artifact upload action steps for build
Add PNG UML diagrams for SendScreenViewModel, SettingsScreenViewModel, and UserRepository under uml/Images. These new binary assets provide visual documentation of the viewmodel and repository structure.
Add unit tests for ContentResolver extension and SelectDestNodeScreenViewModel. Tests cover getUriNameAndSize (file URIs, null/query/cursor behaviors, name/size extraction) and ViewModel behaviors (initial state, collecting node state, onClickReceiver success/failure paths and interactions with AppServer). Also add UML class diagram sources and PNG images for both components. Minor whitespace adjustment in SelectDestNodeScreenViewModel.kt.
# Conflicts: # app/src/test/java/com/greybox/projectmesh/viewModel/SelectDestNodeScreenViewModelTest.kt # app/src/test/java/com/greybox/projectmesh/viewModel/SendScreenViewModelTest.kt # app/src/test/java/com/greybox/projectmesh/viewModel/SettingsScreenViewModelTest.kt
Add PNG renderings for messaging UML assets (Conversation, ConversationDao, JSONSchema, Message, MessageDao) under uml/Images/Components/messaging and move corresponding .puml class diagrams into uml/class-diagrams/components/messaging to better organize messaging-related UML files.
Add comprehensive unit tests for MessageNetworkHandler (app/src/test/.../MessageNetworkHandlerTest.kt) covering sendChatMessage (request construction, file query param, and exception handling) and handleIncomingMessage (mapping messages to users, conversation creation/update, and unknown-sender behavior). Tests mock OkHttp, Kodein DI, repositories and GlobalApp globals. Also add UML class diagram and PNG (uml/class-diagrams/... .puml and uml/Images/...) describing MessageNetworkHandler structure and companion.
Add unit tests for MessageService (MessageServiceTest.kt) covering sendMessage behavior: verifies message is saved before network send, repository failures prevent network sends, and network failures propagate after save. Also add UML assets (MessageService.png and MessageService.puml) documenting the MessageService class and its dependencies.
Add comprehensive unit tests for UserDao using an in-memory Room database and Robolectric (SDK 29). Tests cover insert/getByUuid, getUserByIp, updateUser, hasWithID, getAllConnectedUsers, getAllUsers, and missing-query behavior, and use ExperimentalCoroutinesApi with runTest. Also add a PlantUML class diagram and corresponding PNG for the UserDao component.
Add unit tests for UserEntity that verify default nullable fields, data class equality/hashCode/copy behavior, and kotlinx.serialization round-trip. Also add a PlantUML class diagram and corresponding PNG image to document the UserEntity structure.
Adds a Robolectric test for NotificationHelper and supporting UML assets. New test (app/src/test/java/com/greybox/projectmesh/util/NotificationHelperTest.kt) verifies: creation of notification channel on API 26+, no channel behavior on API <26, and that showFileReceivedNotification posts a notification with expected title/text/auto-cancel flag and intent extras. Also adds UML diagram and image (uml/class-diagrams/components/util/NotificationHelper.puml and uml/Images/Components/util/NotificationHelper.png) documenting the NotificationHelper API and its related classes. These changes improve test coverage and documentation for notification behavior.
…oject-Mesh into unitTesting-asu2025F
Introduce comprehensive unit tests for core components and add UML diagrams/images. Adds tests for MNetLoggerAndroid (log filtering, history trimming, file persistence, export), Context extension helpers (permissions, Wi‑Fi capabilities, device info), AppServer (routes, outgoing transfers, chat handling, reachability), and testing utilities (TestDeviceEntry/TestDeviceService behavior and initialization). Also includes PlantUML class diagrams and component images for the covered modules to aid design documentation.
There was a problem hiding this comment.
Code Review
This pull request significantly enhances the project's testing infrastructure and documentation. It introduces a comprehensive suite of unit tests for view models, repositories, and DAOs, utilizing libraries such as MockK, Robolectric, and Turbine. Additionally, it adds numerous PlantUML diagrams for architectural clarity, configures a CI pipeline with Prettier and Husky, and refactors core components like the Logger and FileEncoder. Feedback focuses on improving the quality and consistency of the new tests, including removing redundant dependency declarations and commented-out code, consolidating duplicate test rules into shared utilities, ensuring proper test isolation by clearing internal state in setup methods, and correcting package and filename mismatches.
| class ReceiveScreenViewModelTest { | ||
|
|
||
| private val mainDispatcher = StandardTestDispatcher() | ||
|
|
||
| @Before | ||
| fun setUp() { | ||
| mockkStatic(Looper::class) | ||
| every { Looper.getMainLooper() } returns mockk(relaxed = true) | ||
| Dispatchers.setMain(mainDispatcher) | ||
| } | ||
|
|
||
| @After | ||
| fun tearDown() { | ||
| Dispatchers.resetMain() | ||
| } |
There was a problem hiding this comment.
Instead of manually setting and resetting the main dispatcher in setUp and tearDown, consider using the shared MainDispatcherRule from the testutil package. This would make the test setup cleaner and more consistent with other view model tests in the project.
Example:
@get:Rule
val mainDispatcherRule = MainDispatcherRule()| @@ -0,0 +1,225 @@ | |||
| // File: app/src/test/java/com/greybox/projectmesh/views/NetworkScreenUiLogicTest.kt | |||
There was a problem hiding this comment.
| @OptIn(ExperimentalCoroutinesApi::class) | ||
| class MainDispatcherRule( | ||
| private val dispatcher: TestDispatcher = StandardTestDispatcher() | ||
| ) : TestWatcher() { | ||
|
|
||
| override fun starting(description: Description) { | ||
| Dispatchers.setMain(dispatcher) | ||
| } | ||
|
|
||
| override fun finished(description: Description) { | ||
| Dispatchers.resetMain() | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
| @OptIn(ExperimentalCoroutinesApi::class) | ||
| class ConversationsMainDispatcherRule( | ||
| private val dispatcher: TestDispatcher = StandardTestDispatcher() | ||
| ) : TestWatcher() { | ||
|
|
||
| override fun starting(description: Description) { | ||
| Dispatchers.setMain(dispatcher) | ||
| } | ||
|
|
||
| override fun finished(description: Description) { | ||
| Dispatchers.resetMain() | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
This ConversationsMainDispatcherRule is a duplicate of the MainDispatcherRule defined in app/src/test/java/com/greybox/projectmesh/testutil/MainDispatcherRule.kt. To avoid code duplication and improve maintainability, please remove this local definition and import the shared one from the testutil package.
| @@ -0,0 +1,31 @@ | |||
| package com.greybox.projectmesh.utils | |||
There was a problem hiding this comment.
The package declaration for this test file is com.greybox.projectmesh.utils, but it is located in the messaging/utils directory and tests Logger.kt from that package. For consistency with standard project structure, please update the package to com.greybox.projectmesh.messaging.utils.
| package com.greybox.projectmesh.utils | |
| package com.greybox.projectmesh.messaging.utils |
| @@ -0,0 +1,233 @@ | |||
| // File: app/src/test/java/com/greybox/projectmesh/views/ReceiveScreenUiLogicTest.kt | |||
There was a problem hiding this comment.
| @@ -0,0 +1,418 @@ | |||
| // File: app/src/test/java/com/greybox/projectmesh/views/RequestPermissionsUiLogicTest.kt | |||
There was a problem hiding this comment.
| @@ -0,0 +1,107 @@ | |||
| // File: app/src/test/java/com/greybox/projectmesh/views/SelectDestNodeScreenUiLogicTest.kt | |||
There was a problem hiding this comment.
| @@ -0,0 +1,187 @@ | |||
| // File: app/src/test/java/com/greybox/projectmesh/views/SendScreenUiLogicTest.kt | |||
There was a problem hiding this comment.
| @@ -0,0 +1,237 @@ | |||
| // File: app/src/test/java/com/greybox/projectmesh/views/SettingsScreenUiLogicTest.kt | |||
There was a problem hiding this comment.
This pull request introduces JVM unit test cases along with PlantUML (PUML) diagrams and their corresponding exported images to improve both code reliability and architectural clarity of the entire project. The primary goal of this change is to strengthen the testing foundation while also providing visual documentation that makes it easier to understand the system structure and data flow.
JVM test cases are unit tests that run on the Java Virtual Machine without requiring an Android device or emulator. These tests are located in the test directory and focus on validating core application logic such as ViewModel behavior, repository operations, utility functions, and state management using flows. Since they do not depend on the Android framework, they execute quickly and are ideal for iterative development and continuous integration.
The addition of these tests improves the stability of the codebase by ensuring that critical business logic behaves as expected under different scenarios. It also establishes a foundation for scalable testing practices, making it easier to extend coverage as new features are added.
Alongside the tests, this pull request includes PlantUML diagrams that represent different layers of the application components. These diagrams help visualize relationships, dependencies, and data flow within the system. Exported image versions of these diagrams are also included so that they can be viewed without requiring PlantUML setup, making them useful for documentation and onboarding.
While this pull request significantly improves testing at the logic level, Android-specific testing is still pending. The remaining work includes the following. First, UI testing using Jetpack Compose needs to be implemented to validate composable rendering, user interactions, and navigation flows. Second, integration testing is required to verify interactions between ViewModels and UI, as well as end-to-end user flows such as messaging and file transfers. Third, features that depend on the Android framework such as file handling with MediaStore, URI operations, intents, and permissions need to be tested using instrumentation tests. Fourth, device-specific behaviors such as network state changes, lifecycle handling, and background processing also need validation on real devices or emulators.
In summary, this pull request completes the addition of core JVM-based testing and architectural documentation, while Android instrumentation and UI testing remain the next steps to achieve full test coverage.