[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant-backoffice] 01/02: testing
From: |
gnunet |
Subject: |
[taler-merchant-backoffice] 01/02: testing |
Date: |
Sun, 23 Oct 2022 18:11:15 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository merchant-backoffice.
commit 73235c4a0453ff393c5bf9b20bc9ccc1a90c70d5
Author: MS <ms@taler.net>
AuthorDate: Sun Oct 23 17:56:58 2022 +0200
testing
point development server to bank.demo.taler.net
---
packages/bank/README.md | 16 ++++++++++-
packages/bank/mocks/demo-window.js | 28 +++++++++++++++++++
packages/bank/package.json | 3 ++-
packages/bank/preact.mock.demo.js | 55 ++++++++++++++++++++++++++++++++++++++
4 files changed, 100 insertions(+), 2 deletions(-)
diff --git a/packages/bank/README.md b/packages/bank/README.md
index 73b2abb..233e4d7 100644
--- a/packages/bank/README.md
+++ b/packages/bank/README.md
@@ -1,5 +1,19 @@
# bank web
+## Testing at bank.demo.taler.net
+
+the command "pnpm dev-demo" mocks the 'window' object
+to address any request to the backend at bank.demo.taler.net,
+and launches the development server (see mocks/demo-window.js).
+
+Point your browser at localhost:9090, in order to get the
+SPA automatically compiled and loaded.
+
+Note: even if login/register/withdraw operations do reach
+the backend, the 'window' object as shown in the javascript
+console relates however to "localhost:9090" (FIXME).
+
+
## CLI Commands
- `npm install`: Installs dependencies
@@ -18,4 +32,4 @@
For detailed explanation on how things work, checkout the [CLI
Readme](https://github.com/developit/preact-cli/blob/master/README.md).
-It's worth noting that you may need to use Node.JS v12/14 on some builds of
Node.JS as webpack attempts to make MD4 hashes, which are unsupported in some
OpenSSL versions used by more modern NodeJS versions.
\ No newline at end of file
+It's worth noting that you may need to use Node.JS v12/14 on some builds of
Node.JS as webpack attempts to make MD4 hashes, which are unsupported in some
OpenSSL versions used by more modern NodeJS versions.
diff --git a/packages/bank/mocks/demo-window.js
b/packages/bank/mocks/demo-window.js
new file mode 100644
index 0000000..4400590
--- /dev/null
+++ b/packages/bank/mocks/demo-window.js
@@ -0,0 +1,28 @@
+Object.defineProperty(window, 'requestAnimationFrame', {
+ value: function(cb) {} // Silence the browser.
+})
+
+Object.defineProperty(window, 'localStorage', {
+ value: {
+ store: {},
+ getItem: function(key) {
+ return this.store[key];
+ },
+ setItem: function(key, value) {
+ return this.store[key] = value;
+ },
+ clear: function() {
+ this.store = {};
+ }
+ }
+});
+Object.defineProperty(window, 'location', {
+ value: {
+ origin: "https://bank.demo.taler.net",
+ search: "",
+ pathname: "/demobanks/default",
+ href: "https://bank.demo.taler.net/demobanks/default"
+ }
+})
+
+export default window;
diff --git a/packages/bank/package.json b/packages/bank/package.json
index cf59ff3..a44da5c 100644
--- a/packages/bank/package.json
+++ b/packages/bank/package.json
@@ -5,6 +5,7 @@
"license": "AGPL-3.0-OR-LATER",
"scripts": {
"dev": "preact watch --port ${PORT:=9090} --no-sw --no-esm -c
preact.mock.js",
+ "dev-demo": "preact watch --port ${PORT:=9090} --no-sw --no-esm -c
preact.mock.demo.js",
"build": "preact build --no-sw --no-esm -c preact.single-config.js --dest
build && sh remove-link-stylesheet.sh",
"serve": "sirv build --port ${PORT:=8080} --cors --single",
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
@@ -122,4 +123,4 @@
"<rootDir>/tests/__mocks__/setupTests.ts"
]
}
-}
\ No newline at end of file
+}
diff --git a/packages/bank/preact.mock.demo.js
b/packages/bank/preact.mock.demo.js
new file mode 100644
index 0000000..e58ef1d
--- /dev/null
+++ b/packages/bank/preact.mock.demo.js
@@ -0,0 +1,55 @@
+/*
+ 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 { DefinePlugin, ProvidePlugin } from 'webpack';
+
+import pack from './package.json';
+import * as cp from 'child_process';
+
+const commitHash = cp.execSync('git rev-parse --short HEAD').toString();
+import path from 'path';
+
+export default {
+ webpack(config, env, helpers) {
+ // Ensure that process.env will not be undefined at runtime.
+ config.node.process = 'mock'
+ let DEMO_SITES = {
+ "Blog": process.env.TALER_ENV_URL_MERCHANT_BLOG,
+ "Donations": process.env.TALER_ENV_URL_MERCHANT_DONATIONS,
+ "Survey": process.env.TALER_ENV_URL_MERCHANT_SURVEY,
+ "Landing": process.env.TALER_ENV_URL_INTRO,
+ "Bank": process.env.TALER_ENV_URL_BANK,
+ }
+ console.log("demo links found", DEMO_SITES);
+ // Add __VERSION__ to be use in the html.
+ config.plugins.push(
+ new DefinePlugin({
+ 'process.env.__VERSION__': JSON.stringify(env.isProd ? pack.version :
`dev-${commitHash}`) ,
+ }),
+ // 'window' gets mocked to point at a running euFin instance.
+ new ProvidePlugin({window: path.resolve("mocks/demo-window")}),
+ new DefinePlugin({"DEMO_SITES": JSON.stringify(DEMO_SITES)})
+ );
+
+ let { index } = helpers.getPluginsByName(config,
'WebpackFixStyleOnlyEntriesPlugin')[0]
+ config.plugins.splice(index, 1)
+ }
+}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.