[PR #6564] [MERGED] [PM-32566] Refactor cookie acquisition ViewModel and simplify tests #37179

Closed
opened 2026-04-21 04:15:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/6564
Author: @SaintPatrck
Created: 2/23/2026
Status: Merged
Merged: 2/24/2026
Merged by: @SaintPatrck

Base: mainHead: cookie-vending/e2e-testing-updates


📝 Commits (4)

  • 658ce2f [PM-32566] Refactor cookie acquisition ViewModel and simplify tests
  • bec49dd Deduplicate cookie parsing logic
  • 976b16e Address comments
  • 03e6c94 Fix CookieUtilsTest to use public API and add cookie parsing coverage

📊 Changes

14 files changed (+256 additions, -134 deletions)

View changed files

📝 app/src/main/AndroidManifest.xml (+1 -1)
📝 app/src/main/kotlin/com/x8bit/bitwarden/MainActivity.kt (+5 -0)
📝 app/src/main/kotlin/com/x8bit/bitwarden/MainViewModel.kt (+19 -15)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/auth/repository/util/CookieUtils.kt (+27 -4)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/network/NetworkCookieManager.kt (+10 -1)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/network/NetworkCookieManagerImpl.kt (+13 -0)
📝 app/src/main/kotlin/com/x8bit/bitwarden/ui/platform/feature/cookieacquisition/CookieAcquisitionScreen.kt (+10 -1)
📝 app/src/main/kotlin/com/x8bit/bitwarden/ui/platform/feature/cookieacquisition/CookieAcquisitionViewModel.kt (+44 -21)
📝 app/src/main/kotlin/com/x8bit/bitwarden/ui/platform/model/AuthTabLaunchers.kt (+1 -0)
📝 app/src/test/kotlin/com/x8bit/bitwarden/data/auth/repository/util/CookieUtilsTest.kt (+74 -72)
📝 app/src/test/kotlin/com/x8bit/bitwarden/ui/auth/feature/enterprisesignon/EnterpriseSignOnScreenTest.kt (+1 -0)
📝 app/src/test/kotlin/com/x8bit/bitwarden/ui/auth/feature/twofactorlogin/TwoFactorLoginScreenTest.kt (+1 -0)
📝 app/src/test/kotlin/com/x8bit/bitwarden/ui/platform/feature/cookieacquisition/CookieAcquisitionScreenTest.kt (+28 -4)
📝 app/src/test/kotlin/com/x8bit/bitwarden/ui/platform/feature/cookieacquisition/CookieAcquisitionViewModelTest.kt (+22 -15)

📄 Description

🎟️ Tracking

PM-32566

📔 Objective

Refactor the cookie acquisition flow to simplify hostname derivation and improve reliability:

  • Add hostname to CookieAcquisitionState: Snapshot the hostname via requireNotNull at ViewModel init time, since MainViewModel guarantees the request is non-null when navigating to this screen.
  • Add filterNotNull to MainViewModel: Prevent the cookie acquisition screen from being navigated to on the initial null emission of the StateFlow.
  • Move AuthTabData construction into ViewModel: Follow the established pattern from EnterpriseSignOnViewModel where the event carries all data needed by the screen.
  • Simplify CookieUtilsTest: Remove duplicate cookie-parsing tests from the Intent extension section (covered by Uri extension tests), and replace lateinit/@BeforeEach with inline property initialization.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/6564 **Author:** [@SaintPatrck](https://github.com/SaintPatrck) **Created:** 2/23/2026 **Status:** ✅ Merged **Merged:** 2/24/2026 **Merged by:** [@SaintPatrck](https://github.com/SaintPatrck) **Base:** `main` ← **Head:** `cookie-vending/e2e-testing-updates` --- ### 📝 Commits (4) - [`658ce2f`](https://github.com/bitwarden/android/commit/658ce2f75cbaa8913a0152423b99600bd54b7a1a) [PM-32566] Refactor cookie acquisition ViewModel and simplify tests - [`bec49dd`](https://github.com/bitwarden/android/commit/bec49dd7b3afb0021a66f5a73bcce87fe6cafc1b) Deduplicate cookie parsing logic - [`976b16e`](https://github.com/bitwarden/android/commit/976b16eaacf9bf9fbcecf55e94f6a91d95083191) Address comments - [`03e6c94`](https://github.com/bitwarden/android/commit/03e6c949ebbcc180affc6118f35e7e4b5f937234) Fix CookieUtilsTest to use public API and add cookie parsing coverage ### 📊 Changes **14 files changed** (+256 additions, -134 deletions) <details> <summary>View changed files</summary> 📝 `app/src/main/AndroidManifest.xml` (+1 -1) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/MainActivity.kt` (+5 -0) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/MainViewModel.kt` (+19 -15) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/auth/repository/util/CookieUtils.kt` (+27 -4) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/network/NetworkCookieManager.kt` (+10 -1) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/network/NetworkCookieManagerImpl.kt` (+13 -0) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/ui/platform/feature/cookieacquisition/CookieAcquisitionScreen.kt` (+10 -1) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/ui/platform/feature/cookieacquisition/CookieAcquisitionViewModel.kt` (+44 -21) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/ui/platform/model/AuthTabLaunchers.kt` (+1 -0) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/data/auth/repository/util/CookieUtilsTest.kt` (+74 -72) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/ui/auth/feature/enterprisesignon/EnterpriseSignOnScreenTest.kt` (+1 -0) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/ui/auth/feature/twofactorlogin/TwoFactorLoginScreenTest.kt` (+1 -0) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/ui/platform/feature/cookieacquisition/CookieAcquisitionScreenTest.kt` (+28 -4) 📝 `app/src/test/kotlin/com/x8bit/bitwarden/ui/platform/feature/cookieacquisition/CookieAcquisitionViewModelTest.kt` (+22 -15) </details> ### 📄 Description ## 🎟️ Tracking PM-32566 ## 📔 Objective Refactor the cookie acquisition flow to simplify hostname derivation and improve reliability: - Add hostname to CookieAcquisitionState: Snapshot the hostname via requireNotNull at ViewModel init time, since MainViewModel guarantees the request is non-null when navigating to this screen. - Add filterNotNull to MainViewModel: Prevent the cookie acquisition screen from being navigated to on the initial null emission of the StateFlow. - Move AuthTabData construction into ViewModel: Follow the established pattern from EnterpriseSignOnViewModel where the event carries all data needed by the screen. - Simplify CookieUtilsTest: Remove duplicate cookie-parsing tests from the Intent extension section (covered by Uri extension tests), and replace `lateinit/@BeforeEach` with inline property initialization. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-21 04:15:25 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#37179