Skip to content

test: add coverage for CreateDeckDialog.displayFeedback()#20291

Open
siddhesh-06 wants to merge 3 commits intoankidroid:mainfrom
siddhesh-06:displayFeedback-test-cases
Open

test: add coverage for CreateDeckDialog.displayFeedback()#20291
siddhesh-06 wants to merge 3 commits intoankidroid:mainfrom
siddhesh-06:displayFeedback-test-cases

Conversation

@siddhesh-06
Copy link
Contributor

@siddhesh-06 siddhesh-06 commented Feb 2, 2026

Purpose / Description

Added test coverage for displayFeedback() method in CreateDeckDialog

  1. Removed @NeedsTest annotation and implemented 5 test cases covering Toast (non-Activity context)
  2. Verifies that Toast is displayed for application context.
  3. Tests both LENGTH_SHORT and LENGTH_LONG durations, empty messages, and multiple sequential is correctly displayed to users

Fixes

Fixes #13283

How Has This Been Tested?

Ran ./gradlew jacocoUnitTestReport

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@welcome
Copy link

welcome bot commented Feb 2, 2026

First PR! 🚀 We sincerely appreciate that you have taken the time to propose a change to AnkiDroid! Please have patience with us as we are all volunteers - we will get to this as soon as possible.

@david-allison
Copy link
Member

Hi, this looks AI generated to me. Can I confirm you've read our AI policy: https://github.com/ankidroid/Anki-Android/blob/main/AI_POLICY.md

@siddhesh-06
Copy link
Contributor Author

Hi, this looks AI generated to me. Can I confirm you've read our AI policy: https://github.com/ankidroid/Anki-Android/blob/main/AI_POLICY.md

Hello @david-allison, I consulted AI as a learning aid for 3–4 test cases where shadowOf(Looper.getMainLooper()).idle() and activity.window.decorView were required, as I wasn’t aware of this approach earlier. After understanding it, I wrote and verified the final implementation myself. If this violates project rules, I can revert or refactor those tests.

@david-allison
Copy link
Member

david-allison commented Feb 3, 2026

A revert would be appreciated, leaving the test name/description with an @Ignore("TODO") or your re-implementation.

Thanks for your honesty. TRULY!!!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll also want to remove the implementations which are AI generated, they're far too verbose and don't fit the idioms of our codebase and this file, for example:

@Test
fun nameMayNotBeZeroLength() {
testDialog(DeckDialogType.DECK) {
assertThat("Ok is disabled if zero length input", positiveButton.isEnabled, equalTo(false))
input = "NotEmpty"
assertThat("Ok is enabled if not zero length input", positiveButton.isEnabled, equalTo(true))
input = "A::B"
assertThat("OK is enabled if fully qualified input provided ('A::B')", positiveButton.isEnabled, equalTo(true))
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve removed the verbose patterns and updated the test cases so they match the codebase idioms.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still using CreateDeckDialog(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the withCreateDeckDialogUsingApplicationContext method, which creates an instance of CreateDeckDialog using the application context. Currently, we only have CreateDeckDialog for the activity context, implemented via withCreateDeckDialog. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Cleanup]: Add Tests to the code (@NeedsTest)

2 participants

Comments