Scribe-Android icon indicating copy to clipboard operation
Scribe-Android copied to clipboard

Write Tests for SettingsScreen

Open angrezichatterbox opened this issue 8 months ago • 6 comments

Terms

Description

This issue focuses on adding test coverage to SettingsScreen.kt in the be.scri.ui.screens.settings package.
The screen currently has 0% coverage (methods, branches, lines, instructions), and this task will improve that by introducing unit tests and instrumented UI tests where necessary.

Components & Test Type Classification

Component / Function Description Test Type Notes
SettingsScreen(...) Main screen composable Instrumented UI Test Needs Compose UI test framework
InstallKeyboardButton(onClick) Reusable UI component Instrumented UI Test Should verify visibility and interaction
Dimensions object Static UI constants Unit Test No context needed
Lifecycle observer (inside DisposableEffect) Refreshes settings on resume Instrumented Should be tested using lifecycle state change
ViewModel interactions (collectAsState()) Reactive state collection Instrumented Requires Compose + State testing setup
UI rendering of ScribeItemList and LazyColumn Visible UI blocks Instrumented Verify list visibility based on state
Intent launching (SettingsUtil.*) External navigation Instrumented Validate calls/mocking of utility methods

Suggested File Structure

test/
└── be/scri/ui/screens/settings/
    └── SettingsScreenUnitTest.kt           // Tests for Dimensions and pure logic

androidTest/
└── be/scri/ui/screens/settings/
    └── SettingsScreenInstrumentedTest.kt   // Compose UI tests + ViewModel integration

Contribution

Happy to help anyone solve this issue or take this up myself at some point :)

angrezichatterbox avatar Apr 13 '25 10:04 angrezichatterbox

@adityanarvekar This would a good issue to begin with if have explored the repository a bit. Happy to help in any way possible :)

angrezichatterbox avatar Apr 13 '25 10:04 angrezichatterbox

I would love to work on this issue. Could you please assign it to me? 😊

majidhawa avatar Apr 20 '25 09:04 majidhawa

Thanks for picking this up, @majidhawa! Please let us know if you need any support :)

andrewtavis avatar Apr 20 '25 09:04 andrewtavis

Hi @angrezichatterbox and @andrewtavis 👋🏽,

As I begin working on the tests for SettingsScreen.kt, I wanted to confirm something before proceeding. While exploring the project structure, I noticed that there are currently no existing test files under the test/ or androidTest/ directories, and as a result, these folders don’t appear in the Android view of Android Studio.

I did switch to the Project view, where I can see the full directory structure, but I still don’t see the package be.scri.ui.screens.settings under either test or androidTest. From what I understand, this is likely because no tests have been created yet.

Just to be sure, am I expected to manually create the required package structure and test files (SettingsScreenUnitTest.kt and SettingsScreenInstrumentedTest.kt) as suggested in the issue description? Once I get your go-ahead, I’ll proceed with setting them up and start adding the tests.

Thank you 😊

majidhawa avatar Apr 21 '25 16:04 majidhawa

Hey @majidhawa

Sorry, we were not able to get to you earlier. You would now see the android tests folder structure created in the directory as instrumentation tests are added for the project. If there are no specific tests for any package you could create the package and the subdirectories and then create the files under them for the tests.

Thanks for the efforts @majidhawa 😄

angrezichatterbox avatar May 06 '25 15:05 angrezichatterbox

Thanks so much for the clarification, @angrezichatterbox 😊

That makes perfect sense now. I actually figured it out shortly after and went ahead to manually create the required package structure for both unit and instrumented tests as suggested.

Here’s how I organized the test directories: app/ src/ test/ java/be/scri/ui/screens/settings/SettingsScreenUnitTest.kt androidTest/ java/be/scri/ui/screens/settings/SettingsScreenInstrumentedTest.kt While setting this up, I initially ran into some issues related to the JDK configuration. Gradle was trying to use Java 21, which didn’t have the required compiler tools, so the tests wouldn’t run. I resolved it by switching to Java 17 and explicitly pointing Gradle to the correct JDK path.

After that, I was able to successfully run the unit tests for the Dimensions object. I’m now working on the instrumented tests for SettingsScreen, focusing on Compose UI rendering and ViewModel state handling.

I’ll continue pushing forward and will reach out if anything else comes up. Thanks again for the support.

majidhawa avatar May 07 '25 17:05 majidhawa

Hey hey @majidhawa 👋 Quick check in to see if you need any support with the work for this issue :) Please let us know if there's anything we can do to support!

andrewtavis avatar May 24 '25 20:05 andrewtavis

Hey @andrewtavis , Thanks for checking in. I was able to set up the required package structure and got the unit tests for the Dimensions object running successfully. However, I ran into a bit of a blocker with the instrumented tests.

When I run all tests together (e.g., using “Run Tests”), things seem to work fine. But when I try running the instrumented test file individually (SettingsScreenInstrumentedTest.kt), it throws errors. I suspect this might be due to how the test files or dependencies are organized.

I noticed someone else raised a similar concern in the group, so I’m waiting for tomorrow’s meeting to get more clarity and confirm whether I’ve set up everything correctly. Once I’m sure about the structure, I’ll continue with the remaining tests.

Thanks again for the support.

majidhawa avatar May 25 '25 14:05 majidhawa

@angrezichatterbox I would like to work on this issue

navaneeth0041 avatar Jul 26 '25 08:07 navaneeth0041

I would also like to work on this

AtharvaNair04 avatar Jul 26 '25 10:07 AtharvaNair04

Thanks @navaneeth0041 and @AtharvaNair04 for picking this up!

andrewtavis avatar Jul 26 '25 10:07 andrewtavis

@angrezichatterbox I would like to work on this test UI rendering of ScribeItemList and LazyColumn

ashwinpraveengo avatar Jul 27 '25 05:07 ashwinpraveengo

I would close this issue for now. We could create new issues for tests based on the current state and coverage.

Thanks for the work @AtharvaNair04 @ashwinpraveengo @Kota-Jagadeesh. Hope we can see you more within the project.

angrezichatterbox avatar Aug 08 '25 18:08 angrezichatterbox

Really thank you all some much for your great work! 😊 I'd reiterate what @angrezichatterbox said above: Would be so great to have you all continue to contribute :) :)

andrewtavis avatar Aug 08 '25 18:08 andrewtavis