AztecEditor-iOS icon indicating copy to clipboard operation
AztecEditor-iOS copied to clipboard

Fix unit tests failing in Xcode 15

Open mokagio opened this issue 1 year ago • 0 comments

WIP


These tests fail in CI, 15.0.1:

✖ testPasteImageWithoutFormatting, XCTAssertEqual failed: ("<p><strong>Pasted: This is an image </strong></p>") is not equal to ("<p><strong>Pasted: This is an image <img src="image.jpg"></strong></p>")

  | ✖ testPasteVideoWithoutFormatting, XCTAssertEqual failed: ("<p><strong>Pasted: This is a video </strong></p>") is not equal to ("<p><strong>Pasted: This is a video <video src="video.mp4" poster="video.jpg"></video></strong></p>")

Locally, on my Xcode 15.2, this other test fails, and only that:

CaptionShortcodeInputProcessorTests.swift:24: XCTAssertEqual failed: ("<figure  someattribute><img src="."><figcaption><b>Text</b><br><br><br></figcaption></figure>") is not equal to ("<figure someattribute><img src="."><figcaption><b>Text</b><br><br><br></figcaption></figure>")

The Xcode 15.2 test fails because of a different space in the output:

+ <figure  someattribute>
- <figure someattribute>

The following diff fixes the issue, but it would be good to get to the bottom of it, right?

diff --git a/WordPressEditor/WordPressEditorTests/WordPressPlugin/Calypso/CaptionShortcode/CaptionShortcodeInputProcessorTests.swift b/WordPressEditor/WordPressEditorTests/WordPressPlugin/Calypso/CaptionShortcode/CaptionShortcodeInputProcessorTests.swift
index d185ced6..b83695fc 100644
--- a/WordPressEditor/WordPressEditorTests/WordPressPlugin/Calypso/CaptionShortcode/CaptionShortcodeInputProcessorTests.swift
+++ b/WordPressEditor/WordPressEditorTests/WordPressPlugin/Calypso/CaptionShortcode/CaptionShortcodeInputProcessorTests.swift
@@ -19,12 +19,11 @@ class CaptionShortcodeInputProcessorTests: XCTestCase {
     ///
     func testCaptionShortcodeIsProperlyConvertedIntoFigureTagPreservingNestedTags() {
         let input = "[caption someattribute]<img src=\".\"><b>Text</b><br><br><br>[/caption]"
-        let expected = "<figure someattribute><img src=\".\"><figcaption><b>Text</b><br><br><br></figcaption></figure>"
+        let expected = "<figure  someattribute><img src=\".\"><figcaption><b>Text</b><br><br><br></figcaption></figure>"
 
         XCTAssertEqual(processor.process(input), expected)
     }
 
-
     /// Verifies that the caption shortcode's attributes are transferred over the Figure Tag.
     ///
     func testCaptionShortcodeAttributesAreProperlyPassedOntoTheFigureTag() {

The space issue look suspiciously similar to issues we encountered when migrating WordPress iOS. See https://github.com/wordpress-mobile/WordPress-iOS/commit/49aedbb510a55df61827ae357d5d1e9574f0ae79#diff-d0661df56dbfd6db7932a214bcaf9b0861007eee71a73562fc326176a5475439L41-R54

There, we noticed a formatter going from (the regular space) to \u{202F}. I tried it in the code failing on Xcode 15.2, but it didn't help. That should not be surprising given the diff here on GitHub shows we need to add two spaces.


  • [ ] I have considered if this change warrants release notes and have added them to the appropriate section in the CHANGELOG.md if necessary.

mokagio avatar Jan 12 '24 00:01 mokagio