trackslash
VAULT-14 P2

Dark-mode snapshot tests record light-mode images

0
All issues

Description

Snapshot tests that switch to dark mode with .preferredColorScheme(colorScheme) save light-mode images under their dark names, so dark mode isn't actually covered for those views.

Measured on main (cee9f963), every dark-named image in these tests is light:

  • BackupImportFlowViewSnapshotTests (3)
  • BackupKeyChangeViewSnapshotTests (19)
  • BackupKeyDecryptorViewSnapshotTests (3)
  • LabeledTextFieldSnapshotTests (17, added in VAULT-10)
  • OTPCodeDetailViewSnapshotTests (21)
  • RecoveryPhraseDetailViewSnapshotTests (25)
  • SecureNoteDetailViewSnapshotTests (27)
  • SettingsDangerViewSnapshotTests (3)
  • VaultDetailEncryptionEditViewSnapshotTests (6)
  • VaultStoreFailureViewSnapshotTests (3)

preferredColorScheme sets the test host window's style rather than the snapshotted view's, and in record runs it can carry over into later tests. The tests that render dark correctly (DetailEditorSnapshotTests, CreateItemPickerViewSnapshotTests, AutoBackupViewSnapshotTests, BackupPDFViewSnapshotTests) use .environment(\.colorScheme, colorScheme) on the view, plus UITraitCollection(userInterfaceStyle: .dark) traits in assertSnapshot where glass is involved.

Fix: switch these tests to the same approach (ideally one shared helper), re-record the dark images and check each one by eye.

GitHub

0

No branches or pull requests linked.

Comments

1
Bradley

Fixed in https://github.com/badbundle/vault-app/pull/609 (merged as 784fe08c).

Every snapshot test that renders in a colour scheme now goes through one shared helper, assertSnapshot(of:colorScheme:named:). It sets the scheme on the view's environment and on the host's traits. No preferredColorScheme is left in the tests.

Re-recorded images:

  • 127 dark references were re-recorded, and all of them are now dark (average brightness 1–29 out of 255, down from 234–253).
  • No light references changed.

Known limitation: buttons in a snapshotted view's own navigation bar still render their light-mode label offscreen. This affects the Cancel button in three backup sheets. It's documented in the helper.