Skip to content

Add iOS view tests and run them on a simulator in CI - #32

Merged
servercimen merged 8 commits into
feature/content-settledfrom
feature/ios-view-tests
Nov 24, 2026
Merged

servercimen merged 8 commits into
feature/content-settledfrom
feature/ios-view-tests

Conversation

@servercimen

Copy link
Copy Markdown
Owner

Part 2 of a stack of 13 pull requests. The base is #31 (feature/content-settled). #31 (part 1) tells how to merge the stack.

On this stacked branch, swift test passes (195 tests), and the iOS build and build-for-testing pass.

Summary

Until now, no test used TranscriptTextView or TranscriptText, and CI only built the package for iOS. This change adds view tests for iOS and a CI job that runs them on a simulator. The tests use contentSettled() from the base branch to wait for layouts that come back later.

  • Add the test target TranscriptKitViewTests. All of its code is under #if canImport(UIKit), so on macOS the target is empty and swift test runs as before.
  • Add 18 tests of TranscriptTextView: sizing (sizeThatFits at a width, a new width, the height of empty text), the first layout (synchronous for plain text and for a stream), a streamed append that arrives later, the line limit, selection (select(_:), selectAll, onSelectionChange, selectsAllWhenShown, one selection per window), hit testing (point(inside:with:) with and without selection, on and off a link), and a view that leaves its window.
  • Add 3 tests of TranscriptText in a UIHostingController: rows in a LazyVStack are as tall as their text, a streamed row grows when text arrives, and the line limit of the environment applies.
  • Each test has its own window and views of a fixed size, and a time limit of one minute. The tests compare the view with a DocumentLayout at the same width and style, not with fixed numbers. Thus the screen size and the fonts of the device do not change the results.
  • Add the CI job "iOS view tests". It picks the first available iPhone simulator of the newest iOS runtime that the simulator SDK of the selected Xcode supports. Then it runs xcodebuild test -only-testing:TranscriptKitViewTests on that simulator.
  • Tell in the README how to run the view tests.
  • A finding, not changed here: a style set on a view that has a width lays out the empty text at once. The document set after it then comes from the background, so its first layout is not synchronous. The tests set the style before the width. The README of the base branch now tells this.

Tests

  • swift test on macOS: 195 tests pass. The view test target is empty on macOS, so the count is the same as on the base branch.
  • xcodebuild build-for-testing -scheme TranscriptKit -destination 'generic/platform=iOS' CODE_SIGNING_ALLOWED=NO: passes. It builds TranscriptKitViewTests.xctest.
  • The view tests did not run on this machine. A package test bundle has no host app, so it cannot run on a device. Under Mac Catalyst it has no NSApplication, so it cannot open a window. The CI job of this pull request is the first run of the view tests, on a simulator.

Checked on an iPhone 12 mini

Not run. xcodebuild test on the phone stops before the build, because a device does not support tool-hosted tests.

Not checked

  • The view tests themselves. No run on a simulator, a device or a Mac has passed or failed yet.

Known limits

  • No test taps a link. The tap handler is private, and a real tap needs a UI test. The tests check only the hit test on the link.

🤖 Generated with Claude Code

servercimen and others added 7 commits November 24, 2026 11:23
A new test target holds tests that need UIKit. On macOS the target is
empty, so swift test runs as before.

The tests cover sizing, the first layout, the line limit, selection and
hit testing. Each test gives its views and windows a fixed size, so the
screen size does not change the results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tests show TranscriptText in a hosting controller. They check that
rows in a lazy stack are as tall as their text, that a streamed row
grows when text arrives, and that the line limit of the environment
applies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The new job "iOS view tests" picks the first available iPhone
simulator of the newest iOS runtime. Then it runs the
TranscriptKitViewTests target with xcodebuild test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A style set while the view has a width lays out the empty text at once.
The text set after it then comes from the background, so the line limit
test read a height of 0. The tests now set the style first.

Also remove two checks that depend on UIKit details outside the task:
a move to another window, and a row width that the safe area can change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A runner image can hold an iOS runtime that is newer than the SDK of its
Xcode. The step now skips runtimes that are newer than the simulator
SDK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
contentSettled() has no timeout of its own. A view that does not settle
made the CI job wait for its full timeout, and the log did not name the
test. Now each test of the two view suites stops after one minute.

Remove the check that empty text has no intrinsic height before the
first layout. It tested an internal state, not the behavior. The check
of sizeThatFits stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@servercimen
servercimen added this pull request to stack #45 November 24, 2026 21:01
@servercimen
servercimen merged commit b7fd3fb into main Nov 24, 2026
3 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