summaryrefslogtreecommitdiff
path: root/makima/ios/Tests/MakimaUITests/ScreenshotTests.swift
diff options
context:
space:
mode:
Diffstat (limited to 'makima/ios/Tests/MakimaUITests/ScreenshotTests.swift')
-rw-r--r--makima/ios/Tests/MakimaUITests/ScreenshotTests.swift73
1 files changed, 73 insertions, 0 deletions
diff --git a/makima/ios/Tests/MakimaUITests/ScreenshotTests.swift b/makima/ios/Tests/MakimaUITests/ScreenshotTests.swift
new file mode 100644
index 0000000..6d0fba9
--- /dev/null
+++ b/makima/ios/Tests/MakimaUITests/ScreenshotTests.swift
@@ -0,0 +1,73 @@
+import XCTest
+
+/// Driven by CI to capture deterministic screenshots when the app is built
+/// with `-DSCREENSHOT_MODE`. Saves PNGs as XCTest attachments; CI extracts
+/// them from the .xcresult bundle.
+final class ScreenshotTests: XCTestCase {
+ var app: XCUIApplication!
+
+ override func setUp() {
+ super.setUp()
+ continueAfterFailure = false
+ app = XCUIApplication()
+ app.launchArguments += ["-AppleLanguages", "(en)", "-AppleLocale", "en_US"]
+ app.launch()
+ }
+
+ func test01_Home() throws {
+ // Wait for home content to appear
+ let contracts = app.staticTexts["CONTRACTS//"]
+ XCTAssertTrue(contracts.waitForExistence(timeout: 10))
+ snapshot("01-home")
+ }
+
+ func test02_Contracts() throws {
+ let contracts = app.staticTexts["CONTRACTS//"]
+ XCTAssertTrue(contracts.waitForExistence(timeout: 10))
+ contracts.tap()
+ let header = app.staticTexts["CONTRACTS"]
+ _ = header.waitForExistence(timeout: 5)
+ sleep(1)
+ snapshot("02-contracts")
+ }
+
+ func test03_TaskDetail() throws {
+ let recent = app.staticTexts["RECENT TASKS//"]
+ XCTAssertTrue(recent.waitForExistence(timeout: 10))
+ recent.tap()
+ // TasksListView should now be visible
+ let firstTask = app.staticTexts.matching(NSPredicate(format: "label CONTAINS 'HomeStore' OR label CONTAINS 'WebSocket livestream'"))
+ .firstMatch
+ _ = firstTask.waitForExistence(timeout: 5)
+ firstTask.tap()
+ sleep(2)
+ snapshot("03-task-detail")
+ }
+
+ func test04_Directives() throws {
+ let dirs = app.staticTexts["DIRECTIVES//"]
+ XCTAssertTrue(dirs.waitForExistence(timeout: 10))
+ dirs.tap()
+ sleep(1)
+ snapshot("04-directives")
+ }
+
+ func test05_Settings() throws {
+ let gear = app.buttons["Settings"]
+ XCTAssertTrue(gear.waitForExistence(timeout: 10))
+ gear.tap()
+ sleep(1)
+ snapshot("05-settings")
+ }
+
+ // MARK: - Helpers
+
+ /// Adds a screenshot to the test result as an attachment with a stable name.
+ private func snapshot(_ name: String) {
+ let screenshot = XCUIScreen.main.screenshot()
+ let attachment = XCTAttachment(screenshot: screenshot)
+ attachment.name = name
+ attachment.lifetime = .keepAlways
+ add(attachment)
+ }
+}