Skip to content

Conversation

@kidinov
Copy link
Contributor

@kidinov kidinov commented Dec 9, 2025

WOOMOB-1854

Description

Wire up the card reader connection dialog into WooPos screens:

  • Home screen shows connection dialog when reader is disconnected
  • Settings screen gets card reader update action
  • Toolbar and totals ViewModels trigger connection flow when needed
  • Update related tests

Test Steps

  • Verify connection and update flows work in the POS
  • Smoke test IPP
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@dangermattic
Copy link
Collaborator

dangermattic commented Dec 9, 2025

1 Error
🚫 This PR is tagged with status: do not merge label(s).

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit1105aa1
Direct Downloadwoocommerce-wear-prototype-build-pr15072-1105aa1.apk

@kidinov kidinov changed the title [WOOMOB-1854] Integrate card reader connection into WooPos screens [WOOMOB-1854] PR 4/6: Integrate card reader connection into WooPos screens Dec 9, 2025
@kidinov kidinov changed the title [WOOMOB-1854] PR 4/6: Integrate card reader connection into WooPos screens [WOOMOB-1854] PR 4/5: Integrate card reader connection into WooPos screens Dec 9, 2025
@wpmobilebot
Copy link
Collaborator

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit1105aa1
Direct Downloadwoocommerce-prototype-build-pr15072-1105aa1.apk

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 52.63158% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.18%. Comparing base (d84f687) to head (1105aa1).

Files with missing lines Patch % Lines
...roid/ui/woopos/settings/WooPosSettingsViewModel.kt 0.00% 10 Missing ⚠️
...erce/android/ui/woopos/home/WooPosHomeViewModel.kt 0.00% 5 Missing and 1 partial ⚠️
...eader/WooPosSettingsHardwareCardReaderViewModel.kt 81.81% 2 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                         @@
##             woomob-1854-pr3-dialog-viewmodel   #15072   +/-   ##
===================================================================
  Coverage                               38.17%   38.18%           
- Complexity                              10361    10364    +3     
===================================================================
  Files                                    2173     2173           
  Lines                                  124570   124600   +30     
  Branches                                17247    17251    +4     
===================================================================
+ Hits                                    47560    47575   +15     
- Misses                                  72204    72219   +15     
  Partials                                 4806     4806           

☔ 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.

@kidinov kidinov requested a review from samiuelson December 9, 2025 09:54
@kidinov kidinov added status: do not merge Dependent on another PR, ready for review but not ready for merge. feature: POS labels Dec 9, 2025
@kidinov kidinov marked this pull request as ready for review December 9, 2025 09:55
@kidinov kidinov changed the title [WOOMOB-1854] PR 4/5: Integrate card reader connection into WooPos screens [HACK][Woo POS] PR 4/5: Integrate card reader connection into WooPos screens Dec 10, 2025
@samiuelson samiuelson self-assigned this Dec 12, 2025
@samiuelson samiuelson requested a review from Copilot December 16, 2025 17:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR integrates card reader connection and update dialogs into WooPos screens, moving from direct facade calls to an event-driven architecture using dialog states and parent-child event communication.

Key changes:

  • Connection and update operations now trigger dialog events instead of direct facade calls
  • Settings and Home screens show card reader connection/update dialogs via state management
  • Toolbar and totals ViewModels use connection controller for disconnect operations

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
WooPosSettingsHardwareCardReaderViewModelTest.kt Updated tests to verify connection/update events are sent instead of direct facade calls; added controller factory mock
WooPosTotalsViewModelTest.kt Updated test to verify connection dialog event is sent when reader connection is needed
WooPosHomeFloatingToolbarViewModelTest.kt Updated tests to verify connection dialog events and controller disconnect usage; added controller factory mock
WooPosSettingsHardwareCardReaderViewModel.kt Changed connect/update to send events; disconnect now uses controller; added controller factory dependency
WooPosSettingsViewModel.kt Added handlers for card reader connection/update dialog events from child components
WooPosSettingsState.kt Added CardReaderConnectionDialog and CardReaderUpdateDialog dialog states
WooPosSettingsScreen.kt Added UI integration to show card reader connection and update dialogs based on state
WooPosTotalsViewModel.kt Changed connect reader click to send dialog event instead of calling facade
WooPosHomeFloatingToolbarViewModel.kt Changed connection to send dialog event; disconnect now uses controller; added controller factory dependency
WooPosHomeViewModel.kt Added handler for ShowCardReaderConnectionDialog event and dismiss event
WooPosHomeUIEvent.kt Added DismissCardReaderConnectionDialog event
WooPosHomeState.kt Added CardReaderConnectionDialog dialog state
WooPosHomeScreen.kt Added UI integration to show card reader connection dialog based on state
WooPosHomeChildToParentCommunication.kt Added ShowCardReaderConnectionDialog event and SettingsEvent variants for connection/update dialogs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to +46
private val controller: WooPosCardReaderConnectionController by lazy {
controllerFactory.create(viewModelScope)
}
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The controller is initialized lazily but only used for the disconnect operation. This means the controller won't be created until the first disconnect call, which could lead to unexpected behavior if other controller lifecycle management is expected. Consider either initializing it eagerly in the init block or documenting why lazy initialization is appropriate here.

Suggested change
private val controller: WooPosCardReaderConnectionController by lazy {
controllerFactory.create(viewModelScope)
}
private val controller: WooPosCardReaderConnectionController = controllerFactory.create(viewModelScope)

Copilot uses AI. Check for mistakes.
Comment on lines 66 to 69
fun onDisconnectClicked() {
viewModelScope.launch {
cardReaderFacade.disconnectFromReader()
controller.disconnect()
}
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The onDisconnectClicked method now uses controller.disconnect instead of cardReaderFacade.disconnectFromReader, but there is no test coverage for this functionality. Consider adding a test case to verify that controller.disconnect is called when onDisconnectClicked is invoked, similar to how the toolbar ViewModel tests verify disconnect behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +42
private val controller: WooPosCardReaderConnectionController by lazy {
controllerFactory.create(viewModelScope)
}
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The controller is initialized lazily but only used for the disconnect operation. This means the controller won't be created until the first disconnect call, which could lead to unexpected behavior if other controller lifecycle management is expected. Consider either initializing it eagerly in the init block or documenting why lazy initialization is appropriate here.

Suggested change
private val controller: WooPosCardReaderConnectionController by lazy {
controllerFactory.create(viewModelScope)
}
private val controller: WooPosCardReaderConnectionController =
controllerFactory.create(viewModelScope)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement feature: POS Hack Week status: do not merge Dependent on another PR, ready for review but not ready for merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants