mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Prefire compatibility with Xcode 15 (#1773)
* xcode ready solution * now the previews won't fail but get generated * delay in some screens that require a waiting state (the bloom does not work in previews) * better code * longer delay removed and redone lfs readded as lfs
This commit is contained in:
@@ -42,8 +42,8 @@ class PreviewTests: XCTestCase {
|
||||
private func assertSnapshots(matching preview: _Preview, testName: String = #function) {
|
||||
let isScreen = preview.layout == .device
|
||||
let device = preview.device?.snapshotDevice() ?? deviceConfig
|
||||
var delay: TimeInterval = 1.0
|
||||
var precision: Float = 0.99
|
||||
var delay: TimeInterval = 0
|
||||
var precision: Float = 1
|
||||
|
||||
let view = preview.content
|
||||
.onPreferenceChange(DelayPreferenceKey.self) { delay = $0 }
|
||||
@@ -54,13 +54,17 @@ class PreviewTests: XCTestCase {
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
)
|
||||
|
||||
assertSnapshot(
|
||||
matching: matchingView,
|
||||
as: .prefireImage(precision: { precision }, duration: { delay }, layout: isScreen ? .device(config: device) : .sizeThatFits),
|
||||
named: preview.displayName{% if argument.file %},
|
||||
file: file{% endif %},
|
||||
testName: testName
|
||||
)
|
||||
let failure = verifySnapshot(of: matchingView,
|
||||
as: .prefireImage(precision: { precision }, duration: { delay }, layout: isScreen ? .device(config: device) : .sizeThatFits),
|
||||
named: preview.displayName{% if argument.file %},
|
||||
file: file{% endif %},
|
||||
testName: testName)
|
||||
|
||||
if let failure,
|
||||
!failure.contains("No reference was found on disk."),
|
||||
!failure.contains("to test against the newly-recorded snapshot") {
|
||||
XCTFail(failure)
|
||||
}
|
||||
|
||||
#if canImport(AccessibilitySnapshot)
|
||||
let vc = UIHostingController(rootView: matchingView)
|
||||
@@ -83,9 +87,13 @@ class PreviewTests: XCTestCase {
|
||||
fatalError("Switch to using \(simulatorDevice) for these tests.")
|
||||
}
|
||||
|
||||
guard osVersion.majorVersion == requiredOSVersion else {
|
||||
guard osVersion.majorVersion == requiredOSVersion else {
|
||||
fatalError("Switch to iOS \(requiredOSVersion) for these tests.")
|
||||
}
|
||||
|
||||
guard UITraitCollection.current.userInterfaceStyle == .light else {
|
||||
fatalError("Switch to light mode for these tests.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user