From fdc493df7fdcb6fda35894ec5a3cc7990dc8ea13 Mon Sep 17 00:00:00 2001 From: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> Date: Tue, 1 Feb 2022 17:24:13 +0100 Subject: [PATCH] fix: Support array of payment status filters when listing orders (#1013) --- integration-tests/api/__tests__/admin/order.js | 15 +++++++++------ packages/medusa/src/types/orders.ts | 10 +++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/integration-tests/api/__tests__/admin/order.js b/integration-tests/api/__tests__/admin/order.js index 721dba381a..9ee709884f 100644 --- a/integration-tests/api/__tests__/admin/order.js +++ b/integration-tests/api/__tests__/admin/order.js @@ -1234,15 +1234,18 @@ describe("/admin/orders", () => { ]) }) - it("lists all orders with a fulfillment status = fulfilled", async () => { + it("lists all orders with a fulfillment status = fulfilled and payment status = captured", async () => { const api = useApi() const response = await api - .get("/admin/orders?fulfillment_status[]=fulfilled", { - headers: { - authorization: "Bearer test_token", - }, - }) + .get( + "/admin/orders?fulfillment_status[]=fulfilled&payment_status[]=captured", + { + headers: { + authorization: "Bearer test_token", + }, + } + ) .catch((err) => console.log(err)) expect(response.status).toEqual(200) diff --git a/packages/medusa/src/types/orders.ts b/packages/medusa/src/types/orders.ts index 728d714a0f..3bb0f5a235 100644 --- a/packages/medusa/src/types/orders.ts +++ b/packages/medusa/src/types/orders.ts @@ -1,12 +1,12 @@ import { Type } from "class-transformer" import { - IsString, - IsOptional, IsArray, IsEnum, - ValidateNested, - IsNotEmpty, IsInt, + IsNotEmpty, + IsOptional, + IsString, + ValidateNested, } from "class-validator" import { DateComparisonOperator } from "./common" @@ -60,7 +60,7 @@ export class AdminListOrdersSelector { fulfillment_status?: string[] @IsArray() - @IsEnum(PaymentStatus) + @IsEnum(PaymentStatus, { each: true }) @IsOptional() payment_status?: string[]