Skip to content

Conversation

@LRNcardozoWDF
Copy link
Member

@LRNcardozoWDF LRNcardozoWDF commented Nov 28, 2025

🎟️ Tracking

PM-25906

📔 Objective

Add tests for account switcher for iOS 26.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@LRNcardozoWDF LRNcardozoWDF requested review from a team and matt-livefront as code owners November 28, 2025 04:40
@claude
Copy link

claude bot commented Nov 28, 2025

Claude finished @LRNcardozoWDF's task in 1m 45s —— View job


Code Review Complete

Review posted by bitwarden-code-reviewer agent.

Summary: Comprehensive test coverage successfully added for iOS 26 account switcher visibility across 5 processor test files (49 new test cases). Tests follow proper patterns with iOS version gating and appropriate assertions.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2025

Logo
Checkmarx One – Scan Summary & Details0ace9533-b391-4a7d-b1f9-4641e9c8b294

Great job! No new security vulnerabilities introduced in this pull request

@codecov
Copy link

codecov bot commented Nov 28, 2025

Codecov Report

❌ Patch coverage is 96.22642% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.57%. Comparing base (8ce5d66) to head (d95a520).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...I/Auth/VaultUnlock/VaultUnlockProcessorTests.swift 96.66% 14 Missing ⚠️
...Shared/UI/Auth/Landing/LandingProcessorTests.swift 96.61% 11 Missing ⚠️
...ault/Vault/VaultList/VaultListProcessorTests.swift 96.08% 9 Missing ⚠️
...AutofillList/VaultAutofillListProcessorTests.swift 92.30% 3 Missing ⚠️
...emSelection/VaultItemSelectionProcessorTests.swift 93.47% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2168      +/-   ##
==========================================
+ Coverage   85.39%   85.57%   +0.18%     
==========================================
  Files        1731     1731              
  Lines      145718   146774    +1056     
==========================================
+ Hits       124433   125606    +1173     
+ Misses      21285    21168     -117     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}

subject.state.profileSwitcherState.isVisible = true
await subject.perform(.profileSwitcher(.accountPressed(ProfileSwitcherItem.fixture(userId: "1"))))
Copy link

Choose a reason for hiding this comment

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

Test setup ordering issue: Mock data is configured AFTER the action is performed (line 173), but these values should be set up BEFORE calling perform() on line 173.

The lines 174-181 should be moved above line 172. The test setup should follow this order:

  1. Configure all mock dependencies and initial state
  2. Perform the action being tested
  3. Assert the results

This same issue appears in VaultAutofillListProcessorTests.swift:test_perform_profileSwitcher_accountPressed_iOS26() at line 201.

}

subject.state.profileSwitcherState.isVisible = true
await subject.perform(.profileSwitcher(.accountPressed(ProfileSwitcherItem.fixture(userId: "1"))))
Copy link

Choose a reason for hiding this comment

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

Test setup ordering issue: Same problem as in VaultItemSelectionProcessorTests.swift - mock data (lines 202-209) is configured AFTER the action is performed (line 201).

Move lines 202-209 above line 200 to ensure proper test setup order.

}

subject.state.profileSwitcherState.isVisible = true
await subject.perform(.profileSwitcher(.accountPressed(ProfileSwitcherItem.fixture(userId: "1"))))
Copy link

Choose a reason for hiding this comment

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

Critical: Test setup ordering violation

Mock data is configured AFTER the action is performed. Lines 173-180 must be moved above line 172.

Current (incorrect) order:

  1. Set state (line 171) ✅
  2. Perform action (line 172) ❌ Too early!
  3. Configure mocks (lines 173-180) ❌ Too late!

Correct order should be:

  1. Set state
  2. Configure all mocks (activeAccount, altAccounts, vaultTimeout)
  3. Then perform action
  4. Assert results

This follows the standard Arrange-Act-Assert pattern (Testing.md:1033-1037). Currently the test runs with uninitialized mock values, producing incorrect results.

