gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: making test passed


From: gnunet
Subject: [taler-wallet-core] branch master updated: making test passed
Date: Fri, 12 Jan 2024 15:25:56 +0100

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

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

The following commit(s) were added to refs/heads/master by this push:
     new 23a075a44 making test passed
23a075a44 is described below

commit 23a075a44e14a7b6e151857aa4c1ba0e298036c2
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Fri Jan 12 11:25:38 2024 -0300

    making test passed
---
 packages/aml-backoffice-ui/src/forms.ts            |  5 +-
 packages/aml-backoffice-ui/src/forms/902_11e.ts    |  2 +-
 packages/aml-backoffice-ui/src/forms/902_12e.ts    |  2 +-
 packages/aml-backoffice-ui/src/forms/902_13e.ts    |  2 +-
 packages/aml-backoffice-ui/src/forms/902_15e.ts    |  2 +-
 packages/aml-backoffice-ui/src/forms/902_1e.ts     |  4 +-
 packages/aml-backoffice-ui/src/forms/902_4e.ts     |  2 +-
 packages/aml-backoffice-ui/src/forms/902_5e.ts     |  4 +-
 packages/aml-backoffice-ui/src/forms/902_9e.ts     |  2 +-
 .../aml-backoffice-ui/src/forms/declaration.ts     | 70 ++++++++++++++++++++++
 packages/aml-backoffice-ui/src/forms/index.ts      | 34 +----------
 packages/aml-backoffice-ui/src/forms/simplest.ts   |  2 +-
 .../src/pages/AntiMoneyLaunderingForm.tsx          |  4 +-
 .../aml-backoffice-ui/src/pages/CaseDetails.tsx    |  9 +--
 .../aml-backoffice-ui/src/pages/NewFormEntry.tsx   |  3 +-
 .../src/pages/ShowConsolidated.stories.tsx         | 12 +++-
 16 files changed, 107 insertions(+), 52 deletions(-)

diff --git a/packages/aml-backoffice-ui/src/forms.ts 
b/packages/aml-backoffice-ui/src/forms.ts
index d48faa2b2..cc9e4c7e8 100644
--- a/packages/aml-backoffice-ui/src/forms.ts
+++ b/packages/aml-backoffice-ui/src/forms.ts
@@ -18,4 +18,7 @@ export * from "./forms/index.js";
 
 /**
  * this file is here to have a flat dist folder
- */
\ No newline at end of file
+ * 
+ * this file is being build in a bundle separated 
+ * from the main one.
+ */
diff --git a/packages/aml-backoffice-ui/src/forms/902_11e.ts 
b/packages/aml-backoffice-ui/src/forms/902_11e.ts
index 258f75135..71ca8bcf4 100644
--- a/packages/aml-backoffice-ui/src/forms/902_11e.ts
+++ b/packages/aml-backoffice-ui/src/forms/902_11e.ts
@@ -1,6 +1,6 @@
 import type { TranslatedString } from "@gnu-taler/taler-util";
 import type { FlexibleForm, FormState, InternationalizationAPI } from 
"@gnu-taler/web-util/browser";
-import { BaseForm } from "./index.js";
+import { BaseForm } from "./declaration.js";
 import { resolutionSection } from "./simplest.js";
 
 export const v1 = (i18n: InternationalizationAPI) => (current: BaseForm): 
