Repository navigation
Add iOS view tests and run them on a simulator in CI - #32
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 testpasses (195 tests), and the iOS build and build-for-testing pass.Summary
Until now, no test used
TranscriptTextVieworTranscriptText, 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 usecontentSettled()from the base branch to wait for layouts that come back later.TranscriptKitViewTests. All of its code is under#if canImport(UIKit), so on macOS the target is empty andswift testruns as before.TranscriptTextView: sizing (sizeThatFitsat 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.TranscriptTextin aUIHostingController: rows in aLazyVStackare as tall as their text, a streamed row grows when text arrives, and the line limit of the environment applies.DocumentLayoutat the same width and style, not with fixed numbers. Thus the screen size and the fonts of the device do not change the results.xcodebuild test -only-testing:TranscriptKitViewTestson that simulator.styleset 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 teston 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 buildsTranscriptKitViewTests.xctest.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 teston the phone stops before the build, because a device does not support tool-hosted tests.Not checked
Known limits
🤖 Generated with Claude Code