@alphapoint/apex-web 5.5.6 → 5.8.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/apex.integration.test.js +435 -0
- package/lib/apex.js +37 -1
- package/lib/apex.test.js +138 -0
- package/lib/components/2FA/PasskeyOption.js +126 -0
- package/lib/components/2FA/TwoFactorAuthComponent.js +24 -5
- package/lib/components/2FA/TwoFactorAuthComponent.test.js +94 -0
- package/lib/components/2FA/TwoFactorAuthContainer.js +139 -27
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +627 -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/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.js +34 -6
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.test.js +298 -0
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalComponent.js +26 -4
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalContainer.js +4 -1
- package/lib/components/DigitalAssets/digitalAssetsPriceLabel.test.js +238 -0
- package/lib/components/EnableTwoFactorAuth/Disable2FAForm.js +22 -7
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.js +15 -5
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.test.js +460 -0
- package/lib/components/EnableTwoFactorAuth/Disable2FAModalContainer.js +108 -16
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +7 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +105 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +15 -3
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.css +13 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.js +246 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.test.js +521 -0
- package/lib/components/InstrumentPositions/InstrumentPositionsContainer.js +4 -1
- package/lib/components/Login/LoginFormComponent.js +1 -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/OrderEntryComponents/advancedForm/AdvancedOrderFormContainer.js +2 -0
- package/lib/components/OrderEntryComponents/common/FormAmountFields.js +5 -0
- package/lib/components/OrderEntryComponents/common/TwapScheduleFields.js +98 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.js +86 -39
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.test.js +326 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryContainer.js +10 -2
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.test.js +99 -0
- package/lib/components/OrderHistoryComponents/InactiveOrders/InactiveOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/OpenOrders/OpenOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.test.js +113 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.css +108 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.test.js +983 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCardComponent.js +500 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/index.js +9 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +4 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +29 -17
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.test.js +135 -0
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +12 -4
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +268 -0
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthForm.test.js +475 -0
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormComponent.js +26 -5
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormContainer.js +50 -32
- package/lib/components/common/APAutoTabInput/APAutoTabInput.js +5 -2
- package/lib/components/common/APSelect/APSelect.js +3 -1
- package/lib/components/common/ErrorBoundary/ErrorBoundary.css +35 -0
- package/lib/components/common/ErrorBoundary/ErrorBoundary.js +87 -0
- package/lib/config/CONFIG.md +4 -0
- package/lib/config/configDefault.json +2 -1
- package/lib/constants/sendOrder/orderEntryFormConstants.js +23 -4
- package/lib/constants/sendOrder/timeInForceConstants.js +3 -1
- package/lib/constants/sendOrder/twapRejectReasons.js +26 -0
- package/lib/helpers/errorTextFormatter.js +13 -4
- package/lib/helpers/errorTextFormatter.test.js +26 -0
- package/lib/helpers/orderHistoryHelper.js +13 -1
- package/lib/helpers/orderHistoryHelper.test.js +58 -13
- package/lib/helpers/passkeyApi.js +228 -0
- package/lib/helpers/passkeyApi.test.js +171 -0
- package/lib/helpers/placeOrderHelper.js +76 -61
- package/lib/helpers/placeOrderHelper.test.js +169 -10
- package/lib/helpers/recalculateOrderHelper.js +4 -1
- package/lib/helpers/recalculateOrderHelper.test.js +88 -2
- package/lib/helpers/twapOrderHelper.js +265 -0
- package/lib/helpers/twapOrderHelper.test.js +467 -0
- package/lib/helpers/twoFactorAuthCancellation.js +38 -0
- package/lib/helpers/webauthnHelper.js +300 -0
- package/lib/helpers/webauthnHelper.test.js +199 -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/hocs/withOneSubmission.js +168 -0
- 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 +77 -9
- package/lib/redux/actions/apiActions.test.js +233 -0
- package/lib/redux/actions/authActions.js +514 -198
- package/lib/redux/actions/authActions.test.js +627 -47
- package/lib/redux/actions/depositActions.js +1 -1
- package/lib/redux/actions/depositActions.test.js +100 -30
- package/lib/redux/actions/fusionAuthActions.test.js +265 -84
- package/lib/redux/actions/interestAccountActions.js +12 -3
- package/lib/redux/actions/interestAccountActions.test.js +73 -0
- package/lib/redux/actions/modalActions.js +1 -0
- package/lib/redux/actions/orderEntryActions.blockTrade.test.js +306 -0
- package/lib/redux/actions/orderEntryActions.js +74 -22
- package/lib/redux/actions/orderEntryActions.test.js +63 -11
- package/lib/redux/actions/orderHistoryActions.js +20 -8
- package/lib/redux/actions/orderHistoryActions.test.js +63 -0
- package/lib/redux/actions/userActions.js +379 -179
- package/lib/redux/actions/userActions.test.js +925 -234
- 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/margin/actions/marginActions.js +6 -3
- package/lib/redux/margin/actions/marginActions.test.js +166 -0
- package/lib/redux/middlewares/authMiddleware.js +5 -0
- package/lib/redux/middlewares/authMiddleware.test.js +88 -29
- package/lib/redux/reducers/authReducer.js +1 -0
- package/lib/redux/reducers/authReducer.test.js +38 -0
- package/lib/redux/reducers/userReducer.js +10 -0
- package/lib/redux/reducers/userReducer.test.js +29 -0
- package/lib/redux/selectors/orderEntrySelector.js +19 -8
- package/lib/redux/selectors/orderEntrySelector.test.js +209 -0
- package/lib/redux/selectors/orderTotalSelector.test.js +40 -1
- 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/lib/services/fms/fms.js +2 -0
- package/lib/services/fms/fms.test.js +35 -0
- package/package.json +4 -4
|
@@ -11,6 +11,7 @@ var positionActions = _interopRequireWildcard(require("./positionActions"));
|
|
|
11
11
|
var withdrawActions = _interopRequireWildcard(require("./withdrawActions"));
|
|
12
12
|
var transferActions = _interopRequireWildcard(require("./transferActions"));
|
|
13
13
|
var _modalActions = require("./modalActions");
|
|
14
|
+
var _authActions = require("./authActions");
|
|
14
15
|
var _verificationLevelUpdateService = _interopRequireDefault(require("../../services/subscriptions/verificationLevelUpdateService"));
|
|
15
16
|
var _config = _interopRequireDefault(require("../../config"));
|
|
16
17
|
var _excluded = ["ResendVerificationEmail"];
|
|
@@ -565,49 +566,269 @@ describe('userActions', function () {
|
|
|
565
566
|
}
|
|
566
567
|
};
|
|
567
568
|
});
|
|
568
|
-
it('should log an error when GetUserInfo fails', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
569
|
+
it('should log an error and mark accounts as loaded when GetUserInfo fails', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
569
570
|
return _regenerator().w(function (_context) {
|
|
570
571
|
while (1) switch (_context.n) {
|
|
571
572
|
case 0:
|
|
572
573
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserInfo', Promise.reject(new Error('fail')));
|
|
573
574
|
_context.n = 1;
|
|
574
|
-
return
|
|
575
|
+
return actions.getUserInfo(99)(dispatchStub, getState);
|
|
575
576
|
case 1:
|
|
576
577
|
expect(console.error).toHaveBeenCalledWith('getUserInfo action error', expect.anything());
|
|
578
|
+
expect(dispatchStub).toHaveBeenCalledWith(actions.accountsLoaded());
|
|
579
|
+
expect(_apex["default"].connection.RPCPromise).not.toHaveBeenCalledWith('GetOMSs', expect.anything());
|
|
577
580
|
case 2:
|
|
578
581
|
return _context.a(2);
|
|
579
582
|
}
|
|
580
583
|
}, _callee);
|
|
581
584
|
})));
|
|
582
|
-
it('
|
|
585
|
+
it('stores the system margin flag before the user info', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
586
|
+
var store, types;
|
|
583
587
|
return _regenerator().w(function (_context2) {
|
|
584
588
|
while (1) switch (_context2.n) {
|
|
585
589
|
case 0:
|
|
590
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserInfo', {
|
|
591
|
+
o: JSON.stringify({
|
|
592
|
+
UserId: 99,
|
|
593
|
+
OMSId: 99,
|
|
594
|
+
AccountId: 99,
|
|
595
|
+
OperatorId: 1,
|
|
596
|
+
MarginBorrowerEnabled: true
|
|
597
|
+
})
|
|
598
|
+
});
|
|
599
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetOMSs', {
|
|
600
|
+
o: JSON.stringify([{
|
|
601
|
+
OMSId: 99,
|
|
602
|
+
SystemMarginEnabled: true
|
|
603
|
+
}])
|
|
604
|
+
});
|
|
605
|
+
store = mockStore({
|
|
606
|
+
api: {
|
|
607
|
+
validate2FARequiredEndpoints: {}
|
|
608
|
+
},
|
|
609
|
+
auth: {
|
|
610
|
+
isAuthenticated: true
|
|
611
|
+
},
|
|
612
|
+
user: {
|
|
613
|
+
accounts: [],
|
|
614
|
+
userInfo: {}
|
|
615
|
+
}
|
|
616
|
+
});
|
|
586
617
|
_context2.n = 1;
|
|
587
|
-
return actions.getUserInfo(99)
|
|
618
|
+
return store.dispatch(actions.getUserInfo(99));
|
|
588
619
|
case 1:
|
|
589
|
-
|
|
590
|
-
|
|
620
|
+
types = store.getActions().map(function (a) {
|
|
621
|
+
return a.type;
|
|
622
|
+
});
|
|
623
|
+
expect(types).toContain('RECEIVE_SYSTEM_MARGIN_ENABLED');
|
|
624
|
+
expect(types.indexOf('RECEIVE_SYSTEM_MARGIN_ENABLED')).toBeLessThan(types.indexOf(actions.USER_INFO_FETCHED));
|
|
625
|
+
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetAllMarginInstrumentConfigs', {
|
|
626
|
+
OMSId: 99
|
|
591
627
|
});
|
|
592
628
|
case 2:
|
|
593
629
|
return _context2.a(2);
|
|
594
630
|
}
|
|
595
631
|
}, _callee2);
|
|
596
632
|
})));
|
|
597
|
-
it('
|
|
633
|
+
it('does not request margin instrument configs when system margin is disabled', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
634
|
+
var store;
|
|
598
635
|
return _regenerator().w(function (_context3) {
|
|
599
636
|
while (1) switch (_context3.n) {
|
|
600
637
|
case 0:
|
|
638
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserInfo', {
|
|
639
|
+
o: JSON.stringify({
|
|
640
|
+
UserId: 99,
|
|
641
|
+
OMSId: 99,
|
|
642
|
+
AccountId: 99,
|
|
643
|
+
OperatorId: 1,
|
|
644
|
+
MarginBorrowerEnabled: true
|
|
645
|
+
})
|
|
646
|
+
});
|
|
647
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetOMSs', {
|
|
648
|
+
o: JSON.stringify([{
|
|
649
|
+
OMSId: 99,
|
|
650
|
+
SystemMarginEnabled: false
|
|
651
|
+
}])
|
|
652
|
+
});
|
|
653
|
+
store = mockStore({
|
|
654
|
+
api: {
|
|
655
|
+
validate2FARequiredEndpoints: {}
|
|
656
|
+
},
|
|
657
|
+
auth: {
|
|
658
|
+
isAuthenticated: true
|
|
659
|
+
},
|
|
660
|
+
user: {
|
|
661
|
+
accounts: [],
|
|
662
|
+
userInfo: {}
|
|
663
|
+
}
|
|
664
|
+
});
|
|
601
665
|
_context3.n = 1;
|
|
666
|
+
return store.dispatch(actions.getUserInfo(99));
|
|
667
|
+
case 1:
|
|
668
|
+
expect(store.getActions().map(function (a) {
|
|
669
|
+
return a.type;
|
|
670
|
+
})).toContain(actions.USER_INFO_FETCHED);
|
|
671
|
+
expect(_apex["default"].connection.RPCPromise).not.toHaveBeenCalledWith('GetAllMarginInstrumentConfigs', expect.anything());
|
|
672
|
+
case 2:
|
|
673
|
+
return _context3.a(2);
|
|
674
|
+
}
|
|
675
|
+
}, _callee3);
|
|
676
|
+
})));
|
|
677
|
+
it('ends the session and reports it when the gateway refuses GetUserInfo', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
678
|
+
var store, types;
|
|
679
|
+
return _regenerator().w(function (_context4) {
|
|
680
|
+
while (1) switch (_context4.n) {
|
|
681
|
+
case 0:
|
|
682
|
+
// callAPI turns an m:5 "Endpoint Not Found" reply into this payload.
|
|
683
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserInfo', Promise.reject({
|
|
684
|
+
m: 5,
|
|
685
|
+
i: 20,
|
|
686
|
+
n: 'GetUserInfo',
|
|
687
|
+
o: 'Endpoint Not Found'
|
|
688
|
+
}));
|
|
689
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('LogOut', Promise.resolve({
|
|
690
|
+
o: '{}'
|
|
691
|
+
}));
|
|
692
|
+
store = mockStore({
|
|
693
|
+
api: {
|
|
694
|
+
validate2FARequiredEndpoints: {}
|
|
695
|
+
},
|
|
696
|
+
auth: {
|
|
697
|
+
isAuthenticated: true
|
|
698
|
+
},
|
|
699
|
+
user: {
|
|
700
|
+
accounts: [],
|
|
701
|
+
userInfo: {}
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
_context4.n = 1;
|
|
705
|
+
return store.dispatch(actions.getUserInfo(1));
|
|
706
|
+
case 1:
|
|
707
|
+
types = store.getActions().map(function (a) {
|
|
708
|
+
return a.type;
|
|
709
|
+
});
|
|
710
|
+
expect(types).toContain(actions.ACCOUNTS_LOADED);
|
|
711
|
+
expect(types).toContain('AUTH_NONE');
|
|
712
|
+
expect(types.indexOf('AUTH_NONE')).toBeLessThan(types.indexOf('AUTH_ERROR'));
|
|
713
|
+
expect(store.getActions()).toContainEqual({
|
|
714
|
+
type: 'AUTH_ERROR',
|
|
715
|
+
payload: {
|
|
716
|
+
isAuthenticated: false,
|
|
717
|
+
errorMsg: actions.USER_INFO_REFUSED_MESSAGE,
|
|
718
|
+
pending: false
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
expect(_apex["default"].connection.RPCPromise).not.toHaveBeenCalledWith('GetOMSs', expect.anything());
|
|
722
|
+
expect(_apex["default"].connection.RPCPromise).not.toHaveBeenCalledWith('GetUserAccounts', expect.anything());
|
|
723
|
+
expect(console.error).toHaveBeenCalledWith('GetUserInfo was refused, ending the session', expect.anything());
|
|
724
|
+
case 2:
|
|
725
|
+
return _context4.a(2);
|
|
726
|
+
}
|
|
727
|
+
}, _callee4);
|
|
728
|
+
})));
|
|
729
|
+
it('uses a generic message when GetUserInfo fails for another reason', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
730
|
+
var store;
|
|
731
|
+
return _regenerator().w(function (_context5) {
|
|
732
|
+
while (1) switch (_context5.n) {
|
|
733
|
+
case 0:
|
|
734
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserInfo', {
|
|
735
|
+
o: JSON.stringify({
|
|
736
|
+
result: false,
|
|
737
|
+
errormsg: 'Server Error',
|
|
738
|
+
errorcode: 100
|
|
739
|
+
})
|
|
740
|
+
});
|
|
741
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('LogOut', Promise.resolve({
|
|
742
|
+
o: '{}'
|
|
743
|
+
}));
|
|
744
|
+
store = mockStore({
|
|
745
|
+
api: {
|
|
746
|
+
validate2FARequiredEndpoints: {}
|
|
747
|
+
},
|
|
748
|
+
auth: {
|
|
749
|
+
isAuthenticated: true
|
|
750
|
+
},
|
|
751
|
+
user: {
|
|
752
|
+
accounts: [],
|
|
753
|
+
userInfo: {}
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
_context5.n = 1;
|
|
757
|
+
return store.dispatch(actions.getUserInfo(1));
|
|
758
|
+
case 1:
|
|
759
|
+
expect(store.getActions()).toContainEqual({
|
|
760
|
+
type: 'AUTH_ERROR',
|
|
761
|
+
payload: {
|
|
762
|
+
isAuthenticated: false,
|
|
763
|
+
errorMsg: actions.USER_INFO_FAILED_MESSAGE,
|
|
764
|
+
pending: false
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
case 2:
|
|
768
|
+
return _context5.a(2);
|
|
769
|
+
}
|
|
770
|
+
}, _callee5);
|
|
771
|
+
})));
|
|
772
|
+
it('does not end the session when GetUserInfo succeeds', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
773
|
+
var store, types;
|
|
774
|
+
return _regenerator().w(function (_context6) {
|
|
775
|
+
while (1) switch (_context6.n) {
|
|
776
|
+
case 0:
|
|
777
|
+
store = mockStore({
|
|
778
|
+
api: {
|
|
779
|
+
validate2FARequiredEndpoints: {}
|
|
780
|
+
},
|
|
781
|
+
auth: {
|
|
782
|
+
isAuthenticated: true
|
|
783
|
+
},
|
|
784
|
+
user: {
|
|
785
|
+
accounts: [],
|
|
786
|
+
userInfo: {}
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
_context6.n = 1;
|
|
790
|
+
return store.dispatch(actions.getUserInfo(99));
|
|
791
|
+
case 1:
|
|
792
|
+
types = store.getActions().map(function (a) {
|
|
793
|
+
return a.type;
|
|
794
|
+
});
|
|
795
|
+
expect(types).not.toContain('AUTH_NONE');
|
|
796
|
+
expect(types).not.toContain('AUTH_ERROR');
|
|
797
|
+
expect(types).toContain(actions.USER_INFO_FETCHED);
|
|
798
|
+
case 2:
|
|
799
|
+
return _context6.a(2);
|
|
800
|
+
}
|
|
801
|
+
}, _callee6);
|
|
802
|
+
})));
|
|
803
|
+
it('getUserInfo should call apex.connection.RPCPromise with GetUserInfo', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
804
|
+
return _regenerator().w(function (_context7) {
|
|
805
|
+
while (1) switch (_context7.n) {
|
|
806
|
+
case 0:
|
|
807
|
+
_context7.n = 1;
|
|
808
|
+
return actions.getUserInfo(99)(dispatchStub, getState);
|
|
809
|
+
case 1:
|
|
810
|
+
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetUserInfo', {
|
|
811
|
+
UserId: 99
|
|
812
|
+
});
|
|
813
|
+
case 2:
|
|
814
|
+
return _context7.a(2);
|
|
815
|
+
}
|
|
816
|
+
}, _callee7);
|
|
817
|
+
})));
|
|
818
|
+
it('getUserPermissions should call apex.connection.RPCPromise with GetUserPermissions', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
819
|
+
return _regenerator().w(function (_context8) {
|
|
820
|
+
while (1) switch (_context8.n) {
|
|
821
|
+
case 0:
|
|
822
|
+
_context8.n = 1;
|
|
602
823
|
return actions.getUserPermissions(99)(dispatchStub);
|
|
603
824
|
case 1:
|
|
604
825
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetUserPermissions', {
|
|
605
826
|
UserId: 99
|
|
606
827
|
});
|
|
607
828
|
case 2:
|
|
608
|
-
return
|
|
829
|
+
return _context8.a(2);
|
|
609
830
|
}
|
|
610
|
-
},
|
|
831
|
+
}, _callee8);
|
|
611
832
|
})));
|
|
612
833
|
});
|
|
613
834
|
describe('getUserConfig', function () {
|
|
@@ -615,28 +836,28 @@ describe('userActions', function () {
|
|
|
615
836
|
jest.clearAllMocks();
|
|
616
837
|
_apex["default"].connection.resetRPCPromiseResponses();
|
|
617
838
|
});
|
|
618
|
-
it('should call console error if response is rejected', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
619
|
-
return _regenerator().w(function (
|
|
620
|
-
while (1) switch (
|
|
839
|
+
it('should call console error if response is rejected', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
840
|
+
return _regenerator().w(function (_context9) {
|
|
841
|
+
while (1) switch (_context9.n) {
|
|
621
842
|
case 0:
|
|
622
843
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserConfig', Promise.reject(new Error('fail')));
|
|
623
|
-
|
|
844
|
+
_context9.n = 1;
|
|
624
845
|
return actions.getUserConfig(99)(dispatchStub);
|
|
625
846
|
case 1:
|
|
626
847
|
expect(console.error).toHaveBeenCalledWith('getUserConfig action error', expect.anything());
|
|
627
848
|
case 2:
|
|
628
|
-
return
|
|
849
|
+
return _context9.a(2);
|
|
629
850
|
}
|
|
630
|
-
},
|
|
851
|
+
}, _callee9);
|
|
631
852
|
})));
|
|
632
|
-
it('getUserConfig should call apex.connection.RPCPromise with GetUserConfig', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
633
|
-
return _regenerator().w(function (
|
|
634
|
-
while (1) switch (
|
|
853
|
+
it('getUserConfig should call apex.connection.RPCPromise with GetUserConfig', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
854
|
+
return _regenerator().w(function (_context0) {
|
|
855
|
+
while (1) switch (_context0.n) {
|
|
635
856
|
case 0:
|
|
636
857
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserConfig', {
|
|
637
858
|
o: JSON.stringify([])
|
|
638
859
|
});
|
|
639
|
-
|
|
860
|
+
_context0.n = 1;
|
|
640
861
|
return actions.getUserConfig(99)(dispatchStub);
|
|
641
862
|
case 1:
|
|
642
863
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetUserConfig', {
|
|
@@ -644,9 +865,9 @@ describe('userActions', function () {
|
|
|
644
865
|
UserName: undefined
|
|
645
866
|
});
|
|
646
867
|
case 2:
|
|
647
|
-
return
|
|
868
|
+
return _context0.a(2);
|
|
648
869
|
}
|
|
649
|
-
},
|
|
870
|
+
}, _callee0);
|
|
650
871
|
})));
|
|
651
872
|
});
|
|
652
873
|
describe('getUserAccounts', function () {
|
|
@@ -657,10 +878,10 @@ describe('userActions', function () {
|
|
|
657
878
|
o: JSON.stringify({})
|
|
658
879
|
});
|
|
659
880
|
});
|
|
660
|
-
it('should call apex.connection.getUserAccounts', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
881
|
+
it('should call apex.connection.getUserAccounts', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
661
882
|
var userAccountIds, accountInfo;
|
|
662
|
-
return _regenerator().w(function (
|
|
663
|
-
while (1) switch (
|
|
883
|
+
return _regenerator().w(function (_context1) {
|
|
884
|
+
while (1) switch (_context1.n) {
|
|
664
885
|
case 0:
|
|
665
886
|
userAccountIds = [1];
|
|
666
887
|
accountInfo = {
|
|
@@ -672,46 +893,46 @@ describe('userActions', function () {
|
|
|
672
893
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetAccountInfo', {
|
|
673
894
|
o: JSON.stringify(accountInfo)
|
|
674
895
|
});
|
|
675
|
-
|
|
896
|
+
_context1.n = 1;
|
|
676
897
|
return actions.getUserAccounts(99)(dispatchStub);
|
|
677
898
|
case 1:
|
|
678
899
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetUserAccounts', {
|
|
679
900
|
OMSId: 99
|
|
680
901
|
});
|
|
681
902
|
case 2:
|
|
682
|
-
return
|
|
903
|
+
return _context1.a(2);
|
|
683
904
|
}
|
|
684
|
-
},
|
|
905
|
+
}, _callee1);
|
|
685
906
|
})));
|
|
686
|
-
it('should call getAccountInfo after getUserAccounts for each UserAccount', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
907
|
+
it('should call getAccountInfo after getUserAccounts for each UserAccount', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
687
908
|
var userAccountIds, getAccountInfoCalls;
|
|
688
|
-
return _regenerator().w(function (
|
|
689
|
-
while (1) switch (
|
|
909
|
+
return _regenerator().w(function (_context10) {
|
|
910
|
+
while (1) switch (_context10.n) {
|
|
690
911
|
case 0:
|
|
691
912
|
userAccountIds = [1, 2, 3];
|
|
692
913
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', {
|
|
693
914
|
o: JSON.stringify(userAccountIds)
|
|
694
915
|
});
|
|
695
|
-
|
|
916
|
+
_context10.n = 1;
|
|
696
917
|
return actions.getUserAccounts(99)(dispatchStub);
|
|
697
918
|
case 1:
|
|
698
|
-
getAccountInfoCalls = _apex["default"].connection.RPCPromise.mock.calls.filter(function (
|
|
699
|
-
var
|
|
700
|
-
endpoint =
|
|
919
|
+
getAccountInfoCalls = _apex["default"].connection.RPCPromise.mock.calls.filter(function (_ref11) {
|
|
920
|
+
var _ref12 = _slicedToArray(_ref11, 1),
|
|
921
|
+
endpoint = _ref12[0];
|
|
701
922
|
return endpoint === 'GetAccountInfo';
|
|
702
923
|
});
|
|
703
924
|
expect(getAccountInfoCalls.length).toBe(3);
|
|
704
925
|
case 2:
|
|
705
|
-
return
|
|
926
|
+
return _context10.a(2);
|
|
706
927
|
}
|
|
707
|
-
},
|
|
928
|
+
}, _callee10);
|
|
708
929
|
})));
|
|
709
930
|
|
|
710
931
|
// example of test not needed for 100% coverage, but very nessisary for actual coverage
|
|
711
|
-
it('should dispatch expected thunks after getting user accounts', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
932
|
+
it('should dispatch expected thunks after getting user accounts', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
712
933
|
var userAccountIds, accountInfo, expectedActions;
|
|
713
|
-
return _regenerator().w(function (
|
|
714
|
-
while (1) switch (
|
|
934
|
+
return _regenerator().w(function (_context11) {
|
|
935
|
+
while (1) switch (_context11.n) {
|
|
715
936
|
case 0:
|
|
716
937
|
userAccountIds = [1];
|
|
717
938
|
accountInfo = {
|
|
@@ -737,20 +958,20 @@ describe('userActions', function () {
|
|
|
737
958
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetAccountInfo', {
|
|
738
959
|
o: JSON.stringify(accountInfo)
|
|
739
960
|
});
|
|
740
|
-
|
|
961
|
+
_context11.n = 1;
|
|
741
962
|
return store.dispatch(actions.getUserAccounts());
|
|
742
963
|
case 1:
|
|
743
964
|
expect(store.getActions()).toEqual(expect.arrayContaining(expectedActions));
|
|
744
965
|
expect(_verificationLevelUpdateService["default"].subscribe).toHaveBeenCalled();
|
|
745
966
|
case 2:
|
|
746
|
-
return
|
|
967
|
+
return _context11.a(2);
|
|
747
968
|
}
|
|
748
|
-
},
|
|
969
|
+
}, _callee11);
|
|
749
970
|
})));
|
|
750
|
-
it('should dispatch expected thunks after getting user accounts if UpfrontKYC is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
971
|
+
it('should dispatch expected thunks after getting user accounts if UpfrontKYC is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
751
972
|
var userAccountIds, accountInfo, expectedActions;
|
|
752
|
-
return _regenerator().w(function (
|
|
753
|
-
while (1) switch (
|
|
973
|
+
return _regenerator().w(function (_context12) {
|
|
974
|
+
while (1) switch (_context12.n) {
|
|
754
975
|
case 0:
|
|
755
976
|
_config["default"].setReturnValue(false);
|
|
756
977
|
userAccountIds = [1];
|
|
@@ -777,25 +998,91 @@ describe('userActions', function () {
|
|
|
777
998
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetAccountInfo', {
|
|
778
999
|
o: JSON.stringify(accountInfo)
|
|
779
1000
|
});
|
|
780
|
-
|
|
1001
|
+
_context12.n = 1;
|
|
781
1002
|
return store.dispatch(actions.getUserAccounts());
|
|
782
1003
|
case 1:
|
|
783
1004
|
expect(store.getActions()).toEqual(expect.arrayContaining(expectedActions));
|
|
784
1005
|
expect(_verificationLevelUpdateService["default"].subscribe).toHaveBeenCalled();
|
|
785
1006
|
case 2:
|
|
786
|
-
return
|
|
1007
|
+
return _context12.a(2);
|
|
787
1008
|
}
|
|
788
|
-
},
|
|
1009
|
+
}, _callee12);
|
|
1010
|
+
})));
|
|
1011
|
+
it('should mark accounts as loaded after receiving them', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
1012
|
+
var types;
|
|
1013
|
+
return _regenerator().w(function (_context13) {
|
|
1014
|
+
while (1) switch (_context13.n) {
|
|
1015
|
+
case 0:
|
|
1016
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', {
|
|
1017
|
+
o: JSON.stringify([1])
|
|
1018
|
+
});
|
|
1019
|
+
_context13.n = 1;
|
|
1020
|
+
return store.dispatch(actions.getUserAccounts(99));
|
|
1021
|
+
case 1:
|
|
1022
|
+
types = store.getActions().map(function (_ref16) {
|
|
1023
|
+
var type = _ref16.type;
|
|
1024
|
+
return type;
|
|
1025
|
+
});
|
|
1026
|
+
expect(types[types.length - 1]).toBe(actions.ACCOUNTS_LOADED);
|
|
1027
|
+
expect(types.indexOf(actions.RECEIVE_ACCOUNT)).toBeLessThan(types.indexOf(actions.ACCOUNTS_LOADED));
|
|
1028
|
+
case 2:
|
|
1029
|
+
return _context13.a(2);
|
|
1030
|
+
}
|
|
1031
|
+
}, _callee13);
|
|
1032
|
+
})));
|
|
1033
|
+
it('should resolve with no accounts and mark them as loaded when GetUserAccounts returns an error payload', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
1034
|
+
var errorPayload, accounts;
|
|
1035
|
+
return _regenerator().w(function (_context14) {
|
|
1036
|
+
while (1) switch (_context14.n) {
|
|
1037
|
+
case 0:
|
|
1038
|
+
errorPayload = {
|
|
1039
|
+
result: false,
|
|
1040
|
+
errormsg: 'Not Authorized',
|
|
1041
|
+
errorcode: 20
|
|
1042
|
+
};
|
|
1043
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', {
|
|
1044
|
+
o: JSON.stringify(errorPayload)
|
|
1045
|
+
});
|
|
1046
|
+
_context14.n = 1;
|
|
1047
|
+
return store.dispatch(actions.getUserAccounts(99));
|
|
1048
|
+
case 1:
|
|
1049
|
+
accounts = _context14.v;
|
|
1050
|
+
expect(accounts).toEqual([]);
|
|
1051
|
+
expect(console.error).toHaveBeenCalledWith('GetUserAccounts did not return an array', errorPayload);
|
|
1052
|
+
expect(_apex["default"].connection.RPCPromise).not.toHaveBeenCalledWith('GetAccountInfo', expect.anything());
|
|
1053
|
+
expect(store.getActions()).toEqual([actions.accountsLoaded()]);
|
|
1054
|
+
case 2:
|
|
1055
|
+
return _context14.a(2);
|
|
1056
|
+
}
|
|
1057
|
+
}, _callee14);
|
|
1058
|
+
})));
|
|
1059
|
+
it('should resolve with no accounts and mark them as loaded when GetUserAccounts rejects', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
1060
|
+
var accounts;
|
|
1061
|
+
return _regenerator().w(function (_context15) {
|
|
1062
|
+
while (1) switch (_context15.n) {
|
|
1063
|
+
case 0:
|
|
1064
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', Promise.reject(new Error('fail')));
|
|
1065
|
+
_context15.n = 1;
|
|
1066
|
+
return store.dispatch(actions.getUserAccounts(99));
|
|
1067
|
+
case 1:
|
|
1068
|
+
accounts = _context15.v;
|
|
1069
|
+
expect(accounts).toEqual([]);
|
|
1070
|
+
expect(console.error).toHaveBeenCalledWith('getUserAccounts action error', expect.anything());
|
|
1071
|
+
expect(store.getActions()).toEqual([actions.accountsLoaded()]);
|
|
1072
|
+
case 2:
|
|
1073
|
+
return _context15.a(2);
|
|
1074
|
+
}
|
|
1075
|
+
}, _callee15);
|
|
789
1076
|
})));
|
|
790
1077
|
});
|
|
791
1078
|
describe('selectAccount', function () {
|
|
792
|
-
it('should dispatch expected thunks after select account if privateMarketData = false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1079
|
+
it('should dispatch expected thunks after select account if privateMarketData = false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
|
|
793
1080
|
var accountId, expectedActions;
|
|
794
|
-
return _regenerator().w(function (
|
|
795
|
-
while (1) switch (
|
|
1081
|
+
return _regenerator().w(function (_context16) {
|
|
1082
|
+
while (1) switch (_context16.n) {
|
|
796
1083
|
case 0:
|
|
797
1084
|
accountId = 1;
|
|
798
|
-
|
|
1085
|
+
_context16.n = 1;
|
|
799
1086
|
return store.dispatch(actions.selectAccount(1, 1));
|
|
800
1087
|
case 1:
|
|
801
1088
|
expectedActions = [{
|
|
@@ -811,18 +1098,18 @@ describe('userActions', function () {
|
|
|
811
1098
|
expect(positionActions.getAccountPositions).toHaveBeenCalled();
|
|
812
1099
|
expect(positionActions.subscribeToAccountPositionEvents).toHaveBeenCalled();
|
|
813
1100
|
case 2:
|
|
814
|
-
return
|
|
1101
|
+
return _context16.a(2);
|
|
815
1102
|
}
|
|
816
|
-
},
|
|
1103
|
+
}, _callee16);
|
|
817
1104
|
})));
|
|
818
|
-
it('should dispatch expected thunks after select account if privateMarketData = true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1105
|
+
it('should dispatch expected thunks after select account if privateMarketData = true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
819
1106
|
var accountId, expectedActions;
|
|
820
|
-
return _regenerator().w(function (
|
|
821
|
-
while (1) switch (
|
|
1107
|
+
return _regenerator().w(function (_context17) {
|
|
1108
|
+
while (1) switch (_context17.n) {
|
|
822
1109
|
case 0:
|
|
823
1110
|
_config["default"].setPrivateMarketData(true);
|
|
824
1111
|
accountId = 1;
|
|
825
|
-
|
|
1112
|
+
_context17.n = 1;
|
|
826
1113
|
return store.dispatch(actions.selectAccount(1, 1));
|
|
827
1114
|
case 1:
|
|
828
1115
|
expectedActions = [{
|
|
@@ -838,9 +1125,9 @@ describe('userActions', function () {
|
|
|
838
1125
|
expect(positionActions.getAccountPositions).toHaveBeenCalled();
|
|
839
1126
|
expect(positionActions.subscribeToAccountPositionEvents).toHaveBeenCalled();
|
|
840
1127
|
case 2:
|
|
841
|
-
return
|
|
1128
|
+
return _context17.a(2);
|
|
842
1129
|
}
|
|
843
|
-
},
|
|
1130
|
+
}, _callee17);
|
|
844
1131
|
})));
|
|
845
1132
|
});
|
|
846
1133
|
describe('updateAccount', function () {
|
|
@@ -863,16 +1150,16 @@ describe('userActions', function () {
|
|
|
863
1150
|
}
|
|
864
1151
|
});
|
|
865
1152
|
});
|
|
866
|
-
it('should call UpdateAccount from apex', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
867
|
-
return _regenerator().w(function (
|
|
868
|
-
while (1) switch (
|
|
1153
|
+
it('should call UpdateAccount from apex', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
|
|
1154
|
+
return _regenerator().w(function (_context18) {
|
|
1155
|
+
while (1) switch (_context18.n) {
|
|
869
1156
|
case 0:
|
|
870
1157
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
871
1158
|
o: JSON.stringify({
|
|
872
1159
|
result: false
|
|
873
1160
|
})
|
|
874
1161
|
});
|
|
875
|
-
|
|
1162
|
+
_context18.n = 1;
|
|
876
1163
|
return store.dispatch(actions.updateAccount());
|
|
877
1164
|
case 1:
|
|
878
1165
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('UpdateAccount', {
|
|
@@ -881,14 +1168,14 @@ describe('userActions', function () {
|
|
|
881
1168
|
LoyaltyProductId: 0
|
|
882
1169
|
});
|
|
883
1170
|
case 2:
|
|
884
|
-
return
|
|
1171
|
+
return _context18.a(2);
|
|
885
1172
|
}
|
|
886
|
-
},
|
|
1173
|
+
}, _callee18);
|
|
887
1174
|
})));
|
|
888
|
-
it('should call UpdateAccount from apex with params if loyaltyProduct is passed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1175
|
+
it('should call UpdateAccount from apex with params if loyaltyProduct is passed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
|
|
889
1176
|
var loyaltyProduct;
|
|
890
|
-
return _regenerator().w(function (
|
|
891
|
-
while (1) switch (
|
|
1177
|
+
return _regenerator().w(function (_context19) {
|
|
1178
|
+
while (1) switch (_context19.n) {
|
|
892
1179
|
case 0:
|
|
893
1180
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
894
1181
|
o: JSON.stringify({
|
|
@@ -899,7 +1186,7 @@ describe('userActions', function () {
|
|
|
899
1186
|
ProductId: 2,
|
|
900
1187
|
Amount: 1
|
|
901
1188
|
};
|
|
902
|
-
|
|
1189
|
+
_context19.n = 1;
|
|
903
1190
|
return store.dispatch(actions.updateAccount(loyaltyProduct));
|
|
904
1191
|
case 1:
|
|
905
1192
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('UpdateAccount', {
|
|
@@ -908,14 +1195,14 @@ describe('userActions', function () {
|
|
|
908
1195
|
LoyaltyProductId: 2
|
|
909
1196
|
});
|
|
910
1197
|
case 2:
|
|
911
|
-
return
|
|
1198
|
+
return _context19.a(2);
|
|
912
1199
|
}
|
|
913
|
-
},
|
|
1200
|
+
}, _callee19);
|
|
914
1201
|
})));
|
|
915
|
-
it('should call UpdateAccount from apex with params if loyaltyProduct is passed and Amount === 0', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1202
|
+
it('should call UpdateAccount from apex with params if loyaltyProduct is passed and Amount === 0', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
|
|
916
1203
|
var loyaltyProduct;
|
|
917
|
-
return _regenerator().w(function (
|
|
918
|
-
while (1) switch (
|
|
1204
|
+
return _regenerator().w(function (_context20) {
|
|
1205
|
+
while (1) switch (_context20.n) {
|
|
919
1206
|
case 0:
|
|
920
1207
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
921
1208
|
o: JSON.stringify({
|
|
@@ -926,7 +1213,7 @@ describe('userActions', function () {
|
|
|
926
1213
|
ProductId: 2,
|
|
927
1214
|
Amount: 0
|
|
928
1215
|
};
|
|
929
|
-
|
|
1216
|
+
_context20.n = 1;
|
|
930
1217
|
return store.dispatch(actions.updateAccount(loyaltyProduct));
|
|
931
1218
|
case 1:
|
|
932
1219
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('UpdateAccount', {
|
|
@@ -935,13 +1222,13 @@ describe('userActions', function () {
|
|
|
935
1222
|
LoyaltyProductId: 2
|
|
936
1223
|
});
|
|
937
1224
|
case 2:
|
|
938
|
-
return
|
|
1225
|
+
return _context20.a(2);
|
|
939
1226
|
}
|
|
940
|
-
},
|
|
1227
|
+
}, _callee20);
|
|
941
1228
|
})));
|
|
942
|
-
it('should dispatch expected action if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
943
|
-
return _regenerator().w(function (
|
|
944
|
-
while (1) switch (
|
|
1229
|
+
it('should dispatch expected action if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
|
|
1230
|
+
return _regenerator().w(function (_context21) {
|
|
1231
|
+
while (1) switch (_context21.n) {
|
|
945
1232
|
case 0:
|
|
946
1233
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
947
1234
|
o: JSON.stringify({
|
|
@@ -951,20 +1238,20 @@ describe('userActions', function () {
|
|
|
951
1238
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', {
|
|
952
1239
|
o: JSON.stringify([])
|
|
953
1240
|
});
|
|
954
|
-
|
|
1241
|
+
_context21.n = 1;
|
|
955
1242
|
return store.dispatch(actions.updateAccount());
|
|
956
1243
|
case 1:
|
|
957
1244
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetUserAccounts', {
|
|
958
1245
|
OMSId: 1
|
|
959
1246
|
});
|
|
960
1247
|
case 2:
|
|
961
|
-
return
|
|
1248
|
+
return _context21.a(2);
|
|
962
1249
|
}
|
|
963
|
-
},
|
|
1250
|
+
}, _callee21);
|
|
964
1251
|
})));
|
|
965
|
-
it('should dispatch showSnack if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
966
|
-
return _regenerator().w(function (
|
|
967
|
-
while (1) switch (
|
|
1252
|
+
it('should dispatch showSnack if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22() {
|
|
1253
|
+
return _regenerator().w(function (_context22) {
|
|
1254
|
+
while (1) switch (_context22.n) {
|
|
968
1255
|
case 0:
|
|
969
1256
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
970
1257
|
o: JSON.stringify({
|
|
@@ -974,7 +1261,7 @@ describe('userActions', function () {
|
|
|
974
1261
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', {
|
|
975
1262
|
o: JSON.stringify([])
|
|
976
1263
|
});
|
|
977
|
-
|
|
1264
|
+
_context22.n = 1;
|
|
978
1265
|
return store.dispatch(actions.updateAccount());
|
|
979
1266
|
case 1:
|
|
980
1267
|
expect(snackbarActions.showSnack).toHaveBeenCalledWith({
|
|
@@ -983,14 +1270,14 @@ describe('userActions', function () {
|
|
|
983
1270
|
type: 'success'
|
|
984
1271
|
});
|
|
985
1272
|
case 2:
|
|
986
|
-
return
|
|
1273
|
+
return _context22.a(2);
|
|
987
1274
|
}
|
|
988
|
-
},
|
|
1275
|
+
}, _callee22);
|
|
989
1276
|
})));
|
|
990
|
-
it('should dispatch showSnack if response result is true and loyaltyProduct is passed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1277
|
+
it('should dispatch showSnack if response result is true and loyaltyProduct is passed', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23() {
|
|
991
1278
|
var loyaltyProduct;
|
|
992
|
-
return _regenerator().w(function (
|
|
993
|
-
while (1) switch (
|
|
1279
|
+
return _regenerator().w(function (_context23) {
|
|
1280
|
+
while (1) switch (_context23.n) {
|
|
994
1281
|
case 0:
|
|
995
1282
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
996
1283
|
o: JSON.stringify({
|
|
@@ -1004,7 +1291,7 @@ describe('userActions', function () {
|
|
|
1004
1291
|
ProductId: 2,
|
|
1005
1292
|
Amount: 0
|
|
1006
1293
|
};
|
|
1007
|
-
|
|
1294
|
+
_context23.n = 1;
|
|
1008
1295
|
return store.dispatch(actions.updateAccount(loyaltyProduct));
|
|
1009
1296
|
case 1:
|
|
1010
1297
|
expect(snackbarActions.showSnack).toHaveBeenCalledWith({
|
|
@@ -1013,37 +1300,37 @@ describe('userActions', function () {
|
|
|
1013
1300
|
type: 'success'
|
|
1014
1301
|
});
|
|
1015
1302
|
case 2:
|
|
1016
|
-
return
|
|
1303
|
+
return _context23.a(2);
|
|
1017
1304
|
}
|
|
1018
|
-
},
|
|
1305
|
+
}, _callee23);
|
|
1019
1306
|
})));
|
|
1020
|
-
it('should dispatch showSnack if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1021
|
-
return _regenerator().w(function (
|
|
1022
|
-
while (1) switch (
|
|
1307
|
+
it('should dispatch showSnack if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24() {
|
|
1308
|
+
return _regenerator().w(function (_context24) {
|
|
1309
|
+
while (1) switch (_context24.n) {
|
|
1023
1310
|
case 0:
|
|
1024
1311
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
1025
1312
|
o: JSON.stringify({
|
|
1026
1313
|
result: false
|
|
1027
1314
|
})
|
|
1028
1315
|
});
|
|
1029
|
-
|
|
1316
|
+
_context24.n = 1;
|
|
1030
1317
|
return store.dispatch(actions.updateAccount());
|
|
1031
1318
|
case 1:
|
|
1032
1319
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1033
1320
|
case 2:
|
|
1034
|
-
return
|
|
1321
|
+
return _context24.a(2);
|
|
1035
1322
|
}
|
|
1036
|
-
},
|
|
1323
|
+
}, _callee24);
|
|
1037
1324
|
})));
|
|
1038
1325
|
});
|
|
1039
1326
|
describe('setUserInfo', function () {
|
|
1040
1327
|
beforeEach(function () {
|
|
1041
1328
|
_apex["default"].connection.resetRPCPromiseResponses();
|
|
1042
1329
|
});
|
|
1043
|
-
it('should call apex.connection.RPCPromise with SetUserInfo', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1330
|
+
it('should call apex.connection.RPCPromise with SetUserInfo', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25() {
|
|
1044
1331
|
var user;
|
|
1045
|
-
return _regenerator().w(function (
|
|
1046
|
-
while (1) switch (
|
|
1332
|
+
return _regenerator().w(function (_context25) {
|
|
1333
|
+
while (1) switch (_context25.n) {
|
|
1047
1334
|
case 0:
|
|
1048
1335
|
user = {
|
|
1049
1336
|
UserName: 'UserName',
|
|
@@ -1052,7 +1339,7 @@ describe('userActions', function () {
|
|
|
1052
1339
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserInfo', {
|
|
1053
1340
|
o: JSON.stringify({})
|
|
1054
1341
|
});
|
|
1055
|
-
|
|
1342
|
+
_context25.n = 1;
|
|
1056
1343
|
return actions.setUserInfo(user)(dispatchStub);
|
|
1057
1344
|
case 1:
|
|
1058
1345
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('SetUserInfo', {
|
|
@@ -1060,14 +1347,14 @@ describe('userActions', function () {
|
|
|
1060
1347
|
Email: undefined
|
|
1061
1348
|
});
|
|
1062
1349
|
case 2:
|
|
1063
|
-
return
|
|
1350
|
+
return _context25.a(2);
|
|
1064
1351
|
}
|
|
1065
|
-
},
|
|
1352
|
+
}, _callee25);
|
|
1066
1353
|
})));
|
|
1067
|
-
it('should dispatch expected actions after set user info', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1354
|
+
it('should dispatch expected actions after set user info', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26() {
|
|
1068
1355
|
var userInfo, user, expectedActions;
|
|
1069
|
-
return _regenerator().w(function (
|
|
1070
|
-
while (1) switch (
|
|
1356
|
+
return _regenerator().w(function (_context26) {
|
|
1357
|
+
while (1) switch (_context26.n) {
|
|
1071
1358
|
case 0:
|
|
1072
1359
|
userInfo = {
|
|
1073
1360
|
result: true
|
|
@@ -1083,19 +1370,19 @@ describe('userActions', function () {
|
|
|
1083
1370
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserInfo', {
|
|
1084
1371
|
o: JSON.stringify(userInfo)
|
|
1085
1372
|
});
|
|
1086
|
-
|
|
1373
|
+
_context26.n = 1;
|
|
1087
1374
|
return store.dispatch(actions.setUserInfo(user));
|
|
1088
1375
|
case 1:
|
|
1089
1376
|
expect(store.getActions()).toEqual(expect.arrayContaining(expectedActions));
|
|
1090
1377
|
case 2:
|
|
1091
|
-
return
|
|
1378
|
+
return _context26.a(2);
|
|
1092
1379
|
}
|
|
1093
|
-
},
|
|
1380
|
+
}, _callee26);
|
|
1094
1381
|
})));
|
|
1095
|
-
it('should dispatch expected actions after failed set user info', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1382
|
+
it('should dispatch expected actions after failed set user info', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27() {
|
|
1096
1383
|
var userInfo, user;
|
|
1097
|
-
return _regenerator().w(function (
|
|
1098
|
-
while (1) switch (
|
|
1384
|
+
return _regenerator().w(function (_context27) {
|
|
1385
|
+
while (1) switch (_context27.n) {
|
|
1099
1386
|
case 0:
|
|
1100
1387
|
userInfo = {
|
|
1101
1388
|
result: false
|
|
@@ -1107,14 +1394,14 @@ describe('userActions', function () {
|
|
|
1107
1394
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserInfo', {
|
|
1108
1395
|
o: JSON.stringify(userInfo)
|
|
1109
1396
|
});
|
|
1110
|
-
|
|
1397
|
+
_context27.n = 1;
|
|
1111
1398
|
return store.dispatch(actions.setUserInfo(user));
|
|
1112
1399
|
case 1:
|
|
1113
1400
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1114
1401
|
case 2:
|
|
1115
|
-
return
|
|
1402
|
+
return _context27.a(2);
|
|
1116
1403
|
}
|
|
1117
|
-
},
|
|
1404
|
+
}, _callee27);
|
|
1118
1405
|
})));
|
|
1119
1406
|
});
|
|
1120
1407
|
describe('setUserConfig', function () {
|
|
@@ -1127,16 +1414,16 @@ describe('userActions', function () {
|
|
|
1127
1414
|
})
|
|
1128
1415
|
});
|
|
1129
1416
|
});
|
|
1130
|
-
it('should call apex.connection.RPCPromise with SetUserConfig', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1131
|
-
return _regenerator().w(function (
|
|
1132
|
-
while (1) switch (
|
|
1417
|
+
it('should call apex.connection.RPCPromise with SetUserConfig', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee28() {
|
|
1418
|
+
return _regenerator().w(function (_context28) {
|
|
1419
|
+
while (1) switch (_context28.n) {
|
|
1133
1420
|
case 0:
|
|
1134
1421
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserConfig', {
|
|
1135
1422
|
o: JSON.stringify({
|
|
1136
1423
|
result: false
|
|
1137
1424
|
})
|
|
1138
1425
|
});
|
|
1139
|
-
|
|
1426
|
+
_context28.n = 1;
|
|
1140
1427
|
return store.dispatch(actions.setUserConfig());
|
|
1141
1428
|
case 1:
|
|
1142
1429
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('SetUserConfig', {
|
|
@@ -1145,23 +1432,23 @@ describe('userActions', function () {
|
|
|
1145
1432
|
Config: undefined
|
|
1146
1433
|
});
|
|
1147
1434
|
case 2:
|
|
1148
|
-
return
|
|
1435
|
+
return _context28.a(2);
|
|
1149
1436
|
}
|
|
1150
|
-
},
|
|
1437
|
+
}, _callee28);
|
|
1151
1438
|
})));
|
|
1152
|
-
it('should dispatch expected actions after set user config', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1153
|
-
return _regenerator().w(function (
|
|
1154
|
-
while (1) switch (
|
|
1439
|
+
it('should dispatch expected actions after set user config', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee29() {
|
|
1440
|
+
return _regenerator().w(function (_context29) {
|
|
1441
|
+
while (1) switch (_context29.n) {
|
|
1155
1442
|
case 0:
|
|
1156
1443
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserConfig', {
|
|
1157
1444
|
o: JSON.stringify({
|
|
1158
1445
|
result: true
|
|
1159
1446
|
})
|
|
1160
1447
|
});
|
|
1161
|
-
|
|
1448
|
+
_context29.n = 1;
|
|
1162
1449
|
return store.dispatch(actions.setUserConfig());
|
|
1163
1450
|
case 1:
|
|
1164
|
-
return
|
|
1451
|
+
return _context29.a(2, new Promise(function (resolve, reject) {
|
|
1165
1452
|
setTimeout(function () {
|
|
1166
1453
|
try {
|
|
1167
1454
|
expect(store.getActions()).toEqual([{
|
|
@@ -1177,32 +1464,32 @@ describe('userActions', function () {
|
|
|
1177
1464
|
}, 0);
|
|
1178
1465
|
}));
|
|
1179
1466
|
}
|
|
1180
|
-
},
|
|
1467
|
+
}, _callee29);
|
|
1181
1468
|
})));
|
|
1182
|
-
it('should dispatch expected actions after failed set user config', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1183
|
-
return _regenerator().w(function (
|
|
1184
|
-
while (1) switch (
|
|
1469
|
+
it('should dispatch expected actions after failed set user config', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee30() {
|
|
1470
|
+
return _regenerator().w(function (_context30) {
|
|
1471
|
+
while (1) switch (_context30.n) {
|
|
1185
1472
|
case 0:
|
|
1186
1473
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserConfig', {
|
|
1187
1474
|
o: JSON.stringify({
|
|
1188
1475
|
result: false
|
|
1189
1476
|
})
|
|
1190
1477
|
});
|
|
1191
|
-
|
|
1478
|
+
_context30.n = 1;
|
|
1192
1479
|
return store.dispatch(actions.setUserConfig());
|
|
1193
1480
|
case 1:
|
|
1194
1481
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1195
1482
|
case 2:
|
|
1196
|
-
return
|
|
1483
|
+
return _context30.a(2);
|
|
1197
1484
|
}
|
|
1198
|
-
},
|
|
1485
|
+
}, _callee30);
|
|
1199
1486
|
})));
|
|
1200
1487
|
});
|
|
1201
1488
|
describe('enable2FA', function () {
|
|
1202
|
-
it('should call apex.connection.Authenticate2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1489
|
+
it('should call apex.connection.Authenticate2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee31() {
|
|
1203
1490
|
var getState;
|
|
1204
|
-
return _regenerator().w(function (
|
|
1205
|
-
while (1) switch (
|
|
1491
|
+
return _regenerator().w(function (_context31) {
|
|
1492
|
+
while (1) switch (_context31.n) {
|
|
1206
1493
|
case 0:
|
|
1207
1494
|
_apex["default"].connection.setResponse({
|
|
1208
1495
|
Authenticated: true
|
|
@@ -1216,23 +1503,23 @@ describe('userActions', function () {
|
|
|
1216
1503
|
}
|
|
1217
1504
|
};
|
|
1218
1505
|
});
|
|
1219
|
-
|
|
1506
|
+
_context31.n = 1;
|
|
1220
1507
|
return actions.enable2FA()(dispatchStub, getState);
|
|
1221
1508
|
case 1:
|
|
1222
1509
|
expect(_apex["default"].connection.Authenticate2FA).toHaveBeenCalled();
|
|
1223
1510
|
case 2:
|
|
1224
|
-
return
|
|
1511
|
+
return _context31.a(2);
|
|
1225
1512
|
}
|
|
1226
|
-
},
|
|
1513
|
+
}, _callee31);
|
|
1227
1514
|
})));
|
|
1228
|
-
it('should dispatch expected actions after enable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1229
|
-
return _regenerator().w(function (
|
|
1230
|
-
while (1) switch (
|
|
1515
|
+
it('should dispatch expected actions after enable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee32() {
|
|
1516
|
+
return _regenerator().w(function (_context32) {
|
|
1517
|
+
while (1) switch (_context32.n) {
|
|
1231
1518
|
case 0:
|
|
1232
1519
|
_apex["default"].connection.setResponse({
|
|
1233
1520
|
Authenticated: true
|
|
1234
1521
|
});
|
|
1235
|
-
|
|
1522
|
+
_context32.n = 1;
|
|
1236
1523
|
return store.dispatch(actions.enable2FA());
|
|
1237
1524
|
case 1:
|
|
1238
1525
|
expect(store.getActions()).toContainEqual({
|
|
@@ -1247,32 +1534,32 @@ describe('userActions', function () {
|
|
|
1247
1534
|
});
|
|
1248
1535
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1249
1536
|
case 2:
|
|
1250
|
-
return
|
|
1537
|
+
return _context32.a(2);
|
|
1251
1538
|
}
|
|
1252
|
-
},
|
|
1539
|
+
}, _callee32);
|
|
1253
1540
|
})));
|
|
1254
|
-
it('should dispatch expected actions after failed enable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1255
|
-
return _regenerator().w(function (
|
|
1256
|
-
while (1) switch (
|
|
1541
|
+
it('should dispatch expected actions after failed enable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee33() {
|
|
1542
|
+
return _regenerator().w(function (_context33) {
|
|
1543
|
+
while (1) switch (_context33.n) {
|
|
1257
1544
|
case 0:
|
|
1258
1545
|
_apex["default"].connection.setResponse({
|
|
1259
1546
|
Authenticated: false
|
|
1260
1547
|
});
|
|
1261
|
-
|
|
1548
|
+
_context33.n = 1;
|
|
1262
1549
|
return store.dispatch(actions.enable2FA());
|
|
1263
1550
|
case 1:
|
|
1264
1551
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1265
1552
|
case 2:
|
|
1266
|
-
return
|
|
1553
|
+
return _context33.a(2);
|
|
1267
1554
|
}
|
|
1268
|
-
},
|
|
1555
|
+
}, _callee33);
|
|
1269
1556
|
})));
|
|
1270
1557
|
});
|
|
1271
1558
|
describe('disable2FA', function () {
|
|
1272
|
-
it('should call apex.connection.Disable2FA andapex.connection.Authenticate2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1559
|
+
it('should call apex.connection.Disable2FA andapex.connection.Authenticate2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee34() {
|
|
1273
1560
|
var getState;
|
|
1274
|
-
return _regenerator().w(function (
|
|
1275
|
-
while (1) switch (
|
|
1561
|
+
return _regenerator().w(function (_context34) {
|
|
1562
|
+
while (1) switch (_context34.n) {
|
|
1276
1563
|
case 0:
|
|
1277
1564
|
getState = jest.fn(function () {
|
|
1278
1565
|
return {
|
|
@@ -1289,7 +1576,7 @@ describe('userActions', function () {
|
|
|
1289
1576
|
Authenticated: true
|
|
1290
1577
|
})
|
|
1291
1578
|
}));
|
|
1292
|
-
|
|
1579
|
+
_context34.n = 1;
|
|
1293
1580
|
return actions.disable2FA()(dispatchStub, getState);
|
|
1294
1581
|
case 1:
|
|
1295
1582
|
expect(_apex["default"].connection.Disable2FA).toHaveBeenCalled();
|
|
@@ -1297,20 +1584,20 @@ describe('userActions', function () {
|
|
|
1297
1584
|
Code: undefined
|
|
1298
1585
|
});
|
|
1299
1586
|
case 2:
|
|
1300
|
-
return
|
|
1587
|
+
return _context34.a(2);
|
|
1301
1588
|
}
|
|
1302
|
-
},
|
|
1589
|
+
}, _callee34);
|
|
1303
1590
|
})));
|
|
1304
|
-
it('should dispatch expected actions after disable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1305
|
-
return _regenerator().w(function (
|
|
1306
|
-
while (1) switch (
|
|
1591
|
+
it('should dispatch expected actions after disable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee35() {
|
|
1592
|
+
return _regenerator().w(function (_context35) {
|
|
1593
|
+
while (1) switch (_context35.n) {
|
|
1307
1594
|
case 0:
|
|
1308
1595
|
_apex["default"].connection.setRPCPromiseReturnValue(Promise.resolve({
|
|
1309
1596
|
o: JSON.stringify({
|
|
1310
1597
|
Authenticated: true
|
|
1311
1598
|
})
|
|
1312
1599
|
}));
|
|
1313
|
-
|
|
1600
|
+
_context35.n = 1;
|
|
1314
1601
|
return store.dispatch(actions.disable2FA());
|
|
1315
1602
|
case 1:
|
|
1316
1603
|
expect(store.getActions()).toContainEqual({
|
|
@@ -1322,51 +1609,408 @@ describe('userActions', function () {
|
|
|
1322
1609
|
expect(_modalActions.closeModal).toHaveBeenCalledWith(_modalActions.MODAL_TYPES.DISABLE_2FA);
|
|
1323
1610
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1324
1611
|
case 2:
|
|
1325
|
-
return
|
|
1612
|
+
return _context35.a(2);
|
|
1326
1613
|
}
|
|
1327
|
-
},
|
|
1614
|
+
}, _callee35);
|
|
1328
1615
|
})));
|
|
1329
|
-
it('should dispatch expected actions after failed disable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1330
|
-
return _regenerator().w(function (
|
|
1331
|
-
while (1) switch (
|
|
1616
|
+
it('should dispatch expected actions after failed disable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee36() {
|
|
1617
|
+
return _regenerator().w(function (_context36) {
|
|
1618
|
+
while (1) switch (_context36.n) {
|
|
1332
1619
|
case 0:
|
|
1333
1620
|
_apex["default"].connection.setRPCPromiseReturnValue(Promise.resolve({
|
|
1334
1621
|
o: JSON.stringify({
|
|
1335
1622
|
Authenticated: false
|
|
1336
1623
|
})
|
|
1337
1624
|
}));
|
|
1338
|
-
|
|
1625
|
+
_context36.n = 1;
|
|
1339
1626
|
return store.dispatch(actions.disable2FA());
|
|
1340
1627
|
case 1:
|
|
1341
1628
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1342
1629
|
case 2:
|
|
1343
|
-
return
|
|
1630
|
+
return _context36.a(2);
|
|
1344
1631
|
}
|
|
1345
|
-
},
|
|
1632
|
+
}, _callee36);
|
|
1633
|
+
})));
|
|
1634
|
+
it('shows Code Rejected instead of throwing when Disable2FA fails', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee37() {
|
|
1635
|
+
return _regenerator().w(function (_context37) {
|
|
1636
|
+
while (1) switch (_context37.n) {
|
|
1637
|
+
case 0:
|
|
1638
|
+
_apex["default"].connection.Disable2FA.mockImplementationOnce(function () {
|
|
1639
|
+
return Promise.reject(new Error('socket closed'));
|
|
1640
|
+
});
|
|
1641
|
+
_context37.n = 1;
|
|
1642
|
+
return expect(store.dispatch(actions.disable2FA('123456'))).resolves.toBeUndefined();
|
|
1643
|
+
case 1:
|
|
1644
|
+
expect(snackbarActions.showSnack).toHaveBeenCalledWith(expect.objectContaining({
|
|
1645
|
+
text: 'Code Rejected'
|
|
1646
|
+
}));
|
|
1647
|
+
case 2:
|
|
1648
|
+
return _context37.a(2);
|
|
1649
|
+
}
|
|
1650
|
+
}, _callee37);
|
|
1651
|
+
})));
|
|
1652
|
+
it('forgets the passkey-only state and reloads the user config once 2FA is off', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee38() {
|
|
1653
|
+
var withUser;
|
|
1654
|
+
return _regenerator().w(function (_context38) {
|
|
1655
|
+
while (1) switch (_context38.n) {
|
|
1656
|
+
case 0:
|
|
1657
|
+
_apex["default"].connection.setRPCPromiseReturnValue(Promise.resolve({
|
|
1658
|
+
o: JSON.stringify({
|
|
1659
|
+
Authenticated: true
|
|
1660
|
+
})
|
|
1661
|
+
}));
|
|
1662
|
+
withUser = mockStore({
|
|
1663
|
+
user: {
|
|
1664
|
+
userInfo: {
|
|
1665
|
+
Use2FA: true,
|
|
1666
|
+
UserId: 7,
|
|
1667
|
+
UserName: 'u'
|
|
1668
|
+
}
|
|
1669
|
+
},
|
|
1670
|
+
api: {
|
|
1671
|
+
validate2FARequiredEndpoints: {}
|
|
1672
|
+
}
|
|
1673
|
+
});
|
|
1674
|
+
_context38.n = 1;
|
|
1675
|
+
return withUser.dispatch(actions.disable2FA('123456'));
|
|
1676
|
+
case 1:
|
|
1677
|
+
expect(withUser.getActions()).toContainEqual({
|
|
1678
|
+
type: 'AUTH_PASSKEY_ONLY',
|
|
1679
|
+
payload: {
|
|
1680
|
+
passkeyOnly: false
|
|
1681
|
+
}
|
|
1682
|
+
});
|
|
1683
|
+
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetUserConfig', {
|
|
1684
|
+
UserId: 7,
|
|
1685
|
+
UserName: 'u'
|
|
1686
|
+
});
|
|
1687
|
+
case 2:
|
|
1688
|
+
return _context38.a(2);
|
|
1689
|
+
}
|
|
1690
|
+
}, _callee38);
|
|
1691
|
+
})));
|
|
1692
|
+
it("writes nothing into the next user's state when the reply comes after logout", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee39() {
|
|
1693
|
+
var release, withUser, disabling;
|
|
1694
|
+
return _regenerator().w(function (_context39) {
|
|
1695
|
+
while (1) switch (_context39.n) {
|
|
1696
|
+
case 0:
|
|
1697
|
+
_apex["default"].connection.setRPCPromiseReturnValue(new Promise(function (resolve) {
|
|
1698
|
+
release = resolve;
|
|
1699
|
+
}));
|
|
1700
|
+
global.localStorage.removeItem = jest.fn();
|
|
1701
|
+
withUser = mockStore({
|
|
1702
|
+
auth: {
|
|
1703
|
+
isAuthenticated: true
|
|
1704
|
+
},
|
|
1705
|
+
user: {
|
|
1706
|
+
userInfo: {
|
|
1707
|
+
Use2FA: true,
|
|
1708
|
+
UserId: 7,
|
|
1709
|
+
UserName: 'u'
|
|
1710
|
+
}
|
|
1711
|
+
},
|
|
1712
|
+
api: {
|
|
1713
|
+
validate2FARequiredEndpoints: {}
|
|
1714
|
+
}
|
|
1715
|
+
});
|
|
1716
|
+
disabling = withUser.dispatch(actions.disable2FA('123456'));
|
|
1717
|
+
withUser.dispatch((0, _authActions.logout)());
|
|
1718
|
+
withUser.clearActions();
|
|
1719
|
+
release({
|
|
1720
|
+
o: JSON.stringify({
|
|
1721
|
+
Authenticated: true
|
|
1722
|
+
})
|
|
1723
|
+
});
|
|
1724
|
+
_context39.n = 1;
|
|
1725
|
+
return disabling;
|
|
1726
|
+
case 1:
|
|
1727
|
+
expect(withUser.getActions()).toEqual([]);
|
|
1728
|
+
case 2:
|
|
1729
|
+
return _context39.a(2);
|
|
1730
|
+
}
|
|
1731
|
+
}, _callee39);
|
|
1732
|
+
})));
|
|
1733
|
+
});
|
|
1734
|
+
describe('reloadSecondFactorState', function () {
|
|
1735
|
+
var withUser = function withUser() {
|
|
1736
|
+
return mockStore({
|
|
1737
|
+
user: {
|
|
1738
|
+
userInfo: {
|
|
1739
|
+
Use2FA: false,
|
|
1740
|
+
UserId: 7,
|
|
1741
|
+
UserName: 'u'
|
|
1742
|
+
}
|
|
1743
|
+
},
|
|
1744
|
+
api: {
|
|
1745
|
+
validate2FARequiredEndpoints: {}
|
|
1746
|
+
}
|
|
1747
|
+
});
|
|
1748
|
+
};
|
|
1749
|
+
it('reads the user info and user config again', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee40() {
|
|
1750
|
+
var store2;
|
|
1751
|
+
return _regenerator().w(function (_context40) {
|
|
1752
|
+
while (1) switch (_context40.n) {
|
|
1753
|
+
case 0:
|
|
1754
|
+
store2 = withUser();
|
|
1755
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserInfo', Promise.resolve({
|
|
1756
|
+
o: JSON.stringify({
|
|
1757
|
+
UserId: 7,
|
|
1758
|
+
Use2FA: true
|
|
1759
|
+
})
|
|
1760
|
+
}));
|
|
1761
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserConfig', Promise.resolve({
|
|
1762
|
+
o: JSON.stringify([{
|
|
1763
|
+
Key: '2FAType',
|
|
1764
|
+
Value: 'WebAuthn'
|
|
1765
|
+
}])
|
|
1766
|
+
}));
|
|
1767
|
+
_context40.n = 1;
|
|
1768
|
+
return store2.dispatch(actions.reloadSecondFactorState());
|
|
1769
|
+
case 1:
|
|
1770
|
+
expect(store2.getActions()).toEqual([{
|
|
1771
|
+
type: actions.USER_INFO_FETCHED,
|
|
1772
|
+
payload: {
|
|
1773
|
+
UserId: 7,
|
|
1774
|
+
Use2FA: true
|
|
1775
|
+
}
|
|
1776
|
+
}, {
|
|
1777
|
+
type: actions.USER_CONFIG_FETCHED,
|
|
1778
|
+
payload: [{
|
|
1779
|
+
Key: '2FAType',
|
|
1780
|
+
Value: 'WebAuthn'
|
|
1781
|
+
}]
|
|
1782
|
+
}]);
|
|
1783
|
+
case 2:
|
|
1784
|
+
return _context40.a(2);
|
|
1785
|
+
}
|
|
1786
|
+
}, _callee40);
|
|
1787
|
+
})));
|
|
1788
|
+
it('keeps the user info it has when GetUserInfo is refused', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee41() {
|
|
1789
|
+
var store2;
|
|
1790
|
+
return _regenerator().w(function (_context41) {
|
|
1791
|
+
while (1) switch (_context41.n) {
|
|
1792
|
+
case 0:
|
|
1793
|
+
store2 = withUser();
|
|
1794
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserInfo', Promise.resolve({
|
|
1795
|
+
o: JSON.stringify({
|
|
1796
|
+
result: false,
|
|
1797
|
+
errormsg: 'Operation Failed'
|
|
1798
|
+
})
|
|
1799
|
+
}));
|
|
1800
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserConfig', Promise.resolve({
|
|
1801
|
+
o: '[]'
|
|
1802
|
+
}));
|
|
1803
|
+
_context41.n = 1;
|
|
1804
|
+
return store2.dispatch(actions.reloadSecondFactorState());
|
|
1805
|
+
case 1:
|
|
1806
|
+
expect(store2.getActions()).toEqual([{
|
|
1807
|
+
type: actions.USER_CONFIG_FETCHED,
|
|
1808
|
+
payload: []
|
|
1809
|
+
}]);
|
|
1810
|
+
case 2:
|
|
1811
|
+
return _context41.a(2);
|
|
1812
|
+
}
|
|
1813
|
+
}, _callee41);
|
|
1814
|
+
})));
|
|
1815
|
+
describe('a reply that comes back after the user logged out', function () {
|
|
1816
|
+
var hold = function hold(endpoint) {
|
|
1817
|
+
var release;
|
|
1818
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint(endpoint, new Promise(function (resolve) {
|
|
1819
|
+
release = function release(body) {
|
|
1820
|
+
return resolve({
|
|
1821
|
+
o: JSON.stringify(body)
|
|
1822
|
+
});
|
|
1823
|
+
};
|
|
1824
|
+
}));
|
|
1825
|
+
return release;
|
|
1826
|
+
};
|
|
1827
|
+
var signedIn = function signedIn() {
|
|
1828
|
+
return mockStore({
|
|
1829
|
+
auth: {
|
|
1830
|
+
isAuthenticated: true
|
|
1831
|
+
},
|
|
1832
|
+
user: {
|
|
1833
|
+
userInfo: {
|
|
1834
|
+
Use2FA: false,
|
|
1835
|
+
UserId: 7,
|
|
1836
|
+
UserName: 'u'
|
|
1837
|
+
}
|
|
1838
|
+
},
|
|
1839
|
+
api: {
|
|
1840
|
+
validate2FARequiredEndpoints: {}
|
|
1841
|
+
}
|
|
1842
|
+
});
|
|
1843
|
+
};
|
|
1844
|
+
beforeEach(function () {
|
|
1845
|
+
jest.clearAllMocks();
|
|
1846
|
+
global.localStorage.removeItem = jest.fn();
|
|
1847
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('LogOut', Promise.resolve({
|
|
1848
|
+
o: '{}'
|
|
1849
|
+
}));
|
|
1850
|
+
});
|
|
1851
|
+
it("does not put the previous user's info into the next user's state, nor ask for their config", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee42() {
|
|
1852
|
+
var release, store2, reloading;
|
|
1853
|
+
return _regenerator().w(function (_context42) {
|
|
1854
|
+
while (1) switch (_context42.n) {
|
|
1855
|
+
case 0:
|
|
1856
|
+
release = hold('GetUserInfo');
|
|
1857
|
+
store2 = signedIn();
|
|
1858
|
+
reloading = store2.dispatch(actions.reloadSecondFactorState());
|
|
1859
|
+
store2.dispatch((0, _authActions.logout)());
|
|
1860
|
+
store2.clearActions();
|
|
1861
|
+
release({
|
|
1862
|
+
UserId: 7,
|
|
1863
|
+
UserName: 'u',
|
|
1864
|
+
Use2FA: true
|
|
1865
|
+
});
|
|
1866
|
+
_context42.n = 1;
|
|
1867
|
+
return reloading;
|
|
1868
|
+
case 1:
|
|
1869
|
+
expect(store2.getActions()).toEqual([]);
|
|
1870
|
+
expect(_apex["default"].connection.RPCPromise).not.toHaveBeenCalledWith('GetUserConfig', expect.anything());
|
|
1871
|
+
case 2:
|
|
1872
|
+
return _context42.a(2);
|
|
1873
|
+
}
|
|
1874
|
+
}, _callee42);
|
|
1875
|
+
})));
|
|
1876
|
+
it("does not put the previous user's 2FA type into the next user's config", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee43() {
|
|
1877
|
+
var release, store2, reloading;
|
|
1878
|
+
return _regenerator().w(function (_context43) {
|
|
1879
|
+
while (1) switch (_context43.n) {
|
|
1880
|
+
case 0:
|
|
1881
|
+
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserInfo', Promise.resolve({
|
|
1882
|
+
o: JSON.stringify({
|
|
1883
|
+
UserId: 7,
|
|
1884
|
+
Use2FA: true
|
|
1885
|
+
})
|
|
1886
|
+
}));
|
|
1887
|
+
release = hold('GetUserConfig');
|
|
1888
|
+
store2 = signedIn();
|
|
1889
|
+
reloading = store2.dispatch(actions.reloadSecondFactorState());
|
|
1890
|
+
_context43.n = 1;
|
|
1891
|
+
return new Promise(function (resolve) {
|
|
1892
|
+
return setTimeout(resolve, 0);
|
|
1893
|
+
});
|
|
1894
|
+
case 1:
|
|
1895
|
+
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetUserConfig', {
|
|
1896
|
+
UserId: 7,
|
|
1897
|
+
UserName: 'u'
|
|
1898
|
+
});
|
|
1899
|
+
store2.dispatch((0, _authActions.logout)());
|
|
1900
|
+
store2.clearActions();
|
|
1901
|
+
release([{
|
|
1902
|
+
Key: '2FAType',
|
|
1903
|
+
Value: 'WebAuthn'
|
|
1904
|
+
}]);
|
|
1905
|
+
_context43.n = 2;
|
|
1906
|
+
return reloading;
|
|
1907
|
+
case 2:
|
|
1908
|
+
expect(store2.getActions()).toEqual([]);
|
|
1909
|
+
case 3:
|
|
1910
|
+
return _context43.a(2);
|
|
1911
|
+
}
|
|
1912
|
+
}, _callee43);
|
|
1913
|
+
})));
|
|
1914
|
+
});
|
|
1915
|
+
});
|
|
1916
|
+
describe('disable2FAWithPasskey', function () {
|
|
1917
|
+
it('sends the passkey answer as Assertion with an empty Code after Disable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee44() {
|
|
1918
|
+
var refusal;
|
|
1919
|
+
return _regenerator().w(function (_context44) {
|
|
1920
|
+
while (1) switch (_context44.n) {
|
|
1921
|
+
case 0:
|
|
1922
|
+
_apex["default"].connection.setRPCPromiseReturnValue(Promise.resolve({
|
|
1923
|
+
o: JSON.stringify({
|
|
1924
|
+
Authenticated: true
|
|
1925
|
+
})
|
|
1926
|
+
}));
|
|
1927
|
+
_context44.n = 1;
|
|
1928
|
+
return store.dispatch(actions.disable2FAWithPasskey('the-assertion'));
|
|
1929
|
+
case 1:
|
|
1930
|
+
refusal = _context44.v;
|
|
1931
|
+
expect(refusal).toBeNull();
|
|
1932
|
+
expect(_apex["default"].connection.Disable2FA).toHaveBeenCalled();
|
|
1933
|
+
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('Authenticate2FA', {
|
|
1934
|
+
Code: '',
|
|
1935
|
+
Assertion: 'the-assertion'
|
|
1936
|
+
});
|
|
1937
|
+
expect(store.getActions()).toContainEqual({
|
|
1938
|
+
type: actions.USER_INFO_FETCHED,
|
|
1939
|
+
payload: {
|
|
1940
|
+
Use2FA: false
|
|
1941
|
+
}
|
|
1942
|
+
});
|
|
1943
|
+
expect(_modalActions.closeModal).toHaveBeenCalledWith(_modalActions.MODAL_TYPES.DISABLE_2FA);
|
|
1944
|
+
case 2:
|
|
1945
|
+
return _context44.a(2);
|
|
1946
|
+
}
|
|
1947
|
+
}, _callee44);
|
|
1948
|
+
})));
|
|
1949
|
+
it("resolves to the gateway's reason and leaves 2FA on when the passkey is refused", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee45() {
|
|
1950
|
+
var refusal;
|
|
1951
|
+
return _regenerator().w(function (_context45) {
|
|
1952
|
+
while (1) switch (_context45.n) {
|
|
1953
|
+
case 0:
|
|
1954
|
+
_modalActions.closeModal.mockClear();
|
|
1955
|
+
_apex["default"].connection.setRPCPromiseReturnValue(Promise.resolve({
|
|
1956
|
+
o: JSON.stringify({
|
|
1957
|
+
Authenticated: false,
|
|
1958
|
+
errormsg: 'Passkeys could not be removed'
|
|
1959
|
+
})
|
|
1960
|
+
}));
|
|
1961
|
+
_context45.n = 1;
|
|
1962
|
+
return store.dispatch(actions.disable2FAWithPasskey('the-assertion'));
|
|
1963
|
+
case 1:
|
|
1964
|
+
refusal = _context45.v;
|
|
1965
|
+
expect(refusal).toBe('Passkeys could not be removed');
|
|
1966
|
+
expect(store.getActions()).not.toContainEqual(expect.objectContaining({
|
|
1967
|
+
type: actions.USER_INFO_FETCHED
|
|
1968
|
+
}));
|
|
1969
|
+
expect(_modalActions.closeModal).not.toHaveBeenCalled();
|
|
1970
|
+
case 2:
|
|
1971
|
+
return _context45.a(2);
|
|
1972
|
+
}
|
|
1973
|
+
}, _callee45);
|
|
1974
|
+
})));
|
|
1975
|
+
it('resolves to a passkey message when the refusal has none', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee46() {
|
|
1976
|
+
return _regenerator().w(function (_context46) {
|
|
1977
|
+
while (1) switch (_context46.n) {
|
|
1978
|
+
case 0:
|
|
1979
|
+
_apex["default"].connection.setRPCPromiseReturnValue(Promise.resolve({
|
|
1980
|
+
o: JSON.stringify({
|
|
1981
|
+
Authenticated: false
|
|
1982
|
+
})
|
|
1983
|
+
}));
|
|
1984
|
+
_context46.n = 1;
|
|
1985
|
+
return expect(store.dispatch(actions.disable2FAWithPasskey('x'))).resolves.toBe('The passkey was not accepted. Try again.');
|
|
1986
|
+
case 1:
|
|
1987
|
+
return _context46.a(2);
|
|
1988
|
+
}
|
|
1989
|
+
}, _callee46);
|
|
1346
1990
|
})));
|
|
1347
1991
|
});
|
|
1348
1992
|
describe('getGoogleQrCode', function () {
|
|
1349
|
-
it('should call apex.connection.EnableGoogle2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1350
|
-
return _regenerator().w(function (
|
|
1351
|
-
while (1) switch (
|
|
1993
|
+
it('should call apex.connection.EnableGoogle2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee47() {
|
|
1994
|
+
return _regenerator().w(function (_context47) {
|
|
1995
|
+
while (1) switch (_context47.n) {
|
|
1352
1996
|
case 0:
|
|
1353
|
-
|
|
1997
|
+
_context47.n = 1;
|
|
1354
1998
|
return actions.getGoogleQrCode()(dispatchStub);
|
|
1355
1999
|
case 1:
|
|
1356
2000
|
expect(_apex["default"].connection.EnableGoogle2FA).toHaveBeenCalled();
|
|
1357
2001
|
case 2:
|
|
1358
|
-
return
|
|
2002
|
+
return _context47.a(2);
|
|
1359
2003
|
}
|
|
1360
|
-
},
|
|
2004
|
+
}, _callee47);
|
|
1361
2005
|
})));
|
|
1362
|
-
it('should dispatch expected actions after getGoogleQrCode', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1363
|
-
return _regenerator().w(function (
|
|
1364
|
-
while (1) switch (
|
|
2006
|
+
it('should dispatch expected actions after getGoogleQrCode', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee48() {
|
|
2007
|
+
return _regenerator().w(function (_context48) {
|
|
2008
|
+
while (1) switch (_context48.n) {
|
|
1365
2009
|
case 0:
|
|
1366
2010
|
_apex["default"].connection.setResponse({
|
|
1367
2011
|
qrCode: 1234
|
|
1368
2012
|
});
|
|
1369
|
-
|
|
2013
|
+
_context48.n = 1;
|
|
1370
2014
|
return store.dispatch(actions.getGoogleQrCode());
|
|
1371
2015
|
case 1:
|
|
1372
2016
|
expect(store.getActions()).toEqual([{
|
|
@@ -1376,16 +2020,63 @@ describe('userActions', function () {
|
|
|
1376
2020
|
}
|
|
1377
2021
|
}]);
|
|
1378
2022
|
case 2:
|
|
1379
|
-
return
|
|
2023
|
+
return _context48.a(2);
|
|
1380
2024
|
}
|
|
1381
|
-
},
|
|
2025
|
+
}, _callee48);
|
|
2026
|
+
})));
|
|
2027
|
+
it('resolves true when the gateway issues a QR code', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee49() {
|
|
2028
|
+
var enrolled;
|
|
2029
|
+
return _regenerator().w(function (_context49) {
|
|
2030
|
+
while (1) switch (_context49.n) {
|
|
2031
|
+
case 0:
|
|
2032
|
+
_apex["default"].connection.setResponse({
|
|
2033
|
+
GoogleQRCode: 'otpauth://totp/x'
|
|
2034
|
+
});
|
|
2035
|
+
_context49.n = 1;
|
|
2036
|
+
return store.dispatch(actions.getGoogleQrCode());
|
|
2037
|
+
case 1:
|
|
2038
|
+
enrolled = _context49.v;
|
|
2039
|
+
expect(enrolled).toBe(true);
|
|
2040
|
+
case 2:
|
|
2041
|
+
return _context49.a(2);
|
|
2042
|
+
}
|
|
2043
|
+
}, _callee49);
|
|
2044
|
+
})));
|
|
2045
|
+
it('shows the gateway refusal, stores no QR code and resolves false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee50() {
|
|
2046
|
+
var errormsg, enrolled;
|
|
2047
|
+
return _regenerator().w(function (_context50) {
|
|
2048
|
+
while (1) switch (_context50.n) {
|
|
2049
|
+
case 0:
|
|
2050
|
+
errormsg = 'Two-factor authentication for this account is managed by your single sign-on provider.';
|
|
2051
|
+
_apex["default"].connection.setResponse({
|
|
2052
|
+
result: false,
|
|
2053
|
+
errormsg: errormsg,
|
|
2054
|
+
errorcode: 104
|
|
2055
|
+
});
|
|
2056
|
+
_context50.n = 1;
|
|
2057
|
+
return store.dispatch(actions.getGoogleQrCode());
|
|
2058
|
+
case 1:
|
|
2059
|
+
enrolled = _context50.v;
|
|
2060
|
+
expect(enrolled).toBe(false);
|
|
2061
|
+
expect(snackbarActions.showSnack).toHaveBeenCalledWith({
|
|
2062
|
+
id: 'ENABLE_2FA_ERROR',
|
|
2063
|
+
text: "104: ".concat(errormsg),
|
|
2064
|
+
type: 'warning'
|
|
2065
|
+
});
|
|
2066
|
+
expect(store.getActions()).not.toContainEqual(expect.objectContaining({
|
|
2067
|
+
type: actions.SET_GOOGLE_QRCODE
|
|
2068
|
+
}));
|
|
2069
|
+
case 2:
|
|
2070
|
+
return _context50.a(2);
|
|
2071
|
+
}
|
|
2072
|
+
}, _callee50);
|
|
1382
2073
|
})));
|
|
1383
2074
|
});
|
|
1384
2075
|
describe('getGoogle2FARecoveryCode', function () {
|
|
1385
|
-
it('should return recovery code', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2076
|
+
it('should return recovery code', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee51() {
|
|
1386
2077
|
var code;
|
|
1387
|
-
return _regenerator().w(function (
|
|
1388
|
-
while (1) switch (
|
|
2078
|
+
return _regenerator().w(function (_context51) {
|
|
2079
|
+
while (1) switch (_context51.n) {
|
|
1389
2080
|
case 0:
|
|
1390
2081
|
code = 123212;
|
|
1391
2082
|
_apex["default"].connection.setRPCPromiseReturnValue(Promise.resolve({
|
|
@@ -1393,21 +2084,21 @@ describe('userActions', function () {
|
|
|
1393
2084
|
Authenticated: true
|
|
1394
2085
|
})
|
|
1395
2086
|
}));
|
|
1396
|
-
|
|
2087
|
+
_context51.n = 1;
|
|
1397
2088
|
return actions.getGoogle2FARecoveryCode(code)(dispatchStub);
|
|
1398
2089
|
case 1:
|
|
1399
2090
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetGoogle2FARecoveryKey', {
|
|
1400
2091
|
Code: code
|
|
1401
2092
|
});
|
|
1402
2093
|
case 2:
|
|
1403
|
-
return
|
|
2094
|
+
return _context51.a(2);
|
|
1404
2095
|
}
|
|
1405
|
-
},
|
|
2096
|
+
}, _callee51);
|
|
1406
2097
|
})));
|
|
1407
|
-
it('should dispatch `showSnack` with warning if `Authenticated` = false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2098
|
+
it('should dispatch `showSnack` with warning if `Authenticated` = false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee52() {
|
|
1408
2099
|
var code, errormsg;
|
|
1409
|
-
return _regenerator().w(function (
|
|
1410
|
-
while (1) switch (
|
|
2100
|
+
return _regenerator().w(function (_context52) {
|
|
2101
|
+
while (1) switch (_context52.n) {
|
|
1411
2102
|
case 0:
|
|
1412
2103
|
code = 123212;
|
|
1413
2104
|
errormsg = 'False';
|
|
@@ -1417,7 +2108,7 @@ describe('userActions', function () {
|
|
|
1417
2108
|
errormsg: errormsg
|
|
1418
2109
|
})
|
|
1419
2110
|
}));
|
|
1420
|
-
|
|
2111
|
+
_context52.n = 1;
|
|
1421
2112
|
return actions.getGoogle2FARecoveryCode(code)(dispatchStub);
|
|
1422
2113
|
case 1:
|
|
1423
2114
|
expect(snackbarActions.showSnack).toHaveBeenCalledWith({
|
|
@@ -1426,14 +2117,14 @@ describe('userActions', function () {
|
|
|
1426
2117
|
type: 'warning'
|
|
1427
2118
|
});
|
|
1428
2119
|
case 2:
|
|
1429
|
-
return
|
|
2120
|
+
return _context52.a(2);
|
|
1430
2121
|
}
|
|
1431
|
-
},
|
|
2122
|
+
}, _callee52);
|
|
1432
2123
|
})));
|
|
1433
|
-
it('should dispatch `change` with code if `Authenticated` = true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2124
|
+
it('should dispatch `change` with code if `Authenticated` = true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee53() {
|
|
1434
2125
|
var code, RecoveryKey;
|
|
1435
|
-
return _regenerator().w(function (
|
|
1436
|
-
while (1) switch (
|
|
2126
|
+
return _regenerator().w(function (_context53) {
|
|
2127
|
+
while (1) switch (_context53.n) {
|
|
1437
2128
|
case 0:
|
|
1438
2129
|
code = 123212;
|
|
1439
2130
|
RecoveryKey = 123123;
|
|
@@ -1443,14 +2134,14 @@ describe('userActions', function () {
|
|
|
1443
2134
|
RecoveryKey: RecoveryKey
|
|
1444
2135
|
})
|
|
1445
2136
|
}));
|
|
1446
|
-
|
|
2137
|
+
_context53.n = 1;
|
|
1447
2138
|
return actions.getGoogle2FARecoveryCode(code)(dispatchStub);
|
|
1448
2139
|
case 1:
|
|
1449
2140
|
expect(_reduxForm.change).toHaveBeenCalledWith('google2FARecoveryKeyModal', 'recoveryKey', RecoveryKey);
|
|
1450
2141
|
case 2:
|
|
1451
|
-
return
|
|
2142
|
+
return _context53.a(2);
|
|
1452
2143
|
}
|
|
1453
|
-
},
|
|
2144
|
+
}, _callee53);
|
|
1454
2145
|
})));
|
|
1455
2146
|
});
|
|
1456
2147
|
describe('updateUserConfig', function () {
|
|
@@ -1547,41 +2238,41 @@ describe('userActions', function () {
|
|
|
1547
2238
|
beforeEach(function () {
|
|
1548
2239
|
jest.clearAllMocks();
|
|
1549
2240
|
});
|
|
1550
|
-
it('should dispatch `sendResetPasswordEmail` and showSnack if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1551
|
-
return _regenerator().w(function (
|
|
1552
|
-
while (1) switch (
|
|
2241
|
+
it('should dispatch `sendResetPasswordEmail` and showSnack if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee54() {
|
|
2242
|
+
return _regenerator().w(function (_context54) {
|
|
2243
|
+
while (1) switch (_context54.n) {
|
|
1553
2244
|
case 0:
|
|
1554
2245
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('ResetPassword', {
|
|
1555
2246
|
o: JSON.stringify({
|
|
1556
2247
|
result: true
|
|
1557
2248
|
})
|
|
1558
2249
|
});
|
|
1559
|
-
|
|
2250
|
+
_context54.n = 1;
|
|
1560
2251
|
return store.dispatch(actions.sendResetPasswordEmail());
|
|
1561
2252
|
case 1:
|
|
1562
2253
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1563
2254
|
case 2:
|
|
1564
|
-
return
|
|
2255
|
+
return _context54.a(2);
|
|
1565
2256
|
}
|
|
1566
|
-
},
|
|
2257
|
+
}, _callee54);
|
|
1567
2258
|
})));
|
|
1568
|
-
it('should dispatch `sendResetPasswordEmail` and showSnack if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1569
|
-
return _regenerator().w(function (
|
|
1570
|
-
while (1) switch (
|
|
2259
|
+
it('should dispatch `sendResetPasswordEmail` and showSnack if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee55() {
|
|
2260
|
+
return _regenerator().w(function (_context55) {
|
|
2261
|
+
while (1) switch (_context55.n) {
|
|
1571
2262
|
case 0:
|
|
1572
2263
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('ResetPassword', {
|
|
1573
2264
|
o: JSON.stringify({
|
|
1574
2265
|
result: false
|
|
1575
2266
|
})
|
|
1576
2267
|
});
|
|
1577
|
-
|
|
2268
|
+
_context55.n = 1;
|
|
1578
2269
|
return store.dispatch(actions.sendResetPasswordEmail());
|
|
1579
2270
|
case 1:
|
|
1580
2271
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1581
2272
|
case 2:
|
|
1582
|
-
return
|
|
2273
|
+
return _context55.a(2);
|
|
1583
2274
|
}
|
|
1584
|
-
},
|
|
2275
|
+
}, _callee55);
|
|
1585
2276
|
})));
|
|
1586
2277
|
});
|
|
1587
2278
|
describe('resendVerificationEmail', function () {
|
|
@@ -1590,46 +2281,46 @@ describe('userActions', function () {
|
|
|
1590
2281
|
jest.clearAllMocks();
|
|
1591
2282
|
store = mockStore({});
|
|
1592
2283
|
});
|
|
1593
|
-
it('should dispatch showSnack if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1594
|
-
return _regenerator().w(function (
|
|
1595
|
-
while (1) switch (
|
|
2284
|
+
it('should dispatch showSnack if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee56() {
|
|
2285
|
+
return _regenerator().w(function (_context56) {
|
|
2286
|
+
while (1) switch (_context56.n) {
|
|
1596
2287
|
case 0:
|
|
1597
2288
|
_apex["default"].connection.setResponse({
|
|
1598
2289
|
result: true
|
|
1599
2290
|
});
|
|
1600
|
-
|
|
2291
|
+
_context56.n = 1;
|
|
1601
2292
|
return store.dispatch(actions.resendVerificationEmail());
|
|
1602
2293
|
case 1:
|
|
1603
2294
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1604
2295
|
case 2:
|
|
1605
|
-
return
|
|
2296
|
+
return _context56.a(2);
|
|
1606
2297
|
}
|
|
1607
|
-
},
|
|
2298
|
+
}, _callee56);
|
|
1608
2299
|
})));
|
|
1609
|
-
it('should dispatch showSnack if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1610
|
-
return _regenerator().w(function (
|
|
1611
|
-
while (1) switch (
|
|
2300
|
+
it('should dispatch showSnack if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee57() {
|
|
2301
|
+
return _regenerator().w(function (_context57) {
|
|
2302
|
+
while (1) switch (_context57.n) {
|
|
1612
2303
|
case 0:
|
|
1613
2304
|
_apex["default"].connection.setResponse({
|
|
1614
2305
|
result: false
|
|
1615
2306
|
});
|
|
1616
|
-
|
|
2307
|
+
_context57.n = 1;
|
|
1617
2308
|
return store.dispatch(actions.resendVerificationEmail());
|
|
1618
2309
|
case 1:
|
|
1619
2310
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1620
2311
|
case 2:
|
|
1621
|
-
return
|
|
2312
|
+
return _context57.a(2);
|
|
1622
2313
|
}
|
|
1623
|
-
},
|
|
2314
|
+
}, _callee57);
|
|
1624
2315
|
})));
|
|
1625
|
-
it('should dispatch showSnack if apex.connection is not include ResendVerificationEmail', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2316
|
+
it('should dispatch showSnack if apex.connection is not include ResendVerificationEmail', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee58() {
|
|
1626
2317
|
var _apex$connection, ResendVerificationEmail, connectionWithoutResendVerificationEmail;
|
|
1627
|
-
return _regenerator().w(function (
|
|
1628
|
-
while (1) switch (
|
|
2318
|
+
return _regenerator().w(function (_context58) {
|
|
2319
|
+
while (1) switch (_context58.n) {
|
|
1629
2320
|
case 0:
|
|
1630
2321
|
_apex$connection = _apex["default"].connection, ResendVerificationEmail = _apex$connection.ResendVerificationEmail, connectionWithoutResendVerificationEmail = _objectWithoutProperties(_apex$connection, _excluded);
|
|
1631
2322
|
_apex["default"].connection = connectionWithoutResendVerificationEmail;
|
|
1632
|
-
|
|
2323
|
+
_context58.n = 1;
|
|
1633
2324
|
return store.dispatch(actions.resendVerificationEmail());
|
|
1634
2325
|
case 1:
|
|
1635
2326
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
@@ -1637,9 +2328,9 @@ describe('userActions', function () {
|
|
|
1637
2328
|
ResendVerificationEmail: ResendVerificationEmail
|
|
1638
2329
|
});
|
|
1639
2330
|
case 2:
|
|
1640
|
-
return
|
|
2331
|
+
return _context58.a(2);
|
|
1641
2332
|
}
|
|
1642
|
-
},
|
|
2333
|
+
}, _callee58);
|
|
1643
2334
|
})));
|
|
1644
2335
|
});
|
|
1645
2336
|
describe('goToResetPasswordFormStep', function () {
|