Files
buzz/scripts/test-mobile-create-channel-accessibility.sh
Matt Toohey ddc3585a3a fix(mobile): say why a channel wasn't created, and centre the iOS error (#9954)
## Summary

When creating a channel fails, the iOS New channel sheet printed the
Dart error's `toString()` under the form: an exception class name, the
relay's machine prefix, or an event id. The text also sat about 20
points right of centre and could run off the right edge.

This makes both creation sheets say what went wrong in a plain sentence,
and lays the iOS error out properly.

![The New channel sheet after tapping Create with a taken name. Before:
the raw Dart exception, right of centre. After: one plain sentence,
centred under the form at the same
height.](https://github.com/user-attachments/assets/52a40441-a478-4546-b351-b88f46d1053f)

**Wording.** A new `createChannelErrorMessage`
(`create_channel_error.dart`) is used by the native iOS sheet and the
Flutter sheet:

| Failure | Before | After |
|---|---|---|
| Name is taken | `Exception: invalid: an open channel named "general"
already exists` | `An open channel named "general" already exists` |
| No connection | `Bad state: Relay session is not connected` |
`Couldn’t create channel. No connection.` |
| Relay silent for 8 seconds | `TimeoutException: Event <64-char id> not
acknowledged within 0:00:08.000000` | `Not confirmed. The relay didn't
respond.` |
| Connection dropped while waiting | raw error text | `Not confirmed.
Connection lost.` |
| Any other `StateError` | `Bad state: …` | the message without `Bad
state:` |

The connection sentences follow the composer and reactions: once the
event has gone out, they say "not confirmed" instead of "try again",
because the relay may have created the channel. `relayErrorMessage`
itself is unchanged.

**Layout (iOS).**
- The error label was the table's `tableFooterView`, framed at x 20 with
the width reduced by 40. `UITableView` keeps a table footer's x and
overwrites its width, so centred text landed 20 points right and long
text ran off the edge.
- The error is now the last section's footer: centred within the same
margins as the field headings, wrapping inside them, with UIKit's own
group spacing above it so it starts at the same height as before.
- After a failed Create the sheet scrolls the error into view.
Previously it could sit below the fold in landscape or at large text
sizes, so a failure showed nothing.

**CI.** `scripts/test-mobile-create-channel-accessibility.sh` existed
but ran in no lane. It is now in the native lane and in the `mobile` and
`mobile-native` path filters.

### Related issue

N/A. No existing issue or open PR found for this. Related: #8807 fixed
the taken-name text in the Flutter sheet; the native iOS sheet from
#8942 did not use that code.

### Testing

- `dart format` and `flutter analyze` over `mobile/`, and the affected
Dart test files (`create_channel_error_test`,
`ios_create_channel_sheet_test`, `channels_page_test`).
- `scripts/test-mobile-create-channel-accessibility.sh` at the default
and the largest text size, on iPhone and iPad simulators (iOS 27.2). It
now asserts the margins, centring, gap, and that a failed Create scrolls
the whole error into view, including the three-row Temporary case.
- Mutations: reverting either Dart call site, the `StateError` arm, the
scroll, the scroll pass count, the centring, or the top gap each fails a
test.
- Ran the app on an iPhone 17 simulator against a seeded relay for the
three failures in the table above (taken name; relay refusing
connections; relay accepting but silent). Measured on the frames: the
error text's centre is within 0.33 pt of the screen's centre (was about
20 pt right), and its gap below the Visibility group is unchanged at
20.33 pt.

Not run: the native assertions on the CI lane's older simulator runtime
(this PR's Mobile Swift native job is the first run), VoiceOver, a real
device, and the Flutter sheet on an Android device. The screenshot was
taken one commit before the head; that last commit changes where the gap
value comes from and renders pixel-identically.

Known gap, unchanged by this PR: on an iPhone in landscape at the
largest text size with the keyboard open, the visible area is shorter
than a three-line error, so its first lines stay above the fold.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Matt Toohey <contact@matttoohey.com>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-26 10:18:58 +11:00

27 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Exercise the production UIKit create-channel field labels on a booted iOS simulator.
set -euo pipefail
repo_root=$(cd "$(dirname "$0")/.." && pwd)
device=${1:?Pass a booted iOS simulator UDID}
flutter_root=$(sed -n 's/^FLUTTER_ROOT=//p' "$repo_root/mobile/ios/Flutter/Generated.xcconfig")
frameworks="$flutter_root/bin/cache/artifacts/engine/ios/Flutter.xcframework/ios-arm64_x86_64-simulator"
fixture=$(mktemp -d)
trap 'rm -r "$fixture"' EXIT
# Compile in one file to exercise the private production controller directly.
cat "$repo_root/mobile/ios/Runner/NavigationTopEdge.swift" \
"$repo_root/mobile/ios/Runner/NativeCreateChannelSheet.swift" \
"$repo_root/mobile/ios/NativeControlTests/CreateChannelAccessibilityTests.swift" > "$fixture/test.swift"
xcrun --sdk iphonesimulator swiftc -parse-as-library \
-sdk "$(xcrun --sdk iphonesimulator --show-sdk-path)" \
-target "$(uname -m)-apple-ios16.0-simulator" \
-F "$frameworks" -framework Flutter \
-Xlinker -rpath -Xlinker "$frameworks" \
"$fixture/test.swift" \
-o "$fixture/create-channel-tests"
# Both runs pin the text size, so the simulator's own setting does not matter.
xcrun simctl spawn "$device" "$fixture/create-channel-tests" \
-UIPreferredContentSizeCategoryName UICTContentSizeCategoryL
# Again at the largest text size, where rows outgrow their estimated height.
xcrun simctl spawn "$device" "$fixture/create-channel-tests" \
-UIPreferredContentSizeCategoryName UICTContentSizeCategoryAccessibilityXXXL