ouisys-engine 2.1.13 → 2.1.17

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.
@@ -183,7 +183,7 @@ function submitMSISDNOnce(_x7, _x8, _x9, _x10) {
183
183
 
184
184
  function _submitMSISDNOnce() {
185
185
  _submitMSISDNOnce = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(window, config, internationalMSISDN, extraParams) {
186
- var submissionError, msisdn, slug, country, device, offer, host, search, extraParamsQs, rockmanId, uniqid, result, error, mcpShieldResult;
186
+ var submissionError, msisdn, slug, country, device, offer, host, search, extraParamsQs, rockmanId, uniqid, result, error, kwCodesWithMcpShied, mcpShieldResult;
187
187
  return regeneratorRuntime.wrap(function _callee3$(_context3) {
188
188
  while (1) {
189
189
  switch (_context3.prev = _context3.next) {
@@ -225,16 +225,21 @@ function _submitMSISDNOnce() {
225
225
  throw error;
226
226
 
227
227
  case 21:
228
- if (!(country && (country.toLowerCase() == "kw" && result.operator == "KW_VIVA" || country.toLowerCase() == "iq"))) {
229
- _context3.next = 32;
228
+ kwCodesWithMcpShied = {
229
+ kw: "kw",
230
+ k2: "k2"
231
+ };
232
+
233
+ if (!(country && (kwCodesWithMcpShied[country.toLowerCase()] && result.operator == "KW_VIVA" || country.toLowerCase() == "iq"))) {
234
+ _context3.next = 33;
230
235
  break;
231
236
  }
232
237
 
233
- _context3.prev = 22;
234
- _context3.next = 25;
238
+ _context3.prev = 23;
239
+ _context3.next = 26;
235
240
  return window.tallymanApi.mcpShield(host, country, slug, device, offer, rockmanId, result.operator, uniqid);
236
241
 
237
- case 25:
242
+ case 26:
238
243
  mcpShieldResult = _context3.sent;
239
244
 
240
245
  if (false == mcpShieldResult.success) {
@@ -244,15 +249,15 @@ function _submitMSISDNOnce() {
244
249
  uniqidResult = mcpShieldResult.uniqid;
245
250
  }
246
251
 
247
- _context3.next = 32;
252
+ _context3.next = 33;
248
253
  break;
249
254
 
250
- case 29:
251
- _context3.prev = 29;
252
- _context3.t0 = _context3["catch"](22);
255
+ case 30:
256
+ _context3.prev = 30;
257
+ _context3.t0 = _context3["catch"](23);
253
258
  console.warn(_context3.t0);
254
259
 
255
- case 32:
260
+ case 33:
256
261
  return _context3.abrupt("return", {
257
262
  type: "SingleMSISDNSubmissionResult",
258
263
  pin: result.pin,
@@ -260,12 +265,12 @@ function _submitMSISDNOnce() {
260
265
  operator: result.operator
261
266
  });
262
267
 
263
- case 33:
268
+ case 34:
264
269
  case "end":
265
270
  return _context3.stop();
266
271
  }
267
272
  }
268
- }, _callee3, null, [[22, 29]]);
273
+ }, _callee3, null, [[23, 30]]);
269
274
  }));
270
275
  return _submitMSISDNOnce.apply(this, arguments);
271
276
  }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var _reduxMockStore = _interopRequireDefault(require("redux-mock-store"));
4
+
5
+ var _reduxThunk = _interopRequireDefault(require("redux-thunk"));
6
+
7
+ var _ = require("..");
8
+
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
11
+ var middlewares = [_reduxThunk.default];
12
+ var mockStore = (0, _reduxMockStore.default)(middlewares);
13
+ var store = mockStore();
14
+ describe('identify strategy action', function () {
15
+ var expectedResult = [{
16
+ "payload": {
17
+ "nextData": {
18
+ "nextAction": "submitMSISDNAction"
19
+ },
20
+ "result": {
21
+ "type": "NothingYet"
22
+ },
23
+ "type": "IDENTIFY_FLOW_BY_MSISDN"
24
+ },
25
+ "type": "IDENTIFY_FLOW_BY_MSISDN"
26
+ }];
27
+ it('identifies flow as ', function () {
28
+ return store //@ts-ignore
29
+ .dispatch((0, _.identifyStrategy)()).then(function () {
30
+ return expect(store.getActions()).toEqual(expectedResult);
31
+ });
32
+ });
33
+ });
@@ -140,163 +140,174 @@ function mockStrategyStateByUrlParam() {
140
140
  }
141
141
 
142
142
  function identifyStrategy() {
143
- return function (dispatch) {
144
- var _getConfig = (0, _utils.getConfig)(),
145
- strategy = _getConfig.strategy,
146
- strategyConfigs = _getConfig.strategyConfigs;
147
-
148
- var search = (0, _utils.searchToObject)();
149
-
150
- if (search["mock-flow"] !== undefined) {
151
- dispatch(mockStrategyStateByUrlParam());
152
- } else {
153
- switch (strategy) {
154
- case "pin-mo-ask-operator":
155
- return dispatch((0, _ask_operator.default)());
156
-
157
- case "pin-mo-redir-ask-mobile-number":
158
- case "pin-mo-ask-mobile-number":
159
- return dispatch((0, _ask_mobile_number.default)());
160
-
161
- case "pin-one-click-detect-operator-by-ip":
162
- case "one-click-mo-pin-detect-operator-by-ip-or-msisdn":
163
- case "mo-redir-one-click-detect-operator-by-ip":
164
- case "mo-one-click-detect-operator-by-ip":
165
- case "click2sms-one-click-detect-operator-by-ip":
166
- case "pin-mo-detect-operator-by-ip":
167
- return dispatch((0, _detect_operator_by_ip.default)());
168
-
169
- case "pin-click2sms-ask-operator":
170
- case "he-pin-one-click-ask-operator":
171
- case "click2sms-one-click-ask-operator":
172
- case "pin-one-click-ask-operator":
173
- return dispatch((0, _ask_operator.default)());
174
-
175
- case "pin-header-enrichment":
176
- case "he-pin-mo-redir-header-enrichment":
177
- case "he-pin-one-click-header-enrichment":
178
- case "he-mo-redir-one-click-header-enrichment":
179
- return dispatch((0, _header_enrichment.default)());
180
- //single flow strategies
181
-
182
- case "pin":
183
- tracker.sendOptInFlowEvent("Pin");
184
- return dispatch({
185
- type: "IDENTIFY_STRATEGY",
186
- payload: {
187
- type: "PIN",
188
- result: {
189
- nextAction: "submitMSISDNAction",
190
- config: strategyConfigs.default.flowConfig
191
- }
192
- }
193
- });
194
-
195
- case "mo":
196
- tracker.sendOptInFlowEvent("Msisdn to sms");
197
- return dispatch({
198
- type: "IDENTIFY_STRATEGY",
199
- payload: {
200
- type: "MO",
201
- result: {
202
- nextAction: "submitMSISDNAction",
203
- config: strategyConfigs.default.flowConfig
204
- }
205
- }
206
- });
207
-
208
- case "mo-redir":
209
- tracker.sendOptInFlowEvent("Redirect");
210
- return dispatch({
211
- type: "IDENTIFY_STRATEGY",
212
- payload: {
213
- type: "MO_REDIR",
214
- result: {
215
- nextAction: "submitMSISDNAction",
216
- config: strategyConfigs.default.flowConfig
217
- }
218
- }
219
- });
220
-
221
- case "one-click":
222
- tracker.sendOptInFlowEvent("3G click");
223
- return dispatch({
224
- type: "IDENTIFY_STRATEGY",
225
- payload: {
226
- type: "ONE_CLICK",
227
- result: {
228
- nextAction: "getRedirectUrlAction",
229
- config: strategyConfigs.default.flowConfig
230
- }
231
- }
232
- });
233
-
234
- case "tallyman-one-click":
235
- tracker.sendOptInFlowEvent("3G click");
236
- return dispatch({
237
- type: "IDENTIFY_STRATEGY",
238
- payload: {
239
- type: "TALLYMAN_ONE_CLICK",
240
- result: {
241
- nextAction: "getRedirectUrlAction",
242
- config: strategyConfigs.default.flowConfig
243
- }
244
- }
245
- });
143
+ return /*#__PURE__*/function () {
144
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch) {
145
+ var _getConfig, strategy, strategyConfigs, search;
246
146
 
247
- case "click2sms":
248
- tracker.sendOptInFlowEvent("Click to sms");
249
- return dispatch({
250
- type: "IDENTIFY_STRATEGY",
251
- payload: {
252
- type: "CLICK2SMS",
253
- result: {
254
- nextAction: "loadOc2sms",
255
- config: strategyConfigs.default.flowConfig
256
- }
257
- }
258
- });
147
+ return regeneratorRuntime.wrap(function _callee$(_context) {
148
+ while (1) {
149
+ switch (_context.prev = _context.next) {
150
+ case 0:
151
+ _getConfig = (0, _utils.getConfig)(), strategy = _getConfig.strategy, strategyConfigs = _getConfig.strategyConfigs;
152
+ search = (0, _utils.searchToObject)();
259
153
 
260
- case "ussd":
261
- tracker.sendOptInFlowEvent("Msisdn to sms");
262
- return dispatch({
263
- type: "IDENTIFY_STRATEGY",
264
- payload: {
265
- type: "USSD",
266
- result: {
267
- nextAction: "submitMSISDNAction",
268
- config: strategyConfigs.default.flowConfig
154
+ if (!(search["mock-flow"] !== undefined)) {
155
+ _context.next = 6;
156
+ break;
269
157
  }
270
- }
271
- });
272
158
 
273
- case "tpay-he":
274
- tracker.sendOptInFlowEvent("Hybrid Pin");
275
- return dispatch({
276
- type: "IDENTIFY_STRATEGY",
277
- payload: {
278
- type: "TPAY_HE",
279
- result: {
280
- nextAction: "loadTpayAction",
281
- config: strategyConfigs.default.flowConfig
282
- }
283
- }
284
- });
159
+ dispatch(mockStrategyStateByUrlParam());
160
+ _context.next = 31;
161
+ break;
162
+
163
+ case 6:
164
+ _context.t0 = strategy;
165
+ _context.next = _context.t0 === "pin-mo-ask-operator" ? 9 : _context.t0 === "pin-mo-redir-ask-mobile-number" ? 10 : _context.t0 === "pin-mo-ask-mobile-number" ? 10 : _context.t0 === "pin-one-click-detect-operator-by-ip" ? 11 : _context.t0 === "one-click-mo-pin-detect-operator-by-ip-or-msisdn" ? 11 : _context.t0 === "mo-redir-one-click-detect-operator-by-ip" ? 11 : _context.t0 === "mo-one-click-detect-operator-by-ip" ? 11 : _context.t0 === "click2sms-one-click-detect-operator-by-ip" ? 11 : _context.t0 === "pin-mo-detect-operator-by-ip" ? 11 : _context.t0 === "pin-click2sms-ask-operator" ? 12 : _context.t0 === "he-pin-one-click-ask-operator" ? 12 : _context.t0 === "click2sms-one-click-ask-operator" ? 12 : _context.t0 === "pin-one-click-ask-operator" ? 12 : _context.t0 === "pin-header-enrichment" ? 13 : _context.t0 === "he-pin-mo-redir-header-enrichment" ? 13 : _context.t0 === "he-pin-one-click-header-enrichment" ? 13 : _context.t0 === "he-mo-redir-one-click-header-enrichment" ? 13 : _context.t0 === "pin" ? 14 : _context.t0 === "mo" ? 16 : _context.t0 === "mo-redir" ? 18 : _context.t0 === "one-click" ? 20 : _context.t0 === "tallyman-one-click" ? 22 : _context.t0 === "click2sms" ? 24 : _context.t0 === "ussd" ? 26 : _context.t0 === "tpay-he" ? 28 : 30;
166
+ break;
167
+
168
+ case 9:
169
+ return _context.abrupt("return", dispatch((0, _ask_operator.default)()));
170
+
171
+ case 10:
172
+ return _context.abrupt("return", dispatch((0, _ask_mobile_number.default)()));
173
+
174
+ case 11:
175
+ return _context.abrupt("return", dispatch((0, _detect_operator_by_ip.default)()));
176
+
177
+ case 12:
178
+ return _context.abrupt("return", dispatch((0, _ask_operator.default)()));
179
+
180
+ case 13:
181
+ return _context.abrupt("return", dispatch((0, _header_enrichment.default)()));
182
+
183
+ case 14:
184
+ tracker.sendOptInFlowEvent("Pin");
185
+ return _context.abrupt("return", dispatch({
186
+ type: "IDENTIFY_STRATEGY",
187
+ payload: {
188
+ type: "PIN",
189
+ result: {
190
+ nextAction: "submitMSISDNAction",
191
+ config: strategyConfigs.default.flowConfig
192
+ }
193
+ }
194
+ }));
195
+
196
+ case 16:
197
+ tracker.sendOptInFlowEvent("Msisdn to sms");
198
+ return _context.abrupt("return", dispatch({
199
+ type: "IDENTIFY_STRATEGY",
200
+ payload: {
201
+ type: "MO",
202
+ result: {
203
+ nextAction: "submitMSISDNAction",
204
+ config: strategyConfigs.default.flowConfig
205
+ }
206
+ }
207
+ }));
208
+
209
+ case 18:
210
+ tracker.sendOptInFlowEvent("Redirect");
211
+ return _context.abrupt("return", dispatch({
212
+ type: "IDENTIFY_STRATEGY",
213
+ payload: {
214
+ type: "MO_REDIR",
215
+ result: {
216
+ nextAction: "submitMSISDNAction",
217
+ config: strategyConfigs.default.flowConfig
218
+ }
219
+ }
220
+ }));
221
+
222
+ case 20:
223
+ tracker.sendOptInFlowEvent("3G click");
224
+ return _context.abrupt("return", dispatch({
225
+ type: "IDENTIFY_STRATEGY",
226
+ payload: {
227
+ type: "ONE_CLICK",
228
+ result: {
229
+ nextAction: "getRedirectUrlAction",
230
+ config: strategyConfigs.default.flowConfig
231
+ }
232
+ }
233
+ }));
234
+
235
+ case 22:
236
+ tracker.sendOptInFlowEvent("3G click");
237
+ return _context.abrupt("return", dispatch({
238
+ type: "IDENTIFY_STRATEGY",
239
+ payload: {
240
+ type: "TALLYMAN_ONE_CLICK",
241
+ result: {
242
+ nextAction: "getRedirectUrlAction",
243
+ config: strategyConfigs.default.flowConfig
244
+ }
245
+ }
246
+ }));
247
+
248
+ case 24:
249
+ tracker.sendOptInFlowEvent("Click to sms");
250
+ return _context.abrupt("return", dispatch({
251
+ type: "IDENTIFY_STRATEGY",
252
+ payload: {
253
+ type: "CLICK2SMS",
254
+ result: {
255
+ nextAction: "loadOc2sms",
256
+ config: strategyConfigs.default.flowConfig
257
+ }
258
+ }
259
+ }));
260
+
261
+ case 26:
262
+ tracker.sendOptInFlowEvent("Msisdn to sms");
263
+ return _context.abrupt("return", dispatch({
264
+ type: "IDENTIFY_STRATEGY",
265
+ payload: {
266
+ type: "USSD",
267
+ result: {
268
+ nextAction: "submitMSISDNAction",
269
+ config: strategyConfigs.default.flowConfig
270
+ }
271
+ }
272
+ }));
273
+
274
+ case 28:
275
+ tracker.sendOptInFlowEvent("Hybrid Pin");
276
+ return _context.abrupt("return", dispatch({
277
+ type: "IDENTIFY_STRATEGY",
278
+ payload: {
279
+ type: "TPAY_HE",
280
+ result: {
281
+ nextAction: "loadTpayAction",
282
+ config: strategyConfigs.default.flowConfig
283
+ }
284
+ }
285
+ }));
286
+
287
+ case 30:
288
+ throw "Strategy not supported";
289
+
290
+ case 31:
291
+ case "end":
292
+ return _context.stop();
293
+ }
294
+ }
295
+ }, _callee);
296
+ }));
285
297
 
286
- default:
287
- throw "Strategy not supported";
288
- }
289
- }
290
- };
298
+ return function (_x) {
299
+ return _ref.apply(this, arguments);
300
+ };
301
+ }();
291
302
  }
