@alphapoint/apex-web 5.5.6 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/2FA/TwoFactorAuthContainer.js +58 -24
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +215 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.css +6 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.js +6 -2
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.test.js +43 -0
- package/lib/components/AccountsDropdown/AccountsDropdownContainer.js +3 -1
- package/lib/components/BalancesList/BalancesListContainer.js +4 -1
- package/lib/components/DigitalAssets/digitalAssetsPriceLabel.test.js +238 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +7 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +105 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +12 -1
- package/lib/components/InstrumentPositions/InstrumentPositionsContainer.js +4 -1
- package/lib/components/MarginBalances/MarginDepositWithdraw/MarginDepositModal/MarginDepositFormContainer.js +2 -1
- package/lib/components/NoAccountBanner/NoAccountBanner.css +9 -0
- package/lib/components/NoAccountBanner/NoAccountBanner.js +58 -0
- package/lib/components/NoAccountBanner/index.js +16 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.css +31 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.js +33 -0
- package/lib/components/NoAccountPlaceholder/index.js +9 -0
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +12 -4
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +246 -0
- package/lib/components/common/ErrorBoundary/ErrorBoundary.css +35 -0
- package/lib/components/common/ErrorBoundary/ErrorBoundary.js +87 -0
- package/lib/helpers/errorTextFormatter.js +13 -4
- package/lib/helpers/errorTextFormatter.test.js +26 -0
- package/lib/helpers/twoFactorAuthCancellation.js +38 -0
- package/lib/hocs/forAccount.js +33 -0
- package/lib/hocs/forAccount.test.js +50 -0
- package/lib/hocs/forVerified.js +16 -2
- package/lib/hocs/withAuthentication.js +3 -1
- package/lib/index.js +3 -2
- package/lib/layouts/HeaderLayout/HeaderLayout.js +2 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.js +3 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.test.js +84 -0
- package/lib/redux/actions/apiActions.js +25 -8
- package/lib/redux/actions/apiActions.test.js +98 -0
- package/lib/redux/actions/interestAccountActions.js +12 -3
- package/lib/redux/actions/interestAccountActions.test.js +73 -0
- package/lib/redux/actions/orderHistoryActions.js +11 -4
- package/lib/redux/actions/userActions.js +97 -34
- package/lib/redux/actions/userActions.test.js +303 -188
- package/lib/redux/actions/withdrawActions.js +62 -29
- package/lib/redux/actions/withdrawActions.test.js +246 -73
- package/lib/redux/actions/withdrawActions.travelRule.test.js +17 -3
- package/lib/redux/reducers/userReducer.js +10 -0
- package/lib/redux/reducers/userReducer.test.js +29 -0
- package/lib/redux/selectors/recentActivitySelector.js +8 -2
- package/lib/redux/selectors/recentActivitySelector.v2.test.js +33 -0
- package/lib/redux/selectors/userSelectors.js +6 -1
- package/lib/redux/selectors/userSelectors.test.js +28 -0
- package/package.json +4 -4
|
@@ -7,6 +7,7 @@ var actions = _interopRequireWildcard(require("./withdrawActions"));
|
|
|
7
7
|
var apiActions = _interopRequireWildcard(require("./apiActions"));
|
|
8
8
|
var snackbarActions = _interopRequireWildcard(require("./snackbarActions"));
|
|
9
9
|
var _withdrawSubscriptionService = _interopRequireDefault(require("../../services/subscriptions/withdrawSubscriptionService"));
|
|
10
|
+
var _twoFactorAuthCancellation = require("../../helpers/twoFactorAuthCancellation");
|
|
10
11
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
13
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
@@ -15,14 +16,19 @@ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.
|
|
|
15
16
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
16
17
|
jest.mock('./apiActions', function () {
|
|
17
18
|
var returnValue = {};
|
|
19
|
+
var rejection = null;
|
|
18
20
|
return {
|
|
19
21
|
callAPI: jest.fn(function () {
|
|
20
22
|
return function () {
|
|
21
|
-
return Promise.resolve(returnValue);
|
|
23
|
+
return rejection ? Promise.reject(rejection) : Promise.resolve(returnValue);
|
|
22
24
|
};
|
|
23
25
|
}),
|
|
24
26
|
setReturnValue: function setReturnValue(value) {
|
|
25
27
|
returnValue = value;
|
|
28
|
+
rejection = null;
|
|
29
|
+
},
|
|
30
|
+
setRejection: function setRejection(error) {
|
|
31
|
+
rejection = error;
|
|
26
32
|
}
|
|
27
33
|
};
|
|
28
34
|
});
|
|
@@ -338,6 +344,8 @@ describe('withdrawActions', function () {
|
|
|
338
344
|
}),
|
|
339
345
|
TemplateType: 'Standard',
|
|
340
346
|
AccountProviderId: 1
|
|
347
|
+
}, {
|
|
348
|
+
rejectOnCancel: true
|
|
341
349
|
});
|
|
342
350
|
});
|
|
343
351
|
it('should show a snackbar with error message if request fails', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
@@ -359,9 +367,127 @@ describe('withdrawActions', function () {
|
|
|
359
367
|
}
|
|
360
368
|
}, _callee9);
|
|
361
369
|
})));
|
|
362
|
-
it('
|
|
363
|
-
|
|
364
|
-
|
|
370
|
+
it.each([['a 2FA refusal without result', {
|
|
371
|
+
Authenticated: false,
|
|
372
|
+
errormsg: 'two-factor authentication is not enabled'
|
|
373
|
+
}], ['an empty object', {}], ['a null reply', null]])('shows a rejection and adds no ticket when the response is %s', /*#__PURE__*/function () {
|
|
374
|
+
var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(_label, reply) {
|
|
375
|
+
return _regenerator().w(function (_context0) {
|
|
376
|
+
while (1) switch (_context0.n) {
|
|
377
|
+
case 0:
|
|
378
|
+
apiActions.setReturnValue(reply);
|
|
379
|
+
_context0.n = 1;
|
|
380
|
+
return store.dispatch(actions.createWithdrawTicket({
|
|
381
|
+
ProductId: 1,
|
|
382
|
+
Amount: 100
|
|
383
|
+
}));
|
|
384
|
+
case 1:
|
|
385
|
+
expect(snackbarActions.showSnack).toHaveBeenCalledWith(expect.objectContaining({
|
|
386
|
+
id: 'withdrawRejectSnack',
|
|
387
|
+
type: 'warning'
|
|
388
|
+
}));
|
|
389
|
+
expect(snackbarActions.showSnack).not.toHaveBeenCalledWith(expect.objectContaining({
|
|
390
|
+
id: 'withdrawSuccessSnack'
|
|
391
|
+
}));
|
|
392
|
+
expect(store.getActions()).not.toContainEqual(expect.objectContaining({
|
|
393
|
+
type: actions.RECEIVE_WITHDRAW_TICKET
|
|
394
|
+
}));
|
|
395
|
+
expect(apiActions.callAPI).not.toHaveBeenCalledWith('GetWithdrawTickets', expect.any(Object));
|
|
396
|
+
case 2:
|
|
397
|
+
return _context0.a(2);
|
|
398
|
+
}
|
|
399
|
+
}, _callee0);
|
|
400
|
+
}));
|
|
401
|
+
return function (_x, _x2) {
|
|
402
|
+
return _ref0.apply(this, arguments);
|
|
403
|
+
};
|
|
404
|
+
}());
|
|
405
|
+
it('shows the success confirmation and no rejection for a confirmed success', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
406
|
+
return _regenerator().w(function (_context1) {
|
|
407
|
+
while (1) switch (_context1.n) {
|
|
408
|
+
case 0:
|
|
409
|
+
apiActions.setReturnValue({
|
|
410
|
+
result: true,
|
|
411
|
+
detail: '123456789'
|
|
412
|
+
});
|
|
413
|
+
_context1.n = 1;
|
|
414
|
+
return store.dispatch(actions.createWithdrawTicket({
|
|
415
|
+
ProductId: 1,
|
|
416
|
+
Amount: 100
|
|
417
|
+
}));
|
|
418
|
+
case 1:
|
|
419
|
+
expect(snackbarActions.showSnack).toHaveBeenCalledWith(expect.objectContaining({
|
|
420
|
+
id: 'withdrawSuccessSnack',
|
|
421
|
+
type: 'success'
|
|
422
|
+
}));
|
|
423
|
+
expect(snackbarActions.showSnack).not.toHaveBeenCalledWith(expect.objectContaining({
|
|
424
|
+
id: 'withdrawRejectSnack'
|
|
425
|
+
}));
|
|
426
|
+
case 2:
|
|
427
|
+
return _context1.a(2);
|
|
428
|
+
}
|
|
429
|
+
}, _callee1);
|
|
430
|
+
})));
|
|
431
|
+
it('shows nothing and adds no ticket when the user dismisses the 2FA modal', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
432
|
+
return _regenerator().w(function (_context10) {
|
|
433
|
+
while (1) switch (_context10.n) {
|
|
434
|
+
case 0:
|
|
435
|
+
apiActions.setRejection(new _twoFactorAuthCancellation.TwoFactorAuthCancelledError());
|
|
436
|
+
_context10.n = 1;
|
|
437
|
+
return store.dispatch(actions.createWithdrawTicket({
|
|
438
|
+
ProductId: 1,
|
|
439
|
+
Amount: 100
|
|
440
|
+
}));
|
|
441
|
+
case 1:
|
|
442
|
+
expect(snackbarActions.showSnack).not.toHaveBeenCalled();
|
|
443
|
+
expect(store.getActions()).not.toContainEqual(expect.objectContaining({
|
|
444
|
+
type: actions.RECEIVE_WITHDRAW_TICKET
|
|
445
|
+
}));
|
|
446
|
+
case 2:
|
|
447
|
+
return _context10.a(2);
|
|
448
|
+
}
|
|
449
|
+
}, _callee10);
|
|
450
|
+
})));
|
|
451
|
+
it('rethrows errors that are not a 2FA dismissal', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
452
|
+
return _regenerator().w(function (_context11) {
|
|
453
|
+
while (1) switch (_context11.n) {
|
|
454
|
+
case 0:
|
|
455
|
+
apiActions.setRejection(new Error('socket closed'));
|
|
456
|
+
_context11.n = 1;
|
|
457
|
+
return expect(store.dispatch(actions.createWithdrawTicket({
|
|
458
|
+
ProductId: 1,
|
|
459
|
+
Amount: 100
|
|
460
|
+
}))).rejects.toThrow('socket closed');
|
|
461
|
+
case 1:
|
|
462
|
+
return _context11.a(2);
|
|
463
|
+
}
|
|
464
|
+
}, _callee11);
|
|
465
|
+
})));
|
|
466
|
+
it('shows the backend message for a 2FA refusal', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
467
|
+
return _regenerator().w(function (_context12) {
|
|
468
|
+
while (1) switch (_context12.n) {
|
|
469
|
+
case 0:
|
|
470
|
+
apiActions.setReturnValue({
|
|
471
|
+
Authenticated: false,
|
|
472
|
+
errormsg: 'two-factor authentication is not enabled'
|
|
473
|
+
});
|
|
474
|
+
_context12.n = 1;
|
|
475
|
+
return store.dispatch(actions.createWithdrawTicket({
|
|
476
|
+
ProductId: 1,
|
|
477
|
+
Amount: 100
|
|
478
|
+
}));
|
|
479
|
+
case 1:
|
|
480
|
+
expect(snackbarActions.showSnack).toHaveBeenCalledWith(expect.objectContaining({
|
|
481
|
+
text: 'two-factor authentication is not enabled'
|
|
482
|
+
}));
|
|
483
|
+
case 2:
|
|
484
|
+
return _context12.a(2);
|
|
485
|
+
}
|
|
486
|
+
}, _callee12);
|
|
487
|
+
})));
|
|
488
|
+
it('should dispatch RECEIVE_WITHDRAW_WORKFLOW_INFO action if withdraw workflow data comes back in the response', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
489
|
+
return _regenerator().w(function (_context13) {
|
|
490
|
+
while (1) switch (_context13.n) {
|
|
365
491
|
case 0:
|
|
366
492
|
apiActions.setReturnValue({
|
|
367
493
|
result: true,
|
|
@@ -370,7 +496,7 @@ describe('withdrawActions', function () {
|
|
|
370
496
|
URL: 'http://localhost'
|
|
371
497
|
})
|
|
372
498
|
});
|
|
373
|
-
|
|
499
|
+
_context13.n = 1;
|
|
374
500
|
return store.dispatch(actions.createWithdrawTicket({
|
|
375
501
|
ProductId: 1,
|
|
376
502
|
Amount: 100
|
|
@@ -384,13 +510,13 @@ describe('withdrawActions', function () {
|
|
|
384
510
|
}
|
|
385
511
|
});
|
|
386
512
|
case 2:
|
|
387
|
-
return
|
|
513
|
+
return _context13.a(2);
|
|
388
514
|
}
|
|
389
|
-
},
|
|
515
|
+
}, _callee13);
|
|
390
516
|
})));
|
|
391
|
-
it('should dispatch CLOSE_SIDE_PANE action when request returns response with null values', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
392
|
-
return _regenerator().w(function (
|
|
393
|
-
while (1) switch (
|
|
517
|
+
it('should dispatch CLOSE_SIDE_PANE action when request returns response with null values', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
518
|
+
return _regenerator().w(function (_context14) {
|
|
519
|
+
while (1) switch (_context14.n) {
|
|
394
520
|
case 0:
|
|
395
521
|
apiActions.setReturnValue({
|
|
396
522
|
result: true,
|
|
@@ -399,7 +525,7 @@ describe('withdrawActions', function () {
|
|
|
399
525
|
URL: null
|
|
400
526
|
})
|
|
401
527
|
});
|
|
402
|
-
|
|
528
|
+
_context14.n = 1;
|
|
403
529
|
return store.dispatch(actions.createWithdrawTicket({
|
|
404
530
|
ProductId: 1,
|
|
405
531
|
Amount: 100
|
|
@@ -410,13 +536,13 @@ describe('withdrawActions', function () {
|
|
|
410
536
|
payload: 'Withdraws'
|
|
411
537
|
});
|
|
412
538
|
case 2:
|
|
413
|
-
return
|
|
539
|
+
return _context14.a(2);
|
|
414
540
|
}
|
|
415
|
-
},
|
|
541
|
+
}, _callee14);
|
|
416
542
|
})));
|
|
417
|
-
it('should dispatch CLOSE_SIDE_PANE action when request returns response with ReplyObject === 0', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
418
|
-
return _regenerator().w(function (
|
|
419
|
-
while (1) switch (
|
|
543
|
+
it('should dispatch CLOSE_SIDE_PANE action when request returns response with ReplyObject === 0', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
544
|
+
return _regenerator().w(function (_context15) {
|
|
545
|
+
while (1) switch (_context15.n) {
|
|
420
546
|
case 0:
|
|
421
547
|
apiActions.setReturnValue({
|
|
422
548
|
result: true,
|
|
@@ -425,7 +551,7 @@ describe('withdrawActions', function () {
|
|
|
425
551
|
URL: null
|
|
426
552
|
})
|
|
427
553
|
});
|
|
428
|
-
|
|
554
|
+
_context15.n = 1;
|
|
429
555
|
return store.dispatch(actions.createWithdrawTicket({
|
|
430
556
|
ProductId: 1,
|
|
431
557
|
Amount: 100
|
|
@@ -436,19 +562,19 @@ describe('withdrawActions', function () {
|
|
|
436
562
|
payload: 'Withdraws'
|
|
437
563
|
});
|
|
438
564
|
case 2:
|
|
439
|
-
return
|
|
565
|
+
return _context15.a(2);
|
|
440
566
|
}
|
|
441
|
-
},
|
|
567
|
+
}, _callee15);
|
|
442
568
|
})));
|
|
443
|
-
it('should dispatch CLOSE_SIDE_PANE action when request returns standard response', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
444
|
-
return _regenerator().w(function (
|
|
445
|
-
while (1) switch (
|
|
569
|
+
it('should dispatch CLOSE_SIDE_PANE action when request returns standard response', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
|
|
570
|
+
return _regenerator().w(function (_context16) {
|
|
571
|
+
while (1) switch (_context16.n) {
|
|
446
572
|
case 0:
|
|
447
573
|
apiActions.setReturnValue({
|
|
448
574
|
result: true,
|
|
449
575
|
detail: '123456789'
|
|
450
576
|
});
|
|
451
|
-
|
|
577
|
+
_context16.n = 1;
|
|
452
578
|
return store.dispatch(actions.createWithdrawTicket({
|
|
453
579
|
ProductId: 1,
|
|
454
580
|
Amount: 100
|
|
@@ -459,19 +585,19 @@ describe('withdrawActions', function () {
|
|
|
459
585
|
payload: 'Withdraws'
|
|
460
586
|
});
|
|
461
587
|
case 2:
|
|
462
|
-
return
|
|
588
|
+
return _context16.a(2);
|
|
463
589
|
}
|
|
464
|
-
},
|
|
590
|
+
}, _callee16);
|
|
465
591
|
})));
|
|
466
|
-
it('should dispatch RECEIVE_WITHDRAW_TICKET action with expected params when successful', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
467
|
-
return _regenerator().w(function (
|
|
468
|
-
while (1) switch (
|
|
592
|
+
it('should dispatch RECEIVE_WITHDRAW_TICKET action with expected params when successful', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
593
|
+
return _regenerator().w(function (_context17) {
|
|
594
|
+
while (1) switch (_context17.n) {
|
|
469
595
|
case 0:
|
|
470
596
|
apiActions.setReturnValue({
|
|
471
597
|
result: true,
|
|
472
598
|
detail: '123456789'
|
|
473
599
|
});
|
|
474
|
-
|
|
600
|
+
_context17.n = 1;
|
|
475
601
|
return store.dispatch(actions.createWithdrawTicket({
|
|
476
602
|
ProductId: 1,
|
|
477
603
|
Amount: 100
|
|
@@ -485,19 +611,19 @@ describe('withdrawActions', function () {
|
|
|
485
611
|
}
|
|
486
612
|
});
|
|
487
613
|
case 2:
|
|
488
|
-
return
|
|
614
|
+
return _context17.a(2);
|
|
489
615
|
}
|
|
490
|
-
},
|
|
616
|
+
}, _callee17);
|
|
491
617
|
})));
|
|
492
|
-
it('should call GetWithdrawTickets via callAPI with expected params if successful', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
493
|
-
return _regenerator().w(function (
|
|
494
|
-
while (1) switch (
|
|
618
|
+
it('should call GetWithdrawTickets via callAPI with expected params if successful', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
|
|
619
|
+
return _regenerator().w(function (_context18) {
|
|
620
|
+
while (1) switch (_context18.n) {
|
|
495
621
|
case 0:
|
|
496
622
|
apiActions.setReturnValue({
|
|
497
623
|
result: true,
|
|
498
624
|
detail: '123456789'
|
|
499
625
|
});
|
|
500
|
-
|
|
626
|
+
_context18.n = 1;
|
|
501
627
|
return store.dispatch(actions.createWithdrawTicket({
|
|
502
628
|
ProductId: 1,
|
|
503
629
|
Amount: 100
|
|
@@ -509,20 +635,20 @@ describe('withdrawActions', function () {
|
|
|
509
635
|
StartIndex: 0
|
|
510
636
|
});
|
|
511
637
|
case 2:
|
|
512
|
-
return
|
|
638
|
+
return _context18.a(2);
|
|
513
639
|
}
|
|
514
|
-
},
|
|
640
|
+
}, _callee18);
|
|
515
641
|
})));
|
|
516
642
|
});
|
|
517
643
|
describe('cancelWithdrawTicket', function () {
|
|
518
|
-
it('should dispatch expected actions if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
519
|
-
return _regenerator().w(function (
|
|
520
|
-
while (1) switch (
|
|
644
|
+
it('should dispatch expected actions if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
|
|
645
|
+
return _regenerator().w(function (_context19) {
|
|
646
|
+
while (1) switch (_context19.n) {
|
|
521
647
|
case 0:
|
|
522
648
|
apiActions.setReturnValue({
|
|
523
649
|
result: true
|
|
524
650
|
});
|
|
525
|
-
|
|
651
|
+
_context19.n = 1;
|
|
526
652
|
return store.dispatch(actions.cancelWithdrawTicket({
|
|
527
653
|
RequestCode: 1
|
|
528
654
|
}));
|
|
@@ -532,43 +658,90 @@ describe('withdrawActions', function () {
|
|
|
532
658
|
UserId: 1,
|
|
533
659
|
AccountId: 1,
|
|
534
660
|
RequestCode: 1
|
|
661
|
+
}, {
|
|
662
|
+
rejectOnCancel: true
|
|
535
663
|
});
|
|
536
664
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
537
665
|
expect(apiActions.callAPI).toHaveBeenCalledWith('GetWithdrawTickets', expect.any(Object));
|
|
538
666
|
case 2:
|
|
539
|
-
return
|
|
667
|
+
return _context19.a(2);
|
|
540
668
|
}
|
|
541
|
-
},
|
|
669
|
+
}, _callee19);
|
|
542
670
|
})));
|
|
543
|
-
it('should dispatch expected actions if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
544
|
-
return _regenerator().w(function (
|
|
545
|
-
while (1) switch (
|
|
671
|
+
it('should dispatch expected actions if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
|
|
672
|
+
return _regenerator().w(function (_context20) {
|
|
673
|
+
while (1) switch (_context20.n) {
|
|
546
674
|
case 0:
|
|
547
675
|
apiActions.setReturnValue({
|
|
548
676
|
result: false
|
|
549
677
|
});
|
|
550
|
-
|
|
678
|
+
_context20.n = 1;
|
|
551
679
|
return store.dispatch(actions.cancelWithdrawTicket({
|
|
552
680
|
RequestCode: 1
|
|
553
681
|
}));
|
|
554
682
|
case 1:
|
|
555
683
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
556
684
|
case 2:
|
|
557
|
-
return
|
|
685
|
+
return _context20.a(2);
|
|
558
686
|
}
|
|
559
|
-
},
|
|
687
|
+
}, _callee20);
|
|
688
|
+
})));
|
|
689
|
+
it.each([['a 2FA refusal without result', {
|
|
690
|
+
Authenticated: false,
|
|
691
|
+
errormsg: 'two-factor authentication is not enabled'
|
|
692
|
+
}], ['an empty object', {}], ['a null reply', null]])('shows a rejection and does not refetch when the response is %s', /*#__PURE__*/function () {
|
|
693
|
+
var _ref21 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(_label, reply) {
|
|
694
|
+
return _regenerator().w(function (_context21) {
|
|
695
|
+
while (1) switch (_context21.n) {
|
|
696
|
+
case 0:
|
|
697
|
+
apiActions.setReturnValue(reply);
|
|
698
|
+
_context21.n = 1;
|
|
699
|
+
return store.dispatch(actions.cancelWithdrawTicket({
|
|
700
|
+
RequestCode: 1
|
|
701
|
+
}));
|
|
702
|
+
case 1:
|
|
703
|
+
expect(snackbarActions.showSnack).toHaveBeenCalledWith(expect.objectContaining({
|
|
704
|
+
id: 'cancelWithdrawSnack',
|
|
705
|
+
type: 'warning'
|
|
706
|
+
}));
|
|
707
|
+
expect(apiActions.callAPI).not.toHaveBeenCalledWith('GetWithdrawTickets', expect.any(Object));
|
|
708
|
+
case 2:
|
|
709
|
+
return _context21.a(2);
|
|
710
|
+
}
|
|
711
|
+
}, _callee21);
|
|
712
|
+
}));
|
|
713
|
+
return function (_x3, _x4) {
|
|
714
|
+
return _ref21.apply(this, arguments);
|
|
715
|
+
};
|
|
716
|
+
}());
|
|
717
|
+
it('shows nothing when the user dismisses the 2FA modal', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22() {
|
|
718
|
+
return _regenerator().w(function (_context22) {
|
|
719
|
+
while (1) switch (_context22.n) {
|
|
720
|
+
case 0:
|
|
721
|
+
apiActions.setRejection(new _twoFactorAuthCancellation.TwoFactorAuthCancelledError());
|
|
722
|
+
_context22.n = 1;
|
|
723
|
+
return store.dispatch(actions.cancelWithdrawTicket({
|
|
724
|
+
RequestCode: 1
|
|
725
|
+
}));
|
|
726
|
+
case 1:
|
|
727
|
+
expect(snackbarActions.showSnack).not.toHaveBeenCalled();
|
|
728
|
+
expect(apiActions.callAPI).not.toHaveBeenCalledWith('GetWithdrawTickets', expect.any(Object));
|
|
729
|
+
case 2:
|
|
730
|
+
return _context22.a(2);
|
|
731
|
+
}
|
|
732
|
+
}, _callee22);
|
|
560
733
|
})));
|
|
561
734
|
});
|
|
562
735
|
describe('getWithdrawFee', function () {
|
|
563
|
-
it('should dispatch expected actions if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
564
|
-
return _regenerator().w(function (
|
|
565
|
-
while (1) switch (
|
|
736
|
+
it('should dispatch expected actions if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23() {
|
|
737
|
+
return _regenerator().w(function (_context23) {
|
|
738
|
+
while (1) switch (_context23.n) {
|
|
566
739
|
case 0:
|
|
567
740
|
apiActions.setReturnValue({
|
|
568
741
|
result: true,
|
|
569
742
|
FeeAmount: 2
|
|
570
743
|
});
|
|
571
|
-
|
|
744
|
+
_context23.n = 1;
|
|
572
745
|
return store.dispatch(actions.getWithdrawFee(1, 2));
|
|
573
746
|
case 1:
|
|
574
747
|
expect(apiActions.callAPI).toHaveBeenCalledWith('GetWithdrawFee', expect.any(Object));
|
|
@@ -580,45 +753,45 @@ describe('withdrawActions', function () {
|
|
|
580
753
|
}
|
|
581
754
|
});
|
|
582
755
|
case 2:
|
|
583
|
-
return
|
|
756
|
+
return _context23.a(2);
|
|
584
757
|
}
|
|
585
|
-
},
|
|
758
|
+
}, _callee23);
|
|
586
759
|
})));
|
|
587
|
-
it('should dispatch expected actions if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
588
|
-
return _regenerator().w(function (
|
|
589
|
-
while (1) switch (
|
|
760
|
+
it('should dispatch expected actions if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24() {
|
|
761
|
+
return _regenerator().w(function (_context24) {
|
|
762
|
+
while (1) switch (_context24.n) {
|
|
590
763
|
case 0:
|
|
591
764
|
apiActions.setReturnValue({
|
|
592
765
|
result: false
|
|
593
766
|
});
|
|
594
|
-
|
|
767
|
+
_context24.n = 1;
|
|
595
768
|
return store.dispatch(actions.getWithdrawFee(1, 2));
|
|
596
769
|
case 1:
|
|
597
770
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
598
771
|
case 2:
|
|
599
|
-
return
|
|
772
|
+
return _context24.a(2);
|
|
600
773
|
}
|
|
601
|
-
},
|
|
774
|
+
}, _callee24);
|
|
602
775
|
})));
|
|
603
776
|
});
|
|
604
777
|
describe('subscribeToWithdrawalTickets', function () {
|
|
605
|
-
it('should call subscribeToWithdrawalTickets', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
606
|
-
return _regenerator().w(function (
|
|
607
|
-
while (1) switch (
|
|
778
|
+
it('should call subscribeToWithdrawalTickets', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25() {
|
|
779
|
+
return _regenerator().w(function (_context25) {
|
|
780
|
+
while (1) switch (_context25.n) {
|
|
608
781
|
case 0:
|
|
609
|
-
|
|
782
|
+
_context25.n = 1;
|
|
610
783
|
return store.dispatch(actions.subscribeToWithdrawalTickets());
|
|
611
784
|
case 1:
|
|
612
785
|
expect(_withdrawSubscriptionService["default"].subscribe).toHaveBeenCalled();
|
|
613
786
|
case 2:
|
|
614
|
-
return
|
|
787
|
+
return _context25.a(2);
|
|
615
788
|
}
|
|
616
|
-
},
|
|
789
|
+
}, _callee25);
|
|
617
790
|
})));
|
|
618
|
-
it("should dispatch ".concat(actions.ADD_WITHDRAWAL_TICKET, " action with update when subscribed"), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
791
|
+
it("should dispatch ".concat(actions.ADD_WITHDRAWAL_TICKET, " action with update when subscribed"), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26() {
|
|
619
792
|
var updates, expectedActions;
|
|
620
|
-
return _regenerator().w(function (
|
|
621
|
-
while (1) switch (
|
|
793
|
+
return _regenerator().w(function (_context26) {
|
|
794
|
+
while (1) switch (_context26.n) {
|
|
622
795
|
case 0:
|
|
623
796
|
updates = [];
|
|
624
797
|
expectedActions = [{
|
|
@@ -626,14 +799,14 @@ describe('withdrawActions', function () {
|
|
|
626
799
|
payload: updates
|
|
627
800
|
}];
|
|
628
801
|
_withdrawSubscriptionService["default"].setUpdateData(updates);
|
|
629
|
-
|
|
802
|
+
_context26.n = 1;
|
|
630
803
|
return store.dispatch(actions.subscribeToWithdrawalTickets());
|
|
631
804
|
case 1:
|
|
632
805
|
expect(store.getActions()).toEqual(expectedActions);
|
|
633
806
|
case 2:
|
|
634
|
-
return
|
|
807
|
+
return _context26.a(2);
|
|
635
808
|
}
|
|
636
|
-
},
|
|
809
|
+
}, _callee26);
|
|
637
810
|
})));
|
|
638
811
|
});
|
|
639
812
|
});
|
|
@@ -136,6 +136,8 @@ describe('withdrawActions - Travel Rule Fields', function () {
|
|
|
136
136
|
TemplateType: 'ToExternalBitcoinAddress',
|
|
137
137
|
AccountProviderId: 34,
|
|
138
138
|
Kytdetails: '{"TravelRuleCounterpartyFirstName":"John","TravelRuleCounterpartyLastName":"Doe","TravelRuleCounterpartyDob":"01/15/1990"}'
|
|
139
|
+
}, {
|
|
140
|
+
rejectOnCancel: true
|
|
139
141
|
});
|
|
140
142
|
expect(_sidePaneActions.closeWithdrawSidePane).toHaveBeenCalled();
|
|
141
143
|
expect(_snackbarActions.showSnack).toHaveBeenCalledWith({
|
|
@@ -179,6 +181,8 @@ describe('withdrawActions - Travel Rule Fields', function () {
|
|
|
179
181
|
TemplateType: 'ToExternalBitcoinAddress',
|
|
180
182
|
AccountProviderId: 34,
|
|
181
183
|
Kytdetails: '{"TravelRuleCounterpartyLastName":"Doe","TravelRuleCounterpartyDob":"01/15/1990"}'
|
|
184
|
+
}, {
|
|
185
|
+
rejectOnCancel: true
|
|
182
186
|
});
|
|
183
187
|
case 2:
|
|
184
188
|
return _context2.a(2);
|
|
@@ -214,7 +218,9 @@ describe('withdrawActions - Travel Rule Fields', function () {
|
|
|
214
218
|
TemplateType: 'ToExternalBitcoinAddress',
|
|
215
219
|
AccountProviderId: 34
|
|
216
220
|
};
|
|
217
|
-
expect(_apiActions.callAPI).toHaveBeenCalledWith('CreateWithdrawTicket', expectedCall
|
|
221
|
+
expect(_apiActions.callAPI).toHaveBeenCalledWith('CreateWithdrawTicket', expectedCall, {
|
|
222
|
+
rejectOnCancel: true
|
|
223
|
+
});
|
|
218
224
|
|
|
219
225
|
// Should not include Kytdetails
|
|
220
226
|
actualCall = _apiActions.callAPI.mock.calls[0][1];
|
|
@@ -258,7 +264,9 @@ describe('withdrawActions - Travel Rule Fields', function () {
|
|
|
258
264
|
TemplateType: 'ToExternalBitcoinAddress',
|
|
259
265
|
AccountProviderId: 34
|
|
260
266
|
};
|
|
261
|
-
expect(_apiActions.callAPI).toHaveBeenCalledWith('CreateWithdrawTicket', expectedCall
|
|
267
|
+
expect(_apiActions.callAPI).toHaveBeenCalledWith('CreateWithdrawTicket', expectedCall, {
|
|
268
|
+
rejectOnCancel: true
|
|
269
|
+
});
|
|
262
270
|
|
|
263
271
|
// Should not include Kytdetails
|
|
264
272
|
actualCall = _apiActions.callAPI.mock.calls[0][1];
|
|
@@ -297,6 +305,8 @@ describe('withdrawActions - Travel Rule Fields', function () {
|
|
|
297
305
|
TemplateType: 'ToExternalBitcoinAddress',
|
|
298
306
|
AccountProviderId: 34,
|
|
299
307
|
Kytdetails: '{"TravelRuleCounterpartyDob":"01/15/1990"}'
|
|
308
|
+
}, {
|
|
309
|
+
rejectOnCancel: true
|
|
300
310
|
});
|
|
301
311
|
case 2:
|
|
302
312
|
return _context5.a(2);
|
|
@@ -318,7 +328,9 @@ describe('withdrawActions - Travel Rule Fields', function () {
|
|
|
318
328
|
case 1:
|
|
319
329
|
expect(_apiActions.callAPI).toHaveBeenCalledWith('CreateWithdrawTicket', expect.objectContaining({
|
|
320
330
|
Kytdetails: '{"TravelRuleCounterpartyFirstName":"John","TravelRuleCounterpartyLastName":"Doe","TravelRuleCounterpartyDob":"01/15/1990"}'
|
|
321
|
-
})
|
|
331
|
+
}), {
|
|
332
|
+
rejectOnCancel: true
|
|
333
|
+
});
|
|
322
334
|
expect(_snackbarActions.showSnack).toHaveBeenCalledWith({
|
|
323
335
|
id: 'withdrawRejectSnack',
|
|
324
336
|
text: 'Travel Rule validation failed',
|
|
@@ -372,6 +384,8 @@ describe('withdrawActions - Travel Rule Fields', function () {
|
|
|
372
384
|
TemplateType: 'ToExternalBitcoinAddress',
|
|
373
385
|
AccountProviderId: 34,
|
|
374
386
|
Kytdetails: '{"TravelRuleCounterpartyFirstName":"John","TravelRuleCounterpartyLastName":"Doe","TravelRuleCounterpartyDob":"01/15/1990"}'
|
|
387
|
+
}, {
|
|
388
|
+
rejectOnCancel: true
|
|
375
389
|
});
|
|
376
390
|
case 2:
|
|
377
391
|
return _context7.a(2);
|
|
@@ -29,6 +29,7 @@ var getInitialState = function getInitialState() {
|
|
|
29
29
|
userInfo: {},
|
|
30
30
|
permissions: [],
|
|
31
31
|
accounts: [],
|
|
32
|
+
accountsLoaded: false,
|
|
32
33
|
userConfig: [],
|
|
33
34
|
selectedAccountId: parseInt(localStorage.getItem('selectedAccountId'), 10) || undefined,
|
|
34
35
|
kyc: {
|
|
@@ -74,6 +75,15 @@ function user() {
|
|
|
74
75
|
accounts: mergedAccounts
|
|
75
76
|
});
|
|
76
77
|
}
|
|
78
|
+
case _userActions.ACCOUNTS_LOADED:
|
|
79
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
80
|
+
accountsLoaded: true,
|
|
81
|
+
// USER_INFO_FETCHED selects the user's default AccountId, which can
|
|
82
|
+
// name an account the user is no longer linked to. With no accounts
|
|
83
|
+
// there is nothing to select, and account-scoped calls for that id are
|
|
84
|
+
// refused, so clear it.
|
|
85
|
+
selectedAccountId: state.accounts.length ? state.selectedAccountId : undefined
|
|
86
|
+
});
|
|
77
87
|
case _kycActions.UPDATE_ACCOUNT:
|
|
78
88
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
79
89
|
accounts: (0, _arrayHelper.updateAccountInArray)(state.accounts, payload)
|
|
@@ -13,6 +13,7 @@ describe('user reducer', function () {
|
|
|
13
13
|
userInfo: {},
|
|
14
14
|
permissions: [],
|
|
15
15
|
accounts: [],
|
|
16
|
+
accountsLoaded: false,
|
|
16
17
|
kyc: {
|
|
17
18
|
urlParams: null
|
|
18
19
|
},
|
|
@@ -23,6 +24,34 @@ describe('user reducer', function () {
|
|
|
23
24
|
};
|
|
24
25
|
expect((0, _userReducer["default"])(undefined, {})).toEqual(expectedState);
|
|
25
26
|
});
|
|
27
|
+
it("should handle ".concat(actions.ACCOUNTS_LOADED, " action"), function () {
|
|
28
|
+
var stateBefore = (0, _userReducer["default"])(undefined, {});
|
|
29
|
+
expect(stateBefore.accountsLoaded).toBe(false);
|
|
30
|
+
var stateAfter = (0, _userReducer["default"])(stateBefore, actions.accountsLoaded());
|
|
31
|
+
expect(stateAfter.accountsLoaded).toBe(true);
|
|
32
|
+
// Loaded with an empty accounts array is the accountless case, and must
|
|
33
|
+
// stay distinguishable from the not-yet-fetched case above.
|
|
34
|
+
expect(stateAfter.accounts).toEqual([]);
|
|
35
|
+
});
|
|
36
|
+
it("should clear selectedAccountId on ".concat(actions.ACCOUNTS_LOADED, " when the user has no accounts"), function () {
|
|
37
|
+
// The user's default AccountId still names an account they were unlinked from.
|
|
38
|
+
var stateBefore = (0, _userReducer["default"])(undefined, actions.userInfoFetched({
|
|
39
|
+
AccountId: 125
|
|
40
|
+
}));
|
|
41
|
+
expect(stateBefore.selectedAccountId).toBe(125);
|
|
42
|
+
var stateAfter = (0, _userReducer["default"])(stateBefore, actions.accountsLoaded());
|
|
43
|
+
expect(stateAfter.selectedAccountId).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
it("should keep selectedAccountId on ".concat(actions.ACCOUNTS_LOADED, " when the user has accounts"), function () {
|
|
46
|
+
var state = (0, _userReducer["default"])(undefined, actions.userInfoFetched({
|
|
47
|
+
AccountId: 7
|
|
48
|
+
}));
|
|
49
|
+
state = (0, _userReducer["default"])(state, actions.receiveAccount([{
|
|
50
|
+
AccountId: 7
|
|
51
|
+
}]));
|
|
52
|
+
state = (0, _userReducer["default"])(state, actions.accountsLoaded());
|
|
53
|
+
expect(state.selectedAccountId).toBe(7);
|
|
54
|
+
});
|
|
26
55
|
it("should handle ".concat(actions.USER_INFO_FETCHED, " action"), function () {
|
|
27
56
|
var user = {
|
|
28
57
|
userID: 40
|