Suggested change
await subject.perform(.profileSwitcher(.accountPressed(ProfileSwitcherItem.fixture(userId: "1"))))
await subject.perform(.profileSwitcher(.accountPressed(ProfileSwitcherItem.fixture(userId: "1"))))
authRepository.activeAccount = .fixture(profile: .fixture(userId: "42"))
authRepository.altAccounts = [
.fixture(),
]
authRepository.vaultTimeout = [
"1": .fiveMinutes,
"42": .immediately,
]

}

subject.state.profileSwitcherState.isVisible = true
await subject.perform(.profileSwitcher(.accountPressed(ProfileSwitcherItem.fixture(userId: "1"))))
Copy link

Choose a reason for hiding this comment

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

Critical: Test setup ordering violation

Same issue as VaultItemSelectionProcessorTests - mock data (lines 201-208) is configured AFTER the action is performed (line 200).

Move lines 201-208 above line 200 to ensure mocks are configured before the test executes.

Suggested change
await subject.perform(.profileSwitcher(.accountPressed(ProfileSwitcherItem.fixture(userId: "1"))))
await subject.perform(.profileSwitcher(.accountPressed(ProfileSwitcherItem.fixture(userId: "1"))))
authRepository.activeAccount = .fixture(profile: .fixture(userId: "42"))
authRepository.altAccounts = [
.fixture(),
]
authRepository.vaultTimeout = [
"1": .fiveMinutes,
"42": .immediately,
]

Copy link
Contributor

@KatherineInCode KatherineInCode left a comment

Choose a reason for hiding this comment

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

On the whole, it looks good, aside from a small thing I mentioned. And the comments Claude generated noting the mock/test order...while it appears to be that way in the original test, I do find it curious. It might be worth adding a comment to them to explain why the order is the way it is?

throw XCTSkip("This test requires iOS 26 or later")
}

subject.state.profileSwitcherState.isVisible = true
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ Doesn't the new profile switcher obviate the need for tracking the state visibility this way?

@claude
Copy link

claude bot commented Dec 15, 2025

Overall Assessment: APPROVE

Reviewed comprehensive iOS 26 test coverage additions for account switcher visibility across 5 processor test files.

Summary:
This PR successfully adds iOS 26-specific test variants for account switcher visibility behavior. The changes follow established patterns, use proper iOS version gating, and maintain consistency with existing test structure. All changes are test-only with no production code modifications.

Test Coverage Added:

  • Landing: 16 new iOS 26 test cases
  • VaultUnlock: 19 new iOS 26 test cases
  • VaultList: 9 new iOS 26 test cases
  • VaultAutofillList: 2 new iOS 26 test cases
  • VaultItemSelection: 3 new iOS 26 test cases

Positive Observations:

  • Proper use of #available(iOS 26, *) version checks with descriptive XCTSkip messages
  • Consistent naming convention using _iOS26 suffix for variant tests
  • Appropriate verification that coordinator.routes.contains(.dismiss) for sheet dismissal on iOS 26
  • Tests properly grouped and follow test ordering guidelines from Testing.md
  • All tests use async/await appropriately
  • Mock setup generally follows Arrange-Act-Assert pattern

Minor Observation (Not Blocking):
In some test files (particularly VaultItemSelectionProcessorTests.swift and VaultAutofillListProcessorTests.swift), there are a few instances where state setup occurs before mock configuration. While functionally correct, a more consistent pattern would be:

  1. Configure all repository/service mocks
  2. Set subject state
  3. Perform the action
  4. Assert results

Example from VaultItemSelectionProcessorTests.swift:167-193:

// Current order works but could be clearer:
subject.state.profileSwitcherState.isVisible = true  // State set first
authRepository.activeAccount = ...                    // Then mocks
authRepository.altAccounts = ...
authRepository.vaultTimeout = ...
await subject.perform(...)                            // Then action

// Suggested (more explicit Arrange-Act-Assert):
authRepository.activeAccount = ...                    // Mocks first
authRepository.altAccounts = ...
authRepository.vaultTimeout = ...
subject.state.profileSwitcherState.isVisible = true  // State second
await subject.perform(...)                            // Action last

This is a stylistic preference for improved readability and doesn't affect test correctness.

Recommendation: APPROVE - This PR meets quality standards and adds valuable test coverage for iOS 26 compatibility.

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.

3 participants