Sanem sarioglu/feature/subtopic listings#172
Conversation
…election - Populate from when a main subject is selected - Persist and validate in - Clear previous sub-skill on subject change - Use chosen sub-skill when creating /
NedenSinir
left a comment
There was a problem hiding this comment.
Overall good, small changes can be considered. No sonarcloude issue nor CI
There was a problem hiding this comment.
Summary: overall changes look reasonable. I found two real test bugs (missing assertions) and a couple of small improvements/safety tweaks you may want to apply
- Problem: Two tests evaluate fetchSemanticsNodes().isNotEmpty() but do not assert the result — the boolean return value is unused, so the tests won't fail if the element isn't present. Fix by asserting (assertTrue or using compose assertions).
- Minor: tests rely on collection indexing ([0]) — OK but can be flaky if dropdown order changes.
Suggested fix (replace the two test bodies to assert the presence):
// showsError_whenNoSubject_onSave
@Test
fun showsError_whenNoSubject_onSave() {
// Ensure subject is empty (initial screen state), click Save
compose.onNodeWithTag(NewSkillScreenTestTag.BUTTON_SAVE_SKILL).performClick()
// Error helper under Subject field should be visible
val nodes = compose
.onAllNodesWithTag(NewSkillScreenTestTag.INVALID_SUBJECT_MSG, useUnmergedTree = true)
.fetchSemanticsNodes()
assertTrue("Expected invalid subject message to be present", nodes.isNotEmpty())
}
// showsError_whenSubjectChosen_butNoSubSkill_onSave
@Test
fun showsError_whenSubjectChosen_butNoSubSkill_onSave() {
// Choose a subject
compose.onNodeWithTag(NewSkillScreenTestTag.SUBJECT_FIELD).performClick()
compose.onAllNodesWithTag(NewSkillScreenTestTag.SUBJECT_DROPDOWN_ITEM_PREFIX)[0].performClick()
// Sub-skill field visible now but we don't choose any sub-skill
// Click Save directly
compose.onNodeWithTag(NewSkillScreenTestTag.BUTTON_SAVE_SKILL).performClick()
// Error helper under Sub-skill field should be visible
val nodes = compose
.onAllNodesWithTag(NewSkillScreenTestTag.INVALID_SUB_SKILL_MSG, useUnmergedTree = true)
.fetchSemanticsNodes()
assertTrue("Expected invalid sub-skill message to be present", nodes.isNotEmpty())
}There was a problem hiding this comment.
Mostly good. A couple of small suggestions:
- You're force-unwrapping selectedSubSkill with !! in addSkill. isValid guards this, but it's safer to avoid !! and bail early if something unexpected occurs.
- Consider returning early or logging instead of !! to make code more robust.
if (state.isValid) {
val price = state.price.toDouble()
val specificSkill = state.selectedSubSkill ?: return // safer than !!
val newSkill =
Skill(
mainSubject = state.subject!!,
skill = specificSkill,
)
...
}-And maybe for error string not just "Error" but you can use "network error" to make it more descriptive
There was a problem hiding this comment.
Tests look comprehensive and updated to include sub-skill flows.
Minor suggestions:
- The FakeLocationRepo comment and signature were simplified; ensure the test file still compiles with the chosen constructor signature.
- Consider keeping more descriptive exception messages in fake repos (e.g., "Network error") to aid debugging when a test fails.
|


What I did
How I did it
SkillsHelper.getSkillNames(subject), updatesubSkillOptions, resetselectedSubSkilland clear any subject/sub-skill errors so the UI shows a fresh sub-skill list for the new subject.setSubSkill(subSkill: String)to store the chosen sub-skill and clear its validation error immediately when a choice is made.setError()now setsinvalidSubSkillMsgonly ifsubject != nullandselectedSubSkillis missing — this ensures users who haven't chosen a subject aren't shown a sub-skill error.subSkillOptionslist to avoid stale/incorrect choices after subject changes.How to verify it
Demo video
Pre-merge checklist
The changes I introduced: