This commit is contained in:
7 files changed
+257
-93
No files matched your search
+31
@@ -1,8 +1,10 @@
|
||||
package com.m57.hermescontrol.ui.chat
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.ui.test.assertCountEquals
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.test.onAllNodesWithTag
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.MediumTest
|
||||
@@ -30,4 +32,33 @@ class MarkdownHeadingRenderingTest {
|
||||
composeTestRule.onNodeWithText("Set foo now").assertIsDisplayed()
|
||||
composeTestRule.onNodeWithText("**Set `foo` now**").assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun quoteAndListContinuationRenderNestedCodeBlocks() {
|
||||
composeTestRule.setContent {
|
||||
MaterialTheme {
|
||||
MarkdownText(
|
||||
text =
|
||||
"""
|
||||
> # Quote heading
|
||||
> ```kotlin
|
||||
> val quoted = 1
|
||||
> ```
|
||||
|
||||
- Item
|
||||
```kotlin
|
||||
val listed = 2
|
||||
```
|
||||
""".trimIndent(),
|
||||
textColor = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
composeTestRule.onNodeWithText("Quote heading").assertIsDisplayed()
|
||||
composeTestRule.onNodeWithText("Item").assertIsDisplayed()
|
||||
composeTestRule.onAllNodesWithTag("code_block").assertCountEquals(2)
|
||||
composeTestRule.onNodeWithText("val quoted = 1", substring = true).assertIsDisplayed()
|
||||
composeTestRule.onNodeWithText("val listed = 2", substring = true).assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,19 @@
|
||||
package com.m57.hermescontrol.ui.chat
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.getUnclippedBoundsInRoot
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.test.onNodeWithTag
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.MediumTest
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -32,4 +40,26 @@ class MarkdownTableRenderingTest {
|
||||
composeTestRule.onNodeWithText("**Name**").assertDoesNotExist()
|
||||
composeTestRule.onNodeWithText("`code`").assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun columnsSizeToContentAndStayAlignedAcrossRows() {
|
||||
composeTestRule.setContent {
|
||||
MaterialTheme {
|
||||
Box(Modifier.width(220.dp)) {
|
||||
MarkdownText(
|
||||
text = "| ID | Description |\n| --- | --- |\n| A | A considerably longer table value |",
|
||||
textColor = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val idHeader = composeTestRule.onNodeWithTag("markdown_table_header_0").getUnclippedBoundsInRoot()
|
||||
val descHeader = composeTestRule.onNodeWithTag("markdown_table_header_1").getUnclippedBoundsInRoot()
|
||||
val idCell = composeTestRule.onNodeWithTag("markdown_table_cell_0_0").getUnclippedBoundsInRoot()
|
||||
val descCell = composeTestRule.onNodeWithTag("markdown_table_cell_0_1").getUnclippedBoundsInRoot()
|
||||
assertTrue(descHeader.right - descHeader.left > idHeader.right - idHeader.left)
|
||||
assertEquals(idHeader.right - idHeader.left, idCell.right - idCell.left)
|
||||
assertEquals(descHeader.right - descHeader.left, descCell.right - descCell.left)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user