Converge on same naming convention for snapshots in the preview tests as in the UI tests.

This commit is contained in:
Stefan Ceriu 2025-03-04 18:33:39 +02:00 committed by Stefan Ceriu
parent ffafca6d64
commit fb8a1f33d8
2286 changed files with 2932 additions and 3029 deletions

View File

@ -4,8 +4,7 @@
version = "1.7"> version = "1.7">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
buildImplicitDependencies = "YES" buildImplicitDependencies = "YES">
runPostActionsOnFailure = "NO">
<BuildActionEntries> <BuildActionEntries>
<BuildActionEntry <BuildActionEntry
buildForTesting = "YES" buildForTesting = "YES"
@ -30,12 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES" codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES"> onlyGenerateCoverageForSpecifiedTargets = "YES">
<TestPlans>
<TestPlanReference
default = "YES"
reference = "container:UnitTests/SupportingFiles/UnitTests.xctestplan">
</TestPlanReference>
</TestPlans>
<MacroExpansion> <MacroExpansion>
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
@ -45,10 +38,6 @@
ReferencedContainer = "container:ElementX.xcodeproj"> ReferencedContainer = "container:ElementX.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<Testables>
</Testables>
<CommandLineArguments>
</CommandLineArguments>
<CodeCoverageTargets> <CodeCoverageTargets>
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
@ -58,6 +47,12 @@
ReferencedContainer = "container:ElementX.xcodeproj"> ReferencedContainer = "container:ElementX.xcodeproj">
</BuildableReference> </BuildableReference>
</CodeCoverageTargets> </CodeCoverageTargets>
<TestPlans>
<TestPlanReference
reference = "container:UnitTests/SupportingFiles/UnitTests.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Debug"
@ -79,8 +74,6 @@
ReferencedContainer = "container:ElementX.xcodeproj"> ReferencedContainer = "container:ElementX.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables> <EnvironmentVariables>
<EnvironmentVariable <EnvironmentVariable
key = "HTTPS_PROXY" key = "HTTPS_PROXY"
@ -115,8 +108,6 @@
ReferencedContainer = "container:ElementX.xcodeproj"> ReferencedContainer = "container:ElementX.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<CommandLineArguments>
</CommandLineArguments>
</ProfileAction> </ProfileAction>
<AnalyzeAction <AnalyzeAction
buildConfiguration = "Debug"> buildConfiguration = "Debug">

View File

@ -4,8 +4,7 @@
version = "1.7"> version = "1.7">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
buildImplicitDependencies = "YES" buildImplicitDependencies = "YES">
runPostActionsOnFailure = "NO">
<BuildActionEntries> <BuildActionEntries>
<BuildActionEntry <BuildActionEntry
buildForTesting = "YES" buildForTesting = "YES"
@ -30,12 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES" codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES"> onlyGenerateCoverageForSpecifiedTargets = "YES">
<TestPlans>
<TestPlanReference
default = "YES"
reference = "container:PreviewTests/SupportingFiles/PreviewTests.xctestplan">
</TestPlanReference>
</TestPlans>
<MacroExpansion> <MacroExpansion>
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
@ -45,10 +38,6 @@
ReferencedContainer = "container:ElementX.xcodeproj"> ReferencedContainer = "container:ElementX.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<Testables>
</Testables>
<CommandLineArguments>
</CommandLineArguments>
<CodeCoverageTargets> <CodeCoverageTargets>
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
@ -58,6 +47,12 @@
ReferencedContainer = "container:ElementX.xcodeproj"> ReferencedContainer = "container:ElementX.xcodeproj">
</BuildableReference> </BuildableReference>
</CodeCoverageTargets> </CodeCoverageTargets>
<TestPlans>
<TestPlanReference
reference = "container:PreviewTests/SupportingFiles/PreviewTests.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug" buildConfiguration = "Debug"
@ -78,8 +73,6 @@
ReferencedContainer = "container:ElementX.xcodeproj"> ReferencedContainer = "container:ElementX.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"
@ -87,8 +80,6 @@
savedToolIdentifier = "" savedToolIdentifier = ""
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"> debugDocumentVersioning = "YES">
<CommandLineArguments>
</CommandLineArguments>
<MacroExpansion> <MacroExpansion>
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"

View File

@ -137,7 +137,7 @@ struct BugReportScreen: View {
// MARK: - Previews // MARK: - Previews
struct BugReport_Previews: PreviewProvider, TestablePreview { struct BugReportScreen_Previews: PreviewProvider, TestablePreview {
static var previews: some View { static var previews: some View {
NavigationStack { NavigationStack {
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))))) let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))))
@ -145,8 +145,8 @@ struct BugReport_Previews: PreviewProvider, TestablePreview {
clientProxy: clientProxy, clientProxy: clientProxy,
screenshot: nil, screenshot: nil,
isModallyPresented: false).context) isModallyPresented: false).context)
.previewDisplayName("Without Screenshot")
} }
.previewDisplayName("Without Screenshot")
NavigationStack { NavigationStack {
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))))) let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))))
@ -154,7 +154,7 @@ struct BugReport_Previews: PreviewProvider, TestablePreview {
clientProxy: clientProxy, clientProxy: clientProxy,
screenshot: Asset.Images.appLogo.image, screenshot: Asset.Images.appLogo.image,
isModallyPresented: false).context) isModallyPresented: false).context)
.previewDisplayName("With Screenshot")
} }
.previewDisplayName("With Screenshot")
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -51,7 +51,7 @@ class PreviewTests: XCTestCase {
// MARK: - Snapshots // MARK: - Snapshots
func assertSnapshots(matching preview: _Preview, testName: String = #function) async throws { func assertSnapshots(matching preview: _Preview, testName: String = #function, step: Int) async throws {
let preferences = SnapshotPreferences() let preferences = SnapshotPreferences()
let preferenceReadingView = preview.content let preferenceReadingView = preview.content
@ -68,6 +68,9 @@ class PreviewTests: XCTestCase {
try await deferred.fulfill() try await deferred.fulfill()
} }
var sanitizedSuiteName = String(testName.suffix(testName.count - "test".count).dropLast(2))
sanitizedSuiteName = sanitizedSuiteName.prefix(1).lowercased() + sanitizedSuiteName.dropFirst()
for deviceName in snapshotDevices { for deviceName in snapshotDevices {
guard var device = PreviewDevice(rawValue: deviceName).snapshotDevice() else { guard var device = PreviewDevice(rawValue: deviceName).snapshotDevice() else {
fatalError("Unknown device name: \(deviceName)") fatalError("Unknown device name: \(deviceName)")
@ -76,11 +79,19 @@ class PreviewTests: XCTestCase {
device.safeArea = .one device.safeArea = .one
// Ignore specific device display scale // Ignore specific device display scale
let traits = UITraitCollection(displayScale: 2.0) let traits = UITraitCollection(displayScale: 2.0)
var testName = ""
if let displayName = preview.displayName {
testName = "\(displayName)-\(deviceName)-\(localeCode)"
} else {
testName = "\(deviceName)-\(localeCode)-\(step)"
}
if let failure = assertSnapshots(matching: preview.content, if let failure = assertSnapshots(matching: preview.content,
name: preview.displayName, name: testName,
isScreen: preview.layout == .device, isScreen: preview.layout == .device,
device: device, device: device,
testName: testName + deviceName + "-" + localeCode, testName: sanitizedSuiteName,
traits: traits, traits: traits,
preferences: preferences) { preferences: preferences) {
XCTFail(failure) XCTFail(failure)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More