screenshots: never capture a screen that is still loading !31
1 file changed, +34 −1
gitbayUITests/LiveSmokeUITests.swift +34 −1
| @@ -729,9 +729,42 @@ extension LiveSmokeUITests { | ||
| 729 | 729 | focusAndType(tokenField, token + "\n") |
| 730 | 730 | XCTAssertTrue(app.staticTexts["Dashboard"].firstMatch |
| 731 | 731 | .waitForExistence(timeout: 20), "sign-in did not land") |
| 732 | dismissSavePasswordPrompt() | |
| 732 | 733 | } |
| 733 | 734 | |
| 734 | private func snap(_ name: String) { | |
| 735 | /// iOS offers to save whatever went into a SecureField, and the sheet | |
| 736 | /// sits over the app until answered — over the dashboard, in one set | |
| 737 | /// of store screenshots. It belongs to springboard, not to the app. | |
| 738 | private func dismissSavePasswordPrompt() { | |
| 739 | let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") | |
| 740 | let notNow = springboard.buttons["Not Now"].firstMatch | |
| 741 | if notNow.waitForExistence(timeout: 8) { | |
| 742 | notNow.tap() | |
| 743 | _ = waitForDisappearance(notNow, timeout: 10) | |
| 744 | return | |
| 745 | } | |
| 746 | let inApp = app.buttons["Not Now"].firstMatch | |
| 747 | if inApp.waitForExistence(timeout: 3) { | |
| 748 | inApp.tap() | |
| 749 | _ = waitForDisappearance(inApp, timeout: 10) | |
| 750 | return | |
| 751 | } | |
| 752 | // No prompt is fine: iOS only offers once per credential. | |
| 753 | } | |
| 754 | ||
| 755 | /// Capture a screen, but not while it is still loading. These go to | |
| 756 | /// the App Store, and a spinner shipped as a screenshot once already. | |
| 757 | private func snap(_ name: String, file: StaticString = #filePath, line: UInt = #line) { | |
| 758 | let spinner = app.activityIndicators.firstMatch | |
| 759 | if spinner.exists { | |
| 760 | XCTAssertTrue(waitForDisappearance(spinner, timeout: 30), | |
| 761 | "\(name) still loading after 30s", file: file, line: line) | |
| 762 | } | |
| 763 | // A list that has loaded has rows; an empty state has text. Either | |
| 764 | // way something must be on screen besides chrome. | |
| 765 | let content = app.cells.firstMatch | |
| 766 | _ = content.waitForExistence(timeout: 10) | |
| 767 | ||
| 735 | 768 | let attachment = XCTAttachment(screenshot: app.screenshot()) |
| 736 | 769 | attachment.name = name |
| 737 | 770 | attachment.lifetime = .keepAlways |