test(m9): replace full-timeout negative waits with dwell assertion #140

Closed
opened 2026-09-12 16:50:44 +01:00 by gronod · 0 comments
Owner

Problem

Two negative assertions in Milestone2UITests use XCTAssertFalse(el.waitForExistence(timeout: 3)), which always burns the full 3s timeout on the negative (expected) path because waitForExistence only returns early on success:

  • Tests/ICCeryUITests/Milestone2UITests.swift:319 — preset deletion confirmation
  • Tests/ICCeryUITests/Milestone2UITests.swift:351 — preset re-import setup

An audit of all XCTAssertFalse(...waitForExistence...) and XCTAssertFalse(...exists...) sites across Tests/ICCeryUITests/ confirmed these are the only two full-timeout negative waits; the rest already use the instant .exists form.

Change

Add a small assertAbsent(_:dwell:) helper next to the existing waitFor helper in Milestone2UITests.swift, then replace the two waitForExistence(timeout: 3) sites with it:

/// Assert an element stays absent after a short dwell — unlike
/// `waitForExistence`, which always burns its full timeout on the
/// negative path.
private func assertAbsent(_ el: XCUIElement, dwell: TimeInterval = 0.5,
                          _ message: String = "expected element to stay absent",
                          file: StaticString = #filePath, line: UInt = #line) {
    RunLoop.current.run(until: Date().addingTimeInterval(dwell))
    XCTAssertFalse(el.exists, message, file: file, line: line)
}

The 0.5s dwell lets the SwiftUI list settle after the synchronous store deletion before asserting absence. ~6s saved per suite run.

Acceptance

  • testSaveAndDeleteCustomPreset and testPresetExportImport pass with the new helper.
  • No other test file changes.

Scope

  • Tests/ICCeryUITests/Milestone2UITests.swift only.
  • Out of scope: collapsing app-side delays (separate issue), CI workflow changes.
## Problem Two negative assertions in `Milestone2UITests` use `XCTAssertFalse(el.waitForExistence(timeout: 3))`, which always burns the full 3s timeout on the negative (expected) path because `waitForExistence` only returns early on success: - `Tests/ICCeryUITests/Milestone2UITests.swift:319` — preset deletion confirmation - `Tests/ICCeryUITests/Milestone2UITests.swift:351` — preset re-import setup An audit of all `XCTAssertFalse(...waitForExistence...)` and `XCTAssertFalse(...exists...)` sites across `Tests/ICCeryUITests/` confirmed these are the only two full-timeout negative waits; the rest already use the instant `.exists` form. ## Change Add a small `assertAbsent(_:dwell:)` helper next to the existing `waitFor` helper in `Milestone2UITests.swift`, then replace the two `waitForExistence(timeout: 3)` sites with it: ```swift /// Assert an element stays absent after a short dwell — unlike /// `waitForExistence`, which always burns its full timeout on the /// negative path. private func assertAbsent(_ el: XCUIElement, dwell: TimeInterval = 0.5, _ message: String = "expected element to stay absent", file: StaticString = #filePath, line: UInt = #line) { RunLoop.current.run(until: Date().addingTimeInterval(dwell)) XCTAssertFalse(el.exists, message, file: file, line: line) } ``` The 0.5s dwell lets the SwiftUI list settle after the synchronous store deletion before asserting absence. ~6s saved per suite run. ## Acceptance - `testSaveAndDeleteCustomPreset` and `testPresetExportImport` pass with the new helper. - No other test file changes. ## Scope - `Tests/ICCeryUITests/Milestone2UITests.swift` only. - Out of scope: collapsing app-side delays (separate issue), CI workflow changes.
gronod added the Kind/Testing
Priority
Low
4
Project/ICCery-v2Feature/UI
labels 2026-09-12 16:50:45 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gronod/iccery-v2-mac#140