@@ -44,6 +44,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
4444import com.nextcloud.android.sso.model.SingleSignOnAccount
4545import java.io.IOException
4646import java.time.LocalDateTime
47+ import java.time.format.DateTimeFormatter
4748import kotlinx.coroutines.CompletableDeferred
4849import kotlinx.coroutines.flow.first
4950import kotlinx.coroutines.runBlocking
@@ -1672,6 +1673,32 @@ class AppLaunchTest {
16721673 onView(withId(R .id.markdown_editor)).check(matches(withText(" before after" )))
16731674 }
16741675
1676+ @Test
1677+ fun toolbarInsertsLocalDateTimeAtTheSelection () {
1678+ importAccount(" alice" , " Existing note" , " etag-1" , 10 )
1679+ composeRule.onNodeWithText(" Existing note" ).performClick()
1680+ composeRule.enterEditMode()
1681+ onView(withId(R .id.markdown_editor)).perform(click(), replaceText(" before after" ))
1682+ composeRule.runOnUiThread {
1683+ composeRule.activity.findViewById< org.qownnotes.mobile.markdown.MarkdownEditText > (
1684+ R .id.markdown_editor
1685+ ).setSelection(7 , 12 )
1686+ }
1687+
1688+ val before = LocalDateTime .now()
1689+ composeRule.onNodeWithTag(" insert-datetime" ).performScrollTo().performClick()
1690+ val after = LocalDateTime .now()
1691+ val formatter = DateTimeFormatter .ofPattern(" yyyy-MM-dd HH:mm:ss" )
1692+ composeRule.waitUntil(timeoutMillis = 10_000 ) {
1693+ val text = composeRule.runOnIdle {
1694+ composeRule.activity.findViewById<TextView >(R .id.markdown_editor).text.toString()
1695+ }
1696+ text == " before ${before.format(formatter)} " ||
1697+ text == " before ${after.format(formatter)} "
1698+ }
1699+ onView(withId(R .id.markdown_editor)).check(matches(hasFocus()))
1700+ }
1701+
16751702 @Test
16761703 fun toolbarCreatesListAndCheckboxListItems () {
16771704 importAccount(" alice" , " Existing note" , " etag-1" , 10 )
0 commit comments