Skip to content

Wait for async-enabled controls in tapAsync, add expectEnabledAsync - #2

Merged
ast3150 merged 1 commit into
mainfrom
feature/async-toolbar-refresh
Nov 11, 2026
Merged

ast3150 merged 1 commit into
mainfrom
feature/async-toolbar-refresh

Conversation

@ast3150

@ast3150 ast3150 commented Nov 11, 2026

Copy link
Copy Markdown
Member

Problem

Since iOS 27, SwiftUI refreshes toolbar items as async main-actor work. The synchronous API (tap, pump, expect) spins a nested run loop that does not drain this work. After an edit, a bar button stays disabled, and keeps its old action closure, until the test suspends. Tests that tap "Done" or check isEnabled right after an edit fail. The failures depend on test order.

Change

  • tapAsync retries a control it cannot activate yet (for example a disabled one) until its timeout, and settles in between. A control that stays disabled still throws, now after the timeout.
  • New expectEnabledAsync(_:timeout:): waits until an element with the label is enabled.
  • README: a note on the iOS 27 toolbar behaviour and the new API.

Tests

  • New package tests: tapAsync waits for a control that async work enables, expectEnabledAsync waits for it, and tapAsync still refuses a control that stays disabled.
  • Package suite: 23/23 on iPhone 18 Pro, iOS 27.2.
  • Checked in a consuming project through a local path dependency: 1236 hosted tests green on iOS 27.2.

🤖 Generated with Claude Code

Since iOS 27 SwiftUI refreshes toolbar items as async main-actor work,
which the synchronous pump never drains. After an edit, a bar button
stays disabled until the test suspends.

- tapAsync retries a control it cannot activate yet until its timeout,
  settling in between.
- expectEnabledAsync waits for an enabled element.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ast3150
ast3150 merged commit c89b3b1 into main Nov 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant