diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 05c28a5..8e063ab 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,10 +22,10 @@ jobs: - name: Configure Xcode 15 run: | - sudo xcode-select -s /Applications/Xcode_15.2.app + sudo xcode-select -s /Applications/Xcode_15.4.app - name: Run tests - run: xcodebuild test -scheme 'Compound' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' -skipPackagePluginValidation -resultBundlePath Logs/CompoundTests.xcresult + run: xcodebuild test -scheme 'Compound' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone SE (3rd generation),OS=17.5' -skipPackagePluginValidation -resultBundlePath Logs/CompoundTests.xcresult - name: Zip artifacts if: failure() # We only care about artefacts if the tests fail diff --git a/Tests/CompoundTests/.prefire.yml b/Tests/CompoundTests/.prefire.yml index 3f39cdc..0d33eec 100644 --- a/Tests/CompoundTests/.prefire.yml +++ b/Tests/CompoundTests/.prefire.yml @@ -1,5 +1,5 @@ test_configuration: - - simulator_device: "iPhone15" + - simulator_device: "iPhone14,6" # iPhone SE 3rd Generation - required_os: 17 - template_file_path: PreviewTests.stencil - snapshot_devices: diff --git a/Tests/CompoundTests/PreviewTests.stencil b/Tests/CompoundTests/PreviewTests.stencil index 6e2e71e..e0b7472 100644 --- a/Tests/CompoundTests/PreviewTests.stencil +++ b/Tests/CompoundTests/PreviewTests.stencil @@ -77,8 +77,8 @@ class PreviewTests: XCTestCase { fatalError("Unknown device name: \(deviceName)") } - // Ignore specific device safe area - device.safeArea = .zero + // Ignore specific device safe area (using the workaround value to fix rendering issues). + device.safeArea = .one // Ignore specific device display scale let traits = UITraitCollection(displayScale: 2.0) @@ -144,7 +144,7 @@ class PreviewTests: XCTestCase { if let simulatorDevice { let deviceModel = ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] guard deviceModel?.contains(simulatorDevice) ?? false else { - fatalError("Switch to using \(simulatorDevice) for these tests.") + fatalError("\(deviceModel ?? "Unknown") is the wrong one. Switch to using \(simulatorDevice) for these tests.") } } @@ -200,10 +200,11 @@ private extension Snapshotting where Value: SwiftUI.View, Format == UIImage { config = deviceConfig #endif case .sizeThatFits: - config = .init(safeArea: .zero, size: nil, traits: traits) + // Make sure to use the workaround safe area insets. + config = .init(safeArea: .one, size: nil, traits: traits) case let .fixed(width: width, height: height): - let size = CGSize(width: width, height: height) - config = .init(safeArea: .zero, size: size, traits: traits) + // Make sure to use the workaround safe area insets. + config = .init(safeArea: .one, size: size, traits: traits) } return SimplySnapshotting(pathExtension: "png", diffing: .prefireImage(precision: precision, perceptualPrecision: perceptualPrecision, scale: traits.displayScale)) @@ -256,3 +257,9 @@ private extension Diffing where Value == UIImage { ) } } + +private extension UIEdgeInsets { + /// A custom inset that prevents the snapshotting library from rendering the + /// origin at (10000, 10000) which breaks some of our views such as MessageText. + static var one: UIEdgeInsets { UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1) } +} \ No newline at end of file diff --git a/Tests/CompoundTests/__Snapshots__ b/Tests/CompoundTests/__Snapshots__ index 171a28d..a1bdb71 160000 --- a/Tests/CompoundTests/__Snapshots__ +++ b/Tests/CompoundTests/__Snapshots__ @@ -1 +1 @@ -Subproject commit 171a28d538328e75efbdb69da59d500e2d603f6b +Subproject commit a1bdb71e6f863456cb3e9ef08cd3992de9fec75e