292
303
 
293
304
  function checkSubscriptionAction(trackingArgs) {
294
305
  return /*#__PURE__*/function () {
295
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch, store) {
306
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(dispatch, store) {
296
307
  var currentState, maybeConfig;
297
- return regeneratorRuntime.wrap(function _callee$(_context) {
308
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
298
309
  while (1) {
299
- switch (_context.prev = _context.next) {
310
+ switch (_context2.prev = _context2.next) {
300
311
  case 0:
301
312
  currentState = store().strategy.currentState; //@ts-ignore
302
313
 
@@ -318,14 +329,14 @@ function checkSubscriptionAction(trackingArgs) {
318
329
 
319
330
  case 3:
320
331
  case "end":
321
- return _context.stop();
332
+ return _context2.stop();
322
333
  }
323
334
  }
324
- }, _callee);
335
+ }, _callee2);
325
336
  }));
326
337
 
327
- return function (_x, _x2) {
328
- return _ref.apply(this, arguments);
338
+ return function (_x2, _x3) {
339
+ return _ref2.apply(this, arguments);
329
340
  };
330
341
  }();
331
342
  }
@@ -165,13 +165,14 @@ function left(l) {
165
165
  var getConfig = function getConfig() {
166
166
  try {
167
167
  if (process.env.testing == "true") {
168
- // const configs:IStrategy = require("../../test-tools/config.json");
169
- //@ts-ignore
170
- return {};
171
- } else {
172
- var _configs = require("../../../../../config.json");
168
+ var _configs = require("../../../mockData/config.json"); //@ts-ignore
169
+
173
170
 
174
171
  return _configs;
172
+ } else {
173
+ var _configs2 = require("../../../../../config.json");
174
+
175
+ return _configs2;
175
176
  }
176
177
  } catch (ex) {
177
178
  throw "config.json not found";
@@ -7,8 +7,8 @@ import { IMoRedirActions } from "../reducers/moRedirFlow/MoRedirTypes";
7
7
  import { IOneClickActions } from "../reducers/oneClickFlow/OneClickTypes";
8
8
  import { IClick2SmsActions } from "../reducers/click2smsFlow/Click2smsTypes";
9
9
  import { ITpayHeActions } from "../reducers/tpayHeFlow/TpayHeTypes";
10
- declare type IApplicationActions = IStrategyActions | IPinActions | IMoActions | IMoRedirActions | IOneClickActions | IClick2SmsActions | IUssdActions | ITpayHeActions;
11
- declare const store: import("redux").Store<import("redux").CombinedState<IApplicationState>, import("redux").AnyAction> & {
10
+ export declare type IApplicationActions = IStrategyActions | IPinActions | IMoActions | IMoRedirActions | IOneClickActions | IClick2SmsActions | IUssdActions | ITpayHeActions;
11
+ declare const store: import("redux").Store<import("redux").EmptyObject & IApplicationState, import("redux").AnyAction> & {
12
12
  dispatch: import("redux-thunk").ThunkDispatch<IApplicationState, undefined, IApplicationActions>;
13
13
  };
14
14
  export default store;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { UserConfig } from '../global/interfaces/user';
3
+ interface NestedObjectWithStrings {
4
+ [key: string]: string | NestedObjectWithStrings;
5
+ }
6
+ interface TranslationsItem {
7
+ translations: {
8
+ lang: string;
9
+ entries: NestedObjectWithStrings;
10
+ };
11
+ }
12
+ interface Translations {
13
+ [key: string]: TranslationsItem;
14
+ }
15
+ interface UserMock {
16
+ USER: {
17
+ payload: Partial<UserConfig>;
18
+ };
19
+ }
20
+ export declare const renderWithRouterAndUserMock: (children: React.ReactNode, userApiMock: UserMock, translations: Translations) => void;
21
+ export {};
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.renderWithRouterAndUserMock = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _reactRouterDom = require("react-router-dom");
11
+
12
+ var _testUtils = require("./test-utils");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ var renderWithRouterAndUserMock = function renderWithRouterAndUserMock(children, userApiMock, translations) {
17
+ (0, _testUtils.render)(<_reactRouterDom.MemoryRouter>{children}</_reactRouterDom.MemoryRouter>, {
18
+ initialState: {
19
+ api: userApiMock,
20
+ distributor: {
21
+ selectedOutlet: {
22
+ eid: 'SEELENAMAR',
23
+ salesOrg: '1010',
24
+ name: 'Elena Martinez Sweden Bar',
25
+ tradeChannel1Desc: 'On-trade',
26
+ region: 'Khammuane',
27
+ city: 'ນະຄອນຫລວງວຽງຈັນ',
28
+ address: 'ວັດຈັນ ຈັນທະບູລີ ',
29
+ selected: true
30
+ }
31
+ },
32
+ user: {
33
+ isLoggedIn: true
34
+ }
35
+ },
36
+ translations: translations
37
+ });
38
+ };
39
+
40
+ exports.renderWithRouterAndUserMock = renderWithRouterAndUserMock;
@@ -0,0 +1 @@
1
+ import 'whatwg-fetch';
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.array.includes");
4
+
5
+ require("core-js/modules/es.string.includes");
6
+
7
+ require("whatwg-fetch");
8
+
9
+ // Jenkins seems to have installed a custom certificate which causes the logs to be poluted
10
+ // This little hack fixes that
11
+ var logErr = console.error; // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+
13
+ console.error = function (message) {
14
+ if (message && message.includes('ERR_TLS_CERT_ALTNAME_INVALID')) return;
15
+
16
+ for (var _len = arguments.length, optionalParams = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
17
+ optionalParams[_key - 1] = arguments[_key];
18
+ }
19
+
20
+ logErr(message, optionalParams);
21
+ };
22
+
23
+ jest.mock('../auth/authHandler');
24
+ global.scrollTo = jest.fn();
@@ -0,0 +1,28 @@
1
+ {
2
+ "strategy": "pin-mo-redir-ask-mobile-number",
3
+ "country": "ae",
4
+ "strategyConfigs": {
5
+ "default": {
6
+ "flow": "pin",
7
+ "flowConfig": {
8
+ "host": "w1.buz2mobile.com",
9
+ "slug": "ae-actel-pin-and-cg",
10
+ "device": "smart",
11
+ "country": "ae",
12
+ "service": "buz2mobile"
13
+ }
14
+ },
15
+ "operators": {
16
+ "AE_DU": {
17
+ "flow": "moRedir",
18
+ "flowConfig": {
19
+ "host": "w1.buz2mobile.com",
20
+ "slug": "ae-actel-pin-and-cg",
21
+ "device": "smart",
22
+ "country": "ae",
23
+ "service": "buz2mobile"
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }