Skip to content

Conversation

@malinajirka
Copy link
Contributor

@malinajirka malinajirka commented Dec 2, 2025

Fixes WOOMOB-1583

Description

Fixed an issue in the POS orders split view where empty search results would continue displaying the previously selected order details instead of showing an empty state. The right pane now properly displays "No order selected." when search returns no results, while preserving existing selection behavior for successful searches.

Key Changes:

  • Made selectedDetails nullable in WooPosOrdersState.Content
  • Updated search logic to set selectedDetails to null when search returns no results or errors
  • Enhanced UI to show skeleton during search and empty state when no order is selected
  • Improved selection preservation logic in replaceOrders to handle cases where no order is currently selected

Test Steps

  1. Open POS Orders screen with existing orders displayed
  2. Select any order to view its details in the right pane
  3. Use search to find orders that exist - verify selection is preserved if the selected order is in results, or first result is selected if not
  4. Use search with a query that returns no results (e.g., "xyz123")
  5. Verify the right pane shows "No order selected." with an empty state icon instead of the previous order details
  6. Search again for orders that exist - verify the first result is automatically selected
  7. Test search errors by temporarily disconnecting network - verify right pane shows empty state

Images/gif

Screen.Recording.2025-12-02.at.15.48.26.mov
  • 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.

@malinajirka malinajirka requested a review from Copilot December 2, 2025 16:25
@malinajirka malinajirka added this to the 23.9 milestone Dec 2, 2025
Copilot finished reviewing on behalf of malinajirka December 2, 2025 16:28
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 fixes an issue where the POS orders split view incorrectly displayed stale order details when search returned no results. The fix makes selectedDetails nullable in the state and properly sets it to null when searches fail or return empty results.

Key Changes:

  • Made selectedDetails nullable in WooPosOrdersState.Content to support "no order selected" scenarios
  • Enhanced search error and empty result handling to clear selected details
  • Updated UI to display appropriate states: order details when selected, loading skeleton during search, and empty state when no order is selected

Reviewed changes

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

Show a summary per file
File Description
WooPosOrdersState.kt Changed selectedDetails from non-null to nullable type to support empty selection state
WooPosOrdersViewModel.kt Updated search logic to set selectedDetails to null on error/empty results, and enhanced selection preservation in replaceOrders
WooPosOrdersScreen.kt Added conditional rendering logic to show empty state, loading skeleton, or order details based on state; added preview function
WooPosOrdersLoadingState.kt Changed OrderDetailsLoadingPane visibility from private to public for reuse in search scenarios
strings.xml Added new string resource for "No order selected" message
WooPosOrdersViewModelTest.kt Updated all tests to handle nullable selectedDetails and added comprehensive tests for search scenarios including empty results and selection preservation

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

val loadedItems = content.items as WooPosOrdersState.Content.Items.Loaded
val selectedItem = loadedItems.items.keys.first { it.isSelected }
assertThat(selectedItem.id).isEqualTo(5L)
}
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

Missing test coverage: The implementation sets selectedDetails to null when a search error occurs (ViewModel line 358), but there's no test to verify this behavior. Consider adding a test similar to given search returns no results, when search performed, then selectedDetails is null but for the error case to ensure selectedDetails is properly set to null when SearchOrdersResult.Error is returned.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e066ac4897afd483ec6dd90cc26e00198a9764a6

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 2, 2025

📲 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
Commite066ac4
Direct Downloadwoocommerce-wear-prototype-build-pr15051-e066ac4.apk

@malinajirka malinajirka requested a review from toupper December 2, 2025 16:39
@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
Commite066ac4
Direct Downloadwoocommerce-prototype-build-pr15051-e066ac4.apk

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 58.33333% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.62%. Comparing base (020f488) to head (e066ac4).

Files with missing lines Patch % Lines
.../android/ui/woopos/orders/WooPosOrdersViewModel.kt 60.00% 0 Missing and 4 partials ⚠️
...droid/ui/woopos/orders/WooPosOrdersLoadingState.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk   #15051   +/-   ##
=========================================
  Coverage     38.61%   38.62%           
  Complexity    10312    10312           
=========================================
  Files          2163     2163           
  Lines        122674   122679    +5     
  Branches      16934    16938    +4     
=========================================
+ Hits          47366    47379   +13     
+ Misses        70503    70494    -9     
- Partials       4805     4806    +1     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants