// Story's script home in the real app on a simulator (owner's phone, 20 Nov // 2026): a swipe on a scene row scrolls the home, the cast scrolls sideways, // and a tap on a row still opens its scene. The app brings in the crowded // invented script (sixty-four scenes, sixty characters) on a fresh simulator. import XCTest final class StoryHomeScrollTests: XCTestCase { private func launched() -> XCUIApplication { let app = XCUIApplication() app.launchArguments += ["-story-ink-seed", "YES", "-story-ink-crowd", "YES"] app.launch() return app } /// A scene row by the place in its title. private func row(_ app: XCUIApplication, _ words: String) -> XCUIElement { app.buttons.containing(NSPredicate(format: "label CONTAINS[c] %@", words)).firstMatch } // RULE: a swipe up on a scene row scrolls the home: the row moves up under the finger at once. func testASwipeOnASceneRowScrollsTheHome() { let app = launched() let first = row(app, "Waiting Room") XCTAssertTrue(first.waitForExistence(timeout: 60), "the crowded script came in") let second = row(app, "Platform One") XCTAssertTrue(second.waitForExistence(timeout: 5)) let before = second.frame.minY second.swipeUp() let after = second.exists ? second.frame.minY : -.infinity XCTAssertLessThan(after, before - 100, "the home scrolled under a swipe on a row") // And back down by a swipe on another row. let lower = row(app, "Signal Box") if lower.exists, lower.isHittable { lower.swipeDown() } else { app.swipeDown() } } // RULE: the cast still scrolls sideways, and a tap on a scene row still opens the scene. func testTheCastScrollsSidewaysAndATapOpensAScene() { let app = launched() let first = row(app, "Waiting Room") XCTAssertTrue(first.waitForExistence(timeout: 60)) // The first face of the cast on screen (each says how many lines its person speaks). let faces = app.buttons.matching(NSPredicate(format: "label CONTAINS[c] %@", " lines")) XCTAssertTrue(faces.firstMatch.waitForExistence(timeout: 5), "the cast stands") let face = faces.allElementsBoundByIndex.first { $0.isHittable } XCTAssertNotNil(face, "a face of the cast is on screen") if let face { let x = face.frame.minX face.swipeLeft() XCTAssertLessThan(face.frame.minX, x - 40, "the cast moved sideways") } first.tap() XCTAssertTrue(app.staticTexts["INT. WAITING ROOM - NIGHT"].waitForExistence(timeout: 10), "the scene opened") } }