aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-11-09 10:00:24 -0300
committerSebastian <sebasjm@gmail.com>2023-11-09 10:00:24 -0300
commitab9ce29b56f5f8d8bfa16570e56cfe13810cad6a (patch)
tree8f53be86fca5a80e3939749651ad61c07fa43899
parentd2f8962fd00f2f9137d50e15b139c76db7ed0c7c (diff)
downloadwallet-core-ab9ce29b56f5f8d8bfa16570e56cfe13810cad6a.tar.xz
update test for "limit=0" optimization
-rw-r--r--packages/merchant-backoffice-ui/src/hooks/order.test.ts82
-rw-r--r--packages/merchant-backoffice-ui/src/hooks/transfer.test.ts29
-rw-r--r--packages/merchant-backoffice-ui/src/hooks/urls.ts12
3 files changed, 34 insertions, 89 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/order.test.ts b/packages/merchant-backoffice-ui/src/hooks/order.test.ts
index aa67743df..c243309a8 100644
--- a/packages/merchant-backoffice-ui/src/hooks/order.test.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/order.test.ts
@@ -38,16 +38,9 @@ describe("order api interaction with listing", () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [{ order_id: "1" } as MerchantBackend.Orders.OrderHistoryEntry],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
response: {
- orders: [{ order_id: "2" } as MerchantBackend.Orders.OrderHistoryEntry],
+ orders: [{ order_id: "1" }, { order_id: "2" } as MerchantBackend.Orders.OrderHistoryEntry],
},
});
@@ -85,16 +78,9 @@ describe("order api interaction with listing", () => {
});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [{ order_id: "1" } as any],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
response: {
- orders: [{ order_id: "2" } as any, { order_id: "3" } as any],
+ orders: [{ order_id: "1" }, { order_id: "2" } as any, { order_id: "3" } as any],
},
});
@@ -125,21 +111,12 @@ describe("order api interaction with listing", () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [
- {
- order_id: "1",
- amount: "EUR:12",
- refundable: true,
- } as MerchantBackend.Orders.OrderHistoryEntry,
- ],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
- response: { orders: [] },
+ response: { orders: [{
+ order_id: "1",
+ amount: "EUR:12",
+ refundable: true,
+ } as MerchantBackend.Orders.OrderHistoryEntry] },
});
const newDate = (d: Date) => {
@@ -182,17 +159,10 @@ describe("order api interaction with listing", () => {
});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [
- { order_id: "1", amount: "EUR:12", refundable: false } as any,
- ],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
- response: { orders: [] },
+ response: { orders: [
+ { order_id: "1", amount: "EUR:12", refundable: false } as any,
+ ] },
});
api.refundOrder("1", {
@@ -230,16 +200,9 @@ describe("order api interaction with listing", () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [{ order_id: "1" } as MerchantBackend.Orders.OrderHistoryEntry],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
response: {
- orders: [{ order_id: "2" } as MerchantBackend.Orders.OrderHistoryEntry],
+ orders: [{ order_id: "1" }, { order_id: "2" } as MerchantBackend.Orders.OrderHistoryEntry],
},
});
@@ -272,13 +235,6 @@ describe("order api interaction with listing", () => {
env.addRequestExpectation(API_DELETE_ORDER("1"), {});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
response: {
orders: [{ order_id: "2" } as any],
@@ -459,14 +415,14 @@ describe("order listing pagination", () => {
it("should not load more if has reach the end", async () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 20, wired: "yes", date_ms: 12 },
+ qparam: { delta: 20, wired: "yes", date_s: 12 },
response: {
orders: [{ order_id: "1" } as any],
},
});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: -20, wired: "yes", date_ms: 13 },
+ qparam: { delta: -20, wired: "yes", date_s: 13 },
response: {
orders: [{ order_id: "2" } as any],
},
@@ -478,7 +434,7 @@ describe("order listing pagination", () => {
const hookBehavior = await tests.hookBehaveLikeThis(
() => {
- const date = new Date(12);
+ const date = new Date(12000);
const query = useInstanceOrders({ wired: "yes", date }, newDate);
const api = useOrderAPI();
return { query, api };
@@ -525,14 +481,14 @@ describe("order listing pagination", () => {
const ordersFrom20to0 = [...ordersFrom0to20].reverse();
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 20, wired: "yes", date_ms: 12 },
+ qparam: { delta: 20, wired: "yes", date_s: 12 },
response: {
orders: ordersFrom0to20,
},
});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: -20, wired: "yes", date_ms: 13 },
+ qparam: { delta: -20, wired: "yes", date_s: 13 },
response: {
orders: ordersFrom20to40,
},
@@ -544,7 +500,7 @@ describe("order listing pagination", () => {
const hookBehavior = await tests.hookBehaveLikeThis(
() => {
- const date = new Date(12);
+ const date = new Date(12000);
const query = useInstanceOrders({ wired: "yes", date }, newDate);
const api = useOrderAPI();
return { query, api };
@@ -568,7 +524,7 @@ describe("order listing pagination", () => {
expect(query.isReachingStart).false;
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: -40, wired: "yes", date_ms: 13 },
+ qparam: { delta: -40, wired: "yes", date_s: 13 },
response: {
orders: [...ordersFrom20to40, { order_id: "41" }],
},
@@ -595,7 +551,7 @@ describe("order listing pagination", () => {
});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 40, wired: "yes", date_ms: 12 },
+ qparam: { delta: 40, wired: "yes", date_s: 12 },
response: {
orders: [...ordersFrom0to20, { order_id: "-1" }],
},
diff --git a/packages/merchant-backoffice-ui/src/hooks/transfer.test.ts b/packages/merchant-backoffice-ui/src/hooks/transfer.test.ts
index 10cb4226b..a7187af27 100644
--- a/packages/merchant-backoffice-ui/src/hooks/transfer.test.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/transfer.test.ts
@@ -31,18 +31,9 @@ describe("transfer api interaction with listing", () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_LIST_TRANSFERS, {
- qparam: { limit: 0 },
- response: {
- transfers: [{ wtid: "2" } as MerchantBackend.Transfers.TransferDetails],
- },
- });
- // FIXME: is this query really needed? if the hook is rendered without
- // position argument then then backend is returning the newest and no need
- // to this second query
- env.addRequestExpectation(API_LIST_TRANSFERS, {
qparam: { limit: -20 },
response: {
- transfers: [],
+ transfers: [{ wtid: "2" } as MerchantBackend.Transfers.TransferDetails],
},
});
@@ -84,16 +75,9 @@ describe("transfer api interaction with listing", () => {
});
env.addRequestExpectation(API_LIST_TRANSFERS, {
- qparam: { limit: 0 },
- response: {
- transfers: [{ wtid: "2" } as any, { wtid: "3" } as any],
- },
- });
-
- env.addRequestExpectation(API_LIST_TRANSFERS, {
qparam: { limit: -20 },
response: {
- transfers: [],
+ transfers: [{ wtid: "3" } as any, { wtid: "2" } as any],
},
});
@@ -130,16 +114,9 @@ describe("transfer listing pagination", () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_LIST_TRANSFERS, {
- qparam: { limit: 0, payto_uri: "payto://" },
- response: {
- transfers: [{ wtid: "2" } as any],
- },
- });
-
- env.addRequestExpectation(API_LIST_TRANSFERS, {
qparam: { limit: -20, payto_uri: "payto://" },
response: {
- transfers: [{ wtid: "1" } as any],
+ transfers: [{ wtid: "2" }, { wtid: "1" } as any],
},
});
diff --git a/packages/merchant-backoffice-ui/src/hooks/urls.ts b/packages/merchant-backoffice-ui/src/hooks/urls.ts
index 00c5e95af..b6485259f 100644
--- a/packages/merchant-backoffice-ui/src/hooks/urls.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/urls.ts
@@ -250,6 +250,18 @@ export const API_DELETE_INSTANCE = (id: string): Query<unknown, unknown> => ({
});
////////////////////
+// AUTH
+////////////////////
+
+export const API_NEW_LOGIN: Query<
+ MerchantBackend.Instances.LoginTokenRequest,
+ unknown
+> = ({
+ method: "POST",
+ url: `http://backend/private/token`,
+});
+
+////////////////////
// INSTANCE
////////////////////