FlexibleForm<Form902_11.Form> => ({
diff --git a/packages/aml-backoffice-ui/src/forms/902_12e.ts 
b/packages/aml-backoffice-ui/src/forms/902_12e.ts
index 5a6b80772..0c08d274c 100644
--- a/packages/aml-backoffice-ui/src/forms/902_12e.ts
+++ b/packages/aml-backoffice-ui/src/forms/902_12e.ts
@@ -1,7 +1,7 @@
 import type { AbsoluteTime, TranslatedString } from "@gnu-taler/taler-util";
 import type { FlexibleForm, FormState, InternationalizationAPI } from 
"@gnu-taler/web-util/browser";
 import { resolutionSection } from "./simplest.js";
-import { BaseForm } from "./index.js";
+import { BaseForm } from "./declaration.js";
 
 export const v1 = (i18n: InternationalizationAPI) => (current: BaseForm): 
FlexibleForm<Form902_12.Form> => ({
   design: [
diff --git a/packages/aml-backoffice-ui/src/forms/902_13e.ts 
b/packages/aml-backoffice-ui/src/forms/902_13e.ts
index dce81bc5e..f69884e0e 100644
--- a/packages/aml-backoffice-ui/src/forms/902_13e.ts
+++ b/packages/aml-backoffice-ui/src/forms/902_13e.ts
@@ -1,6 +1,6 @@
 import type { AbsoluteTime } from "@gnu-taler/taler-util";
 import type { FlexibleForm, FormState, InternationalizationAPI } from 
"@gnu-taler/web-util/browser";
-import { BaseForm } from "./index.js";
+import { BaseForm } from "./declaration.js";
 import { resolutionSection } from "./simplest.js";
 
 export const v1 = (i18n: InternationalizationAPI) => (current: BaseForm): 
FlexibleForm<Form902_13.Form> => ({
diff --git a/packages/aml-backoffice-ui/src/forms/902_15e.ts 
b/packages/aml-backoffice-ui/src/forms/902_15e.ts
index 98609852b..2375de389 100644
--- a/packages/aml-backoffice-ui/src/forms/902_15e.ts
+++ b/packages/aml-backoffice-ui/src/forms/902_15e.ts
@@ -1,6 +1,6 @@
 import type { AbsoluteTime } from "@gnu-taler/taler-util";
 import type { FlexibleForm, InternationalizationAPI } from 
"@gnu-taler/web-util/browser";
-import { BaseForm } from "./index.js";
+import { BaseForm } from "./declaration.js";
 import { resolutionSection } from "./simplest.js";
 
 export const v1 = (i18n: InternationalizationAPI) => (current: BaseForm): 
FlexibleForm<Form902_15.Form> => ({
diff --git a/packages/aml-backoffice-ui/src/forms/902_1e.ts 
b/packages/aml-backoffice-ui/src/forms/902_1e.ts
index 2db6f1b7e..2287db369 100644
--- a/packages/aml-backoffice-ui/src/forms/902_1e.ts
+++ b/packages/aml-backoffice-ui/src/forms/902_1e.ts
@@ -1,6 +1,6 @@
 import type { AbsoluteTime, TranslatedString } from "@gnu-taler/taler-util";
 import type { FlexibleForm, FormState, InternationalizationAPI } from 
"@gnu-taler/web-util/browser";
-import { BaseForm } from "./index.js";
+import { BaseForm, uiForms } from "./declaration.js";
 import { resolutionSection } from "./simplest.js";
 
 export const v1 = (i18n: InternationalizationAPI) => (current: BaseForm): 
FlexibleForm<Form902_1.Form> => ({
@@ -370,7 +370,7 @@ export const v1 = (i18n: InternationalizationAPI) => 
(current: BaseForm): Flexib
           props: {
             name: "acceptance.language",
             label: i18n.str`Languages`,
-            choices: window.amlExchangeBackoffice!.currencies(i18n),
+            choices: uiForms.currencies(i18n),
             unique: true,
           },
         },
diff --git a/packages/aml-backoffice-ui/src/forms/902_4e.ts 
b/packages/aml-backoffice-ui/src/forms/902_4e.ts
index e6d15eae3..b31a8dcba 100644
--- a/packages/aml-backoffice-ui/src/forms/902_4e.ts
+++ b/packages/aml-backoffice-ui/src/forms/902_4e.ts
@@ -2,7 +2,7 @@ import type { AbsoluteTime, TranslatedString } from 
"@gnu-taler/taler-util";
 import type { FlexibleForm, FormState, InternationalizationAPI } from 
"@gnu-taler/web-util/browser";
 import { h as create } from "preact";
 import { resolutionSection } from "./simplest.js";
-import { BaseForm } from "./index.js";
+import { BaseForm } from "./declaration.js";
 import { ArrowRightIcon, ChevronRightIcon } from "./icons.js";
 
 export const v1 = (i18n: InternationalizationAPI) => (current: BaseForm): 
FlexibleForm<Form902_4.Form> => ({
diff --git a/packages/aml-backoffice-ui/src/forms/902_5e.ts 
b/packages/aml-backoffice-ui/src/forms/902_5e.ts
index f8dc82b7c..3af03ed22 100644
--- a/packages/aml-backoffice-ui/src/forms/902_5e.ts
+++ b/packages/aml-backoffice-ui/src/forms/902_5e.ts
@@ -1,6 +1,6 @@
 import type { TranslatedString } from "@gnu-taler/taler-util";
 import type { FlexibleForm, FormState, InternationalizationAPI } from 
"@gnu-taler/web-util/browser";
-import { BaseForm } from "./index.js";
+import { BaseForm, uiForms } from "./declaration.js";
 import { resolutionSection } from "./simplest.js";
 
 export const v1 = (i18n: InternationalizationAPI) => (current: BaseForm): 
FlexibleForm<Form902_5.Form> => ({
@@ -62,7 +62,7 @@ export const v1 = (i18n: InternationalizationAPI) => 
(current: BaseForm): Flexib
           props: {
             name: "originOfAssets.currency",
             label: i18n.str`Currency`,
-            choices: window.amlExchangeBackoffice!.currencies(i18n),
+            choices: uiForms.currencies(i18n),
           },
         },
         {
diff --git a/packages/aml-backoffice-ui/src/forms/902_9e.ts 
b/packages/aml-backoffice-ui/src/forms/902_9e.ts
index 274d76445..e0e7a6d65 100644
--- a/packages/aml-backoffice-ui/src/forms/902_9e.ts
+++ b/packages/aml-backoffice-ui/src/forms/902_9e.ts
@@ -1,7 +1,7 @@
 import { AbsoluteTime, TranslatedString } from "@gnu-taler/taler-util";
 import { FlexibleForm, FormState, InternationalizationAPI } from 
"@gnu-taler/web-util/browser";
 import { resolutionSection } from "./simplest.js";
-import { BaseForm } from "./index.js";
+import { BaseForm } from "./declaration.js";
 
 export const v1 = (i18n: InternationalizationAPI) => (current: BaseForm): 
FlexibleForm<Form902_9.Form> => ({
   design: [
diff --git a/packages/aml-backoffice-ui/src/forms/declaration.ts 
b/packages/aml-backoffice-ui/src/forms/declaration.ts
new file mode 100644
index 000000000..6c52a4bfe
--- /dev/null
+++ b/packages/aml-backoffice-ui/src/forms/declaration.ts
@@ -0,0 +1,70 @@
+/*
+ This file is part of GNU Taler
+ (C) 2022 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+ */
+
+import type { AmountJson, TranslatedString } from "@gnu-taler/taler-util";
+import type { FlexibleForm, InternationalizationAPI } from 
"@gnu-taler/web-util/browser";
+import { AmlExchangeBackend } from "../utils/types.js";
+
+/**
+ * import entry point without hard reference.
+ * 
+ * This file just export types and UI Forms 
+ * based on what `globalThis` contiain.
+ * 
+ * `./index.js` must be imorted first before 
+ * so `globaThis` will have the correct value. 
+ */
+
+export interface BaseForm {
+  state: AmlExchangeBackend.AmlState;
+  threshold: AmountJson;
+}
+
+export type FormMetadata<T extends BaseForm> = {
+  label: TranslatedString,
+  id: string,
+  version: number,
+  impl: (current: T) => FlexibleForm<T>
+}
+
+interface LabelValue {
+  label: TranslatedString;
+  value: string,
+}
+
+export interface UiForms {
+  currencies: (i18n: InternationalizationAPI) => LabelValue[],
+  languages: (i18n: InternationalizationAPI) => LabelValue[],
+  forms: (i18n: InternationalizationAPI) => Array<FormMetadata<BaseForm>>,
+}
+
+/**
+ * Global settings for the UI.
+ */
+const defaultUIForms: UiForms = {
+  currencies: () => [],
+  languages: () => [],
+  forms: () => [],
+};
+
+declare global {
+  var amlExchangeBackoffice: UiForms;
+}
+
+export const uiForms: UiForms =
+  "amlExchangeBackoffice" in globalThis
+    ? (globalThis as any).amlExchangeBackoffice
+    : defaultUIForms;
diff --git a/packages/aml-backoffice-ui/src/forms/index.ts 
b/packages/aml-backoffice-ui/src/forms/index.ts
index c449bf467..f41122bc7 100644
--- a/packages/aml-backoffice-ui/src/forms/index.ts
+++ b/packages/aml-backoffice-ui/src/forms/index.ts
@@ -1,6 +1,4 @@
-import type { AmountJson, TranslatedString } from "@gnu-taler/taler-util";
-import type { AmlExchangeBackend } from "../utils/types.js";
-import type { FlexibleForm, InternationalizationAPI } from 
"@gnu-taler/web-util/browser";
+import type { InternationalizationAPI } from "@gnu-taler/web-util/browser";
 import { v1 as form_902_11e_v1 } from "./902_11e.js";
 import { v1 as form_902_12e_v1 } from "./902_12e.js";
 import { v1 as form_902_13e_v1 } from "./902_13e.js";
@@ -10,20 +8,7 @@ import { v1 as form_902_4e_v1 } from "./902_4e.js";
 import { v1 as form_902_5e_v1 } from "./902_5e.js";
 import { v1 as form_902_9e_v1 } from "./902_9e.js";
 import { v1 as simplest } from "./simplest.js";
-
-export interface BaseForm {
-  state: AmlExchangeBackend.AmlState;
-  threshold: AmountJson;
-}
-
-
-export type FormMetadata<T extends BaseForm> = {
-  label: TranslatedString,
-  id: string,
-  version: number,
-  impl: (current: T) => FlexibleForm<T>
-}
-
+import { BaseForm, FormMetadata } from "./declaration.js";
 
 const languages = (i18n: InternationalizationAPI) => [
   {
@@ -214,17 +199,4 @@ const currencies = (i18n: InternationalizationAPI) => [
   },
 ];
 
-interface AmlExchangeBackoffice {
-  currencies: typeof currencies,
-  languages: typeof languages,
-  forms: typeof forms,
-}
-declare global {
-  interface Window {
-    amlExchangeBackoffice?: AmlExchangeBackoffice;
-  }
-}
-
-if (typeof window !== "undefined" && !window.amlExchangeBackoffice) {
-  window.amlExchangeBackoffice = { currencies, languages, forms }
-}
+globalThis.amlExchangeBackoffice = { currencies, languages, forms }
diff --git a/packages/aml-backoffice-ui/src/forms/simplest.ts 
b/packages/aml-backoffice-ui/src/forms/simplest.ts
index 1561076df..735ca9bfc 100644
--- a/packages/aml-backoffice-ui/src/forms/simplest.ts
+++ b/packages/aml-backoffice-ui/src/forms/simplest.ts
@@ -3,7 +3,7 @@ import type {
 } from "@gnu-taler/taler-util";
 
 import type { DoubleColumnFormSection, FlexibleForm, FormState, 
InternationalizationAPI } from "@gnu-taler/web-util/browser";
-import { BaseForm } from "./index.js";
+import { BaseForm } from "./declaration.js";
 import { amlStateConverter } from "../utils/converter.js";
 import { AmlExchangeBackend } from "../utils/types.js";
 
diff --git a/packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx 
b/packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx
index 07ef0481a..aa1247d5f 100644
--- a/packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx
+++ b/packages/aml-backoffice-ui/src/pages/AntiMoneyLaunderingForm.tsx
@@ -2,13 +2,13 @@ import { AbsoluteTime, AmountJson, Amounts, Codec, 
OperationResult, buildCodecFo
 import { DefaultForm, useTranslationContext } from 
"@gnu-taler/web-util/browser";
 import { h } from "preact";
 import { useExchangeApiContext } from "../context/config.js";
-import { FormMetadata } from "../forms/index.js";
+import { FormMetadata, uiForms } from "../forms/declaration.js";
 import { Pages } from "../pages.js";
 import { AmlExchangeBackend } from "../utils/types.js";
 
 export function AntiMoneyLaunderingForm({ account, formId, onSubmit }: { 
account: string, formId: string, onSubmit: (justification: Justification, 
state: AmlExchangeBackend.AmlState, threshold: AmountJson) => Promise<void>; }) 
{
   const { i18n } = useTranslationContext()
-  const theForm = window.amlExchangeBackoffice!.forms(i18n).find((v) => v.id 
=== formId)
+  const theForm = uiForms.forms(i18n).find((v) => v.id === formId)
   if (!theForm) {
     return <div>form with id {formId} not found</div>
   }
diff --git a/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx 
b/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx
index 409124121..7f33dcb90 100644
--- a/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx
+++ b/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx
@@ -10,12 +10,13 @@ import { DefaultForm, ErrorLoading, 
InternationalizationAPI, Loading, useTransla
 import { format } from "date-fns";
 import { Fragment, VNode, h } from "preact";
 import { useState } from "preact/hooks";
-import { FormMetadata } from "../forms/index.js";
+import { FormMetadata } from "../forms/declaration.js";
 import { useCaseDetails } from "../hooks/useCaseDetails.js";
 import { Pages } from "../pages.js";
 import { Justification, parseJustification } from 
"./AntiMoneyLaunderingForm.js";
 import { ShowConsolidated } from "./ShowConsolidated.js";
 import { AmlExchangeBackend } from "../utils/types.js";
+import { uiForms } from "../forms/declaration.js";
 
 export type AmlEvent = AmlFormEvent | AmlFormEventError | KycCollectionEvent | 
KycExpirationEvent;
 type AmlFormEvent = {
@@ -72,11 +73,11 @@ function titleForJustification(op: ReturnType<typeof 
parseJustification>, i18n:
 export function getEventsFromAmlHistory(
   aml: AmlExchangeBackend.AmlDecisionDetail[],
   kyc: AmlExchangeBackend.KycDetail[],
+  i18n: InternationalizationAPI,
 ): AmlEvent[] {
-  const { i18n } = useTranslationContext()
   const ae: AmlEvent[] = aml.map((a) => {
 
-    const just = parseJustification(a.justification, 
window.amlExchangeBackoffice!.forms(i18n))
+    const just = parseJustification(a.justification, uiForms.forms(i18n))
     return {
       type: just.type === "ok" ? "aml-form" : "aml-form-error",
       state: a.new_state,
@@ -133,7 +134,7 @@ export function CaseDetails({ account }: { account: string 
}) {
   }
   const { aml_history, kyc_attributes } = details.body
 
-  const events = getEventsFromAmlHistory(aml_history, kyc_attributes);
+  const events = getEventsFromAmlHistory(aml_history, kyc_attributes, i18n);
 
   if (showForm !== undefined) {
     return <DefaultForm
diff --git a/packages/aml-backoffice-ui/src/pages/NewFormEntry.tsx 
b/packages/aml-backoffice-ui/src/pages/NewFormEntry.tsx
index fe82df089..4f9b909e0 100644
--- a/packages/aml-backoffice-ui/src/pages/NewFormEntry.tsx
+++ b/packages/aml-backoffice-ui/src/pages/NewFormEntry.tsx
@@ -6,6 +6,7 @@ import { useOfficer } from "../hooks/useOfficer.js";
 import { Pages } from "../pages.js";
 import { AntiMoneyLaunderingForm } from "./AntiMoneyLaunderingForm.js";
 import { HandleAccountNotReady } from "./HandleAccountNotReady.js";
+import { uiForms } from "../forms/declaration.js";
 
 export function NewFormEntry({
   account,
@@ -84,7 +85,7 @@ function SelectForm({ account }: { account: string }) {
   return (
     <div>
       <pre>New form for account: {account.substring(0, 16)}...</pre>
-      {window.amlExchangeBackoffice!.forms(i18n).map((form, idx) => {
+      {uiForms.forms(i18n).map((form, idx) => {
         return (
           <a
             href={Pages.newFormEntry.url({ account, type: form.id })}
diff --git a/packages/aml-backoffice-ui/src/pages/ShowConsolidated.stories.tsx 
b/packages/aml-backoffice-ui/src/pages/ShowConsolidated.stories.tsx
index dc073a5f5..f985e6ff5 100644
--- a/packages/aml-backoffice-ui/src/pages/ShowConsolidated.stories.tsx
+++ b/packages/aml-backoffice-ui/src/pages/ShowConsolidated.stories.tsx
@@ -26,13 +26,21 @@ import {
 import * as tests from "@gnu-taler/web-util/testing";
 import { getEventsFromAmlHistory } from "./CaseDetails.js";
 import { AbsoluteTime, Duration } from "@gnu-taler/taler-util";
+import { InternationalizationAPI } from "@gnu-taler/web-util/browser";
 
 export default {
   title: "show consolidated",
 };
 
+const nullTranslator: InternationalizationAPI = {
+  str: (str: any) => str,
+  singular: (str: any) => str,
+  translate: (str: any) => str,
+  Translate: (str: any) => str,
+}
+
 export const WithEmptyHistory = tests.createExample(TestedComponent, {
-  history: getEventsFromAmlHistory([], []),
+  history: getEventsFromAmlHistory([], [], nullTranslator),
   until: AbsoluteTime.now()
 });
 
@@ -101,7 +109,7 @@ export const WithSomeEvents = 
tests.createExample(TestedComponent, {
     attributes: {
       email: "sebasjm@qwdde.com"
     }
-  }]),
+  }], nullTranslator),
   until: AbsoluteTime.now()
 });
 

-- 
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]