Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUM-7475 [SR][SwiftUI] Update snapshot tests #2131

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public enum Fixture: CaseIterable {
case .popups:
return UIStoryboard.basic.instantiateViewController(withIdentifier: "Popups")
case .swiftUI:
if #available(iOS 13.0, *) {
return UIHostingController(rootView: Text("Hello SwiftUI"))
if #available(iOS 15.0, *) {
return UIHostingController(rootView: SwiftUIView())
} else {
return ErrorViewController(message: "`.swiftUI` fixture is only available on iOS 13+")
return ErrorViewController(message: "`.swiftUI` fixture is only available on iOS 15+")
}
//- Navigation Bars
case .navigationBars:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Flowers_1.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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 15.0, *)
struct SwiftUIView: View {
var body: some View {
VStack(spacing: 10) {
Text("Hello, SwiftUI!")
.font(.headline)

Label("Label with Icon", systemImage: "star.fill")
.font(.subheadline)
.foregroundStyle(.secondary)

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

Button(action: {}) {
Text("SwiftUI Button")
.padding()
.foregroundStyle(.background)
.background(Color.blue)
.cornerRadius(8)
}

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

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

// "Content" image
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: shouldRecord,
folderPath: snapshotsFolderPath,
fileNamePrefix: "maskAll_images"
)

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

// Mask none
try takeSnapshotFor(
.swiftUI,
with: [.maskSensitiveInputs],
imagePrivacyLevel: .maskNone,
shouldRecord: shouldRecord,
folderPath: snapshotsFolderPath,
fileNamePrefix: "maskNone_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":"598e97a5a0faaced2f11948d9189a7b498a1a355"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"hash":"b457cde706442ac13f09f810ecbc075b016f386b"}

This file was deleted.