// Show, search, Drop and Delete (DECISIONS, 21 Nov 2026; CONTRACT §3, §11, // §12): Show lists All and the groups, then Late, Repeating, Dropped and // Done, and a view stands in place of the days; the magnifier opens search, // results come as the words are typed, and a tap lands on the item; Drop // keeps a to-do under Dropped, where Bring back opens it again; Delete asks // first. Invented crowd only, put back as it came in. import XCTest final class DaysShowTests: DaysUITestCase { // RULE: Show offers the four views after the groups; a view stands in place of the days and the control reads its name; All brings the days back. @MainActor func testShowOffersTheFourViews() throws { let app = DaysUI.launch() DaysUI.days(app) try skipUnderTheShellsCard(app) DaysUI.filter(app).tap() for view in ["Late", "Repeating", "Dropped", "Done"] { XCTAssertTrue(DaysUI.button(app, view).waitForExistence(timeout: 3), "Show offers \(view)") } DaysUI.button(app, "Late").tap() let late = app.buttons.matching(NSPredicate(format: "label BEGINSWITH %@", "Showing Late")).firstMatch XCTAssertTrue(late.waitForExistence(timeout: 5), "the control reads Late") XCTAssertFalse(app.buttons.matching(NSPredicate(format: "label BEGINSWITH %@", "Today, ")).firstMatch.exists, "Late stands in place of the days") late.tap() DaysUI.all(app).tap() XCTAssertTrue(app.buttons.matching(NSPredicate(format: "label BEGINSWITH %@", "Today, ")).firstMatch.waitForExistence(timeout: 5), "All brings the days back") } // RULE: the magnifier opens search with the keyboard up; results come as the words are typed, under Coming; a tap closes search and lands on the item; words that find nothing say so. @MainActor func testSearchFindsAndLands() throws { let app = DaysUI.launch() DaysUI.days(app) try skipUnderTheShellsCard(app) DaysUI.button(app, "Search Days").tap() let field = DaysUI.field(app, "Search") XCTAssertTrue(field.waitForExistence(timeout: 5), "search opened") _ = DaysUI.keyboard(app) field.typeText("zzqx nothing") XCTAssertTrue(app.staticTexts.matching(NSPredicate(format: "label BEGINSWITH %@", "Nothing found for")).firstMatch.waitForExistence(timeout: 5), "nothing found says so") for _ in 0..<"zzqx nothing".count { field.typeText(XCUIKeyboardKey.delete.rawValue) } field.typeText("chore 27") XCTAssertTrue(app.staticTexts["COMING"].waitForExistence(timeout: 5), "results come under Coming") let found = app.buttons.matching(NSPredicate(format: "label BEGINSWITH %@", "Invented chore 27 ")).firstMatch XCTAssertTrue(found.waitForExistence(timeout: 5), "the chore is found") found.coordinate(withNormalizedOffset: CGVector(dx: 0.6, dy: 0.5)).tap() XCTAssertTrue(field.waitForNonExistence(timeout: 4), "a tap closed search") settle(1.5) let landed = app.buttons.matching(NSPredicate(format: "label BEGINSWITH %@", "Invented chore 27 ")).firstMatch XCTAssertTrue(landed.exists && landed.isHittable, "it landed on the chore in Days") } // RULE: Drop keeps a to-do under Dropped, where Bring back opens it again; Delete asks first, and Keep keeps it. @MainActor func testDropBringBackAndDeleteAsksFirst() throws { let app = DaysUI.launch(["-days-open", "todo"]) let title = DaysUI.field(app, "Title") XCTAssertTrue(title.waitForExistence(timeout: 90), "the to-do's sheet opened") try skipUnderTheShellsCard(app, wait: 0) let words = title.value as? String ?? "" // Delete asks first; Keep keeps it. DaysUI.button(app, "Delete").tap() XCTAssertTrue(app.staticTexts["Delete “\(words)”?"].waitForExistence(timeout: 3), "Delete asks first") DaysUI.button(app, "Keep").tap() XCTAssertTrue(app.staticTexts["Delete “\(words)”?"].waitForNonExistence(timeout: 3), "Keep kept it") XCTAssertTrue(title.exists, "the sheet still stands") // Drop: under Dropped, with Bring back. DaysUI.button(app, "Drop").tap() XCTAssertTrue(title.waitForNonExistence(timeout: 4), "Drop closed the sheet") XCTAssertTrue(app.staticTexts["Dropped: \(words)."].waitForExistence(timeout: 4), "it says Dropped") DaysUI.filter(app).tap() DaysUI.button(app, "Dropped").tap() let row = app.buttons.matching(NSPredicate(format: "label BEGINSWITH %@", words + ",")).firstMatch XCTAssertTrue(row.waitForExistence(timeout: 5), "\(words) stands under Dropped") let back = DaysUI.button(app, "Bring back") XCTAssertTrue(back.exists, "with Bring back") back.tap() XCTAssertTrue(app.staticTexts["Back: \(words)."].waitForExistence(timeout: 4), "Bring back brought it back") XCTAssertTrue(row.waitForNonExistence(timeout: 5), "it left Dropped") DaysUI.filter(app).tap() DaysUI.all(app).tap() } }