pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.
https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing
MIT License
3.79k stars 581 forks source link

Disabled button from SwiftUI is incorrectly rendered on macOS Ventura #670

Open wojciech-kulik opened 2 years ago

wojciech-kulik commented 2 years ago

Describe the bug After migrating to macOS Ventura and Xcode 14.0.1 disabled buttons on my snapshots are incorrectly rendered.

To Reproduce

func testSnapshot() {
    let controller = NSHostingController(rootView: MyView())
    controller.view.frame = .init(x: 0, y: 0, width: 600, height: 600)
    assertSnapshot(matching: controller, as: .image)
}

// ...

struct MyView: View {
    var body: some View {
        VStack {
            Button(action: {}, label: { Text("Delete").frame(width: 150) })
                .disabled(true)
        }
    }
}

Expected behavior The disabled Button should be correctly rendered with dark text.

Screenshots Incorrect button:

image

Expected button:

image

Environment

Additional context Buttons work properly when I run the application. I noticed that this problem occurs also on the SwiftUI preview until you change something on the View. It looks like the button is in the middle of the transformation, the background is greyed out but the text is still white. .wait(for: X, on: .image) doesn't help either.