@amanat-qa/utils-frontend 1.0.7 → 1.0.8
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/dist/API/baseAPI.js +143 -75
- package/dist/DB/baseDB.js +138 -40
- package/dist/data/JSONLoader.js +1 -1
- package/dist/data/dataUtils.js +324 -268
- package/dist/data/filesParser.js +61 -42
- package/dist/data/gitlabCIGenerator.js +21 -11
- package/dist/log/logger.js +78 -49
- package/dist/random/randomizer.js +131 -99
- package/dist/str/strUtils.js +23 -7
- package/dist/time/timeUtils.js +58 -42
- package/package.json +1 -1
package/dist/data/dataUtils.js
CHANGED
|
@@ -1,277 +1,333 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
6
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
7
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
10
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
11
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
17
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
18
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
19
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
20
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
21
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
22
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
23
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
24
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
25
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
|
+
var moment = require('moment');
|
|
27
|
+
var _require = require('xml2js'),
|
|
28
|
+
parseStringPromise = _require.parseStringPromise;
|
|
29
|
+
var JSONLoader = require('./JSONLoader');
|
|
30
|
+
var StrUtils = require('../str/strUtils');
|
|
31
|
+
var TimeUtils = require('../time/timeUtils');
|
|
32
|
+
var Randomizer = require('../random/randomizer');
|
|
33
|
+
var DataUtils = /*#__PURE__*/function () {
|
|
34
|
+
function DataUtils() {
|
|
35
|
+
_classCallCheck(this, DataUtils);
|
|
14
36
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (raw) {
|
|
32
|
-
cy.intercept('GET', url).as(alias);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const query = {};
|
|
36
|
-
if (sortColumn) query['sort[column]'] = sortColumn;
|
|
37
|
-
if (sortValue) query['sort[value]'] = sortValue;
|
|
38
|
-
if (searchColumn && searchValue) {
|
|
39
|
-
query['search[column]'] = searchColumn;
|
|
40
|
-
query['search[value]'] = searchValue;
|
|
41
|
-
}
|
|
42
|
-
if (page) query.page = String(page);
|
|
43
|
-
if (perPage) query.per_page = String(perPage);
|
|
44
|
-
cy.intercept({
|
|
45
|
-
method: 'GET',
|
|
46
|
-
url,
|
|
47
|
-
query
|
|
48
|
-
}).as(alias);
|
|
49
|
-
}
|
|
50
|
-
static extractDataArray(interception) {
|
|
51
|
-
return interception.response.body.data || [];
|
|
52
|
-
}
|
|
53
|
-
static isSorted(arr, order = 'asc') {
|
|
54
|
-
const sorted = [...arr].sort((a, b) => order === 'asc' ? a - b : b - a);
|
|
55
|
-
return JSON.stringify(arr) === JSON.stringify(sorted);
|
|
56
|
-
}
|
|
57
|
-
static waitForPolicyList(alias, path) {
|
|
58
|
-
return cy.wait(`@${alias}`).then(interception => {
|
|
59
|
-
const parts = ['response', 'body', ...path.split('.')];
|
|
60
|
-
const result = parts.reduce((acc, key) => acc && typeof acc === 'object' ? acc[key] : {}, interception);
|
|
61
|
-
return result;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
static getFromRequest(url, alias) {
|
|
65
|
-
cy.intercept(url).as(alias);
|
|
66
|
-
return cy.wait(`@${alias}`).then(interception => interception.response.body);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* requires one mandatory argument: clients.
|
|
71
|
-
* options contain optional parameters:
|
|
72
|
-
* residency,
|
|
73
|
-
* type of document being passport,
|
|
74
|
-
* having driver license
|
|
75
|
-
* and being under 60 years old:
|
|
76
|
-
* @param {string[]} clients
|
|
77
|
-
* @param {Object} options
|
|
78
|
-
* @param {boolean} options.isResident
|
|
79
|
-
* @param {boolean} options.hasPassport
|
|
80
|
-
* @param {boolean} options.hasDriverLicence
|
|
81
|
-
* @param {boolean} options.isUnderSixtyYearsOld
|
|
82
|
-
*/
|
|
83
|
-
static filterClients(clients, options = {}) {
|
|
84
|
-
const {
|
|
85
|
-
isResident
|
|
86
|
-
} = options;
|
|
87
|
-
const {
|
|
88
|
-
hasPassport
|
|
89
|
-
} = options;
|
|
90
|
-
const {
|
|
91
|
-
hasDriverLicence
|
|
92
|
-
} = options;
|
|
93
|
-
const {
|
|
94
|
-
isUnderSixtyYearsOld
|
|
95
|
-
} = options;
|
|
96
|
-
const {
|
|
97
|
-
isJuridical
|
|
98
|
-
} = options;
|
|
99
|
-
let filteredClients = [...clients];
|
|
100
|
-
filteredClients = filteredClients.filter(client => {
|
|
101
|
-
if (isResident !== undefined) {
|
|
102
|
-
return isResident ? client.resident_bool : !client.resident_bool;
|
|
37
|
+
return _createClass(DataUtils, null, [{
|
|
38
|
+
key: "XMLToJSON",
|
|
39
|
+
value: function () {
|
|
40
|
+
var _XMLToJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(xml) {
|
|
41
|
+
return _regenerator().w(function (_context) {
|
|
42
|
+
while (1) switch (_context.n) {
|
|
43
|
+
case 0:
|
|
44
|
+
_context.n = 1;
|
|
45
|
+
return parseStringPromise(xml);
|
|
46
|
+
case 1:
|
|
47
|
+
return _context.a(2, _context.v.response);
|
|
48
|
+
}
|
|
49
|
+
}, _callee);
|
|
50
|
+
}));
|
|
51
|
+
function XMLToJSON(_x) {
|
|
52
|
+
return _XMLToJSON.apply(this, arguments);
|
|
103
53
|
}
|
|
104
|
-
return
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return
|
|
54
|
+
return XMLToJSON;
|
|
55
|
+
}()
|
|
56
|
+
}, {
|
|
57
|
+
key: "getFromRequests",
|
|
58
|
+
value: function getFromRequests(url1, alias1, url2, alias2) {
|
|
59
|
+
cy.intercept(url1).as(alias1);
|
|
60
|
+
cy.intercept(url2).as(alias2);
|
|
61
|
+
return cy.wait(["@".concat(alias1), "@".concat(alias2)]).then(function (_ref) {
|
|
62
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
63
|
+
interception1 = _ref2[0],
|
|
64
|
+
interception2 = _ref2[1];
|
|
65
|
+
return [interception1.response.body, interception2.response.body];
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "interceptPolicyList",
|
|
70
|
+
value: function interceptPolicyList() {
|
|
71
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
72
|
+
url = _ref3.url,
|
|
73
|
+
sortColumn = _ref3.sortColumn,
|
|
74
|
+
sortValue = _ref3.sortValue,
|
|
75
|
+
searchColumn = _ref3.searchColumn,
|
|
76
|
+
searchValue = _ref3.searchValue,
|
|
77
|
+
page = _ref3.page,
|
|
78
|
+
perPage = _ref3.perPage,
|
|
79
|
+
alias = _ref3.alias,
|
|
80
|
+
_ref3$raw = _ref3.raw,
|
|
81
|
+
raw = _ref3$raw === void 0 ? false : _ref3$raw;
|
|
82
|
+
if (raw) {
|
|
83
|
+
cy.intercept('GET', url).as(alias);
|
|
84
|
+
return;
|
|
116
85
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (
|
|
121
|
-
|
|
86
|
+
var query = {};
|
|
87
|
+
if (sortColumn) query['sort[column]'] = sortColumn;
|
|
88
|
+
if (sortValue) query['sort[value]'] = sortValue;
|
|
89
|
+
if (searchColumn && searchValue) {
|
|
90
|
+
query['search[column]'] = searchColumn;
|
|
91
|
+
query['search[value]'] = searchValue;
|
|
122
92
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
93
|
+
if (page) query.page = String(page);
|
|
94
|
+
if (perPage) query.per_page = String(perPage);
|
|
95
|
+
cy.intercept({
|
|
96
|
+
method: 'GET',
|
|
97
|
+
url: url,
|
|
98
|
+
query: query
|
|
99
|
+
}).as(alias);
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "extractDataArray",
|
|
103
|
+
value: function extractDataArray(interception) {
|
|
104
|
+
return interception.response.body.data || [];
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "isSorted",
|
|
108
|
+
value: function isSorted(arr) {
|
|
109
|
+
var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'asc';
|
|
110
|
+
var sorted = _toConsumableArray(arr).sort(function (a, b) {
|
|
111
|
+
return order === 'asc' ? a - b : b - a;
|
|
112
|
+
});
|
|
113
|
+
return JSON.stringify(arr) === JSON.stringify(sorted);
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "waitForPolicyList",
|
|
117
|
+
value: function waitForPolicyList(alias, path) {
|
|
118
|
+
return cy.wait("@".concat(alias)).then(function (interception) {
|
|
119
|
+
var parts = ['response', 'body'].concat(_toConsumableArray(path.split('.')));
|
|
120
|
+
var result = parts.reduce(function (acc, key) {
|
|
121
|
+
return acc && _typeof(acc) === 'object' ? acc[key] : {};
|
|
122
|
+
}, interception);
|
|
123
|
+
return result;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "getFromRequest",
|
|
128
|
+
value: function getFromRequest(url, alias) {
|
|
129
|
+
cy.intercept(url).as(alias);
|
|
130
|
+
return cy.wait("@".concat(alias)).then(function (interception) {
|
|
131
|
+
return interception.response.body;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* requires one mandatory argument: clients.
|
|
137
|
+
* options contain optional parameters:
|
|
138
|
+
* residency,
|
|
139
|
+
* type of document being passport,
|
|
140
|
+
* having driver license
|
|
141
|
+
* and being under 60 years old:
|
|
142
|
+
* @param {string[]} clients
|
|
143
|
+
* @param {Object} options
|
|
144
|
+
* @param {boolean} options.isResident
|
|
145
|
+
* @param {boolean} options.hasPassport
|
|
146
|
+
* @param {boolean} options.hasDriverLicence
|
|
147
|
+
* @param {boolean} options.isUnderSixtyYearsOld
|
|
148
|
+
*/
|
|
149
|
+
}, {
|
|
150
|
+
key: "filterClients",
|
|
151
|
+
value: function filterClients(clients) {
|
|
152
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
153
|
+
var isResident = options.isResident;
|
|
154
|
+
var hasPassport = options.hasPassport;
|
|
155
|
+
var hasDriverLicence = options.hasDriverLicence;
|
|
156
|
+
var isUnderSixtyYearsOld = options.isUnderSixtyYearsOld;
|
|
157
|
+
var isJuridical = options.isJuridical;
|
|
158
|
+
var filteredClients = _toConsumableArray(clients);
|
|
159
|
+
filteredClients = filteredClients.filter(function (client) {
|
|
160
|
+
if (isResident !== undefined) {
|
|
161
|
+
return isResident ? client.resident_bool : !client.resident_bool;
|
|
162
|
+
}
|
|
163
|
+
return true;
|
|
164
|
+
});
|
|
165
|
+
filteredClients = filteredClients.filter(function (client) {
|
|
166
|
+
if (hasDriverLicence !== undefined) {
|
|
167
|
+
return hasDriverLicence ? client.driving_license : !client.driving_license;
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
});
|
|
171
|
+
filteredClients = filteredClients.filter(function (client) {
|
|
172
|
+
if (hasPassport !== undefined) {
|
|
173
|
+
var hasLetter = /[a-zA-Z]/.test(client.document_number);
|
|
174
|
+
return hasPassport ? client.document_type_id === 11 && hasLetter : client.document_type_id !== 11;
|
|
175
|
+
}
|
|
176
|
+
return true;
|
|
177
|
+
});
|
|
178
|
+
filteredClients = filteredClients.filter(function (client) {
|
|
179
|
+
if (isUnderSixtyYearsOld !== undefined) {
|
|
180
|
+
return isUnderSixtyYearsOld ? moment(client.born) > moment().subtract(60, 'years') : moment(client.born) <= moment().subtract(60, 'years');
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
});
|
|
184
|
+
filteredClients = filteredClients.filter(function (client) {
|
|
185
|
+
if (isJuridical !== undefined) {
|
|
186
|
+
return isJuridical ? !client.natural_person_bool : client.natural_person_bool;
|
|
187
|
+
}
|
|
188
|
+
return true;
|
|
189
|
+
});
|
|
190
|
+
return filteredClients;
|
|
191
|
+
}
|
|
192
|
+
}, {
|
|
193
|
+
key: "createRandomCarStructure",
|
|
194
|
+
value: function createRandomCarStructure(carsArr) {
|
|
195
|
+
var randomCarIndex = Randomizer.getRandomInteger(carsArr.length - 1);
|
|
196
|
+
var tempCar = carsArr[randomCarIndex];
|
|
197
|
+
var resultCar = _objectSpread({}, tempCar);
|
|
198
|
+
resultCar.dt_reg_cert = {};
|
|
199
|
+
resultCar.dt_reg_cert.YMD = tempCar.dt_reg_cert;
|
|
200
|
+
resultCar.dt_reg_cert.DMY = TimeUtils.reformatDateFromYMDToDMY(tempCar.dt_reg_cert);
|
|
201
|
+
resultCar.year = tempCar.year.toString();
|
|
202
|
+
resultCar.engine_volume = tempCar.engine_volume.toString();
|
|
203
|
+
resultCar.model = {};
|
|
204
|
+
resultCar.model.OGPO = tempCar.model;
|
|
205
|
+
resultCar.model.KASKO = {};
|
|
206
|
+
resultCar.model.KASKO.get = tempCar.model;
|
|
207
|
+
resultCar.model.KASKO.set = tempCar.id !== 1 ? StrUtils.toTitleCase(tempCar.model) : '5 серия';
|
|
208
|
+
resultCar.mark = {};
|
|
209
|
+
resultCar.mark.OGPO = tempCar.mark;
|
|
210
|
+
resultCar.mark.KASKO = {};
|
|
211
|
+
resultCar.mark.KASKO.get = tempCar.mark;
|
|
212
|
+
resultCar.mark.KASKO.set = tempCar.id !== 1 ? StrUtils.toTitleCase(tempCar.mark) : tempCar.mark;
|
|
213
|
+
resultCar.region_id = JSONLoader.testData.carRegion;
|
|
214
|
+
resultCar.type_id = JSONLoader.testData.carType;
|
|
215
|
+
return resultCar;
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
key: "createRandomClientsStructures",
|
|
219
|
+
value: function createRandomClientsStructures(clientsArr) {
|
|
220
|
+
var randomHolderIndex = 0;
|
|
221
|
+
var randomInsuredIndex = 0;
|
|
222
|
+
var randomBeneficiaryIndex = 0;
|
|
223
|
+
if (clientsArr.length > 1) {
|
|
224
|
+
randomHolderIndex = Randomizer.getRandomInteger(clientsArr.length - 1);
|
|
225
|
+
do {
|
|
226
|
+
randomInsuredIndex = Randomizer.getRandomInteger(clientsArr.length - 1);
|
|
227
|
+
} while (randomInsuredIndex === randomHolderIndex);
|
|
228
|
+
do {
|
|
229
|
+
randomBeneficiaryIndex = Randomizer.getRandomInteger(clientsArr.length - 1);
|
|
230
|
+
} while (randomBeneficiaryIndex === randomHolderIndex || randomBeneficiaryIndex === randomInsuredIndex);
|
|
128
231
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
232
|
+
var tempHolder = clientsArr[randomHolderIndex];
|
|
233
|
+
var tempInsured = clientsArr[randomInsuredIndex];
|
|
234
|
+
var tempBeneficiary = clientsArr[randomBeneficiaryIndex];
|
|
235
|
+
var resultHolder = _objectSpread({}, tempHolder);
|
|
236
|
+
var resultInsured = _objectSpread({}, tempInsured);
|
|
237
|
+
var resultBeneficiary = _objectSpread({}, tempBeneficiary);
|
|
238
|
+
resultHolder.document_gived_date = {};
|
|
239
|
+
resultHolder.document_gived_date.YMD = tempHolder.document_gived_date;
|
|
240
|
+
resultHolder.document_gived_date.DMY = TimeUtils.reformatDateFromYMDToDMY(tempHolder.document_gived_date);
|
|
241
|
+
resultHolder.born = {};
|
|
242
|
+
resultHolder.born.YMD = tempHolder.born;
|
|
243
|
+
resultHolder.born.DMY = TimeUtils.reformatDateFromYMDToDMY(tempHolder.born);
|
|
244
|
+
resultHolder.date_issue_license = {};
|
|
245
|
+
resultHolder.date_issue_license.YMD = tempHolder.date_issue_license;
|
|
246
|
+
resultHolder.date_issue_license.DMY = TimeUtils.reformatDateFromYMDToDMY(tempHolder.date_issue_license);
|
|
247
|
+
resultHolder.iin = tempHolder.iin.toString();
|
|
248
|
+
resultHolder.document_type = JSONLoader.dictDocumentType[tempHolder.document_type_id.toString()];
|
|
249
|
+
resultHolder.sex = JSONLoader.dictSexID[tempHolder.sex_id];
|
|
250
|
+
resultHolder.address = JSONLoader.testData.holderAddress;
|
|
251
|
+
resultHolder.email = JSONLoader.testData.holderEmail;
|
|
252
|
+
resultHolder.document_gived_by = JSONLoader.testData.holderDocumentGivedBy;
|
|
253
|
+
resultHolder.document_gived_by_quote = JSONLoader.testData.holderDocumentGivedByQuote;
|
|
254
|
+
resultHolder.pdl = JSONLoader.testData.holderIsPDL;
|
|
255
|
+
resultHolder.driver_certificate_type_id = JSONLoader.testData.holderDriverLicenceType;
|
|
256
|
+
resultHolder.invalid_bool = JSONLoader.testData.holderIsInvalid;
|
|
257
|
+
resultHolder.pensioner_bool = JSONLoader.testData.holderIsPensioner;
|
|
258
|
+
resultHolder.country = JSONLoader.testData.holderCountry;
|
|
259
|
+
resultHolder.region = JSONLoader.testData.holderRegion;
|
|
260
|
+
resultHolder.phone = JSONLoader.testData.holderPhone;
|
|
261
|
+
resultHolder.phoneTrimmed = JSONLoader.testData.holderPhoneTrimmed;
|
|
262
|
+
resultHolder.phoneFormatted = JSONLoader.testData.holderPhoneFormatted;
|
|
263
|
+
resultInsured.document_gived_date = {};
|
|
264
|
+
resultInsured.document_gived_date.YMD = tempInsured.document_gived_date;
|
|
265
|
+
resultInsured.document_gived_date.DMY = TimeUtils.reformatDateFromYMDToDMY(tempInsured.document_gived_date);
|
|
266
|
+
resultInsured.born = {};
|
|
267
|
+
resultInsured.born.YMD = tempInsured.born;
|
|
268
|
+
resultInsured.born.DMY = TimeUtils.reformatDateFromYMDToDMY(tempInsured.born);
|
|
269
|
+
resultInsured.date_issue_license = {};
|
|
270
|
+
resultInsured.date_issue_license.YMD = tempInsured.date_issue_license;
|
|
271
|
+
resultInsured.date_issue_license.DMY = TimeUtils.reformatDateFromYMDToDMY(tempInsured.date_issue_license);
|
|
272
|
+
resultInsured.iin = tempInsured.iin.toString();
|
|
273
|
+
resultInsured.document_type = JSONLoader.dictDocumentType[tempInsured.document_type_id.toString()];
|
|
274
|
+
resultInsured.sex = JSONLoader.dictSexID[tempInsured.sex_id];
|
|
275
|
+
resultInsured.address = JSONLoader.testData.insuredAddress;
|
|
276
|
+
resultInsured.email = JSONLoader.testData.insuredEmail;
|
|
277
|
+
resultInsured.document_gived_by = JSONLoader.testData.insuredDocumentGivedBy;
|
|
278
|
+
resultInsured.pdl = JSONLoader.testData.insuredIsPDL;
|
|
279
|
+
resultInsured.driver_certificate_type_id = JSONLoader.testData.insuredDriverLicenceType;
|
|
280
|
+
resultInsured.invalid_bool = JSONLoader.testData.insuredIsInvalid;
|
|
281
|
+
resultInsured.pensioner_bool = JSONLoader.testData.insuredIsPensioner;
|
|
282
|
+
resultBeneficiary.document_gived_date = {};
|
|
283
|
+
resultBeneficiary.document_gived_date.YMD = tempBeneficiary.document_gived_date;
|
|
284
|
+
resultBeneficiary.document_gived_date.DMY = TimeUtils.reformatDateFromYMDToDMY(tempBeneficiary.document_gived_date);
|
|
285
|
+
resultBeneficiary.born = {};
|
|
286
|
+
resultBeneficiary.born.YMD = tempBeneficiary.born;
|
|
287
|
+
resultBeneficiary.born.DMY = TimeUtils.reformatDateFromYMDToDMY(tempBeneficiary.born);
|
|
288
|
+
resultBeneficiary.date_issue_license = {};
|
|
289
|
+
resultBeneficiary.date_issue_license.YMD = tempBeneficiary.date_issue_license;
|
|
290
|
+
resultBeneficiary.date_issue_license.DMY = TimeUtils.reformatDateFromYMDToDMY(tempBeneficiary.date_issue_license);
|
|
291
|
+
resultBeneficiary.iin = tempBeneficiary.iin.toString();
|
|
292
|
+
resultBeneficiary.document_type = JSONLoader.dictDocumentType[tempBeneficiary.document_type_id.toString()];
|
|
293
|
+
resultBeneficiary.sex = JSONLoader.dictSexID[tempBeneficiary.sex_id];
|
|
294
|
+
resultBeneficiary.address = JSONLoader.testData.beneficiaryAddress;
|
|
295
|
+
resultBeneficiary.email = JSONLoader.testData.beneficiaryEmail;
|
|
296
|
+
resultBeneficiary.document_gived_by = JSONLoader.testData.beneficiaryDocumentGivedBy;
|
|
297
|
+
resultBeneficiary.document_gived_by_quote = JSONLoader.testData.beneficiaryDocumentGivedByQuote;
|
|
298
|
+
resultBeneficiary.pdl = JSONLoader.testData.beneficiaryIsPDL;
|
|
299
|
+
resultBeneficiary.driver_certificate_type_id = JSONLoader.testData.beneficiaryDriverLicenceType;
|
|
300
|
+
resultBeneficiary.invalid_bool = JSONLoader.testData.beneficiaryIsInvalid;
|
|
301
|
+
resultBeneficiary.pensioner_bool = JSONLoader.testData.beneficiaryIsPensioner;
|
|
302
|
+
return {
|
|
303
|
+
holder: resultHolder,
|
|
304
|
+
insured: resultInsured,
|
|
305
|
+
beneficiary: resultBeneficiary
|
|
306
|
+
};
|
|
170
307
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
resultHolder.email = JSONLoader.testData.holderEmail;
|
|
197
|
-
resultHolder.document_gived_by = JSONLoader.testData.holderDocumentGivedBy;
|
|
198
|
-
resultHolder.document_gived_by_quote = JSONLoader.testData.holderDocumentGivedByQuote;
|
|
199
|
-
resultHolder.pdl = JSONLoader.testData.holderIsPDL;
|
|
200
|
-
resultHolder.driver_certificate_type_id = JSONLoader.testData.holderDriverLicenceType;
|
|
201
|
-
resultHolder.invalid_bool = JSONLoader.testData.holderIsInvalid;
|
|
202
|
-
resultHolder.pensioner_bool = JSONLoader.testData.holderIsPensioner;
|
|
203
|
-
resultHolder.country = JSONLoader.testData.holderCountry;
|
|
204
|
-
resultHolder.region = JSONLoader.testData.holderRegion;
|
|
205
|
-
resultHolder.phone = JSONLoader.testData.holderPhone;
|
|
206
|
-
resultHolder.phoneTrimmed = JSONLoader.testData.holderPhoneTrimmed;
|
|
207
|
-
resultHolder.phoneFormatted = JSONLoader.testData.holderPhoneFormatted;
|
|
208
|
-
resultInsured.document_gived_date = {};
|
|
209
|
-
resultInsured.document_gived_date.YMD = tempInsured.document_gived_date;
|
|
210
|
-
resultInsured.document_gived_date.DMY = TimeUtils.reformatDateFromYMDToDMY(tempInsured.document_gived_date);
|
|
211
|
-
resultInsured.born = {};
|
|
212
|
-
resultInsured.born.YMD = tempInsured.born;
|
|
213
|
-
resultInsured.born.DMY = TimeUtils.reformatDateFromYMDToDMY(tempInsured.born);
|
|
214
|
-
resultInsured.date_issue_license = {};
|
|
215
|
-
resultInsured.date_issue_license.YMD = tempInsured.date_issue_license;
|
|
216
|
-
resultInsured.date_issue_license.DMY = TimeUtils.reformatDateFromYMDToDMY(tempInsured.date_issue_license);
|
|
217
|
-
resultInsured.iin = tempInsured.iin.toString();
|
|
218
|
-
resultInsured.document_type = JSONLoader.dictDocumentType[tempInsured.document_type_id.toString()];
|
|
219
|
-
resultInsured.sex = JSONLoader.dictSexID[tempInsured.sex_id];
|
|
220
|
-
resultInsured.address = JSONLoader.testData.insuredAddress;
|
|
221
|
-
resultInsured.email = JSONLoader.testData.insuredEmail;
|
|
222
|
-
resultInsured.document_gived_by = JSONLoader.testData.insuredDocumentGivedBy;
|
|
223
|
-
resultInsured.pdl = JSONLoader.testData.insuredIsPDL;
|
|
224
|
-
resultInsured.driver_certificate_type_id = JSONLoader.testData.insuredDriverLicenceType;
|
|
225
|
-
resultInsured.invalid_bool = JSONLoader.testData.insuredIsInvalid;
|
|
226
|
-
resultInsured.pensioner_bool = JSONLoader.testData.insuredIsPensioner;
|
|
227
|
-
resultBeneficiary.document_gived_date = {};
|
|
228
|
-
resultBeneficiary.document_gived_date.YMD = tempBeneficiary.document_gived_date;
|
|
229
|
-
resultBeneficiary.document_gived_date.DMY = TimeUtils.reformatDateFromYMDToDMY(tempBeneficiary.document_gived_date);
|
|
230
|
-
resultBeneficiary.born = {};
|
|
231
|
-
resultBeneficiary.born.YMD = tempBeneficiary.born;
|
|
232
|
-
resultBeneficiary.born.DMY = TimeUtils.reformatDateFromYMDToDMY(tempBeneficiary.born);
|
|
233
|
-
resultBeneficiary.date_issue_license = {};
|
|
234
|
-
resultBeneficiary.date_issue_license.YMD = tempBeneficiary.date_issue_license;
|
|
235
|
-
resultBeneficiary.date_issue_license.DMY = TimeUtils.reformatDateFromYMDToDMY(tempBeneficiary.date_issue_license);
|
|
236
|
-
resultBeneficiary.iin = tempBeneficiary.iin.toString();
|
|
237
|
-
resultBeneficiary.document_type = JSONLoader.dictDocumentType[tempBeneficiary.document_type_id.toString()];
|
|
238
|
-
resultBeneficiary.sex = JSONLoader.dictSexID[tempBeneficiary.sex_id];
|
|
239
|
-
resultBeneficiary.address = JSONLoader.testData.beneficiaryAddress;
|
|
240
|
-
resultBeneficiary.email = JSONLoader.testData.beneficiaryEmail;
|
|
241
|
-
resultBeneficiary.document_gived_by = JSONLoader.testData.beneficiaryDocumentGivedBy;
|
|
242
|
-
resultBeneficiary.document_gived_by_quote = JSONLoader.testData.beneficiaryDocumentGivedByQuote;
|
|
243
|
-
resultBeneficiary.pdl = JSONLoader.testData.beneficiaryIsPDL;
|
|
244
|
-
resultBeneficiary.driver_certificate_type_id = JSONLoader.testData.beneficiaryDriverLicenceType;
|
|
245
|
-
resultBeneficiary.invalid_bool = JSONLoader.testData.beneficiaryIsInvalid;
|
|
246
|
-
resultBeneficiary.pensioner_bool = JSONLoader.testData.beneficiaryIsPensioner;
|
|
247
|
-
return {
|
|
248
|
-
holder: resultHolder,
|
|
249
|
-
insured: resultInsured,
|
|
250
|
-
beneficiary: resultBeneficiary
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
static prepareSetClientRequestBody(getClientResponse, client) {
|
|
254
|
-
const requestBody = {
|
|
255
|
-
...getClientResponse.data.data
|
|
256
|
-
};
|
|
257
|
-
requestBody.first_name = client.first_name;
|
|
258
|
-
requestBody.middle_name = client.middle_name;
|
|
259
|
-
requestBody.last_name = client.last_name;
|
|
260
|
-
requestBody.first_name_eng = client.first_name_eng;
|
|
261
|
-
requestBody.last_name_eng = client.last_name_eng;
|
|
262
|
-
requestBody.natural_person_bool = client.natural_person_bool;
|
|
263
|
-
requestBody.sex_id = client.sex_id;
|
|
264
|
-
requestBody.born = requestBody.natural_person_bool ? client.born.DMY : null;
|
|
265
|
-
requestBody.resident_bool = client.resident_bool;
|
|
266
|
-
requestBody.document_number = client.document_number;
|
|
267
|
-
requestBody.document_gived_date = client.document_gived_date.DMY;
|
|
268
|
-
requestBody.document_type_id = client.document_type_id;
|
|
269
|
-
requestBody.verify_bool = requestBody.natural_person_bool ? Number(JSONLoader.configData.verification) : 0;
|
|
270
|
-
requestBody.verify_type_id = requestBody.verify_bool ? 1 : 3;
|
|
271
|
-
requestBody.activity_kind_id = requestBody.natural_person_bool ? 250 : client.activity_kind_id;
|
|
272
|
-
requestBody.economics_sector_id = requestBody.natural_person_bool ? 10 : client.economics_sector_id;
|
|
273
|
-
requestBody.juridical_person_name = requestBody.natural_person_bool ? '' : client.juridical_person_name;
|
|
274
|
-
return requestBody;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
308
|
+
}, {
|
|
309
|
+
key: "prepareSetClientRequestBody",
|
|
310
|
+
value: function prepareSetClientRequestBody(getClientResponse, client) {
|
|
311
|
+
var requestBody = _objectSpread({}, getClientResponse.data.data);
|
|
312
|
+
requestBody.first_name = client.first_name;
|
|
313
|
+
requestBody.middle_name = client.middle_name;
|
|
314
|
+
requestBody.last_name = client.last_name;
|
|
315
|
+
requestBody.first_name_eng = client.first_name_eng;
|
|
316
|
+
requestBody.last_name_eng = client.last_name_eng;
|
|
317
|
+
requestBody.natural_person_bool = client.natural_person_bool;
|
|
318
|
+
requestBody.sex_id = client.sex_id;
|
|
319
|
+
requestBody.born = requestBody.natural_person_bool ? client.born.DMY : null;
|
|
320
|
+
requestBody.resident_bool = client.resident_bool;
|
|
321
|
+
requestBody.document_number = client.document_number;
|
|
322
|
+
requestBody.document_gived_date = client.document_gived_date.DMY;
|
|
323
|
+
requestBody.document_type_id = client.document_type_id;
|
|
324
|
+
requestBody.verify_bool = requestBody.natural_person_bool ? Number(JSONLoader.configData.verification) : 0;
|
|
325
|
+
requestBody.verify_type_id = requestBody.verify_bool ? 1 : 3;
|
|
326
|
+
requestBody.activity_kind_id = requestBody.natural_person_bool ? 250 : client.activity_kind_id;
|
|
327
|
+
requestBody.economics_sector_id = requestBody.natural_person_bool ? 10 : client.economics_sector_id;
|
|
328
|
+
requestBody.juridical_person_name = requestBody.natural_person_bool ? '' : client.juridical_person_name;
|
|
329
|
+
return requestBody;
|
|
330
|
+
}
|
|
331
|
+
}]);
|
|
332
|
+
}();
|
|
277
333
|
module.exports = DataUtils;
|