Repository navigation
test: add TemplateEditorScreen UI tests - #36
Conversation
Covers new/edit mode rendering, name/content validation, tag suggestions, placeholder chips, content editor dialog, discard changes dialog, and max-length enforcement. 22 test cases following existing CustomerIntakeScreenTest patterns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a new comprehensive Android instrumented test suite for TemplateEditorScreen and multiple UI/clipboard/string/resource tweaks, plus dependency version bumps and small plumbing changes across install intent and protobuf configuration. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Veteran mecha engineer pre‑flight feedback (Issue → Impact → Fix → Test):
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cd5a62a7fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@app/src/androidTest/java/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreenTest.kt`:
- Around line 96-101: The tests contradict:
newTemplate_createButtonDisabledWhenNameBlank() asserts the Create button is
disabled, but savingWithBlankName_showsNameError attempts to click Create when
name is blank; pick the disabled-by-design contract. Update
savingWithBlankName_showsNameError to use setScreenContentNewTemplate() (or the
same setup used by newTemplate_createButtonDisabledWhenNameBlank) and assert
composeRule.onNodeWithText(appContext.getString(R.string.action_create)).assertIsNotEnabled()
instead of performing a click, or if you need to exercise an error path, first
enter a name then clear it and then assert the disabled state/error flow
consistently across both tests (functions:
newTemplate_createButtonDisabledWhenNameBlank,
savingWithBlankName_showsNameError, setScreenContentNewTemplate).
- Around line 88-93: The test newTemplate_nameFieldIsEmpty currently only checks
the name label is displayed; update it to also assert the name input is empty by
locating the name input node (related to
appContext.getString(R.string.label_name) / the name input node used in
setScreenContentNewTemplate) and asserting its text/value is an empty string.
Similarly, update contentEditorDialog_showsMessageLabelAndDoneButton to assert
both the message label node (R.string.label_message or the dialog message node)
is displayed and that the Done button is visible; ensure you target the same
nodes the test uses (composeRule onNode... calls) and add explicit assertions
for the empty-field/value and message-label presence so the tests fail when
those states are incorrect.
- Around line 484-486: The test fixture creates a Template with a hardcoded id
("test-template-id"); replace that with a UUID-shaped id (either a fixed UUID
string or generated via UUID.randomUUID().toString()) in the existing-template
helper so the Template respects domain invariants used for conflict detection;
update the Template instantiation (the Template class usage in
TemplateEditorScreenTest / existing-template helper) to avoid special sentinel
ids like DEFAULT_TEMPLATE_ID ("default") or the new-template sentinel
("__new__") and re-run the edit/discard flows to ensure behavior is unchanged.
- Around line 4-17: The test file is missing imports for onNode() and
assertDoesNotExist(), causing unresolved references in TemplateEditorScreenTest;
add the two Compose testing imports for onNode and assertDoesNotExist (so calls
to onNode(...) and assertDoesNotExist() used in the test methods compile),
ensuring the import statements are placed with the other
androidx.compose.ui.test imports referenced by functions like createComposeRule,
onNodeWithText, performClick, and assertIsDisplayed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6cdccee7-a291-4c8b-b0eb-a8d25bda48f7
📒 Files selected for processing (1)
app/src/androidTest/java/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreenTest.kt
| import androidx.compose.runtime.CompositionLocalProvider | ||
| import androidx.compose.ui.test.SemanticsMatcher | ||
| import androidx.compose.ui.test.assertIsDisplayed | ||
| import androidx.compose.ui.test.assertIsEnabled | ||
| import androidx.compose.ui.test.assertIsNotEnabled | ||
| import androidx.compose.ui.test.hasSetTextAction | ||
| import androidx.compose.ui.test.hasText | ||
| import androidx.compose.ui.test.junit4.createComposeRule | ||
| import androidx.compose.ui.test.onNodeWithContentDescription | ||
| import androidx.compose.ui.test.onNodeWithText | ||
| import androidx.compose.ui.test.performClick | ||
| import androidx.compose.ui.test.performTextClearance | ||
| import androidx.compose.ui.test.performTextInput | ||
| import androidx.test.core.app.ApplicationProvider |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="app/src/androidTest/java/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreenTest.kt"
echo "== Checking file existence =="
if [ -f "$FILE" ]; then
echo "✓ File exists"
wc -l "$FILE"
else
echo "✗ File does not exist at the specified path"
exit 1
fi
echo -e "\n== Usages that require imports =="
rg -n '\bonNode\(|assertDoesNotExist\(' "$FILE" | head -20
echo -e "\n== Current imports section (lines 1-20) =="
head -20 "$FILE"
echo -e "\n== Checking for the specific missing imports =="
rg -n '^import androidx\.compose\.ui\.test\.(onNode|assertDoesNotExist)\b' "$FILE" || echo "No match found (imports are missing)"Repository: H2OKing89/QWelcome
Length of output: 1893
Missing Compose test imports block androidTest compilation
- Issue:
onNode()andassertDoesNotExist()are called throughout the test but their imports are missing. - Impact: Compilation fails with unresolved references at lines 107, 269, 326, 331, 341, 365, 382, 398, 411, 461.
- Fix: Add the two missing imports to the test class.
Patch
import androidx.compose.ui.test.SemanticsMatcher
+import androidx.compose.ui.test.assertDoesNotExist
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.hasSetTextAction
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.createComposeRule
+import androidx.compose.ui.test.onNode
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import androidx.compose.runtime.CompositionLocalProvider | |
| import androidx.compose.ui.test.SemanticsMatcher | |
| import androidx.compose.ui.test.assertIsDisplayed | |
| import androidx.compose.ui.test.assertIsEnabled | |
| import androidx.compose.ui.test.assertIsNotEnabled | |
| import androidx.compose.ui.test.hasSetTextAction | |
| import androidx.compose.ui.test.hasText | |
| import androidx.compose.ui.test.junit4.createComposeRule | |
| import androidx.compose.ui.test.onNodeWithContentDescription | |
| import androidx.compose.ui.test.onNodeWithText | |
| import androidx.compose.ui.test.performClick | |
| import androidx.compose.ui.test.performTextClearance | |
| import androidx.compose.ui.test.performTextInput | |
| import androidx.test.core.app.ApplicationProvider | |
| import androidx.compose.runtime.CompositionLocalProvider | |
| import androidx.compose.ui.test.SemanticsMatcher | |
| import androidx.compose.ui.test.assertDoesNotExist | |
| import androidx.compose.ui.test.assertIsDisplayed | |
| import androidx.compose.ui.test.assertIsEnabled | |
| import androidx.compose.ui.test.assertIsNotEnabled | |
| import androidx.compose.ui.test.hasSetTextAction | |
| import androidx.compose.ui.test.hasText | |
| import androidx.compose.ui.test.junit4.createComposeRule | |
| import androidx.compose.ui.test.onNode | |
| import androidx.compose.ui.test.onNodeWithContentDescription | |
| import androidx.compose.ui.test.onNodeWithText | |
| import androidx.compose.ui.test.performClick | |
| import androidx.compose.ui.test.performTextClearance | |
| import androidx.compose.ui.test.performTextInput | |
| import androidx.test.core.app.ApplicationProvider |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@app/src/androidTest/java/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreenTest.kt`
around lines 4 - 17, The test file is missing imports for onNode() and
assertDoesNotExist(), causing unresolved references in TemplateEditorScreenTest;
add the two Compose testing imports for onNode and assertDoesNotExist (so calls
to onNode(...) and assertDoesNotExist() used in the test methods compile),
ensuring the import statements are placed with the other
androidx.compose.ui.test imports referenced by functions like createComposeRule,
onNodeWithText, performClick, and assertIsDisplayed.
- Fix contradicting tests: savingWithBlankName and typingAfterNameError tried to click a disabled Create button (canSave requires non-blank name). Replaced with createButton_disabledAfterClearingName and createButton_reEnabledAfterRetypingName that test the enter/clear/ retype flow consistently with the disabled-by-design contract. - Strengthen newTemplate_nameFieldIsEmpty: now locates the editable field and asserts its text equals ["Name", ""] via assertTextEquals instead of only checking the label is displayed. - Strengthen contentEditorDialog_showsMessageLabelAndDoneButton: now asserts both the Message label and Done button are displayed. - Replace hardcoded "test-template-id" with UUID-shaped string in existing-template helper to respect domain invariants. - Add assertTextEquals import (extension function needed for the new assertion). onNode and assertDoesNotExist are member functions in Compose BOM 2026.01.00 and do not require explicit imports. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@app/src/androidTest/java/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreenTest.kt`:
- Around line 251-257: Extract the repeated "performClick() + waitForIdle()"
sequence into a private helper method named openContentEditorDialog() and call
it from clickingEditButton_opensContentEditorDialog and the other tests that
open the content editor; specifically, replace the
composeRule.onNodeWithContentDescription(appContext.getString(R.string.action_edit)).performClick()
followed by composeRule.waitForIdle() with a single call to
openContentEditorDialog(), implement the helper to locate the node via
composeRule.onNodeWithContentDescription(...) and performClick() then
waitForIdle(), and update all occurrences (including the other test methods that
currently repeat this sequence) to use the new helper to reduce duplication and
simplify future changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: fce62b25-bacd-4232-acdf-2e0f1bfed66c
📒 Files selected for processing (1)
app/src/androidTest/java/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreenTest.kt
…est/template-editor-screen-tests
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
gradle/libs.versions.toml (1)
1-77: 🧹 Nitpick | 🔵 TrivialScope observation: PR titled "add UI tests" but includes broad dependency bumps.
This file contains nine dependency version changes unrelated to adding
TemplateEditorScreentests. Consider:
- Splitting dependency updates into a separate PR for cleaner bisect/rollback.
- At minimum, call out the version bumps explicitly in the PR description so reviewers know to verify compatibility.
Not blocking, but worth noting for traceability.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@gradle/libs.versions.toml` around lines 1 - 77, PR mixes unrelated dependency version bumps with the "add UI tests" work; separate the changes by removing the version updates from this branch (revert edits to keys such as lifecycle, kotlin, composeBom, agp, protobuf, firebaseBom, coroutinesTest, mockk, navigationCompose in gradle/libs.versions.toml) and create a separate PR containing only those dependency bumps, or at minimum update this PR description to explicitly list each bumped version (e.g., lifecycle="2.10.0", kotlin="2.3.20", composeBom="2026.03.01", agp="9.1.0", protobuf="4.34.1", firebaseBom="34.12.0", coroutinesTest="1.10.2", mockk="1.14.7", navigationCompose="2.9.7") so reviewers can validate compatibility and you can bisect/rollback independently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@gradle/libs.versions.toml`:
- Around line 1-77: PR mixes unrelated dependency version bumps with the "add UI
tests" work; separate the changes by removing the version updates from this
branch (revert edits to keys such as lifecycle, kotlin, composeBom, agp,
protobuf, firebaseBom, coroutinesTest, mockk, navigationCompose in
gradle/libs.versions.toml) and create a separate PR containing only those
dependency bumps, or at minimum update this PR description to explicitly list
each bumped version (e.g., lifecycle="2.10.0", kotlin="2.3.20",
composeBom="2026.03.01", agp="9.1.0", protobuf="4.34.1", firebaseBom="34.12.0",
coroutinesTest="1.10.2", mockk="1.14.7", navigationCompose="2.9.7") so reviewers
can validate compatibility and you can bisect/rollback independently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: a837c417-2c07-4541-82fe-62d403a88241
📒 Files selected for processing (1)
gradle/libs.versions.toml
…and LocalClipboard
…le 10 deprecation warning
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/src/main/java/com/kingpaging/qwelcome/data/GitHubAppUpdater.kt (1)
213-219:⚠️ Potential issue | 🟠 MajorAdd
ACTION_VIEWquery to manifest for APK installer resolution.
- Issue: Code creates
Intent.ACTION_VIEWwith APK MIME type, but manifest<queries>declares onlyACTION_INSTALL_PACKAGEandACTION_SEND.- Impact: On Android 11+,
resolveActivity()returns null (undeclared intent action), unconditionally blocking the install flow.- Fix: Add
ACTION_VIEWintent query toAndroidManifest.xml:Manifest update
<queries> <intent> <action android:name="android.intent.action.INSTALL_PACKAGE" /> <data android:scheme="content" /> </intent> + <intent> + <action android:name="android.intent.action.VIEW" /> + <data android:scheme="content" /> + <data android:mimeType="application/vnd.android.package-archive" /> + </intent> <intent> <action android:name="android.intent.action.SEND" /> <data android:mimeType="text/plain" /> </intent> </queries>
- Test: On Android 11+ device, verify
createInstallIntent()returns non-null when an APK installer is available.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/com/kingpaging/qwelcome/data/GitHubAppUpdater.kt` around lines 213 - 219, The manifest currently only queries ACTION_INSTALL_PACKAGE and ACTION_SEND, so resolveActivity() in createInstallIntent (the Intent built with Intent.ACTION_VIEW and APK_MIME_TYPE) can return null on Android 11+; update AndroidManifest.xml <queries> to include an <intent> entry that declares action "android.intent.action.VIEW" and a matching <data> mimeType "application/vnd.android.package-archive" so the APK installer can be resolved, then rebuild and verify createInstallIntent() returns non-null when an installer is present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/src/main/java/com/kingpaging/qwelcome/data/ExportModels.kt`:
- Around line 177-180: Remove the redundant inner suppression inside
getEffectiveDefaultTemplateId(): keep the function-level
`@Suppress`("DEPRECATION") above fun getEffectiveDefaultTemplateId() and delete
the nested `@Suppress`("DEPRECATION") placed immediately before the return
statement so only the top-level suppression remains; locate the
getEffectiveDefaultTemplateId() method in ExportModels and remove the inner
annotation.
In `@app/src/main/java/com/kingpaging/qwelcome/ui/import_pkg/ImportScreen.kt`:
- Around line 204-216: The clipboard extraction can NPE because the code calls
it.clipData.getItemAt(0).text.toString(); update the paste handling around
clipboardManager.getClipEntry() to safely obtain text (e.g. use
it.clipData.getItemAt(0).coerceToText(context) or use safe-call
text?.toString()) and treat null/coerced-empty as a non-text clipboard: do not
call exceedsImportLimit/ vm.onPasteContent in that case and instead show the
empty-clipboard toast (or the existing R.string.toast_clipboard_empty), while
preserving the existing soundPlayer.playBeep() and import-size check paths
(exceedsImportLimit and vm.onPasteContent).
---
Outside diff comments:
In `@app/src/main/java/com/kingpaging/qwelcome/data/GitHubAppUpdater.kt`:
- Around line 213-219: The manifest currently only queries
ACTION_INSTALL_PACKAGE and ACTION_SEND, so resolveActivity() in
createInstallIntent (the Intent built with Intent.ACTION_VIEW and APK_MIME_TYPE)
can return null on Android 11+; update AndroidManifest.xml <queries> to include
an <intent> entry that declares action "android.intent.action.VIEW" and a
matching <data> mimeType "application/vnd.android.package-archive" so the APK
installer can be resolved, then rebuild and verify createInstallIntent() returns
non-null when an installer is present.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 02e7417e-ecb4-4d69-8bbb-980f70d3add1
📒 Files selected for processing (9)
app/src/main/java/com/kingpaging/qwelcome/data/ExportModels.ktapp/src/main/java/com/kingpaging/qwelcome/data/GitHubAppUpdater.ktapp/src/main/java/com/kingpaging/qwelcome/ui/components/TemplateVariablesSheet.ktapp/src/main/java/com/kingpaging/qwelcome/ui/import_pkg/ImportScreen.ktapp/src/main/java/com/kingpaging/qwelcome/ui/templates/TemplateEditorScreen.ktapp/src/main/java/com/kingpaging/qwelcome/ui/templates/TemplateListScreen.ktapp/src/main/res/values/strings.xmlgradle/libs.versions.tomlproto/build.gradle.kts
Summary
Adds 22 Compose UI tests for
TemplateEditorScreen, covering:Follows existing
CustomerIntakeScreenTestpatterns (CompositionLocals, fake dependencies, DataStore teardown)Test plan
./gradlew connectedAndroidTest)🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
Bug Fixes / UI
Chores