Commit 988289d1b9

988289d1b96771abcce34414dab368df752d5550

parent: 03e7bc5841

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-22 22:22 UTC

live suite: steadier markup preview flow

Hardens testMarkupPreviewFlow before its first live run:
- type through focusAndType instead of a bare tap + typeText
- draft is "**Bold preview**", nothing autocorrect or
  auto-capitalisation would rewrite
- swipe the preview row into hittable range before tapping it, since the
  keyboard can cover it
- fall back to tapping the disclosure's own button if the rendered text
  doesn't show up in 3s, in case the row's identifier lands on the cell
  rather than the toggle
- swipe the rendered text into view before the screenshot
- clear the draft by placing the caret after the last character and
  deleting exactly as many characters as the field holds, then wait for
  the preview row to actually disappear

Layout: unified · split

gitbayUITests/LiveSmokeUITests.swift +18 −11
@@ -1916,7 +1916,7 @@ extension LiveSmokeUITests {
19161916 }
19171917
19181918 /// A comment's preview renders its markup before anything is sent:
1919 /// the bold markers are gone and the words remain. Nothing is posted.
1919 /// the bold markers are gone and the word remains. Nothing is posted.
19201920 func testMarkupPreviewFlow() throws {
19211921 openRepo(Self.fixtureRepo)
19221922 app.staticTexts["Issues"].firstMatch.tap()
@@ -1927,23 +1927,29 @@ extension LiveSmokeUITests {
19271927 let field = app.descendants(matching: .any)
19281928 .matching(identifier: "issue-comment-field").firstMatch
19291929 XCTAssertTrue(scrollTo(field, swipes: 10), "no comment field on the issue")
1930 field.tap()
1931 let draft = "**ui-smoke preview**"
1932 field.typeText(draft)
1930 let draft = "**Bold preview**"
1931 focusAndType(field, draft)
19331932
19341933 let preview = app.descendants(matching: .any)
19351934 .matching(identifier: "issue-comment-preview").firstMatch
19361935 XCTAssertTrue(scrollTo(preview), "no preview row for a non-empty comment")
1936 // The keyboard can cover the row right after typing.
1937 for _ in 0..<3 where !preview.isHittable { app.swipeUp() }
19371938 preview.tap()
1938 XCTAssertTrue(app.staticTexts
1939 .containing(NSPredicate(format: "label CONTAINS 'ui-smoke preview'")).firstMatch
1940 .waitForExistence(timeout: 5), "preview did not render the draft")
1939 let rendered = app.staticTexts
1940 .containing(NSPredicate(format: "label CONTAINS 'Bold preview'")).firstMatch
1941 if !rendered.waitForExistence(timeout: 3) {
1942 // The row's identifier can land on the cell rather than the toggle.
1943 app.buttons["Preview"].firstMatch.tap()
1944 }
1945 XCTAssertTrue(rendered.waitForExistence(timeout: 5), "preview did not render the draft")
19411946 XCTAssertFalse(app.staticTexts
1942 .containing(NSPredicate(format: "label CONTAINS '**ui-smoke'")).firstMatch.exists,
1947 .containing(NSPredicate(format: "label CONTAINS '**Bold'")).firstMatch.exists,
19431948 "preview shows the raw markup")
19441949
19451950 // Kept on success too: this is how the preview's look is checked
19461951 // in light and dark without signing a simulator in by hand.
1952 for _ in 0..<3 where !rendered.isHittable { app.swipeUp() }
19471953 let shot = XCTAttachment(screenshot: app.screenshot())
19481954 shot.name = "markup preview"
19491955 shot.lifetime = .keepAlways
@@ -1951,8 +1957,9 @@ extension LiveSmokeUITests {
19511957
19521958 // Leave the fixture as found: clear the draft, send nothing.
19531959 XCTAssertTrue(scrollTo(field), "comment field scrolled away")
1954 field.tap()
1955 field.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: draft.count))
1956 XCTAssertFalse(preview.exists, "preview row outlived an empty comment")
1960 field.coordinate(withNormalizedOffset: CGVector(dx: 0.98, dy: 0.9)).tap()
1961 let typed = (field.value as? String)?.count ?? draft.count
1962 field.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: typed))
1963 XCTAssertTrue(preview.waitForNonExistence(timeout: 5), "preview row outlived an empty comment")
19571964 }
19581965}