tune up backend dependecies
This commit is contained in:
parent
0029013f8d
commit
fdbe5c12e9
@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of GNU Taler
|
|
||||||
(C) 2021 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/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Sebastian Javier Marchano (sebasjm)
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
"presets": [
|
|
||||||
"preact-cli/babel"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of GNU Taler
|
|
||||||
(C) 2021 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/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Sebastian Javier Marchano (sebasjm)
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
"stories": [
|
|
||||||
"../src/**/*.stories.mdx",
|
|
||||||
"../src/**/*.stories.@(js|jsx|ts|tsx)"
|
|
||||||
],
|
|
||||||
"addons": [
|
|
||||||
"@storybook/preset-scss",
|
|
||||||
"@storybook/addon-a11y",
|
|
||||||
"@storybook/addon-essentials" //docs, control, actions, viewpot, toolbar, background
|
|
||||||
],
|
|
||||||
// sb does not yet support new jsx transform by default
|
|
||||||
// https://github.com/storybookjs/storybook/issues/12881
|
|
||||||
// https://github.com/storybookjs/storybook/issues/12952
|
|
||||||
babel: async (options) => ({
|
|
||||||
...options,
|
|
||||||
presets: [
|
|
||||||
...options.presets,
|
|
||||||
[
|
|
||||||
'@babel/preset-react', {
|
|
||||||
runtime: 'automatic',
|
|
||||||
},
|
|
||||||
'preset-react-jsx-transform'
|
|
||||||
],
|
|
||||||
"@linaria",
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
webpackFinal: (config) => {
|
|
||||||
// should be removed after storybook 6.3
|
|
||||||
// https://github.com/storybookjs/storybook/issues/12853#issuecomment-821576113
|
|
||||||
config.resolve.alias = {
|
|
||||||
react: "preact/compat",
|
|
||||||
"react-dom": "preact/compat",
|
|
||||||
};
|
|
||||||
|
|
||||||
// we need to add @linaria loader AFTER the babel-loader
|
|
||||||
// https://github.com/callstack/linaria/blob/master/docs/BUNDLERS_INTEGRATION.md#webpack
|
|
||||||
config.module.rules[0] = {
|
|
||||||
...(config.module.rules[0]),
|
|
||||||
loader: undefined, // Disable the predefined babel-loader on the rule
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
...(config.module.rules[0].use[0]),
|
|
||||||
loader: 'babel-loader',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: '@linaria/webpack-loader',
|
|
||||||
options: {
|
|
||||||
sourceMap: true, //always true since this is dev
|
|
||||||
babelOptions: {
|
|
||||||
presets: config.module.rules[0].use[0].options.presets,
|
|
||||||
}
|
|
||||||
// Pass the current babel options to linaria's babel instance
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
return config;
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of GNU Taler
|
|
||||||
(C) 2021 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 { ConfigContextProvider } from '../src/context/config'
|
|
||||||
import { InstanceContextProvider } from '../src/context/instance'
|
|
||||||
import { TranslationProvider } from '../src/context/translation'
|
|
||||||
import { BackendContextProvider } from '../src/context/backend'
|
|
||||||
import { h } from 'preact';
|
|
||||||
|
|
||||||
const mockConfig = {
|
|
||||||
backendURL: 'http://demo.taler.net',
|
|
||||||
currency: 'TESTKUDOS'
|
|
||||||
}
|
|
||||||
|
|
||||||
const mockInstance = {
|
|
||||||
id: 'instance-id',
|
|
||||||
token: 'instance-token',
|
|
||||||
admin: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
const mockBackend = {
|
|
||||||
url: 'http://merchant.url',
|
|
||||||
token: 'default-token',
|
|
||||||
triedToLog: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
export const parameters = {
|
|
||||||
controls: { expanded: true },
|
|
||||||
// actions: { argTypesRegex: "^on.*" },
|
|
||||||
}
|
|
||||||
|
|
||||||
export const globalTypes = {
|
|
||||||
locale: {
|
|
||||||
name: 'Locale',
|
|
||||||
description: 'Internationalization locale',
|
|
||||||
defaultValue: 'en',
|
|
||||||
toolbar: {
|
|
||||||
icon: 'globe',
|
|
||||||
items: [
|
|
||||||
{ value: 'en', right: '🇺🇸', title: 'English' },
|
|
||||||
{ value: 'es', right: '🇪🇸', title: 'Spanish' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export const decorators = [
|
|
||||||
(Story, { globals }) => <TranslationProvider initial='en' forceLang={globals.locale}>
|
|
||||||
<Story />
|
|
||||||
</TranslationProvider>,
|
|
||||||
(Story) => <ConfigContextProvider value={mockConfig}>
|
|
||||||
<Story />
|
|
||||||
</ConfigContextProvider>,
|
|
||||||
(Story) => <InstanceContextProvider value={mockInstance}>
|
|
||||||
<Story />
|
|
||||||
</InstanceContextProvider>,
|
|
||||||
(Story) => <BackendContextProvider defaultUrl={mockBackend.url}>
|
|
||||||
<Story />
|
|
||||||
</BackendContextProvider>,
|
|
||||||
];
|
|
@ -1,21 +1,18 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "merchant-backend",
|
"name": "@gnu-taler/merchant-backend",
|
||||||
"version": "0.0.4",
|
"version": "0.0.5",
|
||||||
"license": "MIT",
|
"license": "AGPL-3.0-or-later",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"compile": "rollup -c",
|
||||||
"build": "rollup -c",
|
"build": "rollup -c",
|
||||||
"dev": "rollup -c -w",
|
"dev": "rollup -c -w",
|
||||||
"render-examples": "ts-node -O '{\"module\": \"commonjs\"}' -T render-examples.ts dist/pages dist/examples",
|
"render-examples": "ts-node -O '{\"module\": \"commonjs\"}' -T render-examples.ts dist/pages dist/examples",
|
||||||
"lint-check": "eslint '{src,tests}/**/*.{js,jsx,ts,tsx}'",
|
"lint-check": "eslint '{src,tests}/**/*.{js,jsx,ts,tsx}'",
|
||||||
"lint-fix": "eslint --fix '{src,tests}/**/*.{js,jsx,ts,tsx}'",
|
"lint-fix": "eslint --fix '{src,tests}/**/*.{js,jsx,ts,tsx}'",
|
||||||
"test": "jest ./tests",
|
|
||||||
"dev-test": "jest ./tests --watch",
|
|
||||||
"typedoc": "typedoc src",
|
"typedoc": "typedoc src",
|
||||||
"clean": "rimraf build storybook-static docs single dist",
|
"clean": "rimraf build docs single dist",
|
||||||
"serve-dist": "sirv --port ${PORT:=8080} --cors --single dist",
|
"serve-dist": "sirv --port ${PORT:=8080} --cors --single dist"
|
||||||
"build-storybook": "build-storybook",
|
|
||||||
"storybook": "start-storybook -p 6006"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12",
|
"node": ">=12",
|
||||||
@ -46,15 +43,14 @@
|
|||||||
"date-fns": "^2.21.1",
|
"date-fns": "^2.21.1",
|
||||||
"history": "4.10.1",
|
"history": "4.10.1",
|
||||||
"jed": "^1.1.1",
|
"jed": "^1.1.1",
|
||||||
"preact": "^10.5.13",
|
"preact": "10.11.3",
|
||||||
"preact-router": "^3.2.1",
|
"preact-router": "3.2.1",
|
||||||
"qrcode-generator": "^1.4.4",
|
"qrcode-generator": "^1.4.4",
|
||||||
"swr": "^0.5.5",
|
"swr": "^0.5.5",
|
||||||
"yup": "^0.32.9"
|
"yup": "^0.32.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "7.18.9",
|
"@babel/core": "7.18.9",
|
||||||
"@babel/plugin-transform-react-jsx-source": "7.18.6",
|
|
||||||
"@creativebulma/bulma-tooltip": "^1.2.0",
|
"@creativebulma/bulma-tooltip": "^1.2.0",
|
||||||
"@gnu-taler/pogen": "^0.0.5",
|
"@gnu-taler/pogen": "^0.0.5",
|
||||||
"@linaria/babel-preset": "3.0.0-beta.22",
|
"@linaria/babel-preset": "3.0.0-beta.22",
|
||||||
@ -70,75 +66,26 @@
|
|||||||
"@rollup/plugin-image": "^2.1.1",
|
"@rollup/plugin-image": "^2.1.1",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-replace": "^3.0.0",
|
"@rollup/plugin-replace": "^3.0.0",
|
||||||
"@rollup/plugin-typescript": "^8.2.5",
|
"@rollup/plugin-typescript": "11",
|
||||||
"@storybook/addon-a11y": "^6.2.9",
|
|
||||||
"@storybook/addon-actions": "^6.2.9",
|
|
||||||
"@storybook/addon-essentials": "^6.2.9",
|
|
||||||
"@storybook/addon-links": "^6.2.9",
|
|
||||||
"@storybook/preact": "^6.2.9",
|
|
||||||
"@storybook/preset-scss": "^1.0.3",
|
|
||||||
"@testing-library/preact": "^2.0.1",
|
|
||||||
"@testing-library/preact-hooks": "^1.1.0",
|
|
||||||
"@types/enzyme": "^3.10.8",
|
|
||||||
"@types/history": "^4.7.8",
|
"@types/history": "^4.7.8",
|
||||||
"@types/jest": "^26.0.23",
|
|
||||||
"@types/mocha": "^8.2.2",
|
"@types/mocha": "^8.2.2",
|
||||||
"@types/mustache": "^4.1.2",
|
"@types/mustache": "^4.1.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
||||||
"@typescript-eslint/parser": "^4.22.0",
|
"@typescript-eslint/parser": "^4.22.0",
|
||||||
"babel-loader": "^8.2.2",
|
"babel-loader": "^8.2.2",
|
||||||
"base64-inline-loader": "^1.1.1",
|
"base64-inline-loader": "^1.1.1",
|
||||||
"bulma": "^0.9.2",
|
|
||||||
"bulma-checkbox": "^1.1.1",
|
|
||||||
"bulma-radio": "^1.1.1",
|
|
||||||
"bulma-responsive-tables": "^1.2.3",
|
|
||||||
"bulma-switch-control": "^1.1.1",
|
|
||||||
"bulma-timeline": "^3.0.4",
|
|
||||||
"bulma-upload-control": "^1.2.0",
|
|
||||||
"dotenv": "^8.2.0",
|
|
||||||
"enzyme": "^3.11.0",
|
|
||||||
"enzyme-adapter-preact-pure": "^3.1.0",
|
|
||||||
"eslint": "^7.25.0",
|
"eslint": "^7.25.0",
|
||||||
"eslint-config-preact": "^1.1.4",
|
"eslint-config-preact": "^1.1.4",
|
||||||
"eslint-plugin-header": "^3.1.1",
|
"eslint-plugin-header": "^3.1.1",
|
||||||
"html-webpack-inline-chunk-plugin": "^1.1.1",
|
|
||||||
"html-webpack-inline-source-plugin": "0.0.10",
|
|
||||||
"html-webpack-skip-assets-plugin": "^1.0.1",
|
|
||||||
"inline-chunk-html-plugin": "^1.1.1",
|
|
||||||
"jest": "^26.6.3",
|
|
||||||
"jest-preset-preact": "^4.0.2",
|
|
||||||
"mustache": "^4.2.0",
|
"mustache": "^4.2.0",
|
||||||
"po2json": "^0.4.5",
|
"po2json": "^0.4.5",
|
||||||
"preact-cli": "^3.0.5",
|
|
||||||
"preact-render-to-json": "^3.6.6",
|
|
||||||
"preact-render-to-string": "^5.1.19",
|
"preact-render-to-string": "^5.1.19",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rollup": "^2.56.3",
|
"rollup": "^2.56.3",
|
||||||
"rollup-plugin-bundle-html": "^0.2.2",
|
"rollup-plugin-bundle-html": "^0.2.2",
|
||||||
"rollup-plugin-css-only": "^3.1.0",
|
"rollup-plugin-css-only": "^3.1.0",
|
||||||
"sass": "^1.32.13",
|
|
||||||
"sass-loader": "10.1.1",
|
|
||||||
"script-ext-html-webpack-plugin": "^2.1.5",
|
"script-ext-html-webpack-plugin": "^2.1.5",
|
||||||
"sirv-cli": "^1.0.11",
|
"sirv-cli": "^1.0.11",
|
||||||
"tslib": "^2.3.1",
|
"typescript": "4.8.4"
|
||||||
"typedoc": "^0.20.36",
|
|
||||||
"typescript": "^4.2.4"
|
|
||||||
},
|
|
||||||
"jest": {
|
|
||||||
"preset": "jest-preset-preact",
|
|
||||||
"transformIgnorePatterns": [
|
|
||||||
"node_modules/.pnpm/(?!(@gnu-taler\\+taler-util))",
|
|
||||||
"\\.pnp\\.[^\\/]+$"
|
|
||||||
],
|
|
||||||
"setupFiles": [
|
|
||||||
"<rootDir>/tests/__mocks__/browserMocks.ts",
|
|
||||||
"<rootDir>/tests/__mocks__/setupTests.ts"
|
|
||||||
],
|
|
||||||
"moduleNameMapper": {
|
|
||||||
"\\.(css|less)$": "identity-obj-proxy"
|
|
||||||
},
|
|
||||||
"transform": {
|
|
||||||
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|po)$": "<rootDir>/tests/__mocks__/fileTransformer.js"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,6 @@ import css from 'rollup-plugin-css-only';
|
|||||||
import html from '@rollup/plugin-html';
|
import html from '@rollup/plugin-html';
|
||||||
import commonjs from "@rollup/plugin-commonjs";
|
import commonjs from "@rollup/plugin-commonjs";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const template = async ({
|
const template = async ({
|
||||||
files,
|
files,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -15,18 +15,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Sebastian Javier Marchano (sebasjm)
|
* @author Sebastian Javier Marchano (sebasjm)
|
||||||
*/
|
*/
|
||||||
import { h, VNode } from 'preact';
|
import { h, VNode } from "preact";
|
||||||
import { FooterBar } from '../styled';
|
import { FooterBar } from "../styled/index.js";
|
||||||
|
|
||||||
export function Footer(): VNode {
|
export function Footer(): VNode {
|
||||||
return <FooterBar>
|
return (
|
||||||
|
<FooterBar>
|
||||||
<p>
|
<p>
|
||||||
<a href="https://taler.net/">Learn more about GNU Taler on our website.</a>
|
<a href="https://taler.net/">
|
||||||
|
Learn more about GNU Taler on our website.
|
||||||
|
</a>
|
||||||
<p>Copyright © 2014—2021 Taler Systems SA</p>
|
<p>Copyright © 2014—2021 Taler Systems SA</p>
|
||||||
</p>
|
</p>
|
||||||
</FooterBar>
|
</FooterBar>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,28 +14,41 @@
|
|||||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { h, VNode } from "preact";
|
import { h, VNode } from "preact";
|
||||||
import { useEffect, useRef } from "preact/hooks";
|
import { useEffect, useRef } from "preact/hooks";
|
||||||
import qrcode from "qrcode-generator";
|
import qrcode from "qrcode-generator";
|
||||||
|
|
||||||
export function createSVG(text:string):string {
|
export function createSVG(text: string): string {
|
||||||
const qr = qrcode(0, 'L');
|
const qr = qrcode(0, "L");
|
||||||
qr.addData(text);
|
qr.addData(text);
|
||||||
qr.make();
|
qr.make();
|
||||||
return qr.createSvgTag({
|
return qr.createSvgTag({
|
||||||
scalable: true,
|
scalable: true,
|
||||||
margin: 0
|
margin: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function QR({ text }: { text: string; }):VNode {
|
export function QR({ text }: { text: string }): VNode {
|
||||||
const divRef = useRef<HTMLDivElement>(null);
|
const divRef = useRef<HTMLDivElement>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
divRef.current.innerHTML = createSVG(text)
|
if (divRef.current) {
|
||||||
|
divRef.current.innerHTML = createSVG(text);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return <div style={{ width: '100%', display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
return (
|
||||||
<div style={{ width: '50%', minWidth: 200, maxWidth: 300 }} ref={divRef} />
|
<div
|
||||||
</div>;
|
style={{
|
||||||
}
|
width: "100%",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{ width: "50%", minWidth: 200, maxWidth: 300 }}
|
||||||
|
ref={divRef}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -209,7 +209,7 @@ export async function request<T>(url: string, options: RequestOptions = {}): Pro
|
|||||||
url,
|
url,
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
headers,
|
headers,
|
||||||
cancelToken: !removeAxiosCancelToken? source.token : undefined,
|
cancelToken: !removeAxiosCancelToken ? source.token : undefined,
|
||||||
method: options.method || 'get',
|
method: options.method || 'get',
|
||||||
data: options.data,
|
data: options.data,
|
||||||
params: options.params,
|
params: options.params,
|
||||||
@ -217,8 +217,10 @@ export async function request<T>(url: string, options: RequestOptions = {}): Pro
|
|||||||
})
|
})
|
||||||
return buildRequestOk<T>(res, url, !!options.token)
|
return buildRequestOk<T>(res, url, !!options.token)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const error = buildRequestFailed(e, url, !!options.token)
|
if (axios.isAxiosError(e)) {
|
||||||
throw error
|
throw buildRequestFailed(e, url, !!options.token)
|
||||||
|
}
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,30 +15,30 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Sebastian Javier Marchano (sebasjm)
|
* @author Sebastian Javier Marchano (sebasjm)
|
||||||
*/
|
*/
|
||||||
import { Fragment, h, render, VNode } from 'preact';
|
import { Fragment, h, render, VNode } from "preact";
|
||||||
import { render as renderToString } from 'preact-render-to-string';
|
import { render as renderToString } from "preact-render-to-string";
|
||||||
import { Footer } from '../components/Footer';
|
import { Footer } from "../components/Footer";
|
||||||
import "../css/pure-min.css";
|
import "../css/pure-min.css";
|
||||||
import "../css/style.css";
|
import "../css/style.css";
|
||||||
import { Page } from '../styled';
|
import { Page } from "../styled";
|
||||||
|
|
||||||
function Head(): VNode {
|
function Head(): VNode {
|
||||||
return <title>Status of your tip</title>
|
return <title>Status of your tip</title>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DepletedTip(): VNode {
|
export function DepletedTip(): VNode {
|
||||||
return <Page>
|
return (
|
||||||
|
<Page>
|
||||||
<section>
|
<section>
|
||||||
<h1>Tip already collected</h1>
|
<h1>Tip already collected</h1>
|
||||||
<div>
|
<div>You have already collected this tip.</div>
|
||||||
You have already collected this tip.
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
<Footer />
|
<Footer />
|
||||||
</Page>
|
</Page>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mount(): void {
|
export function mount(): void {
|
||||||
@ -52,9 +52,9 @@ export function mount(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildTimeRendering(): { head: string, body: string } {
|
export function buildTimeRendering(): { head: string; body: string } {
|
||||||
return {
|
return {
|
||||||
head: renderToString(<Head />),
|
head: renderToString(<Head />),
|
||||||
body: renderToString(<DepletedTip />)
|
body: renderToString(<DepletedTip />),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of GNU Taler
|
|
||||||
(C) 2021 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/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Sebastian Javier Marchano (sebasjm)
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Mock Browser API's which are not supported by JSDOM, e.g. ServiceWorker, LocalStorage
|
|
||||||
/**
|
|
||||||
* An example how to mock localStorage is given below 👇
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Mocks localStorage
|
|
||||||
const localStorageMock = (function() {
|
|
||||||
let store = {};
|
|
||||||
|
|
||||||
return {
|
|
||||||
getItem: (key) => store[key] || null,
|
|
||||||
setItem: (key, value) => store[key] = value.toString(),
|
|
||||||
clear: () => store = {}
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
||||||
Object.defineProperty(window, 'localStorage', {
|
|
||||||
value: localStorageMock
|
|
||||||
}); */
|
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of GNU Taler
|
|
||||||
(C) 2021 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/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Sebastian Javier Marchano (sebasjm)
|
|
||||||
*/
|
|
||||||
|
|
||||||
// This fixed an error related to the CSS and loading gif breaking my Jest test
|
|
||||||
// See https://facebook.github.io/jest/docs/en/webpack.html#handling-static-assets
|
|
||||||
export default 'test-file-stub';
|
|
@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of GNU Taler
|
|
||||||
(C) 2021 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/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Sebastian Javier Marchano (sebasjm)
|
|
||||||
*/
|
|
||||||
// fileTransformer.js
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
process(src, filename, config, options) {
|
|
||||||
return `module.exports = ${ JSON.stringify(path.basename(filename)) };`;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of GNU Taler
|
|
||||||
(C) 2021 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/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Sebastian Javier Marchano (sebasjm)
|
|
||||||
*/
|
|
||||||
|
|
||||||
import 'regenerator-runtime/runtime'
|
|
||||||
import { configure } from 'enzyme';
|
|
||||||
import Adapter from 'enzyme-adapter-preact-pure';
|
|
||||||
|
|
||||||
configure({
|
|
||||||
adapter: new Adapter()
|
|
||||||
});
|
|
@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of GNU Taler
|
|
||||||
(C) 2021 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/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Sebastian Javier Marchano (sebasjm)
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { AMOUNT_REGEX, PAYTO_REGEX } from "../../src/utils/constants";
|
|
||||||
|
|
||||||
describe('payto uri format', () => {
|
|
||||||
const valids = [
|
|
||||||
'payto://iban/DE75512108001245126199?amount=EUR:200.0&message=hello',
|
|
||||||
'payto://ach/122000661/1234',
|
|
||||||
'payto://upi/alice@example.com?receiver-name=Alice&amount=INR:200',
|
|
||||||
'payto://void/?amount=EUR:10.5',
|
|
||||||
'payto://ilp/g.acme.bob'
|
|
||||||
]
|
|
||||||
|
|
||||||
test('should be valid', () => {
|
|
||||||
valids.forEach(v => expect(v).toMatch(PAYTO_REGEX))
|
|
||||||
});
|
|
||||||
|
|
||||||
const invalids = [
|
|
||||||
// has two question marks
|
|
||||||
'payto://iban/DE75?512108001245126199?amount=EUR:200.0&message=hello',
|
|
||||||
// has a space
|
|
||||||
'payto://ach /122000661/1234',
|
|
||||||
// has a space
|
|
||||||
'payto://upi/alice@ example.com?receiver-name=Alice&amount=INR:200',
|
|
||||||
// invalid field name (mount instead of amount)
|
|
||||||
'payto://void/?mount=EUR:10.5',
|
|
||||||
// payto:// is incomplete
|
|
||||||
'payto: //ilp/g.acme.bob'
|
|
||||||
]
|
|
||||||
|
|
||||||
test('should not be valid', () => {
|
|
||||||
invalids.forEach(v => expect(v).not.toMatch(PAYTO_REGEX))
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('amount format', () => {
|
|
||||||
const valids = [
|
|
||||||
'ARS:10',
|
|
||||||
'COL:10.2',
|
|
||||||
'UY:1,000.2',
|
|
||||||
'ARS:10.123,123',
|
|
||||||
'ARS:1,000,000',
|
|
||||||
'ARSCOL:10',
|
|
||||||
'THISISTHEMOTHERCOIN:1,000,000.123,123',
|
|
||||||
]
|
|
||||||
|
|
||||||
test('should be valid', () => {
|
|
||||||
valids.forEach(v => expect(v).toMatch(AMOUNT_REGEX))
|
|
||||||
});
|
|
||||||
|
|
||||||
const invalids = [
|
|
||||||
//no currency name
|
|
||||||
':10',
|
|
||||||
//use . instead of ,
|
|
||||||
'ARS:1.000.000',
|
|
||||||
//currency name with numbers
|
|
||||||
'1ARS:10',
|
|
||||||
//currency name with numbers
|
|
||||||
'AR5:10',
|
|
||||||
//missing value
|
|
||||||
'USD:',
|
|
||||||
]
|
|
||||||
|
|
||||||
test('should not be valid', () => {
|
|
||||||
invalids.forEach(v => expect(v).not.toMatch(AMOUNT_REGEX))
|
|
||||||
});
|
|
||||||
|
|
||||||
})
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of GNU Taler
|
|
||||||
(C) 2021 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/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Sebastian Javier Marchano (sebasjm)
|
|
||||||
*/
|
|
||||||
import * as axios from 'axios';
|
|
||||||
|
|
||||||
type Query<Req, Res> = (GetQuery | PostQuery | DeleteQuery | PatchQuery) & RequestResponse<Req, Res>
|
|
||||||
|
|
||||||
interface RequestResponse<Req, Res> {
|
|
||||||
request?: Req,
|
|
||||||
params?: any,
|
|
||||||
response?: Res,
|
|
||||||
}
|
|
||||||
interface GetQuery { get: string }
|
|
||||||
interface PostQuery { post: string }
|
|
||||||
interface DeleteQuery { delete: string }
|
|
||||||
interface PatchQuery { patch: string }
|
|
||||||
|
|
||||||
export function simulateBackendResponse<R, T>(query: Query<R, T>): void {
|
|
||||||
(axios.default as jest.MockedFunction<axios.AxiosStatic>).mockImplementationOnce(function (opt?: axios.AxiosRequestConfig): axios.AxiosPromise {
|
|
||||||
// console.log(opt, JSON.stringify(query,undefined,2))
|
|
||||||
expect(opt).toBeDefined();
|
|
||||||
if (!opt)
|
|
||||||
return Promise.reject();
|
|
||||||
|
|
||||||
// expect(query.request).toStrictEqual(opt.data);
|
|
||||||
// expect(query.params).toStrictEqual(opt.params);
|
|
||||||
if ('get' in query) {
|
|
||||||
expect(opt.method).toBe('get');
|
|
||||||
expect(opt.url).toBe(query.get);
|
|
||||||
}
|
|
||||||
if ('post' in query) {
|
|
||||||
expect(opt.method).toBe('post');
|
|
||||||
expect(opt.url).toBe(query.post);
|
|
||||||
}
|
|
||||||
if ('delete' in query) {
|
|
||||||
expect(opt.method).toBe('delete');
|
|
||||||
expect(opt.url).toBe(query.delete);
|
|
||||||
}
|
|
||||||
if ('patch' in query) {
|
|
||||||
expect(opt.method).toBe('patch');
|
|
||||||
expect(opt.url).toBe(query.patch);
|
|
||||||
}
|
|
||||||
return ({ data: query.response, config: {} } as any);
|
|
||||||
} as any)
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"composite": true,
|
|
||||||
"lib": ["es6", "DOM"],
|
|
||||||
"jsx": "react",
|
|
||||||
"jsxFactory": "h",
|
|
||||||
"jsxFragmentFactory": "Fragment",
|
|
||||||
"moduleResolution": "Node",
|
|
||||||
"module": "ESNext",
|
|
||||||
"target": "ES6",
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"noEmitOnError": true,
|
|
||||||
"strict": true,
|
|
||||||
"incremental": true,
|
|
||||||
"sourceMap": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"importHelpers": true,
|
|
||||||
"rootDir": "./src",
|
|
||||||
"typeRoots": ["./node_modules/@types"]
|
|
||||||
},
|
|
||||||
"include": ["src/**/*"]
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user