mirror of
https://github.com/home-assistant/iOS.git
synced 2026-06-16 23:33:36 -05:00
<!-- Thank you for submitting a Pull Request and helping to improve Home Assistant. Please complete the following sections to help the processing and review of your changes. Please do not delete anything from this template. --> ## Summary SnapshottablePreviews applied in the LocationHistoryListView and Widgets. In LocationHistoryListView, due to how Realm is used and how previews are implemented under the hood, the injected data is written both on `init` and `onAppear`. For Widgets, not all the previews are visible. This is a limitation of the previews UI. I also ended up removing the duplicate snapshots that would assert the behavior when more than the allowed tiles were passed. This can be restored if preferred. --------- Co-authored-by: Bruno Pantaleão Gonçalves <5808343+bgoncal@users.noreply.github.com>
61 lines
1.7 KiB
Swift
61 lines
1.7 KiB
Swift
@testable import HomeAssistant
|
|
|
|
import SharedTesting
|
|
|
|
import Testing
|
|
import WidgetKit
|
|
|
|
struct WidgetsSnapshotTests {
|
|
@available(iOS 18, *)
|
|
@MainActor @Test func systemLargeSnapshots() {
|
|
let size = snapshotSize(for: .systemLarge)
|
|
WidgetBasicContainerView_Previews
|
|
.systemLargeConfigurations
|
|
.assertLightDarkSnapshots(
|
|
layout: .fixed(
|
|
width: size.width,
|
|
height: size.height
|
|
)
|
|
)
|
|
}
|
|
|
|
@available(iOS 18, *)
|
|
@MainActor @Test func systemMediumSnapshots() {
|
|
let size = snapshotSize(for: .systemMedium)
|
|
WidgetBasicContainerView_Previews
|
|
.systemMediumConfigurations
|
|
.assertLightDarkSnapshots(
|
|
layout: .fixed(
|
|
width: size.width,
|
|
height: size.height
|
|
)
|
|
)
|
|
}
|
|
|
|
@available(iOS 18, *)
|
|
@MainActor @Test func systemSmallSnapshots() {
|
|
let size = snapshotSize(for: .systemSmall)
|
|
WidgetBasicContainerView_Previews
|
|
.systemSmallConfigurations
|
|
.assertLightDarkSnapshots(
|
|
layout: .fixed(
|
|
width: size.width,
|
|
height: size.height
|
|
)
|
|
)
|
|
}
|
|
|
|
private func snapshotSize(for family: WidgetFamily) -> CGSize {
|
|
switch family {
|
|
case .systemSmall:
|
|
CGSize(width: 160, height: 160)
|
|
case .systemMedium:
|
|
CGSize(width: 350, height: 160)
|
|
case .systemLarge:
|
|
CGSize(width: 350, height: 310)
|
|
default:
|
|
CGSize(width: 600, height: 600)
|
|
}
|
|
}
|
|
}
|