Fix 10 failing UI tests: kanban scroll, menu-based edit, form submit reliability
- Screens.swift: findTask() now scrolls through kanban columns (swipe left/right) to locate tasks rendered off-screen in LazyHGrid - Suite5: test06/07 use refreshTasks() instead of pullToRefresh() (kanban is horizontal), add API call before navigate for server processing delay - Suite6: test09 opens "Task actions" menu before tapping edit (no detail screen) - Suite8: submitForm() uses coordinate-based keyboard dismiss, retry tap, and longer timeout; test22/23 re-navigate after creation and use waitForExistence Test results: 141/143 passed (was 131/143). Remaining 2 failures are pre-existing (Suite1 test11) and flaky/unrelated (Suite3 testR307). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -51,7 +51,28 @@ struct TaskListScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func findTask(title: String) -> XCUIElement {
|
func findTask(title: String) -> XCUIElement {
|
||||||
app.staticTexts.containing(NSPredicate(format: "label CONTAINS %@", title)).firstMatch
|
let predicate = NSPredicate(format: "label CONTAINS %@", title)
|
||||||
|
let match = app.staticTexts.containing(predicate).firstMatch
|
||||||
|
|
||||||
|
// If found immediately, return
|
||||||
|
if match.waitForExistence(timeout: 3) { return match }
|
||||||
|
|
||||||
|
// Scroll through kanban columns (swipe left up to 6 times)
|
||||||
|
let scrollView = app.scrollViews.firstMatch
|
||||||
|
guard scrollView.exists else { return match }
|
||||||
|
|
||||||
|
for _ in 0..<6 {
|
||||||
|
scrollView.swipeLeft()
|
||||||
|
if match.waitForExistence(timeout: 1) { return match }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scroll back and try right direction
|
||||||
|
for _ in 0..<6 {
|
||||||
|
scrollView.swipeRight()
|
||||||
|
if match.waitForExistence(timeout: 1) { return match }
|
||||||
|
}
|
||||||
|
|
||||||
|
return match
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,18 +100,18 @@ final class Suite5_TaskTests: AuthenticatedUITestCase {
|
|||||||
// Wait for form to dismiss
|
// Wait for form to dismiss
|
||||||
_ = saveButton.waitForNonExistence(timeout: navigationTimeout)
|
_ = saveButton.waitForNonExistence(timeout: navigationTimeout)
|
||||||
|
|
||||||
// Verify task appears in list (may need refresh or scroll in kanban view)
|
// Verify task was created via API (also gives the server time to process)
|
||||||
let newTask = app.staticTexts.containing(NSPredicate(format: "label CONTAINS %@", taskTitle)).firstMatch
|
|
||||||
if !newTask.waitForExistence(timeout: navigationTimeout) {
|
|
||||||
pullToRefresh()
|
|
||||||
}
|
|
||||||
XCTAssertTrue(newTask.waitForExistence(timeout: navigationTimeout), "New task '\(taskTitle)' should appear in the list")
|
|
||||||
|
|
||||||
// Track for cleanup
|
|
||||||
if let items = TestAccountAPIClient.listTasks(token: session.token),
|
if let items = TestAccountAPIClient.listTasks(token: session.token),
|
||||||
let created = items.first(where: { $0.title.contains(taskTitle) }) {
|
let created = items.first(where: { $0.title.contains(taskTitle) }) {
|
||||||
cleaner.trackTask(created.id)
|
cleaner.trackTask(created.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Navigate to tasks tab and refresh to pick up the newly created task
|
||||||
|
navigateToTasks()
|
||||||
|
refreshTasks()
|
||||||
|
let taskListScreen = TaskListScreen(app: app)
|
||||||
|
let newTask = taskListScreen.findTask(title: taskTitle)
|
||||||
|
XCTAssertTrue(newTask.waitForExistence(timeout: loginTimeout), "New task '\(taskTitle)' should appear in the list")
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - 4. View Details
|
// MARK: - 4. View Details
|
||||||
@@ -133,24 +133,23 @@ final class Suite5_TaskTests: AuthenticatedUITestCase {
|
|||||||
saveButton.tap()
|
saveButton.tap()
|
||||||
_ = saveButton.waitForNonExistence(timeout: navigationTimeout)
|
_ = saveButton.waitForNonExistence(timeout: navigationTimeout)
|
||||||
|
|
||||||
// Find and tap the task (may need refresh)
|
// Verify task was created via API (also gives the server time to process)
|
||||||
let taskCard = app.staticTexts.containing(NSPredicate(format: "label CONTAINS %@", taskTitle)).firstMatch
|
|
||||||
if !taskCard.waitForExistence(timeout: navigationTimeout) {
|
|
||||||
pullToRefresh()
|
|
||||||
}
|
|
||||||
taskCard.waitForExistenceOrFail(timeout: navigationTimeout, message: "Created task should appear in list")
|
|
||||||
|
|
||||||
if let items = TestAccountAPIClient.listTasks(token: session.token),
|
if let items = TestAccountAPIClient.listTasks(token: session.token),
|
||||||
let created = items.first(where: { $0.title.contains(taskTitle) }) {
|
let created = items.first(where: { $0.title.contains(taskTitle) }) {
|
||||||
cleaner.trackTask(created.id)
|
cleaner.trackTask(created.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
taskCard.tap()
|
// Navigate to tasks tab and refresh to pick up the newly created task
|
||||||
|
navigateToTasks()
|
||||||
|
refreshTasks()
|
||||||
|
let taskListScreen = TaskListScreen(app: app)
|
||||||
|
let taskCard = taskListScreen.findTask(title: taskTitle)
|
||||||
|
taskCard.waitForExistenceOrFail(timeout: loginTimeout, message: "Created task should appear in list")
|
||||||
|
|
||||||
// After tapping a task, the app should show task details or actions.
|
// Verify the task card is accessible and the actions menu exists
|
||||||
// The navigation bar title or a detail view element should appear.
|
// (There is no task detail screen — cards are self-contained with a context menu)
|
||||||
let navBar = app.navigationBars.firstMatch
|
let actionsMenu = app.buttons["Task actions"].firstMatch
|
||||||
XCTAssertTrue(navBar.waitForExistence(timeout: navigationTimeout), "Task detail view should load after tap")
|
XCTAssertTrue(actionsMenu.waitForExistence(timeout: navigationTimeout), "Task actions menu should be accessible")
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - 5. Navigation
|
// MARK: - 5. Navigation
|
||||||
|
|||||||
@@ -291,7 +291,11 @@ final class Suite6_ComprehensiveTaskTests: AuthenticatedUITestCase {
|
|||||||
|
|
||||||
let task = findTask(title: originalTitle)
|
let task = findTask(title: originalTitle)
|
||||||
XCTAssertTrue(task.waitForExistence(timeout: defaultTimeout), "Task should exist")
|
XCTAssertTrue(task.waitForExistence(timeout: defaultTimeout), "Task should exist")
|
||||||
task.tap()
|
|
||||||
|
// Open the task actions menu on the card (edit is inside a Menu, not a detail screen)
|
||||||
|
let actionsMenu = app.buttons["Task actions"].firstMatch
|
||||||
|
if actionsMenu.waitForExistence(timeout: defaultTimeout) {
|
||||||
|
actionsMenu.tap()
|
||||||
|
|
||||||
let editButton = app.buttons[AccessibilityIdentifiers.Task.editButton].firstMatch
|
let editButton = app.buttons[AccessibilityIdentifiers.Task.editButton].firstMatch
|
||||||
if editButton.waitForExistence(timeout: defaultTimeout) {
|
if editButton.waitForExistence(timeout: defaultTimeout) {
|
||||||
@@ -315,6 +319,7 @@ final class Suite6_ComprehensiveTaskTests: AuthenticatedUITestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// test10_updateAllTaskFields removed — requires Actions menu accessibility identifiers
|
// test10_updateAllTaskFields removed — requires Actions menu accessibility identifiers
|
||||||
|
|
||||||
|
|||||||
@@ -128,18 +128,35 @@ final class Suite8_DocumentWarrantyTests: AuthenticatedUITestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func submitForm(file: StaticString = #filePath, line: UInt = #line) {
|
private func submitForm(file: StaticString = #filePath, line: UInt = #line) {
|
||||||
// Dismiss keyboard so submit button is visible
|
// Dismiss keyboard by tapping outside form fields
|
||||||
dismissKeyboard()
|
app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.15)).tap()
|
||||||
|
_ = app.keyboards.firstMatch.waitForNonExistence(timeout: 3)
|
||||||
|
|
||||||
|
// If keyboard still showing (can happen with long text / autocorrect), try Return key
|
||||||
|
if app.keyboards.firstMatch.exists {
|
||||||
|
app.typeText("\n")
|
||||||
|
_ = app.keyboards.firstMatch.waitForNonExistence(timeout: 2)
|
||||||
|
}
|
||||||
|
|
||||||
let submitButton = docForm.saveButton
|
let submitButton = docForm.saveButton
|
||||||
if !submitButton.exists || !submitButton.isHittable {
|
if !submitButton.exists || !submitButton.isHittable {
|
||||||
app.swipeUp()
|
app.swipeUp()
|
||||||
_ = submitButton.waitForExistence(timeout: defaultTimeout)
|
_ = submitButton.waitForExistence(timeout: navigationTimeout)
|
||||||
}
|
}
|
||||||
XCTAssertTrue(submitButton.exists && submitButton.isEnabled, "Submit button should exist and be enabled", file: file, line: line)
|
XCTAssertTrue(submitButton.exists && submitButton.isEnabled, "Submit button should exist and be enabled", file: file, line: line)
|
||||||
|
|
||||||
|
// First tap attempt
|
||||||
|
if submitButton.isHittable {
|
||||||
submitButton.tap()
|
submitButton.tap()
|
||||||
// Wait for form to dismiss after submit
|
} else {
|
||||||
submitButton.waitForNonExistence(timeout: navigationTimeout, file: file, line: line)
|
submitButton.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for form to dismiss — retry tap if button doesn't disappear
|
||||||
|
if !submitButton.waitForNonExistence(timeout: loginTimeout) && submitButton.exists {
|
||||||
|
submitButton.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
|
||||||
|
_ = submitButton.waitForNonExistence(timeout: loginTimeout)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Look up a just-created document by title and track it for API cleanup.
|
/// Look up a just-created document by title and track it for API cleanup.
|
||||||
@@ -770,10 +787,17 @@ final class Suite8_DocumentWarrantyTests: AuthenticatedUITestCase {
|
|||||||
|
|
||||||
submitForm()
|
submitForm()
|
||||||
|
|
||||||
// Just verify it was created (partial match)
|
// Track via API (also gives server time to process)
|
||||||
|
trackDocumentForCleanup(title: longTitle)
|
||||||
|
|
||||||
|
// Re-navigate to refresh the list after creation
|
||||||
|
navigateToDocuments()
|
||||||
|
switchToDocumentsTab()
|
||||||
|
|
||||||
|
// Verify it was created (partial match with wait)
|
||||||
let partialTitle = String(longTitle.prefix(30))
|
let partialTitle = String(longTitle.prefix(30))
|
||||||
let documentExists = app.staticTexts.containing(NSPredicate(format: "label CONTAINS[c] '\(partialTitle)'")).firstMatch.exists
|
let documentCard = app.staticTexts.containing(NSPredicate(format: "label CONTAINS[c] '\(partialTitle)'")).firstMatch
|
||||||
XCTAssertTrue(documentExists, "Document with long title should be created")
|
XCTAssertTrue(documentCard.waitForExistence(timeout: loginTimeout), "Document with long title should be created")
|
||||||
}
|
}
|
||||||
|
|
||||||
func test23_CreateWarrantyWithSpecialCharacters() {
|
func test23_CreateWarrantyWithSpecialCharacters() {
|
||||||
@@ -792,9 +816,17 @@ final class Suite8_DocumentWarrantyTests: AuthenticatedUITestCase {
|
|||||||
|
|
||||||
submitForm()
|
submitForm()
|
||||||
|
|
||||||
|
// Track via API (also gives server time to process)
|
||||||
|
trackDocumentForCleanup(title: specialTitle)
|
||||||
|
|
||||||
|
// Re-navigate to refresh the list after creation
|
||||||
|
navigateToDocuments()
|
||||||
|
switchToWarrantiesTab()
|
||||||
|
|
||||||
|
// Verify it was created (partial match with wait)
|
||||||
let partialTitle = String(specialTitle.prefix(20))
|
let partialTitle = String(specialTitle.prefix(20))
|
||||||
let warrantyExists = app.staticTexts.containing(NSPredicate(format: "label CONTAINS '\(partialTitle)'")).firstMatch.exists
|
let warrantyCard = app.staticTexts.containing(NSPredicate(format: "label CONTAINS '\(partialTitle)'")).firstMatch
|
||||||
XCTAssertTrue(warrantyExists, "Warranty with special characters should be created")
|
XCTAssertTrue(warrantyCard.waitForExistence(timeout: loginTimeout), "Warranty with special characters should be created")
|
||||||
}
|
}
|
||||||
|
|
||||||
func test24_RapidTabSwitching() {
|
func test24_RapidTabSwitching() {
|
||||||
|
|||||||
Reference in New Issue
Block a user