Skip to content

Conversation

@staskus
Copy link
Contributor

@staskus staskus commented Sep 4, 2025

WOOMOB-1137

Description

Implemented Order List Search using the same patterns from Products and Coupons:

  • Defined a new strategy that calls into separate remote methods that pass a keyword to the orders endpoint, together filtering pos-rest-api
  • Reused POSSearchView that is displayed with animation when the search icon is tapped
  • Implemented the logic within PointOfSaleOrderListController - not caching search results, showing cached list when the search is cleared, remembering the last selection if the search is closed.

Steps to reproduce

  1. Open POS -> Menu -> Orders
  2. Confirm the search icon opens the search bar, and the back button returns to the previous state
  3. Confirm starting to type shows loading, tapping back or clear button shows cached results
  4. Try entering the order number, customer email, or product. Confirm that the appropriate results are shown
  5. Confirm pagination works within search
  6. Let me know any other observations!

Empty, error states are outside the scope

Testing information

Tested on iPad Air 18.5 Simulator

Screenshots

Simulator Screenshot - iPad Air 11-inch (M3) - 2025-09-05 at 15 24 11 Simulator Screenshot - iPad Air 11-inch (M3) - 2025-09-05 at 15 24 17
Simulator.Screen.Recording.-.iPad.Air.11-inch.M3.-.2025-09-05.at.15.25.21.mov

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@staskus staskus added this to the 23.3 milestone Sep 4, 2025
@staskus staskus added type: task An internally driven task. feature: POS labels Sep 4, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 4, 2025

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

App NameWooCommerce iOS Prototype
Build Numberpr16089-c07807f
Version23.2
Bundle IDcom.automattic.alpha.woocommerce
Commitc07807f
Installation URL78o7anq30s2d0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@iamgabrielma iamgabrielma self-assigned this Sep 5, 2025
@iamgabrielma
Copy link
Contributor

iamgabrielma commented Sep 5, 2025

Confirm pagination works within search

I haven't checked the code yet, from testing I found something that I'm not sure if is expected yet: Pagination does not trigger when we close the initial search unless we do a pull to refresh first. Example:

  • In my store, I search for supergoop, this shows results up till 18 June
  • Close search, scroll to the bottom. Results till 18 june remain and no pagination is triggered.
  • It's resolved if we either go back up and pull-to-refresh, then we can navigate to the bottom and pagination triggers again (additional orders till 2 june), or if we exit Orders to the dashboard and go back in
Screen.Recording.2025-09-05.at.15.49.22.mov

I'll check the code now!

@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

Copy link
Contributor

@iamgabrielma iamgabrielma left a comment

Choose a reason for hiding this comment

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

Works as described, LGTM!

let mapper = OrderListMapper(siteID: siteID)
let orders: [Order] = try await enqueue(request, mapper: mapper)
let hasMorePages = orders.count == pageSize
return PagedItems(items: orders, hasMorePages: hasMorePages, totalItems: nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have/want access to totalItems here? I have not tested this much, but consider using the the PagedItems method that parses the responseHeaders as well, ie:

let (orders, responseHeaders) = try await enqueueWithResponseHeaders(request, mapper: mapper)
return createPagedItems(items: orders, responseHeaders: responseHeaders, currentPageNumber: pageNumber) 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll check it out!

let result = try await remote.searchPOSOrders(siteID: sampleSiteID, searchTerm: "test", pageNumber: 1, pageSize: 25)

// Then
XCTAssert(result.items.count == 4)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering, should we use order-load-all for this test? As is always going to return the 4 orders no matter the searchTerm we pass through. Maybe is there some other file that fits better the test? Or a new response? Not a big deal in any case since we're checking that the function parses the response.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mm... There's actually not much to test here since our request expects the same type of Order that we already tested in other tests. Search query doesn't produce any special results. Only the second test is meaningful to verify that we're making the request with the expected parameters.

@staskus
Copy link
Contributor Author

staskus commented Sep 5, 2025

I haven't checked the code yet, from testing I found something that I'm not sure if is expected yet: Pagination does not trigger when we close the initial search unless we do a pull to refresh first. Example:

@iamgabrielma good catch, you're right. AsyncPaginationTracker is in the wrong state after the search is cleared. Maybe need to have two different trackers for search and normal list so they wouldn't interfere with each other.

@staskus staskus enabled auto-merge September 5, 2025 12:29
@staskus staskus merged commit 31699ac into trunk Sep 5, 2025
14 checks passed
@staskus staskus deleted the woomob-1137-woo-poshistorical-orders-order-list-search-ui-and-functionality branch September 5, 2025 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: POS type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants