Skip to content

Commit

Permalink
RUM-7475 [SR][SwiftUI] Update snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mariedm committed Dec 4, 2024
1 parent d3a9222 commit 87caf3a
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public enum Fixture: CaseIterable {
return UIStoryboard.basic.instantiateViewController(withIdentifier: "Popups")
case .swiftUI:
if #available(iOS 13.0, *) {
return UIHostingController(rootView: Text("Hello SwiftUI"))
return UIHostingController(rootView: SwiftUIView())
} else {
return ErrorViewController(message: "`.swiftUI` fixture is only available on iOS 13+")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Flowers_1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/

import SwiftUI

@available(iOS 13.0, *)
struct SwiftUIView: View {
var body: some View {
VStack(spacing: 10) {
Text("Hello, SwiftUI!")
.font(.headline)

if #available(iOS 14.0, *) {
if #available(iOS 15.0, *) {
Label("Label with Icon", systemImage: "star.fill")
.font(.subheadline)
.foregroundStyle(.secondary)
}
}

TextField("Enter text", text: .constant("Placeholder text"))
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding(8)

Button(action: {}) {
if #available(iOS 15.0, *) {
Text("SwiftUI Button")
.padding()
.foregroundStyle(.background)
.background(Color.blue)
.cornerRadius(8)
}
}

Divider()
.frame(height: 2)
.background(Color.purple)
.padding(.horizontal, 20)
.padding(.vertical, 6)

Image("dd_logo", bundle: .module)
.resizable()
.scaledToFit()
.background(Color.purple)
.frame(width: 120, height: 120)
.clipped()

Image("Flowers_1", bundle: .module)
.resizable()
.scaledToFit()
.background(Color.purple)
.frame(width: 120, height: 120)
.clipped()

List {
Text("Item 1")
Text("Item 2")
}.frame(height: 140)

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,35 @@ final class SRSnapshotTests: SnapshotTestCase {
}

func testSwiftUI() throws {
try takeSnapshotFor(.swiftUI, with: [.maskSensitiveInputs, .maskAll], shouldRecord: shouldRecord, folderPath: snapshotsFolderPath)
// Mask all
try takeSnapshotFor(
.swiftUI,
with: [.maskAll],
imagePrivacyLevel: .maskAll,
shouldRecord: true,
folderPath: snapshotsFolderPath,
fileNamePrefix: "maskAll_images"
)

// Intermediate levels
try takeSnapshotFor(
.swiftUI,
with: [.maskAllInputs],
imagePrivacyLevel: .maskNonBundledOnly,
shouldRecord: true,
folderPath: snapshotsFolderPath,
fileNamePrefix: "maskNonBundledOnly_images"
)

// Mask none
try takeSnapshotFor(
.swiftUI,
with: [.maskSensitiveInputs],
imagePrivacyLevel: .maskNone,
shouldRecord: true,
folderPath: snapshotsFolderPath,
fileNamePrefix: "maskAll_images"
)
}

func testNavigationBars() throws {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"hash":"7fd7cbf998758b4cc8b158b9e71da0d082080664"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"hash":"3d49c0331f488fa86d8a7329aa3d51270c94254d"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"hash":"598e97a5a0faaced2f11948d9189a7b498a1a355"}

This file was deleted.

0 comments on commit 87caf3a

Please sign in to comment.