Skip to content

Conversation

@jlpl15
Copy link
Contributor

@jlpl15 jlpl15 commented Jan 6, 2026

📲 What

  • Add unified screenshot test helpers (ScreenshotType, forEachScreenshotType, forEachScreenshotType(withData:), assertAllSnapshots, assertSnapshot overloads for UIViewController/UIView/SwiftUI).
  • Centralize 4- and 5-way orthogonalCombos in the shared combos helper.
  • Standardize snapshot naming and environment/trait setup; shorten snapshot names.

🤔 Why

  • Snapshot tests were inconsistent (device/language sets, dark mode/font handling, manual names).
  • Reduce churn and ensure predictable coverage across devices, languages, light/dark, and Dynamic Type while keeping counts low.

🛠 How

  • forEachScreenshotType: orthogonal coverage of all devices/languages/light/dark/regular+large fonts (caps total to max list size).
  • forEachScreenshotType(withData:): adds an extra data dimension (e.g., intents) without exploding combinations.
  • assertAllSnapshots: owns the loop when you just need a controller factory and types.
  • assertSnapshot overloads:

-UIViewController
-UIView (optional intrinsic sizing)
-SwiftUI View (optional intrinsic sizing)

  • Snapshot names now: File_TestFunc__ (shortened).
  • Updated LoginToutViewControllerTests to use the helpers as a concrete example.
  • Switched to the non-deprecated SnapshotTesting API (of:).

@amy-at-kickstarter
Copy link
Contributor

Can you add a simple test for ScreenshotTestHelpers, demonstrating the code working with a simple example UIViewController?

Copy link
Contributor

@ifosli ifosli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, nice start! I left some comments; to summarize, my main concerns are:

  1. Is it possible to simplify the test helper so the caller can do less work?
  2. We'll need to also add support for swiftUI tests
  3. Let's make the snapshot names shorter, please!
    Feel free to push back against anything I've suggested that you disagree with or that seems too hard/annoying, though!

@jlpl15 jlpl15 requested a review from ifosli January 8, 2026 21:50
Copy link
Contributor

@ifosli ifosli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall strategy looks good now, but I still think the names are too long to be practical. I think it might be useful to have a team discussion around what info we want in test names and why - I know Amy well enough to know that she's got good reasons for wanting all the fields in the name, but I don't know what they are personally.

lang=\(type.language.rawValue),
style=\(type.style.snapshotDescription),
font=\(type.contentSizeCategory.rawValue),
orientation=\(type.orientation.snapshotDescription)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks for adding!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still find these file names to be way too long to be practical, at least in my personal work flow. Maybe it's worth checking with the team what info they find necessary in a snapshot test? Personally, I don't think things like device type and size category are useful enough to be worth the extra words, but I'm okay with being outvoted.

Even without removing information, there's still some things you could do to make the name more streamlined. The full path of this one is ios-oss/Kickstarter-iOS/Features/LoginTout/Controller/__Snapshots__/testLoginToutView.LoginToutViewControllerTests_testLoginToutView_phone4-7inch_en_dark_UICTContentSizeCategoryAccessibilityXXXL_portrait.png. Notice how this includes the test name twice? I also think it'd be worth describing the content size category more concisely if we're going to include it at all - maybe as accessibilityXXL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can drop the file/test prefix from the named: value so the filename is just the config (device/lang/style/font/orientation), and let the test’s Snapshots/testLoginToutView/ folder provide the test context. I’ll also shorten the content-size labels—thinking a11yXXXL as a common shorthand for “accessibility” to keep names shorter, but I can spell out “accessibilityXXXL” if you prefer. With these tweaks, a filename would look like phone4_7inch_en_dark_a11yXXXL_portrait.png. If the team wants to trim further (e.g., drop style/font), I can do that too.

@nativeksr
Copy link
Collaborator

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@jlpl15 jlpl15 requested a review from ifosli January 12, 2026 22:27
Copy link
Contributor

@ifosli ifosli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job on this! I have just one final request to shorten the device name, too, but otherwise I think everything is good to go! Thanks for working so hard on this! If you want to merge this pr, please just make sure you delete the extra screenshots first (the ones with old names).

@jlpl15 jlpl15 marked this pull request as ready for review January 13, 2026 04:36
@jlpl15 jlpl15 merged commit db65e57 into main Jan 13, 2026
5 checks passed
@jlpl15 jlpl15 deleted the JL/MBL-2856 branch January 13, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants