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 {
1916 } 1916 }
1917 1917
1918 /// A comment's preview renders its markup before anything is sent: 1918 /// 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.
1920 func testMarkupPreviewFlow() throws { 1920 func testMarkupPreviewFlow() throws {
1921 openRepo(Self.fixtureRepo) 1921 openRepo(Self.fixtureRepo)
1922 app.staticTexts["Issues"].firstMatch.tap() 1922 app.staticTexts["Issues"].firstMatch.tap()
@@ -1927,23 +1927,29 @@ extension LiveSmokeUITests {
1927 let field = app.descendants(matching: .any) 1927 let field = app.descendants(matching: .any)
1928 .matching(identifier: "issue-comment-field").firstMatch 1928 .matching(identifier: "issue-comment-field").firstMatch
1929 XCTAssertTrue(scrollTo(field, swipes: 10), "no comment field on the issue") 1929 XCTAssertTrue(scrollTo(field, swipes: 10), "no comment field on the issue")
1930 field.tap() 1930 let draft = "**Bold preview**"
1931 let draft = "**ui-smoke preview**" 1931 focusAndType(field, draft)
1932 field.typeText(draft)
1933 1932
1934 let preview = app.descendants(matching: .any) 1933 let preview = app.descendants(matching: .any)
1935 .matching(identifier: "issue-comment-preview").firstMatch 1934 .matching(identifier: "issue-comment-preview").firstMatch
1936 XCTAssertTrue(scrollTo(preview), "no preview row for a non-empty comment") 1935 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() }
1937 preview.tap() 1938 preview.tap()
1938 XCTAssertTrue(app.staticTexts 1939 let rendered = app.staticTexts
1939 .containing(NSPredicate(format: "label CONTAINS 'ui-smoke preview'")).firstMatch 1940 .containing(NSPredicate(format: "label CONTAINS 'Bold preview'")).firstMatch
1940 .waitForExistence(timeout: 5), "preview did not render the draft") 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")
1941 XCTAssertFalse(app.staticTexts 1946 XCTAssertFalse(app.staticTexts
1942 .containing(NSPredicate(format: "label CONTAINS '**ui-smoke'")).firstMatch.exists, 1947 .containing(NSPredicate(format: "label CONTAINS '**Bold'")).firstMatch.exists,
1943 "preview shows the raw markup") 1948 "preview shows the raw markup")
1944 1949
1945 // Kept on success too: this is how the preview's look is checked 1950 // Kept on success too: this is how the preview's look is checked
1946 // in light and dark without signing a simulator in by hand. 1951 // in light and dark without signing a simulator in by hand.
1952 for _ in 0..<3 where !rendered.isHittable { app.swipeUp() }
1947 let shot = XCTAttachment(screenshot: app.screenshot()) 1953 let shot = XCTAttachment(screenshot: app.screenshot())
1948 shot.name = "markup preview" 1954 shot.name = "markup preview"
1949 shot.lifetime = .keepAlways 1955 shot.lifetime = .keepAlways
@@ -1951,8 +1957,9 @@ extension LiveSmokeUITests {
1951 1957
1952 // Leave the fixture as found: clear the draft, send nothing. 1958 // Leave the fixture as found: clear the draft, send nothing.
1953 XCTAssertTrue(scrollTo(field), "comment field scrolled away") 1959 XCTAssertTrue(scrollTo(field), "comment field scrolled away")
1954 field.tap() 1960 field.coordinate(withNormalizedOffset: CGVector(dx: 0.98, dy: 0.9)).tap()
1955 field.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: draft.count)) 1961 let typed = (field.value as? String)?.count ?? draft.count
1956 XCTAssertFalse(preview.exists, "preview row outlived an empty comment") 1962 field.typeText(String(repeating: XCUIKeyboardKey.delete.rawValue, count: typed))
1963 XCTAssertTrue(preview.waitForNonExistence(timeout: 5), "preview row outlived an empty comment")
1957 } 1964 }
1958} 1965}