gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated (98c5e45de -> 102466500)


From: gnunet
Subject: [taler-wallet-core] branch master updated (98c5e45de -> 102466500)
Date: Thu, 09 Nov 2023 14:01:45 +0100

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a change to branch master
in repository wallet-core.

    from 98c5e45de fix testing, skip some that need refactor
     new eb3ce7e9a update test for new auth api
     new d2f8962fd update test for longest currency name
     new ab9ce29b5 update test for "limit=0" optimization
     new e8c39767e add fake url for test
     new 9395b58f6 fix: not evicting cache because of typo
     new 2e73e89ff update test for new response from merchant backend
     new 102466500 floor when moving from ms to secs

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/context/backend.test.ts                    | 26 ++++++-
 .../merchant-backoffice-ui/src/hooks/backend.ts    |  4 +-
 .../src/hooks/instance.test.ts                     | 16 ++++-
 .../merchant-backoffice-ui/src/hooks/order.test.ts | 82 +++++-----------------
 .../merchant-backoffice-ui/src/hooks/product.ts    |  2 +-
 .../merchant-backoffice-ui/src/hooks/testing.tsx   |  6 +-
 .../src/hooks/transfer.test.ts                     | 29 +-------
 packages/merchant-backoffice-ui/src/hooks/urls.ts  | 12 ++++
 .../merchant-backoffice-ui/src/utils/regex.test.ts |  3 +-
 9 files changed, 79 insertions(+), 101 deletions(-)

diff --git a/packages/merchant-backoffice-ui/src/context/backend.test.ts 
b/packages/merchant-backoffice-ui/src/context/backend.test.ts
index ad6393e29..359859819 100644
--- a/packages/merchant-backoffice-ui/src/context/backend.test.ts
+++ b/packages/merchant-backoffice-ui/src/context/backend.test.ts
@@ -31,6 +31,7 @@ import { expect } from "chai";
 import { ApiMockEnvironment } from "../hooks/testing.js";
 import {
   API_CREATE_INSTANCE,
+  API_NEW_LOGIN,
   API_UPDATE_CURRENT_INSTANCE_AUTH,
   API_UPDATE_INSTANCE_AUTH_BY_ID,
 } from "../hooks/urls.js";
@@ -63,6 +64,17 @@ describe("backend context api ", () => {
               name: "instance_name",
             } as MerchantBackend.Instances.QueryInstancesResponse,
           });
+          env.addRequestExpectation(API_NEW_LOGIN, {
+            auth: "another_token",
+            request: {
+              scope: "write",
+              duration: {
+                "d_us": "forever",
+              },
+              refreshable: true,
+            },
+            
+          });
 
           management.setNewAccessToken(undefined,"another_token" as 
AccessToken);
         },
