diff --git a/CHANGES.md b/CHANGES.md index 9a41f3c4ef..9d2a711e84 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ Improvements 🙌: Bugfix 🐛: - Display name not shown under Settings/General (#1926) + - Editing message forgets line breaks and markdown (#1939) - Words containing my name should not trigger notifications (#1781) - Fix changing language issue - Fix FontSize issue (#1483, #1787) diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt index 2be535b16e..3a25b92c2a 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt @@ -30,9 +30,9 @@ import org.matrix.android.sdk.InstrumentedTest * It will not be possible to test all combinations. For the moment I add a few tests, then, depending on the problem discovered in the wild, * we can add more tests to cover the edge cases. * Some tests are suffixed with `_not_passing`, maybe one day we will fix them... - * Element Web should be used as a reference for expected results, but not always. Especially Element Web add lots of `\n` in the - * formatted body, which is quite useless. - * Also Element Web does not provide plain text body when formatted text is provided. The body contains what the user has entered. + * Element Web should be used as a reference for expected results, but not always. + * Also Element Web does not provide plain text body when formatted text is provided. The body contains what the user has entered. We are doing + * the same to be able to edit messages (See #1939) * See https://matrix.org/docs/spec/client_server/latest#m-room-message-msgtypes */ @Suppress("SpellCheckingInspection") @@ -81,6 +81,15 @@ class MarkdownParserTest : InstrumentedTest { ) } + @Test + fun parseBoldNewLines() { + testTypeNewLines( + name = "bold", + markdownPattern = "**", + htmlExpectedTag = "strong" + ) + } + @Test fun parseItalic() { testType( @@ -90,6 +99,15 @@ class MarkdownParserTest : InstrumentedTest { ) } + @Test + fun parseItalicNewLines() { + testTypeNewLines( + name = "italic", + markdownPattern = "*", + htmlExpectedTag = "em" + ) + } + @Test fun parseItalic2() { // Element Web format @@ -108,6 +126,15 @@ class MarkdownParserTest : InstrumentedTest { ) } + @Test + fun parseStrikeNewLines() { + testTypeNewLines( + name = "strike", + markdownPattern = "~~", + htmlExpectedTag = "del" + ) + } + @Test fun parseCode() { testType( @@ -117,6 +144,15 @@ class MarkdownParserTest : InstrumentedTest { ) } + @Test + fun parseCodeNewLines() { + testTypeNewLines( + name = "code", + markdownPattern = "`", + htmlExpectedTag = "code" + ) + } + @Test fun parseCode2() { testType( @@ -126,6 +162,15 @@ class MarkdownParserTest : InstrumentedTest { ) } + @Test + fun parseCode2NewLines() { + testTypeNewLines( + name = "code", + markdownPattern = "``", + htmlExpectedTag = "code" + ) + } + @Test fun parseCode3() { testType( @@ -135,6 +180,15 @@ class MarkdownParserTest : InstrumentedTest { ) } + @Test + fun parseCode3NewLines() { + testTypeNewLines( + name = "code", + markdownPattern = "```", + htmlExpectedTag = "code" + ) + } + @Test fun parseUnorderedList() { "- item1".let { markdownParser.parse(it).expect(it, "
") } + "> quoted\nline2".let { markdownParser.parse(it).expect(it, "quoted
line2
") } } @Test @@ -278,6 +332,26 @@ class MarkdownParserTest : InstrumentedTest { } } + private fun testTypeNewLines(name: String, + markdownPattern: String, + htmlExpectedTag: String) { + // With new line inside the block + "$markdownPattern$name\n$name$markdownPattern" + .let { + markdownParser.parse(it) + .expect(expectedText = it, + expectedFormattedText = "<$htmlExpectedTag>$namequoted
line2