Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Woo POS] Change a default sorting of POS products to "menu_order" #13924

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Networking/Networking/Remote/ProductsRemote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public final class ProductsRemote: Remote, ProductsRemoteProtocol {
ParameterKey.page: POSConstants.page,
ParameterKey.perPage: POSConstants.productsPerPage,
ParameterKey.productType: POSConstants.productType,
ParameterKey.orderBy: OrderKey.name.value,
ParameterKey.orderBy: OrderKey.menuOrder.value,
ParameterKey.order: Order.ascending.value,
ParameterKey.productStatus: POSConstants.productStatus,
]
Expand Down Expand Up @@ -541,6 +541,7 @@ public extension ProductsRemote {
case name
// available for use in `GET wc-analytics/reports/products/stats` only.
case itemsSold
case menuOrder
}

enum Order {
Expand Down Expand Up @@ -625,6 +626,8 @@ private extension ProductsRemote.OrderKey {
return "title"
case .itemsSold:
return "items_sold"
case .menuOrder:
return "menu_order"
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions Networking/NetworkingTests/Remote/ProductsRemoteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,18 @@ final class ProductsRemoteTests: XCTestCase {
}
}

func test_loadAllSimpleProductsForPointOfSale_called_with_menu_order() async throws {
// Given
let remote = ProductsRemote(network: network)

// When
network.simulateResponse(requestUrlSuffix: "products", filename: "products-load-all-type-simple")
let _ = try await remote.loadAllSimpleProductsForPointOfSale(for: sampleSiteID)

// Then
XCTAssertTrue((network.queryParameters ?? []).contains("orderby=menu_order"))
}

func test_loadAllSimpleProductsForPointOfSale_relays_networking_error() async throws {
// Given
let remote = ProductsRemote(network: network)
Expand Down