@@ -72,7 +84,7 @@ describe("backend context api ", () => {
           });
 
           env.addRequestExpectation(API_CREATE_INSTANCE, {
-            auth: "another_token",
+            // auth: "another_token",
             request: {
               id: "new_instance_id",
             } as MerchantBackend.Instances.InstanceConfigurationMessage,
@@ -113,6 +125,16 @@ describe("backend context api ", () => {
               name: "instance_name",
             } as MerchantBackend.Instances.QueryInstancesResponse,
           });
+          env.addRequestExpectation(API_NEW_LOGIN, {
+            auth: "another_token",
+            request: {
+              scope: "write",
+              duration: {
+                "d_us": "forever",
+              },
+              refreshable: true,
+            },            
+          });
           instance.setNewAccessToken(undefined, "another_token" as 
AccessToken);
         },
         ({ instance, management, admin }) => {
@@ -121,7 +143,7 @@ describe("backend context api ", () => {
           });
 
           env.addRequestExpectation(API_CREATE_INSTANCE, {
-            auth: "another_token",
+            // auth: "another_token",
             request: {
               id: "new_instance_id",
             } as MerchantBackend.Instances.InstanceConfigurationMessage,
diff --git a/packages/merchant-backoffice-ui/src/hooks/backend.ts 
b/packages/merchant-backoffice-ui/src/hooks/backend.ts
index 054c074f1..8d99546a8 100644
--- a/packages/merchant-backoffice-ui/src/hooks/backend.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/backend.ts
@@ -332,8 +332,8 @@ export function useBackendInstanceRequest(): 
useBackendInstanceRequestType {
       const [endpoint, paid, refunded, wired, searchDate, delta] = args
       const date_s =
         delta && delta < 0 && searchDate
-          ? (searchDate.getTime() / 1000) + 1
-          : searchDate !== undefined ? (searchDate.getTime() / 1000) : 
undefined;
+          ? Math.floor(searchDate.getTime() / 1000) + 1
+          : searchDate !== undefined ? Math.floor(searchDate.getTime() / 1000) 
: undefined;
       const params: any = {};
       if (paid !== undefined) params.paid = paid;
       if (delta !== undefined) params.delta = delta;
diff --git a/packages/merchant-backoffice-ui/src/hooks/instance.test.ts 
b/packages/merchant-backoffice-ui/src/hooks/instance.test.ts
index 0c0c44590..ee1576764 100644
--- a/packages/merchant-backoffice-ui/src/hooks/instance.test.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/instance.test.ts
@@ -35,6 +35,7 @@ import {
   API_DELETE_INSTANCE,
   API_GET_CURRENT_INSTANCE,
   API_LIST_INSTANCES,
+  API_NEW_LOGIN,
   API_UPDATE_CURRENT_INSTANCE,
   API_UPDATE_CURRENT_INSTANCE_AUTH,
   API_UPDATE_INSTANCE_BY_ID,
@@ -140,7 +141,6 @@ describe("instance api interaction with details", () => {
             name: "instance_name",
             auth: {
               method: "token",
-              token: "not-secret",
             },
           });
           env.addRequestExpectation(API_UPDATE_CURRENT_INSTANCE_AUTH, {
@@ -149,6 +149,16 @@ describe("instance api interaction with details", () => {
               token: "secret",
             } as MerchantBackend.Instances.InstanceAuthConfigurationMessage,
           });
+          env.addRequestExpectation(API_NEW_LOGIN, {
+            auth: "secret",
+            request: {
+              scope: "write",
+              duration: {
+                "d_us": "forever",
+              },
+              refreshable: true,
+            },            
+          });
           env.addRequestExpectation(API_GET_CURRENT_INSTANCE, {
             response: {
               name: "instance_name",
@@ -171,7 +181,7 @@ describe("instance api interaction with details", () => {
             name: "instance_name",
             auth: {
               method: "token",
-              token: "secret",
+              // token: "secret",
             },
           });
         },
@@ -217,7 +227,7 @@ describe("instance api interaction with details", () => {
             name: "instance_name",
             auth: {
               method: "token",
-              token: "not-secret",
+              // token: "not-secret",
             },
           });
           env.addRequestExpectation(API_UPDATE_CURRENT_INSTANCE_AUTH, {
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
@@ -37,17 +37,10 @@ describe("order api interaction with listing", () => {
   it("should evict cache when creating an order", async () => {
     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],
       },
     });
 
@@ -84,17 +77,10 @@ describe("order api interaction with listing", () => {
             response: { order_id: "3" },
           });
 
-          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],
             },
           });
 
@@ -124,22 +110,13 @@ describe("order api interaction with listing", () => {
   it("should evict cache when doing a refund", async () => {
     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) => {
@@ -181,18 +158,11 @@ 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", {
@@ -229,17 +199,10 @@ describe("order api interaction with listing", () => {
   it("should evict cache when deleting an order", async () => {
     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],
       },
     });
 
@@ -271,13 +234,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: {
@@ -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/product.ts 
b/packages/merchant-backoffice-ui/src/hooks/product.ts
index e06ea8ed8..b54cd4d91 100644
--- a/packages/merchant-backoffice-ui/src/hooks/product.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/product.ts
@@ -57,7 +57,7 @@ export function useProductAPI(): ProductAPI {
       data,
     });
 
-    return await mutateAll(/.*"\/private\/products.*/);
+    return await mutateAll(/.*\/private\/products.*/);
   };
 
   const updateProduct = async (
diff --git a/packages/merchant-backoffice-ui/src/hooks/testing.tsx 
b/packages/merchant-backoffice-ui/src/hooks/testing.tsx
index 386944854..3ea22475b 100644
--- a/packages/merchant-backoffice-ui/src/hooks/testing.tsx
+++ b/packages/merchant-backoffice-ui/src/hooks/testing.tsx
@@ -143,10 +143,10 @@ export class ApiMockEnvironment extends MockEnvironment {
         }
 
       }
-      const bankCore = new TalerCoreBankHttpClient("", mockHttpClient)
+      const bankCore = new TalerCoreBankHttpClient("http://localhost";, 
mockHttpClient)
       const bankIntegration = bankCore.getIntegrationAPI()
-      const bankRevenue = bankCore.getRevenueAPI("")
-      const bankWire = bankCore.getWireGatewayAPI("")
+      const bankRevenue = bankCore.getRevenueAPI("a")
+      const bankWire = bankCore.getWireGatewayAPI("b")
 
       return (
         <BackendContextProvider defaultUrl="http://backend";>
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
@@ -30,19 +30,10 @@ describe("transfer api interaction with listing", () => {
   it("should evict cache when informing a transfer", async () => {
     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],
       },
     });
 
@@ -83,17 +74,10 @@ describe("transfer api interaction with listing", () => {
             response: { total: "" } as any,
           });
 
-          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],
             },
           });
 
@@ -129,17 +113,10 @@ describe("transfer listing pagination", () => {
   it("should not load more if has reach the end", async () => {
     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
@@ -249,6 +249,18 @@ export const API_DELETE_INSTANCE = (id: string): 
Query<unknown, unknown> => ({
   url: `http://backend/management/instances/${id}`,
 });
 
+////////////////////
+// AUTH
+////////////////////
+
+export const API_NEW_LOGIN: Query<
+  MerchantBackend.Instances.LoginTokenRequest,
+  unknown
+> = ({
+  method: "POST",
+  url: `http://backend/private/token`,
+});
+
 ////////////////////
 // INSTANCE
 ////////////////////
diff --git a/packages/merchant-backoffice-ui/src/utils/regex.test.ts 
b/packages/merchant-backoffice-ui/src/utils/regex.test.ts
index d473bd08c..984f1a472 100644
--- a/packages/merchant-backoffice-ui/src/utils/regex.test.ts
+++ b/packages/merchant-backoffice-ui/src/utils/regex.test.ts
@@ -61,9 +61,10 @@ describe("amount format", () => {
     "ARS:10.123,123",
     "ARS:1,000,000",
     "ARSCOL:10",
-    "THISISTHEMOTHERCOIN:1,000,000.123,123",
+    "LONGESTCURR:1,000,000.123,123",
   ];
 
+
   it("should be valid", () => {
     valids.forEach((v) => expect(v).match(AMOUNT_REGEX));
   });

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]