@alphapoint/apex-web 5.7.0 → 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 +94 -16
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +412 -0
- 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/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/EnableTwoFactorAuthContainerFactory.js +3 -2
- 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/Login/LoginFormComponent.js +1 -1
- 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.test.js +23 -1
- 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/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/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/webauthnHelper.js +300 -0
- package/lib/helpers/webauthnHelper.test.js +199 -0
- package/lib/hocs/withOneSubmission.js +168 -0
- package/lib/redux/actions/apiActions.js +52 -1
- package/lib/redux/actions/apiActions.test.js +135 -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/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 +9 -4
- package/lib/redux/actions/orderHistoryActions.test.js +63 -0
- package/lib/redux/actions/userActions.js +314 -177
- package/lib/redux/actions/userActions.test.js +844 -268
- 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/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/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"];
|
|
@@ -581,35 +582,253 @@ describe('userActions', function () {
|
|
|
581
582
|
}
|
|
582
583
|
}, _callee);
|
|
583
584
|
})));
|
|
584
|
-
it('
|
|
585
|
+
it('stores the system margin flag before the user info', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
586
|
+
var store, types;
|
|
585
587
|
return _regenerator().w(function (_context2) {
|
|
586
588
|
while (1) switch (_context2.n) {
|
|
587
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
|
+
});
|
|
588
617
|
_context2.n = 1;
|
|
589
|
-
return actions.getUserInfo(99)
|
|
618
|
+
return store.dispatch(actions.getUserInfo(99));
|
|
590
619
|
case 1:
|
|
591
|
-
|
|
592
|
-
|
|
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
|
|
593
627
|
});
|
|
594
628
|
case 2:
|
|
595
629
|
return _context2.a(2);
|
|
596
630
|
}
|
|
597
631
|
}, _callee2);
|
|
598
632
|
})));
|
|
599
|
-
it('
|
|
633
|
+
it('does not request margin instrument configs when system margin is disabled', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
634
|
+
var store;
|
|
600
635
|
return _regenerator().w(function (_context3) {
|
|
601
636
|
while (1) switch (_context3.n) {
|
|
602
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
|
+
});
|
|
603
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;
|
|
604
823
|
return actions.getUserPermissions(99)(dispatchStub);
|
|
605
824
|
case 1:
|
|
606
825
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetUserPermissions', {
|
|
607
826
|
UserId: 99
|
|
608
827
|
});
|
|
609
828
|
case 2:
|
|
610
|
-
return
|
|
829
|
+
return _context8.a(2);
|
|
611
830
|
}
|
|
612
|
-
},
|
|
831
|
+
}, _callee8);
|
|
613
832
|
})));
|
|
614
833
|
});
|
|
615
834
|
describe('getUserConfig', function () {
|
|
@@ -617,28 +836,28 @@ describe('userActions', function () {
|
|
|
617
836
|
jest.clearAllMocks();
|
|
618
837
|
_apex["default"].connection.resetRPCPromiseResponses();
|
|
619
838
|
});
|
|
620
|
-
it('should call console error if response is rejected', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
621
|
-
return _regenerator().w(function (
|
|
622
|
-
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) {
|
|
623
842
|
case 0:
|
|
624
843
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserConfig', Promise.reject(new Error('fail')));
|
|
625
|
-
|
|
844
|
+
_context9.n = 1;
|
|
626
845
|
return actions.getUserConfig(99)(dispatchStub);
|
|
627
846
|
case 1:
|
|
628
847
|
expect(console.error).toHaveBeenCalledWith('getUserConfig action error', expect.anything());
|
|
629
848
|
case 2:
|
|
630
|
-
return
|
|
849
|
+
return _context9.a(2);
|
|
631
850
|
}
|
|
632
|
-
},
|
|
851
|
+
}, _callee9);
|
|
633
852
|
})));
|
|
634
|
-
it('getUserConfig should call apex.connection.RPCPromise with GetUserConfig', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
635
|
-
return _regenerator().w(function (
|
|
636
|
-
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) {
|
|
637
856
|
case 0:
|
|
638
857
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserConfig', {
|
|
639
858
|
o: JSON.stringify([])
|
|
640
859
|
});
|
|
641
|
-
|
|
860
|
+
_context0.n = 1;
|
|
642
861
|
return actions.getUserConfig(99)(dispatchStub);
|
|
643
862
|
case 1:
|
|
644
863
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetUserConfig', {
|
|
@@ -646,9 +865,9 @@ describe('userActions', function () {
|
|
|
646
865
|
UserName: undefined
|
|
647
866
|
});
|
|
648
867
|
case 2:
|
|
649
|
-
return
|
|
868
|
+
return _context0.a(2);
|
|
650
869
|
}
|
|
651
|
-
},
|
|
870
|
+
}, _callee0);
|
|
652
871
|
})));
|
|
653
872
|
});
|
|
654
873
|
describe('getUserAccounts', function () {
|
|
@@ -659,10 +878,10 @@ describe('userActions', function () {
|
|
|
659
878
|
o: JSON.stringify({})
|
|
660
879
|
});
|
|
661
880
|
});
|
|
662
|
-
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() {
|
|
663
882
|
var userAccountIds, accountInfo;
|
|
664
|
-
return _regenerator().w(function (
|
|
665
|
-
while (1) switch (
|
|
883
|
+
return _regenerator().w(function (_context1) {
|
|
884
|
+
while (1) switch (_context1.n) {
|
|
666
885
|
case 0:
|
|
667
886
|
userAccountIds = [1];
|
|
668
887
|
accountInfo = {
|
|
@@ -674,46 +893,46 @@ describe('userActions', function () {
|
|
|
674
893
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetAccountInfo', {
|
|
675
894
|
o: JSON.stringify(accountInfo)
|
|
676
895
|
});
|
|
677
|
-
|
|
896
|
+
_context1.n = 1;
|
|
678
897
|
return actions.getUserAccounts(99)(dispatchStub);
|
|
679
898
|
case 1:
|
|
680
899
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetUserAccounts', {
|
|
681
900
|
OMSId: 99
|
|
682
901
|
});
|
|
683
902
|
case 2:
|
|
684
|
-
return
|
|
903
|
+
return _context1.a(2);
|
|
685
904
|
}
|
|
686
|
-
},
|
|
905
|
+
}, _callee1);
|
|
687
906
|
})));
|
|
688
|
-
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() {
|
|
689
908
|
var userAccountIds, getAccountInfoCalls;
|
|
690
|
-
return _regenerator().w(function (
|
|
691
|
-
while (1) switch (
|
|
909
|
+
return _regenerator().w(function (_context10) {
|
|
910
|
+
while (1) switch (_context10.n) {
|
|
692
911
|
case 0:
|
|
693
912
|
userAccountIds = [1, 2, 3];
|
|
694
913
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', {
|
|
695
914
|
o: JSON.stringify(userAccountIds)
|
|
696
915
|
});
|
|
697
|
-
|
|
916
|
+
_context10.n = 1;
|
|
698
917
|
return actions.getUserAccounts(99)(dispatchStub);
|
|
699
918
|
case 1:
|
|
700
|
-
getAccountInfoCalls = _apex["default"].connection.RPCPromise.mock.calls.filter(function (
|
|
701
|
-
var
|
|
702
|
-
endpoint =
|
|
919
|
+
getAccountInfoCalls = _apex["default"].connection.RPCPromise.mock.calls.filter(function (_ref11) {
|
|
920
|
+
var _ref12 = _slicedToArray(_ref11, 1),
|
|
921
|
+
endpoint = _ref12[0];
|
|
703
922
|
return endpoint === 'GetAccountInfo';
|
|
704
923
|
});
|
|
705
924
|
expect(getAccountInfoCalls.length).toBe(3);
|
|
706
925
|
case 2:
|
|
707
|
-
return
|
|
926
|
+
return _context10.a(2);
|
|
708
927
|
}
|
|
709
|
-
},
|
|
928
|
+
}, _callee10);
|
|
710
929
|
})));
|
|
711
930
|
|
|
712
931
|
// example of test not needed for 100% coverage, but very nessisary for actual coverage
|
|
713
|
-
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() {
|
|
714
933
|
var userAccountIds, accountInfo, expectedActions;
|
|
715
|
-
return _regenerator().w(function (
|
|
716
|
-
while (1) switch (
|
|
934
|
+
return _regenerator().w(function (_context11) {
|
|
935
|
+
while (1) switch (_context11.n) {
|
|
717
936
|
case 0:
|
|
718
937
|
userAccountIds = [1];
|
|
719
938
|
accountInfo = {
|
|
@@ -739,20 +958,20 @@ describe('userActions', function () {
|
|
|
739
958
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetAccountInfo', {
|
|
740
959
|
o: JSON.stringify(accountInfo)
|
|
741
960
|
});
|
|
742
|
-
|
|
961
|
+
_context11.n = 1;
|
|
743
962
|
return store.dispatch(actions.getUserAccounts());
|
|
744
963
|
case 1:
|
|
745
964
|
expect(store.getActions()).toEqual(expect.arrayContaining(expectedActions));
|
|
746
965
|
expect(_verificationLevelUpdateService["default"].subscribe).toHaveBeenCalled();
|
|
747
966
|
case 2:
|
|
748
|
-
return
|
|
967
|
+
return _context11.a(2);
|
|
749
968
|
}
|
|
750
|
-
},
|
|
969
|
+
}, _callee11);
|
|
751
970
|
})));
|
|
752
|
-
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() {
|
|
753
972
|
var userAccountIds, accountInfo, expectedActions;
|
|
754
|
-
return _regenerator().w(function (
|
|
755
|
-
while (1) switch (
|
|
973
|
+
return _regenerator().w(function (_context12) {
|
|
974
|
+
while (1) switch (_context12.n) {
|
|
756
975
|
case 0:
|
|
757
976
|
_config["default"].setReturnValue(false);
|
|
758
977
|
userAccountIds = [1];
|
|
@@ -779,42 +998,42 @@ describe('userActions', function () {
|
|
|
779
998
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetAccountInfo', {
|
|
780
999
|
o: JSON.stringify(accountInfo)
|
|
781
1000
|
});
|
|
782
|
-
|
|
1001
|
+
_context12.n = 1;
|
|
783
1002
|
return store.dispatch(actions.getUserAccounts());
|
|
784
1003
|
case 1:
|
|
785
1004
|
expect(store.getActions()).toEqual(expect.arrayContaining(expectedActions));
|
|
786
1005
|
expect(_verificationLevelUpdateService["default"].subscribe).toHaveBeenCalled();
|
|
787
1006
|
case 2:
|
|
788
|
-
return
|
|
1007
|
+
return _context12.a(2);
|
|
789
1008
|
}
|
|
790
|
-
},
|
|
1009
|
+
}, _callee12);
|
|
791
1010
|
})));
|
|
792
|
-
it('should mark accounts as loaded after receiving them', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1011
|
+
it('should mark accounts as loaded after receiving them', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
793
1012
|
var types;
|
|
794
|
-
return _regenerator().w(function (
|
|
795
|
-
while (1) switch (
|
|
1013
|
+
return _regenerator().w(function (_context13) {
|
|
1014
|
+
while (1) switch (_context13.n) {
|
|
796
1015
|
case 0:
|
|
797
1016
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', {
|
|
798
1017
|
o: JSON.stringify([1])
|
|
799
1018
|
});
|
|
800
|
-
|
|
1019
|
+
_context13.n = 1;
|
|
801
1020
|
return store.dispatch(actions.getUserAccounts(99));
|
|
802
1021
|
case 1:
|
|
803
|
-
types = store.getActions().map(function (
|
|
804
|
-
var type =
|
|
1022
|
+
types = store.getActions().map(function (_ref16) {
|
|
1023
|
+
var type = _ref16.type;
|
|
805
1024
|
return type;
|
|
806
1025
|
});
|
|
807
1026
|
expect(types[types.length - 1]).toBe(actions.ACCOUNTS_LOADED);
|
|
808
1027
|
expect(types.indexOf(actions.RECEIVE_ACCOUNT)).toBeLessThan(types.indexOf(actions.ACCOUNTS_LOADED));
|
|
809
1028
|
case 2:
|
|
810
|
-
return
|
|
1029
|
+
return _context13.a(2);
|
|
811
1030
|
}
|
|
812
|
-
},
|
|
1031
|
+
}, _callee13);
|
|
813
1032
|
})));
|
|
814
|
-
it('should resolve with no accounts and mark them as loaded when GetUserAccounts returns an error payload', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
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() {
|
|
815
1034
|
var errorPayload, accounts;
|
|
816
|
-
return _regenerator().w(function (
|
|
817
|
-
while (1) switch (
|
|
1035
|
+
return _regenerator().w(function (_context14) {
|
|
1036
|
+
while (1) switch (_context14.n) {
|
|
818
1037
|
case 0:
|
|
819
1038
|
errorPayload = {
|
|
820
1039
|
result: false,
|
|
@@ -824,46 +1043,46 @@ describe('userActions', function () {
|
|
|
824
1043
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', {
|
|
825
1044
|
o: JSON.stringify(errorPayload)
|
|
826
1045
|
});
|
|
827
|
-
|
|
1046
|
+
_context14.n = 1;
|
|
828
1047
|
return store.dispatch(actions.getUserAccounts(99));
|
|
829
1048
|
case 1:
|
|
830
|
-
accounts =
|
|
1049
|
+
accounts = _context14.v;
|
|
831
1050
|
expect(accounts).toEqual([]);
|
|
832
1051
|
expect(console.error).toHaveBeenCalledWith('GetUserAccounts did not return an array', errorPayload);
|
|
833
1052
|
expect(_apex["default"].connection.RPCPromise).not.toHaveBeenCalledWith('GetAccountInfo', expect.anything());
|
|
834
1053
|
expect(store.getActions()).toEqual([actions.accountsLoaded()]);
|
|
835
1054
|
case 2:
|
|
836
|
-
return
|
|
1055
|
+
return _context14.a(2);
|
|
837
1056
|
}
|
|
838
|
-
},
|
|
1057
|
+
}, _callee14);
|
|
839
1058
|
})));
|
|
840
|
-
it('should resolve with no accounts and mark them as loaded when GetUserAccounts rejects', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1059
|
+
it('should resolve with no accounts and mark them as loaded when GetUserAccounts rejects', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
|
|
841
1060
|
var accounts;
|
|
842
|
-
return _regenerator().w(function (
|
|
843
|
-
while (1) switch (
|
|
1061
|
+
return _regenerator().w(function (_context15) {
|
|
1062
|
+
while (1) switch (_context15.n) {
|
|
844
1063
|
case 0:
|
|
845
1064
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', Promise.reject(new Error('fail')));
|
|
846
|
-
|
|
1065
|
+
_context15.n = 1;
|
|
847
1066
|
return store.dispatch(actions.getUserAccounts(99));
|
|
848
1067
|
case 1:
|
|
849
|
-
accounts =
|
|
1068
|
+
accounts = _context15.v;
|
|
850
1069
|
expect(accounts).toEqual([]);
|
|
851
1070
|
expect(console.error).toHaveBeenCalledWith('getUserAccounts action error', expect.anything());
|
|
852
1071
|
expect(store.getActions()).toEqual([actions.accountsLoaded()]);
|
|
853
1072
|
case 2:
|
|
854
|
-
return
|
|
1073
|
+
return _context15.a(2);
|
|
855
1074
|
}
|
|
856
|
-
},
|
|
1075
|
+
}, _callee15);
|
|
857
1076
|
})));
|
|
858
1077
|
});
|
|
859
1078
|
describe('selectAccount', function () {
|
|
860
|
-
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() {
|
|
861
1080
|
var accountId, expectedActions;
|
|
862
|
-
return _regenerator().w(function (
|
|
863
|
-
while (1) switch (
|
|
1081
|
+
return _regenerator().w(function (_context16) {
|
|
1082
|
+
while (1) switch (_context16.n) {
|
|
864
1083
|
case 0:
|
|
865
1084
|
accountId = 1;
|
|
866
|
-
|
|
1085
|
+
_context16.n = 1;
|
|
867
1086
|
return store.dispatch(actions.selectAccount(1, 1));
|
|
868
1087
|
case 1:
|
|
869
1088
|
expectedActions = [{
|
|
@@ -879,18 +1098,18 @@ describe('userActions', function () {
|
|
|
879
1098
|
expect(positionActions.getAccountPositions).toHaveBeenCalled();
|
|
880
1099
|
expect(positionActions.subscribeToAccountPositionEvents).toHaveBeenCalled();
|
|
881
1100
|
case 2:
|
|
882
|
-
return
|
|
1101
|
+
return _context16.a(2);
|
|
883
1102
|
}
|
|
884
|
-
},
|
|
1103
|
+
}, _callee16);
|
|
885
1104
|
})));
|
|
886
|
-
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() {
|
|
887
1106
|
var accountId, expectedActions;
|
|
888
|
-
return _regenerator().w(function (
|
|
889
|
-
while (1) switch (
|
|
1107
|
+
return _regenerator().w(function (_context17) {
|
|
1108
|
+
while (1) switch (_context17.n) {
|
|
890
1109
|
case 0:
|
|
891
1110
|
_config["default"].setPrivateMarketData(true);
|
|
892
1111
|
accountId = 1;
|
|
893
|
-
|
|
1112
|
+
_context17.n = 1;
|
|
894
1113
|
return store.dispatch(actions.selectAccount(1, 1));
|
|
895
1114
|
case 1:
|
|
896
1115
|
expectedActions = [{
|
|
@@ -906,9 +1125,9 @@ describe('userActions', function () {
|
|
|
906
1125
|
expect(positionActions.getAccountPositions).toHaveBeenCalled();
|
|
907
1126
|
expect(positionActions.subscribeToAccountPositionEvents).toHaveBeenCalled();
|
|
908
1127
|
case 2:
|
|
909
|
-
return
|
|
1128
|
+
return _context17.a(2);
|
|
910
1129
|
}
|
|
911
|
-
},
|
|
1130
|
+
}, _callee17);
|
|
912
1131
|
})));
|
|
913
1132
|
});
|
|
914
1133
|
describe('updateAccount', function () {
|
|
@@ -931,16 +1150,16 @@ describe('userActions', function () {
|
|
|
931
1150
|
}
|
|
932
1151
|
});
|
|
933
1152
|
});
|
|
934
|
-
it('should call UpdateAccount from apex', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
935
|
-
return _regenerator().w(function (
|
|
936
|
-
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) {
|
|
937
1156
|
case 0:
|
|
938
1157
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
939
1158
|
o: JSON.stringify({
|
|
940
1159
|
result: false
|
|
941
1160
|
})
|
|
942
1161
|
});
|
|
943
|
-
|
|
1162
|
+
_context18.n = 1;
|
|
944
1163
|
return store.dispatch(actions.updateAccount());
|
|
945
1164
|
case 1:
|
|
946
1165
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('UpdateAccount', {
|
|
@@ -949,14 +1168,14 @@ describe('userActions', function () {
|
|
|
949
1168
|
LoyaltyProductId: 0
|
|
950
1169
|
});
|
|
951
1170
|
case 2:
|
|
952
|
-
return
|
|
1171
|
+
return _context18.a(2);
|
|
953
1172
|
}
|
|
954
|
-
},
|
|
1173
|
+
}, _callee18);
|
|
955
1174
|
})));
|
|
956
|
-
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() {
|
|
957
1176
|
var loyaltyProduct;
|
|
958
|
-
return _regenerator().w(function (
|
|
959
|
-
while (1) switch (
|
|
1177
|
+
return _regenerator().w(function (_context19) {
|
|
1178
|
+
while (1) switch (_context19.n) {
|
|
960
1179
|
case 0:
|
|
961
1180
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
962
1181
|
o: JSON.stringify({
|
|
@@ -967,7 +1186,7 @@ describe('userActions', function () {
|
|
|
967
1186
|
ProductId: 2,
|
|
968
1187
|
Amount: 1
|
|
969
1188
|
};
|
|
970
|
-
|
|
1189
|
+
_context19.n = 1;
|
|
971
1190
|
return store.dispatch(actions.updateAccount(loyaltyProduct));
|
|
972
1191
|
case 1:
|
|
973
1192
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('UpdateAccount', {
|
|
@@ -976,14 +1195,14 @@ describe('userActions', function () {
|
|
|
976
1195
|
LoyaltyProductId: 2
|
|
977
1196
|
});
|
|
978
1197
|
case 2:
|
|
979
|
-
return
|
|
1198
|
+
return _context19.a(2);
|
|
980
1199
|
}
|
|
981
|
-
},
|
|
1200
|
+
}, _callee19);
|
|
982
1201
|
})));
|
|
983
|
-
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() {
|
|
984
1203
|
var loyaltyProduct;
|
|
985
|
-
return _regenerator().w(function (
|
|
986
|
-
while (1) switch (
|
|
1204
|
+
return _regenerator().w(function (_context20) {
|
|
1205
|
+
while (1) switch (_context20.n) {
|
|
987
1206
|
case 0:
|
|
988
1207
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
989
1208
|
o: JSON.stringify({
|
|
@@ -994,7 +1213,7 @@ describe('userActions', function () {
|
|
|
994
1213
|
ProductId: 2,
|
|
995
1214
|
Amount: 0
|
|
996
1215
|
};
|
|
997
|
-
|
|
1216
|
+
_context20.n = 1;
|
|
998
1217
|
return store.dispatch(actions.updateAccount(loyaltyProduct));
|
|
999
1218
|
case 1:
|
|
1000
1219
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('UpdateAccount', {
|
|
@@ -1003,13 +1222,13 @@ describe('userActions', function () {
|
|
|
1003
1222
|
LoyaltyProductId: 2
|
|
1004
1223
|
});
|
|
1005
1224
|
case 2:
|
|
1006
|
-
return
|
|
1225
|
+
return _context20.a(2);
|
|
1007
1226
|
}
|
|
1008
|
-
},
|
|
1227
|
+
}, _callee20);
|
|
1009
1228
|
})));
|
|
1010
|
-
it('should dispatch expected action if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1011
|
-
return _regenerator().w(function (
|
|
1012
|
-
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) {
|
|
1013
1232
|
case 0:
|
|
1014
1233
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
1015
1234
|
o: JSON.stringify({
|
|
@@ -1019,20 +1238,20 @@ describe('userActions', function () {
|
|
|
1019
1238
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', {
|
|
1020
1239
|
o: JSON.stringify([])
|
|
1021
1240
|
});
|
|
1022
|
-
|
|
1241
|
+
_context21.n = 1;
|
|
1023
1242
|
return store.dispatch(actions.updateAccount());
|
|
1024
1243
|
case 1:
|
|
1025
1244
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetUserAccounts', {
|
|
1026
1245
|
OMSId: 1
|
|
1027
1246
|
});
|
|
1028
1247
|
case 2:
|
|
1029
|
-
return
|
|
1248
|
+
return _context21.a(2);
|
|
1030
1249
|
}
|
|
1031
|
-
},
|
|
1250
|
+
}, _callee21);
|
|
1032
1251
|
})));
|
|
1033
|
-
it('should dispatch showSnack if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1034
|
-
return _regenerator().w(function (
|
|
1035
|
-
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) {
|
|
1036
1255
|
case 0:
|
|
1037
1256
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
1038
1257
|
o: JSON.stringify({
|
|
@@ -1042,7 +1261,7 @@ describe('userActions', function () {
|
|
|
1042
1261
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('GetUserAccounts', {
|
|
1043
1262
|
o: JSON.stringify([])
|
|
1044
1263
|
});
|
|
1045
|
-
|
|
1264
|
+
_context22.n = 1;
|
|
1046
1265
|
return store.dispatch(actions.updateAccount());
|
|
1047
1266
|
case 1:
|
|
1048
1267
|
expect(snackbarActions.showSnack).toHaveBeenCalledWith({
|
|
@@ -1051,14 +1270,14 @@ describe('userActions', function () {
|
|
|
1051
1270
|
type: 'success'
|
|
1052
1271
|
});
|
|
1053
1272
|
case 2:
|
|
1054
|
-
return
|
|
1273
|
+
return _context22.a(2);
|
|
1055
1274
|
}
|
|
1056
|
-
},
|
|
1275
|
+
}, _callee22);
|
|
1057
1276
|
})));
|
|
1058
|
-
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() {
|
|
1059
1278
|
var loyaltyProduct;
|
|
1060
|
-
return _regenerator().w(function (
|
|
1061
|
-
while (1) switch (
|
|
1279
|
+
return _regenerator().w(function (_context23) {
|
|
1280
|
+
while (1) switch (_context23.n) {
|
|
1062
1281
|
case 0:
|
|
1063
1282
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
1064
1283
|
o: JSON.stringify({
|
|
@@ -1072,7 +1291,7 @@ describe('userActions', function () {
|
|
|
1072
1291
|
ProductId: 2,
|
|
1073
1292
|
Amount: 0
|
|
1074
1293
|
};
|
|
1075
|
-
|
|
1294
|
+
_context23.n = 1;
|
|
1076
1295
|
return store.dispatch(actions.updateAccount(loyaltyProduct));
|
|
1077
1296
|
case 1:
|
|
1078
1297
|
expect(snackbarActions.showSnack).toHaveBeenCalledWith({
|
|
@@ -1081,37 +1300,37 @@ describe('userActions', function () {
|
|
|
1081
1300
|
type: 'success'
|
|
1082
1301
|
});
|
|
1083
1302
|
case 2:
|
|
1084
|
-
return
|
|
1303
|
+
return _context23.a(2);
|
|
1085
1304
|
}
|
|
1086
|
-
},
|
|
1305
|
+
}, _callee23);
|
|
1087
1306
|
})));
|
|
1088
|
-
it('should dispatch showSnack if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1089
|
-
return _regenerator().w(function (
|
|
1090
|
-
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) {
|
|
1091
1310
|
case 0:
|
|
1092
1311
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('UpdateAccount', {
|
|
1093
1312
|
o: JSON.stringify({
|
|
1094
1313
|
result: false
|
|
1095
1314
|
})
|
|
1096
1315
|
});
|
|
1097
|
-
|
|
1316
|
+
_context24.n = 1;
|
|
1098
1317
|
return store.dispatch(actions.updateAccount());
|
|
1099
1318
|
case 1:
|
|
1100
1319
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1101
1320
|
case 2:
|
|
1102
|
-
return
|
|
1321
|
+
return _context24.a(2);
|
|
1103
1322
|
}
|
|
1104
|
-
},
|
|
1323
|
+
}, _callee24);
|
|
1105
1324
|
})));
|
|
1106
1325
|
});
|
|
1107
1326
|
describe('setUserInfo', function () {
|
|
1108
1327
|
beforeEach(function () {
|
|
1109
1328
|
_apex["default"].connection.resetRPCPromiseResponses();
|
|
1110
1329
|
});
|
|
1111
|
-
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() {
|
|
1112
1331
|
var user;
|
|
1113
|
-
return _regenerator().w(function (
|
|
1114
|
-
while (1) switch (
|
|
1332
|
+
return _regenerator().w(function (_context25) {
|
|
1333
|
+
while (1) switch (_context25.n) {
|
|
1115
1334
|
case 0:
|
|
1116
1335
|
user = {
|
|
1117
1336
|
UserName: 'UserName',
|
|
@@ -1120,7 +1339,7 @@ describe('userActions', function () {
|
|
|
1120
1339
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserInfo', {
|
|
1121
1340
|
o: JSON.stringify({})
|
|
1122
1341
|
});
|
|
1123
|
-
|
|
1342
|
+
_context25.n = 1;
|
|
1124
1343
|
return actions.setUserInfo(user)(dispatchStub);
|
|
1125
1344
|
case 1:
|
|
1126
1345
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('SetUserInfo', {
|
|
@@ -1128,14 +1347,14 @@ describe('userActions', function () {
|
|
|
1128
1347
|
Email: undefined
|
|
1129
1348
|
});
|
|
1130
1349
|
case 2:
|
|
1131
|
-
return
|
|
1350
|
+
return _context25.a(2);
|
|
1132
1351
|
}
|
|
1133
|
-
},
|
|
1352
|
+
}, _callee25);
|
|
1134
1353
|
})));
|
|
1135
|
-
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() {
|
|
1136
1355
|
var userInfo, user, expectedActions;
|
|
1137
|
-
return _regenerator().w(function (
|
|
1138
|
-
while (1) switch (
|
|
1356
|
+
return _regenerator().w(function (_context26) {
|
|
1357
|
+
while (1) switch (_context26.n) {
|
|
1139
1358
|
case 0:
|
|
1140
1359
|
userInfo = {
|
|
1141
1360
|
result: true
|
|
@@ -1151,19 +1370,19 @@ describe('userActions', function () {
|
|
|
1151
1370
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserInfo', {
|
|
1152
1371
|
o: JSON.stringify(userInfo)
|
|
1153
1372
|
});
|
|
1154
|
-
|
|
1373
|
+
_context26.n = 1;
|
|
1155
1374
|
return store.dispatch(actions.setUserInfo(user));
|
|
1156
1375
|
case 1:
|
|
1157
1376
|
expect(store.getActions()).toEqual(expect.arrayContaining(expectedActions));
|
|
1158
1377
|
case 2:
|
|
1159
|
-
return
|
|
1378
|
+
return _context26.a(2);
|
|
1160
1379
|
}
|
|
1161
|
-
},
|
|
1380
|
+
}, _callee26);
|
|
1162
1381
|
})));
|
|
1163
|
-
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() {
|
|
1164
1383
|
var userInfo, user;
|
|
1165
|
-
return _regenerator().w(function (
|
|
1166
|
-
while (1) switch (
|
|
1384
|
+
return _regenerator().w(function (_context27) {
|
|
1385
|
+
while (1) switch (_context27.n) {
|
|
1167
1386
|
case 0:
|
|
1168
1387
|
userInfo = {
|
|
1169
1388
|
result: false
|
|
@@ -1175,14 +1394,14 @@ describe('userActions', function () {
|
|
|
1175
1394
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserInfo', {
|
|
1176
1395
|
o: JSON.stringify(userInfo)
|
|
1177
1396
|
});
|
|
1178
|
-
|
|
1397
|
+
_context27.n = 1;
|
|
1179
1398
|
return store.dispatch(actions.setUserInfo(user));
|
|
1180
1399
|
case 1:
|
|
1181
1400
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1182
1401
|
case 2:
|
|
1183
|
-
return
|
|
1402
|
+
return _context27.a(2);
|
|
1184
1403
|
}
|
|
1185
|
-
},
|
|
1404
|
+
}, _callee27);
|
|
1186
1405
|
})));
|
|
1187
1406
|
});
|
|
1188
1407
|
describe('setUserConfig', function () {
|
|
@@ -1195,16 +1414,16 @@ describe('userActions', function () {
|
|
|
1195
1414
|
})
|
|
1196
1415
|
});
|
|
1197
1416
|
});
|
|
1198
|
-
it('should call apex.connection.RPCPromise with SetUserConfig', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1199
|
-
return _regenerator().w(function (
|
|
1200
|
-
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) {
|
|
1201
1420
|
case 0:
|
|
1202
1421
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserConfig', {
|
|
1203
1422
|
o: JSON.stringify({
|
|
1204
1423
|
result: false
|
|
1205
1424
|
})
|
|
1206
1425
|
});
|
|
1207
|
-
|
|
1426
|
+
_context28.n = 1;
|
|
1208
1427
|
return store.dispatch(actions.setUserConfig());
|
|
1209
1428
|
case 1:
|
|
1210
1429
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('SetUserConfig', {
|
|
@@ -1213,23 +1432,23 @@ describe('userActions', function () {
|
|
|
1213
1432
|
Config: undefined
|
|
1214
1433
|
});
|
|
1215
1434
|
case 2:
|
|
1216
|
-
return
|
|
1435
|
+
return _context28.a(2);
|
|
1217
1436
|
}
|
|
1218
|
-
},
|
|
1437
|
+
}, _callee28);
|
|
1219
1438
|
})));
|
|
1220
|
-
it('should dispatch expected actions after set user config', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1221
|
-
return _regenerator().w(function (
|
|
1222
|
-
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) {
|
|
1223
1442
|
case 0:
|
|
1224
1443
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserConfig', {
|
|
1225
1444
|
o: JSON.stringify({
|
|
1226
1445
|
result: true
|
|
1227
1446
|
})
|
|
1228
1447
|
});
|
|
1229
|
-
|
|
1448
|
+
_context29.n = 1;
|
|
1230
1449
|
return store.dispatch(actions.setUserConfig());
|
|
1231
1450
|
case 1:
|
|
1232
|
-
return
|
|
1451
|
+
return _context29.a(2, new Promise(function (resolve, reject) {
|
|
1233
1452
|
setTimeout(function () {
|
|
1234
1453
|
try {
|
|
1235
1454
|
expect(store.getActions()).toEqual([{
|
|
@@ -1245,32 +1464,32 @@ describe('userActions', function () {
|
|
|
1245
1464
|
}, 0);
|
|
1246
1465
|
}));
|
|
1247
1466
|
}
|
|
1248
|
-
},
|
|
1467
|
+
}, _callee29);
|
|
1249
1468
|
})));
|
|
1250
|
-
it('should dispatch expected actions after failed set user config', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1251
|
-
return _regenerator().w(function (
|
|
1252
|
-
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) {
|
|
1253
1472
|
case 0:
|
|
1254
1473
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('SetUserConfig', {
|
|
1255
1474
|
o: JSON.stringify({
|
|
1256
1475
|
result: false
|
|
1257
1476
|
})
|
|
1258
1477
|
});
|
|
1259
|
-
|
|
1478
|
+
_context30.n = 1;
|
|
1260
1479
|
return store.dispatch(actions.setUserConfig());
|
|
1261
1480
|
case 1:
|
|
1262
1481
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1263
1482
|
case 2:
|
|
1264
|
-
return
|
|
1483
|
+
return _context30.a(2);
|
|
1265
1484
|
}
|
|
1266
|
-
},
|
|
1485
|
+
}, _callee30);
|
|
1267
1486
|
})));
|
|
1268
1487
|
});
|
|
1269
1488
|
describe('enable2FA', function () {
|
|
1270
|
-
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() {
|
|
1271
1490
|
var getState;
|
|
1272
|
-
return _regenerator().w(function (
|
|
1273
|
-
while (1) switch (
|
|
1491
|
+
return _regenerator().w(function (_context31) {
|
|
1492
|
+
while (1) switch (_context31.n) {
|
|
1274
1493
|
case 0:
|
|
1275
1494
|
_apex["default"].connection.setResponse({
|
|
1276
1495
|
Authenticated: true
|
|
@@ -1284,23 +1503,23 @@ describe('userActions', function () {
|
|
|
1284
1503
|
}
|
|
1285
1504
|
};
|
|
1286
1505
|
});
|
|
1287
|
-
|
|
1506
|
+
_context31.n = 1;
|
|
1288
1507
|
return actions.enable2FA()(dispatchStub, getState);
|
|
1289
1508
|
case 1:
|
|
1290
1509
|
expect(_apex["default"].connection.Authenticate2FA).toHaveBeenCalled();
|
|
1291
1510
|
case 2:
|
|
1292
|
-
return
|
|
1511
|
+
return _context31.a(2);
|
|
1293
1512
|
}
|
|
1294
|
-
},
|
|
1513
|
+
}, _callee31);
|
|
1295
1514
|
})));
|
|
1296
|
-
it('should dispatch expected actions after enable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1297
|
-
return _regenerator().w(function (
|
|
1298
|
-
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) {
|
|
1299
1518
|
case 0:
|
|
1300
1519
|
_apex["default"].connection.setResponse({
|
|
1301
1520
|
Authenticated: true
|
|
1302
1521
|
});
|
|
1303
|
-
|
|
1522
|
+
_context32.n = 1;
|
|
1304
1523
|
return store.dispatch(actions.enable2FA());
|
|
1305
1524
|
case 1:
|
|
1306
1525
|
expect(store.getActions()).toContainEqual({
|
|
@@ -1315,32 +1534,32 @@ describe('userActions', function () {
|
|
|
1315
1534
|
});
|
|
1316
1535
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1317
1536
|
case 2:
|
|
1318
|
-
return
|
|
1537
|
+
return _context32.a(2);
|
|
1319
1538
|
}
|
|
1320
|
-
},
|
|
1539
|
+
}, _callee32);
|
|
1321
1540
|
})));
|
|
1322
|
-
it('should dispatch expected actions after failed enable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1323
|
-
return _regenerator().w(function (
|
|
1324
|
-
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) {
|
|
1325
1544
|
case 0:
|
|
1326
1545
|
_apex["default"].connection.setResponse({
|
|
1327
1546
|
Authenticated: false
|
|
1328
1547
|
});
|
|
1329
|
-
|
|
1548
|
+
_context33.n = 1;
|
|
1330
1549
|
return store.dispatch(actions.enable2FA());
|
|
1331
1550
|
case 1:
|
|
1332
1551
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1333
1552
|
case 2:
|
|
1334
|
-
return
|
|
1553
|
+
return _context33.a(2);
|
|
1335
1554
|
}
|
|
1336
|
-
},
|
|
1555
|
+
}, _callee33);
|
|
1337
1556
|
})));
|
|
1338
1557
|
});
|
|
1339
1558
|
describe('disable2FA', function () {
|
|
1340
|
-
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() {
|
|
1341
1560
|
var getState;
|
|
1342
|
-
return _regenerator().w(function (
|
|
1343
|
-
while (1) switch (
|
|
1561
|
+
return _regenerator().w(function (_context34) {
|
|
1562
|
+
while (1) switch (_context34.n) {
|
|
1344
1563
|
case 0:
|
|
1345
1564
|
getState = jest.fn(function () {
|
|
1346
1565
|
return {
|
|
@@ -1357,7 +1576,7 @@ describe('userActions', function () {
|
|
|
1357
1576
|
Authenticated: true
|
|
1358
1577
|
})
|
|
1359
1578
|
}));
|
|
1360
|
-
|
|
1579
|
+
_context34.n = 1;
|
|
1361
1580
|
return actions.disable2FA()(dispatchStub, getState);
|
|
1362
1581
|
case 1:
|
|
1363
1582
|
expect(_apex["default"].connection.Disable2FA).toHaveBeenCalled();
|
|
@@ -1365,20 +1584,20 @@ describe('userActions', function () {
|
|
|
1365
1584
|
Code: undefined
|
|
1366
1585
|
});
|
|
1367
1586
|
case 2:
|
|
1368
|
-
return
|
|
1587
|
+
return _context34.a(2);
|
|
1369
1588
|
}
|
|
1370
|
-
},
|
|
1589
|
+
}, _callee34);
|
|
1371
1590
|
})));
|
|
1372
|
-
it('should dispatch expected actions after disable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1373
|
-
return _regenerator().w(function (
|
|
1374
|
-
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) {
|
|
1375
1594
|
case 0:
|
|
1376
1595
|
_apex["default"].connection.setRPCPromiseReturnValue(Promise.resolve({
|
|
1377
1596
|
o: JSON.stringify({
|
|
1378
1597
|
Authenticated: true
|
|
1379
1598
|
})
|
|
1380
1599
|
}));
|
|
1381
|
-
|
|
1600
|
+
_context35.n = 1;
|
|
1382
1601
|
return store.dispatch(actions.disable2FA());
|
|
1383
1602
|
case 1:
|
|
1384
1603
|
expect(store.getActions()).toContainEqual({
|
|
@@ -1390,51 +1609,408 @@ describe('userActions', function () {
|
|
|
1390
1609
|
expect(_modalActions.closeModal).toHaveBeenCalledWith(_modalActions.MODAL_TYPES.DISABLE_2FA);
|
|
1391
1610
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1392
1611
|
case 2:
|
|
1393
|
-
return
|
|
1612
|
+
return _context35.a(2);
|
|
1394
1613
|
}
|
|
1395
|
-
},
|
|
1614
|
+
}, _callee35);
|
|
1396
1615
|
})));
|
|
1397
|
-
it('should dispatch expected actions after failed disable2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1398
|
-
return _regenerator().w(function (
|
|
1399
|
-
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) {
|
|
1400
1619
|
case 0:
|
|
1401
1620
|
_apex["default"].connection.setRPCPromiseReturnValue(Promise.resolve({
|
|
1402
1621
|
o: JSON.stringify({
|
|
1403
1622
|
Authenticated: false
|
|
1404
1623
|
})
|
|
1405
1624
|
}));
|
|
1406
|
-
|
|
1625
|
+
_context36.n = 1;
|
|
1407
1626
|
return store.dispatch(actions.disable2FA());
|
|
1408
1627
|
case 1:
|
|
1409
1628
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1410
1629
|
case 2:
|
|
1411
|
-
return
|
|
1630
|
+
return _context36.a(2);
|
|
1412
1631
|
}
|
|
1413
|
-
},
|
|
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);
|
|
1414
1990
|
})));
|
|
1415
1991
|
});
|
|
1416
1992
|
describe('getGoogleQrCode', function () {
|
|
1417
|
-
it('should call apex.connection.EnableGoogle2FA', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1418
|
-
return _regenerator().w(function (
|
|
1419
|
-
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) {
|
|
1420
1996
|
case 0:
|
|
1421
|
-
|
|
1997
|
+
_context47.n = 1;
|
|
1422
1998
|
return actions.getGoogleQrCode()(dispatchStub);
|
|
1423
1999
|
case 1:
|
|
1424
2000
|
expect(_apex["default"].connection.EnableGoogle2FA).toHaveBeenCalled();
|
|
1425
2001
|
case 2:
|
|
1426
|
-
return
|
|
2002
|
+
return _context47.a(2);
|
|
1427
2003
|
}
|
|
1428
|
-
},
|
|
2004
|
+
}, _callee47);
|
|
1429
2005
|
})));
|
|
1430
|
-
it('should dispatch expected actions after getGoogleQrCode', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1431
|
-
return _regenerator().w(function (
|
|
1432
|
-
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) {
|
|
1433
2009
|
case 0:
|
|
1434
2010
|
_apex["default"].connection.setResponse({
|
|
1435
2011
|
qrCode: 1234
|
|
1436
2012
|
});
|
|
1437
|
-
|
|
2013
|
+
_context48.n = 1;
|
|
1438
2014
|
return store.dispatch(actions.getGoogleQrCode());
|
|
1439
2015
|
case 1:
|
|
1440
2016
|
expect(store.getActions()).toEqual([{
|
|
@@ -1444,32 +2020,32 @@ describe('userActions', function () {
|
|
|
1444
2020
|
}
|
|
1445
2021
|
}]);
|
|
1446
2022
|
case 2:
|
|
1447
|
-
return
|
|
2023
|
+
return _context48.a(2);
|
|
1448
2024
|
}
|
|
1449
|
-
},
|
|
2025
|
+
}, _callee48);
|
|
1450
2026
|
})));
|
|
1451
|
-
it('resolves true when the gateway issues a QR code', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2027
|
+
it('resolves true when the gateway issues a QR code', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee49() {
|
|
1452
2028
|
var enrolled;
|
|
1453
|
-
return _regenerator().w(function (
|
|
1454
|
-
while (1) switch (
|
|
2029
|
+
return _regenerator().w(function (_context49) {
|
|
2030
|
+
while (1) switch (_context49.n) {
|
|
1455
2031
|
case 0:
|
|
1456
2032
|
_apex["default"].connection.setResponse({
|
|
1457
2033
|
GoogleQRCode: 'otpauth://totp/x'
|
|
1458
2034
|
});
|
|
1459
|
-
|
|
2035
|
+
_context49.n = 1;
|
|
1460
2036
|
return store.dispatch(actions.getGoogleQrCode());
|
|
1461
2037
|
case 1:
|
|
1462
|
-
enrolled =
|
|
2038
|
+
enrolled = _context49.v;
|
|
1463
2039
|
expect(enrolled).toBe(true);
|
|
1464
2040
|
case 2:
|
|
1465
|
-
return
|
|
2041
|
+
return _context49.a(2);
|
|
1466
2042
|
}
|
|
1467
|
-
},
|
|
2043
|
+
}, _callee49);
|
|
1468
2044
|
})));
|
|
1469
|
-
it('shows the gateway refusal, stores no QR code and resolves false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2045
|
+
it('shows the gateway refusal, stores no QR code and resolves false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee50() {
|
|
1470
2046
|
var errormsg, enrolled;
|
|
1471
|
-
return _regenerator().w(function (
|
|
1472
|
-
while (1) switch (
|
|
2047
|
+
return _regenerator().w(function (_context50) {
|
|
2048
|
+
while (1) switch (_context50.n) {
|
|
1473
2049
|
case 0:
|
|
1474
2050
|
errormsg = 'Two-factor authentication for this account is managed by your single sign-on provider.';
|
|
1475
2051
|
_apex["default"].connection.setResponse({
|
|
@@ -1477,10 +2053,10 @@ describe('userActions', function () {
|
|
|
1477
2053
|
errormsg: errormsg,
|
|
1478
2054
|
errorcode: 104
|
|
1479
2055
|
});
|
|
1480
|
-
|
|
2056
|
+
_context50.n = 1;
|
|
1481
2057
|
return store.dispatch(actions.getGoogleQrCode());
|
|
1482
2058
|
case 1:
|
|
1483
|
-
enrolled =
|
|
2059
|
+
enrolled = _context50.v;
|
|
1484
2060
|
expect(enrolled).toBe(false);
|
|
1485
2061
|
expect(snackbarActions.showSnack).toHaveBeenCalledWith({
|
|
1486
2062
|
id: 'ENABLE_2FA_ERROR',
|
|
@@ -1491,16 +2067,16 @@ describe('userActions', function () {
|
|
|
1491
2067
|
type: actions.SET_GOOGLE_QRCODE
|
|
1492
2068
|
}));
|
|
1493
2069
|
case 2:
|
|
1494
|
-
return
|
|
2070
|
+
return _context50.a(2);
|
|
1495
2071
|
}
|
|
1496
|
-
},
|
|
2072
|
+
}, _callee50);
|
|
1497
2073
|
})));
|
|
1498
2074
|
});
|
|
1499
2075
|
describe('getGoogle2FARecoveryCode', function () {
|
|
1500
|
-
it('should return recovery code', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2076
|
+
it('should return recovery code', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee51() {
|
|
1501
2077
|
var code;
|
|
1502
|
-
return _regenerator().w(function (
|
|
1503
|
-
while (1) switch (
|
|
2078
|
+
return _regenerator().w(function (_context51) {
|
|
2079
|
+
while (1) switch (_context51.n) {
|
|
1504
2080
|
case 0:
|
|
1505
2081
|
code = 123212;
|
|
1506
2082
|
_apex["default"].connection.setRPCPromiseReturnValue(Promise.resolve({
|
|
@@ -1508,21 +2084,21 @@ describe('userActions', function () {
|
|
|
1508
2084
|
Authenticated: true
|
|
1509
2085
|
})
|
|
1510
2086
|
}));
|
|
1511
|
-
|
|
2087
|
+
_context51.n = 1;
|
|
1512
2088
|
return actions.getGoogle2FARecoveryCode(code)(dispatchStub);
|
|
1513
2089
|
case 1:
|
|
1514
2090
|
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetGoogle2FARecoveryKey', {
|
|
1515
2091
|
Code: code
|
|
1516
2092
|
});
|
|
1517
2093
|
case 2:
|
|
1518
|
-
return
|
|
2094
|
+
return _context51.a(2);
|
|
1519
2095
|
}
|
|
1520
|
-
},
|
|
2096
|
+
}, _callee51);
|
|
1521
2097
|
})));
|
|
1522
|
-
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() {
|
|
1523
2099
|
var code, errormsg;
|
|
1524
|
-
return _regenerator().w(function (
|
|
1525
|
-
while (1) switch (
|
|
2100
|
+
return _regenerator().w(function (_context52) {
|
|
2101
|
+
while (1) switch (_context52.n) {
|
|
1526
2102
|
case 0:
|
|
1527
2103
|
code = 123212;
|
|
1528
2104
|
errormsg = 'False';
|
|
@@ -1532,7 +2108,7 @@ describe('userActions', function () {
|
|
|
1532
2108
|
errormsg: errormsg
|
|
1533
2109
|
})
|
|
1534
2110
|
}));
|
|
1535
|
-
|
|
2111
|
+
_context52.n = 1;
|
|
1536
2112
|
return actions.getGoogle2FARecoveryCode(code)(dispatchStub);
|
|
1537
2113
|
case 1:
|
|
1538
2114
|
expect(snackbarActions.showSnack).toHaveBeenCalledWith({
|
|
@@ -1541,14 +2117,14 @@ describe('userActions', function () {
|
|
|
1541
2117
|
type: 'warning'
|
|
1542
2118
|
});
|
|
1543
2119
|
case 2:
|
|
1544
|
-
return
|
|
2120
|
+
return _context52.a(2);
|
|
1545
2121
|
}
|
|
1546
|
-
},
|
|
2122
|
+
}, _callee52);
|
|
1547
2123
|
})));
|
|
1548
|
-
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() {
|
|
1549
2125
|
var code, RecoveryKey;
|
|
1550
|
-
return _regenerator().w(function (
|
|
1551
|
-
while (1) switch (
|
|
2126
|
+
return _regenerator().w(function (_context53) {
|
|
2127
|
+
while (1) switch (_context53.n) {
|
|
1552
2128
|
case 0:
|
|
1553
2129
|
code = 123212;
|
|
1554
2130
|
RecoveryKey = 123123;
|
|
@@ -1558,14 +2134,14 @@ describe('userActions', function () {
|
|
|
1558
2134
|
RecoveryKey: RecoveryKey
|
|
1559
2135
|
})
|
|
1560
2136
|
}));
|
|
1561
|
-
|
|
2137
|
+
_context53.n = 1;
|
|
1562
2138
|
return actions.getGoogle2FARecoveryCode(code)(dispatchStub);
|
|
1563
2139
|
case 1:
|
|
1564
2140
|
expect(_reduxForm.change).toHaveBeenCalledWith('google2FARecoveryKeyModal', 'recoveryKey', RecoveryKey);
|
|
1565
2141
|
case 2:
|
|
1566
|
-
return
|
|
2142
|
+
return _context53.a(2);
|
|
1567
2143
|
}
|
|
1568
|
-
},
|
|
2144
|
+
}, _callee53);
|
|
1569
2145
|
})));
|
|
1570
2146
|
});
|
|
1571
2147
|
describe('updateUserConfig', function () {
|
|
@@ -1662,41 +2238,41 @@ describe('userActions', function () {
|
|
|
1662
2238
|
beforeEach(function () {
|
|
1663
2239
|
jest.clearAllMocks();
|
|
1664
2240
|
});
|
|
1665
|
-
it('should dispatch `sendResetPasswordEmail` and showSnack if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1666
|
-
return _regenerator().w(function (
|
|
1667
|
-
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) {
|
|
1668
2244
|
case 0:
|
|
1669
2245
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('ResetPassword', {
|
|
1670
2246
|
o: JSON.stringify({
|
|
1671
2247
|
result: true
|
|
1672
2248
|
})
|
|
1673
2249
|
});
|
|
1674
|
-
|
|
2250
|
+
_context54.n = 1;
|
|
1675
2251
|
return store.dispatch(actions.sendResetPasswordEmail());
|
|
1676
2252
|
case 1:
|
|
1677
2253
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1678
2254
|
case 2:
|
|
1679
|
-
return
|
|
2255
|
+
return _context54.a(2);
|
|
1680
2256
|
}
|
|
1681
|
-
},
|
|
2257
|
+
}, _callee54);
|
|
1682
2258
|
})));
|
|
1683
|
-
it('should dispatch `sendResetPasswordEmail` and showSnack if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1684
|
-
return _regenerator().w(function (
|
|
1685
|
-
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) {
|
|
1686
2262
|
case 0:
|
|
1687
2263
|
_apex["default"].connection.setRPCPromiseReturnValueForEndpoint('ResetPassword', {
|
|
1688
2264
|
o: JSON.stringify({
|
|
1689
2265
|
result: false
|
|
1690
2266
|
})
|
|
1691
2267
|
});
|
|
1692
|
-
|
|
2268
|
+
_context55.n = 1;
|
|
1693
2269
|
return store.dispatch(actions.sendResetPasswordEmail());
|
|
1694
2270
|
case 1:
|
|
1695
2271
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1696
2272
|
case 2:
|
|
1697
|
-
return
|
|
2273
|
+
return _context55.a(2);
|
|
1698
2274
|
}
|
|
1699
|
-
},
|
|
2275
|
+
}, _callee55);
|
|
1700
2276
|
})));
|
|
1701
2277
|
});
|
|
1702
2278
|
describe('resendVerificationEmail', function () {
|
|
@@ -1705,46 +2281,46 @@ describe('userActions', function () {
|
|
|
1705
2281
|
jest.clearAllMocks();
|
|
1706
2282
|
store = mockStore({});
|
|
1707
2283
|
});
|
|
1708
|
-
it('should dispatch showSnack if response result is true', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1709
|
-
return _regenerator().w(function (
|
|
1710
|
-
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) {
|
|
1711
2287
|
case 0:
|
|
1712
2288
|
_apex["default"].connection.setResponse({
|
|
1713
2289
|
result: true
|
|
1714
2290
|
});
|
|
1715
|
-
|
|
2291
|
+
_context56.n = 1;
|
|
1716
2292
|
return store.dispatch(actions.resendVerificationEmail());
|
|
1717
2293
|
case 1:
|
|
1718
2294
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1719
2295
|
case 2:
|
|
1720
|
-
return
|
|
2296
|
+
return _context56.a(2);
|
|
1721
2297
|
}
|
|
1722
|
-
},
|
|
2298
|
+
}, _callee56);
|
|
1723
2299
|
})));
|
|
1724
|
-
it('should dispatch showSnack if response result is false', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1725
|
-
return _regenerator().w(function (
|
|
1726
|
-
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) {
|
|
1727
2303
|
case 0:
|
|
1728
2304
|
_apex["default"].connection.setResponse({
|
|
1729
2305
|
result: false
|
|
1730
2306
|
});
|
|
1731
|
-
|
|
2307
|
+
_context57.n = 1;
|
|
1732
2308
|
return store.dispatch(actions.resendVerificationEmail());
|
|
1733
2309
|
case 1:
|
|
1734
2310
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
1735
2311
|
case 2:
|
|
1736
|
-
return
|
|
2312
|
+
return _context57.a(2);
|
|
1737
2313
|
}
|
|
1738
|
-
},
|
|
2314
|
+
}, _callee57);
|
|
1739
2315
|
})));
|
|
1740
|
-
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() {
|
|
1741
2317
|
var _apex$connection, ResendVerificationEmail, connectionWithoutResendVerificationEmail;
|
|
1742
|
-
return _regenerator().w(function (
|
|
1743
|
-
while (1) switch (
|
|
2318
|
+
return _regenerator().w(function (_context58) {
|
|
2319
|
+
while (1) switch (_context58.n) {
|
|
1744
2320
|
case 0:
|
|
1745
2321
|
_apex$connection = _apex["default"].connection, ResendVerificationEmail = _apex$connection.ResendVerificationEmail, connectionWithoutResendVerificationEmail = _objectWithoutProperties(_apex$connection, _excluded);
|
|
1746
2322
|
_apex["default"].connection = connectionWithoutResendVerificationEmail;
|
|
1747
|
-
|
|
2323
|
+
_context58.n = 1;
|
|
1748
2324
|
return store.dispatch(actions.resendVerificationEmail());
|
|
1749
2325
|
case 1:
|
|
1750
2326
|
expect(snackbarActions.showSnack).toHaveBeenCalled();
|
|
@@ -1752,9 +2328,9 @@ describe('userActions', function () {
|
|
|
1752
2328
|
ResendVerificationEmail: ResendVerificationEmail
|
|
1753
2329
|
});
|
|
1754
2330
|
case 2:
|
|
1755
|
-
return
|
|
2331
|
+
return _context58.a(2);
|
|
1756
2332
|
}
|
|
1757
|
-
},
|
|
2333
|
+
}, _callee58);
|
|
1758
2334
|
})));
|
|
1759
2335
|
});
|
|
1760
2336
|
describe('goToResetPasswordFormStep', function () {
|