Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky test: ContextMenu unburied cards when selecting UNBURY #17821

Open
4 tasks done
david-allison opened this issue Jan 15, 2025 · 3 comments
Open
4 tasks done

Flaky test: ContextMenu unburied cards when selecting UNBURY #17821

david-allison opened this issue Jan 15, 2025 · 3 comments
Assignees

Comments

@david-allison
Copy link
Member

david-allison commented Jan 15, 2025

Checked for duplicates?

  • This issue is not a duplicate

Does it also happen in the desktop version?

  • This bug does not occur in the latest version of Anki Desktop

What are the steps to reproduce this bug?

Run tests

DeckPickerTest > [0] > ContextMenu unburied cards when selecting UNBURY[0] FAILED
    java.lang.AssertionError: expected:<1> but was:<0>
        at org.junit.Assert.fail(Assert.java:89)
        at org.junit.Assert.failNotEquals(Assert.java:835)
        at org.junit.Assert.assertEquals(Assert.java:120)
        at org.junit.Assert.assertEquals(Assert.java:146)
        at com.ichi2.anki.DeckPickerTest$ContextMenu unburied cards when selecting UNBURY$1.invokeSuspend(DeckPickerTest.kt:509)
        at com.ichi2.anki.DeckPickerTest$ContextMenu unburied cards when selecting UNBURY$1.invoke(DeckPickerTest.kt)
        at com.ichi2.anki.DeckPickerTest$ContextMenu unburied cards when selecting UNBURY$1.invoke(DeckPickerTest.kt)
        at com.ichi2.testutils.TestClass$runTest$1$1.invokeSuspend(TestClass.kt:318)
        at com.ichi2.testutils.TestClass$runTest$1$1.invoke(TestClass.kt)
        at com.ichi2.testutils.TestClass$runTest$1$1.invoke(TestClass.kt)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$1.invokeSuspend(TestBuilders.kt:318)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
        at kotlinx.coroutines.test.TestDispatcher.processEvent$kotlinx_coroutines_test(TestDispatcher.kt:24)
        at kotlinx.coroutines.test.TestCoroutineScheduler.tryRunNextTaskUnless$kotlinx_coroutines_test(TestCoroutineScheduler.kt:99)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$workRunner$1.invokeSuspend(TestBuilders.kt:327)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:263)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:47)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at kotlinx.coroutines.test.TestBuildersJvmKt.createTestResult(TestBuildersJvm.kt:10)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt.runTest-8Mi8wO0(TestBuilders.kt:310)
        at kotlinx.coroutines.test.TestBuildersKt.runTest-8Mi8wO0(Unknown Source)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt.runTest-8Mi8wO0(TestBuilders.kt:168)
        at kotlinx.coroutines.test.TestBuildersKt.runTest-8Mi8wO0(Unknown Source)
        at com.ichi2.testutils.TestClass.runTest(TestClass.kt:316)
        at com.ichi2.testutils.TestClass.runTest$default(TestClass.kt:305)
        at com.ichi2.anki.DeckPickerTest.ContextMenu unburied cards when selecting UNBURY(DeckPickerTest.kt:497)

Expected behaviour

Test passes

Debug info

@Test
fun `ContextMenu unburied cards when selecting UNBURY`() =
runTest {
startActivityNormallyOpenCollectionWithIntent(DeckPicker::class.java, Intent()).run {
TimeManager.reset()
// stop 'next day' code running, which calls 'unbury'
updateDeckList()
val deckId = addDeck("Deck 1")
getColUnsafe.decks.select(deckId)
getColUnsafe.notetypes.byName("Basic")!!.put("did", deckId)
val card = addBasicNote("front", "back").firstCard()
getColUnsafe.sched.buryCards(listOf(card.id))
updateDeckList()
advanceRobolectricLooper()
assertEquals(1, visibleDeckCount)
assertTrue(getColUnsafe.sched.haveBuried(), "Deck should have buried cards")
supportFragmentManager.selectContextMenuOption(DeckPickerContextMenuOption.UNBURY, deckId)
kotlin.test.assertFalse(getColUnsafe.sched.haveBuried())
}
}

N/A

(Optional) Anything else you want to share?

No response

Research

  • I have checked the manual and the FAQ and could not find a solution to my issue
  • (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)
@david-allison
Copy link
Member Author

issue is in:

assertEquals(1, visibleDeckCount) 

@ujjol1234
Copy link

@david-allison can I work on this?

@david-allison
Copy link
Member Author

Sure

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

No branches or pull requests

2 participants