Commit a29283a1de
Verified · cmc
Layout: unified · split
gitbayUITests/LiveSmokeUITests.swift +45
| @@ -93,6 +93,10 @@ final class LiveSmokeUITests: XCTestCase { | |||
| 93 | try XCTSkipUnless(open.contains(Self.labelledTitle) && open.contains(Self.unlabelledTitle), | 93 | try XCTSkipUnless(open.contains(Self.labelledTitle) && open.contains(Self.unlabelledTitle), |
| 94 | "could not open both label fixture merge requests on \(Self.fixtureRepo)") | 94 | "could not open both label fixture merge requests on \(Self.fixtureRepo)") |
| 95 | } | 95 | } |
| 96 | if name.contains("testMarkupPreviewFlow") { | ||
| 97 | try requireFixtureRepo() | ||
| 98 | ensureFixtureIssue() | ||
| 99 | } | ||
| 96 | } | 100 | } |
| 97 | 101 | ||
| 98 | override func tearDownWithError() throws { | 102 | override func tearDownWithError() throws { |
| @@ -1910,4 +1914,45 @@ extension LiveSmokeUITests { | |||
| 1910 | remove.tap() | 1914 | remove.tap() |
| 1911 | XCTAssertTrue(remove.waitForNonExistence(timeout: 15), "removed label still shown") | 1915 | XCTAssertTrue(remove.waitForNonExistence(timeout: 15), "removed label still shown") |
| 1912 | } | 1916 | } |
| 1917 | |||
| 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. | ||
| 1920 | func testMarkupPreviewFlow() throws { | ||
| 1921 | openRepo(Self.fixtureRepo) | ||
| 1922 | app.staticTexts["Issues"].firstMatch.tap() | ||
| 1923 | let issue = app.staticTexts[Self.fixtureIssueTitle].firstMatch | ||
| 1924 | XCTAssertTrue(issue.waitForExistence(timeout: 15), "fixture issue not listed") | ||
| 1925 | issue.tap() | ||
| 1926 | |||
| 1927 | let field = app.descendants(matching: .any) | ||
| 1928 | .matching(identifier: "issue-comment-field").firstMatch | ||
| 1929 | XCTAssertTrue(scrollTo(field, swipes: 10), "no comment field on the issue") | ||
| 1930 | field.tap() | ||
| 1931 | let draft = "**ui-smoke preview**" | ||
| 1932 | field.typeText(draft) | ||
| 1933 | |||
| 1934 | let preview = app.descendants(matching: .any) | ||
| 1935 | .matching(identifier: "issue-comment-preview").firstMatch | ||
| 1936 | XCTAssertTrue(scrollTo(preview), "no preview row for a non-empty comment") | ||
| 1937 | 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") | ||
| 1941 | XCTAssertFalse(app.staticTexts | ||
| 1942 | .containing(NSPredicate(format: "label CONTAINS '**ui-smoke'")).firstMatch.exists, | ||
| 1943 | "preview shows the raw markup") | ||
| 1944 | |||
| 1945 | // 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. | ||
| 1947 | let shot = XCTAttachment(screenshot: app.screenshot()) | ||
| 1948 | shot.name = "markup preview" | ||
| 1949 | shot.lifetime = .keepAlways | ||
| 1950 | add(shot) | ||
| 1951 | |||
| 1952 | // Leave the fixture as found: clear the draft, send nothing. | ||
| 1953 | 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") | ||
| 1957 | } | ||
| 1913 | } | 1958 | } |