// Settings organised as Comms' You (owner, 23 Nov 2026; shared/DECISIONS.md "Organised as Comms' You"),// as Words', Days' and Story's tests check it: the profile card first, the app's own rows, then Sync,// Storage, Help and feedback and About in that order (with Your Claude, Privacy and Notifications where// the core answers them), each saying how it stands;// each row opens its own page and Back returns to the list; Sign out stands on Profile alone. Every// word is the core's or the app's; these find the parts by identifier.import XCTestenumSettingsGroupedUI { @MainActor staticfunc id(_ app: XCUIApplication, _ identifier: String) -> XCUIElement { app.descendants(matching: .any).matching(identifier: identifier).firstMatch }/// The card, then the rows in Comms' order with the app's own between Sync and Storage. @MainActor staticfunc assertList(_ app: XCUIApplication, own: [String], file: StaticString = #filePath, line: UInt = #line) {let card = id(app, "settings-card") XCTAssertTrue(card.waitForExistence(timeout: 60), "the person's card stands first", file: file, line: line) XCTAssertTrue(id(app, "settings-row-sync").waitForExistence(timeout: 30), "Sync stands", file: file, line: line)let order = own + ["sync", "storage", "help", "about"]var above = card.frame.minYvar swiped = falsefor row in order {let element = id(app, "settings-row-\(row)")if !element.isHittable { swiped = true }SettingsPartsUI.reach(app, element) XCTAssertTrue(element.exists, "\(row) stands", file: file, line: line) XCTAssertFalse(element.label.isEmpty, "\(row) says its name", file: file, line: line)// Read in place while nothing has scrolled; at the largest text each is reached in turn, going down.if !swiped { XCTAssertGreaterThan(element.frame.minY, above, "\(row) stands below the one before", file: file, line: line) } above = element.frame.minY } XCTAssertFalse(id(app, "settings-sign-out").exists, "Sign out stands on Profile alone", file: file, line: line) XCTAssertFalse(id(app, "settings-storage-data").exists, "Storage's parts stand on its page, not the list", file: file, line: line) }/// The list draws whole on its first frame (owner, build 24: the card came first and the rows a second or two/// later). Settings is opened once, so this phone holds the list; then a cold launch opens it with the read held/// back 6 s (`-settings-held`), as a phone with much kept answers late: the card and every row stand at once,/// and none moves when the read lands. @MainActor staticfunc assertDrawnWhole(_ launch: ([String]) -> XCUIApplication, own: [String], file: StaticString = #filePath, line: UInt = #line) {let first = launch([]) XCTAssertTrue(id(first, "settings-row-about").waitForExistence(timeout: 60), "Settings read once", file: file, line: line) first.terminate()let app = launch(["-settings-held", "6"]) XCTAssertTrue(id(app, "settings-card").waitForExistence(timeout: 60), "the card stands", file: file, line: line)let shown = Date()// One snapshot of the screen, so a long page under Settings (Days' list) costs one read of the tree, not one per row.var drawn: [String: CGRect] = [:]func walk(_ element: XCUIElementSnapshot) {if element.identifier.hasPrefix("settings-row-") { drawn[element.identifier] = element.frame } element.children.forEach(walk) }iflet snapshot = try? app.snapshot() { walk(snapshot) } XCTAssertLessThan(Date().timeIntervalSince(shown), 5, "every row was seen before the held read could answer", file: file, line: line)var frames: [String: CGRect] = [:]for row in own + ["sync", "storage", "help", "about"] { XCTAssertNotNil(drawn["settings-row-\(row)"], "\(row) stands with the card, before the read answers", file: file, line: line) frames[row] = drawn["settings-row-\(row)"] }// The read lands (6 s after Settings opened); the values fill in place. _ = app.buttons["__none__"].waitForExistence(timeout: 7)for (row, frame) in frames {let now = id(app, "settings-row-\(row)").frame XCTAssertEqual(now.minY, frame.minY, accuracy: 0.5, "\(row) stayed where it stood", file: file, line: line) XCTAssertEqual(now.height, frame.height, accuracy: 0.5, "\(row) kept its height", file: file, line: line) } }/// A row opens its page; `back` returns to the list. @MainActor staticfuncopen(_ app: XCUIApplication, _ row: String, file: StaticString = #filePath, line: UInt = #line) {let element = id(app, "settings-row-\(row)") XCTAssertTrue(element.waitForExistence(timeout: 30), "\(row) stands", file: file, line: line)SettingsPartsUI.reach(app, element) element.tap() } @MainActor staticfunc back(_ app: XCUIApplication, _ backID: String, file: StaticString = #filePath, line: UInt = #line) {let button = id(app, backID) XCTAssertTrue(button.waitForExistence(timeout: 10), "Back stands", file: file, line: line) button.tap() XCTAssertTrue(id(app, "settings-card").waitForExistence(timeout: 10), "Back returns to the list", file: file, line: line) }/// Storage, Help and feedback, About and Sync each open their page and Back returns; the card opens Profile,/// where Sign out (or, signed out, Sign in) stands. @MainActor staticfunc assertPages(_ app: XCUIApplication, backID: String, file: StaticString = #filePath, line: UInt = #line) {open(app, "storage", file: file, line: line) XCTAssertTrue(id(app, "settings-storage-data").waitForExistence(timeout: 30), "Storage's page says Your data", file: file, line: line)for part in ["files", "other"] { XCTAssertTrue(id(app, "settings-storage-\(part)").exists, "Storage's page says \(part)", file: file, line: line) } XCTAssertTrue(id(app, "settings-free-up").exists, "Storage's page offers Free up space", file: file, line: line) back(app, backID, file: file, line: line)open(app, "help", file: file, line: line) XCTAssertTrue(id(app, "settings-share-report").waitForExistence(timeout: 30), "Help and feedback offers Share a report", file: file, line: line) assertHelpLinks(app, file: file, line: line) back(app, backID, file: file, line: line)open(app, "about", file: file, line: line) XCTAssertTrue(id(app, "settings-about-version").waitForExistence(timeout: 30), "About says the version", file: file, line: line)SettingsPartsUI.assertFactsUnderAbout(app, file: file, line: line) back(app, backID, file: file, line: line)open(app, "sync", file: file, line: line) XCTAssertTrue(id(app, "settings-sync-state").waitForExistence(timeout: 30), "Sync's page says how it stands", file: file, line: line) back(app, backID, file: file, line: line)let card = id(app, "settings-card")SettingsPartsUI.reach(app, card)if !card.isHittable { for _ in0..<14where !card.isHittable { app.swipeDown(velocity: .fast) } } card.tap()// Signed in, the card opens Profile with Sign out; signed out, a tap on it signs in (the number asked).let way = id(app, "settings-sign-out").waitForExistence(timeout: 30) || id(app, "home-customer-phone").exists XCTAssertTrue(way, "the card opens Profile with Sign out, or signs in signed out", file: file, line: line) back(app, backID, file: file, line: line) }/// Help and feedback ends with the privacy policy and Help and contact (both stores ask; store pass, 24 Nov 2026). @MainActor staticfunc assertHelpLinks(_ app: XCUIApplication, file: StaticString = #filePath, line: UInt = #line) {let privacy = id(app, "settings-link-privacy"), support = id(app, "settings-link-support")SettingsPartsUI.reach(app, support) XCTAssertTrue(privacy.waitForExistence(timeout: 10), "Help and feedback offers the privacy policy", file: file, line: line) XCTAssertTrue(support.exists, "Help and feedback offers Help and contact", file: file, line: line) XCTAssertEqual(privacy.label, "Privacy policy", file: file, line: line) XCTAssertEqual(support.label, "Help and contact", file: file, line: line) XCTAssertLessThan(id(app, "settings-share-report").frame.minY, privacy.frame.minY, "after Share a report", file: file, line: line) XCTAssertLessThan(privacy.frame.minY, support.frame.minY, "Privacy policy, then Help and contact", file: file, line: line) }/// The privacy policy opens its page on cottondb.com in Safari, and the app comes back as it was. @MainActor staticfunc assertPrivacyOpens(_ app: XCUIApplication, file: StaticString = #filePath, line: UInt = #line) {open(app, "help", file: file, line: line)let privacy = id(app, "settings-link-privacy")SettingsPartsUI.reach(app, privacy) XCTAssertTrue(privacy.waitForExistence(timeout: 30), file: file, line: line) privacy.tap()let safari = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari") XCTAssertTrue(safari.wait(for: .runningForeground, timeout: 20), "Safari opens the privacy policy", file: file, line: line) app.activate() XCTAssertTrue(privacy.waitForExistence(timeout: 10), "back on Help and feedback", file: file, line: line) }/// Share a report, from Help and feedback's page, shows the report whole first. @MainActor staticfunc assertReportShownFirst(_ app: XCUIApplication, file: StaticString = #filePath, line: UInt = #line) {open(app, "help", file: file, line: line)SettingsPartsUI.assertReportShownFirst(app, file: file, line: line) }}