// Days' export on iPhone (days CONTRACT.md §19 "Export"), over the invented crowd (-days-crowd YES) in the real core // against dev: Settings → Export opens its page (what it makes, Everything, then each group); Everything and one // group each hand the core's .ics to the share sheet. import XCTest final class DaysExportTests: XCTestCase { override func setUp() { continueAfterFailure = false } /// The share sheet rose holding a file whose name contains `name`; then it is closed. @MainActor private func shared(_ app: XCUIApplication, _ name: String, file: StaticString = #filePath, line: UInt = #line) { let sheet = app.otherElements["ActivityListView"] XCTAssertTrue(sheet.waitForExistence(timeout: 20), "the share sheet rose", file: file, line: line) let named = app.descendants(matching: .any).matching(NSPredicate(format: "label CONTAINS %@", name)).firstMatch XCTAssertTrue(named.waitForExistence(timeout: 10), "it holds \(name)", file: file, line: line) // The sheet stands half up, with no Close: a tap above it puts it away, a swipe down if it still stands. app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.12)).tap() if !sheet.waitForNonExistence(timeout: 3), sheet.exists { sheet.swipeDown(velocity: .fast) } XCTAssertTrue(sheet.waitForNonExistence(timeout: 10), "the share sheet closed", file: file, line: line) } // RULE: Export stands among Days' own rows saying what it makes; its page offers Everything and each group, and // each shares the core's calendar file. @MainActor func testExportShareEverythingAndAGroup() { let app = DaysUI.launch(["-days-open", "settings"]) let row = LookUI.id(app, "settings-row-export") XCTAssertTrue(row.waitForExistence(timeout: 60), "Export stands in Days' settings") XCTAssertTrue(row.label.contains("Your events and to-dos as a calendar file."), "it says what it makes: \(row.label)") for _ in 0..<6 where !row.isHittable { app.swipeUp(velocity: .slow) } row.tap() XCTAssertTrue(LookUI.id(app, "settings-page-export").waitForExistence(timeout: 10), "its page opens") XCTAssertTrue(app.staticTexts["Export as a calendar file"].exists, "the page says what it makes") let all = LookUI.id(app, "days-export-all") XCTAssertTrue(all.exists, "Everything") all.tap() shared(app, "Days") let group = app.buttons.matching(NSPredicate(format: "identifier BEGINSWITH 'days-export-' AND identifier != 'days-export-all'")).firstMatch XCTAssertTrue(group.waitForExistence(timeout: 10), "a group of the crowd stands") let name = group.label for _ in 0..<6 where !group.isHittable { app.swipeUp(velocity: .slow) } group.tap() shared(app, name.components(separatedBy: CharacterSet(charactersIn: ":/")).first ?? name) } }