@amanat-qa/utils-frontend 1.0.5 → 1.0.6

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.
@@ -1,18 +1,13 @@
1
- const axios = require('axios');
1
+ "use strict";
2
2
 
3
+ const axios = require('axios');
3
4
  class BaseAPI {
4
5
  #baseURL;
5
-
6
6
  #logString;
7
-
8
7
  #timeout;
9
-
10
8
  #headers;
11
-
12
9
  #logBaseURL;
13
-
14
10
  #axiosInstance;
15
-
16
11
  constructor(options) {
17
12
  this.#baseURL = options.baseURL;
18
13
  this.#logString = options.logString;
@@ -20,57 +15,78 @@ class BaseAPI {
20
15
  this.#headers = options.headers;
21
16
  this.#axiosInstance = this.createInstance();
22
17
  }
23
-
24
18
  createInstance() {
25
19
  if (this.#logString) this.#logBaseURL = `${this.#logString} ${this.#baseURL}`;
26
20
  return axios.create({
27
21
  baseURL: this.#baseURL,
28
22
  timeout: this.#timeout,
29
- headers: this.#headers,
23
+ headers: this.#headers
30
24
  });
31
25
  }
32
-
33
26
  async get(endpoint, params) {
34
27
  const logs = [`[req] ▶ get ${JSON.stringify(params || {})} from ${endpoint}:`];
35
28
  if (this.#logBaseURL) logs.unshift(this.#logBaseURL);
36
29
  try {
37
- const response = await this.#axiosInstance.get(`/${endpoint}`, { params });
30
+ const response = await this.#axiosInstance.get(`/${endpoint}`, {
31
+ params
32
+ });
38
33
  logs.push(`[res] status code: ${response.status}`);
39
- return { data: response.data, status: response.status, logs };
34
+ return {
35
+ data: response.data,
36
+ status: response.status,
37
+ logs
38
+ };
40
39
  } catch (error) {
41
40
  logs.push(`[res] status code: ${error.response.status}`);
42
41
  logs.push(`[res] body: ${JSON.stringify(error.response.data)}`);
43
- return { data: error.response.data, status: error.response.status, logs };
42
+ return {
43
+ data: error.response.data,
44
+ status: error.response.status,
45
+ logs
46
+ };
44
47
  }
45
48
  }
46
-
47
49
  async post(endpoint, params) {
48
50
  const logs = [`[req] ▶ post ${JSON.stringify(params || {})} to ${endpoint}:`];
49
51
  if (this.#logBaseURL) logs.unshift(this.#logBaseURL);
50
52
  try {
51
53
  const response = await this.#axiosInstance.post(`/${endpoint}`, params);
52
54
  logs.push(`[res] status code: ${response.status}`);
53
- return { data: response.data, status: response.status, logs };
55
+ return {
56
+ data: response.data,
57
+ status: response.status,
58
+ logs
59
+ };
54
60
  } catch (error) {
55
61
  logs.push(`[res] status code: ${error.response.status}`);
56
62
  logs.push(`[res] body: ${JSON.stringify(error.response.data)}`);
57
- return { data: error.response.data, status: error.response.status, logs };
63
+ return {
64
+ data: error.response.data,
65
+ status: error.response.status,
66
+ logs
67
+ };
58
68
  }
59
69
  }
60
-
61
70
  async patch(endpoint, params) {
62
71
  const logs = [`[req] ▶ patch ${JSON.stringify(params || {})} to ${endpoint}:`];
63
72
  if (this.#logBaseURL) logs.unshift(this.#logBaseURL);
64
73
  try {
65
74
  const response = await this.#axiosInstance.patch(`/${endpoint}`, params);
66
75
  logs.push(`[res] status code: ${response.status}`);
67
- return { data: response.data, status: response.status, logs };
76
+ return {
77
+ data: response.data,
78
+ status: response.status,
79
+ logs
80
+ };
68
81
  } catch (error) {
69
82
  logs.push(`[res] status code: ${error.response.status}`);
70
83
  logs.push(`[res] body: ${JSON.stringify(error.response.data)}`);
71
- return { data: error.response.data, status: error.response.status, logs };
84
+ return {
85
+ data: error.response.data,
86
+ status: error.response.status,
87
+ logs
88
+ };
72
89
  }
73
90
  }
74
91
  }
75
-
76
- module.exports = BaseAPI;
92
+ module.exports = BaseAPI;
@@ -1,18 +1,13 @@
1
- const mysql = require('mysql2/promise');
1
+ "use strict";
2
2
 
3
+ const mysql = require('mysql2/promise');
3
4
  class BaseDB {
4
5
  #host;
5
-
6
6
  #user;
7
-
8
7
  #port;
9
-
10
8
  #password;
11
-
12
9
  #database;
13
-
14
10
  #connection;
15
-
16
11
  constructor(host, user, password, database, port) {
17
12
  this.#host = host;
18
13
  this.#user = user;
@@ -20,7 +15,6 @@ class BaseDB {
20
15
  this.#database = database;
21
16
  this.#port = port;
22
17
  }
23
-
24
18
  async createConnection() {
25
19
  const logs = [`[inf] ▶ connect to ${this.#database} database`];
26
20
  this.#connection = await mysql.createConnection({
@@ -28,35 +22,34 @@ class BaseDB {
28
22
  user: this.#user,
29
23
  password: this.#password,
30
24
  database: this.#database,
31
- port: this.#port,
25
+ port: this.#port
32
26
  });
33
- return { logs };
27
+ return {
28
+ logs
29
+ };
34
30
  }
35
-
36
31
  async closeConnection() {
37
32
  const logs = [`[inf] ▶ close connection to ${this.#database} database`];
38
33
  await this.#connection.end();
39
- return { logs };
34
+ return {
35
+ logs
36
+ };
40
37
  }
41
-
42
38
  async sqlQuery(query, values) {
43
39
  const [rows] = await this.#connection.query(query, values);
44
40
  return rows;
45
41
  }
46
-
47
- async sqlSelect(
48
- tableName,
49
- target = '*',
50
- conditions = '',
51
- values = [],
52
- options = { hasLogger: true },
53
- ) {
42
+ async sqlSelect(tableName, target = '*', conditions = '', values = [], options = {
43
+ hasLogger: true
44
+ }) {
54
45
  const logs = [];
55
46
  if (options.hasLogger) logs.push(`[inf] ▶ select ${target} from ${tableName} table`);
56
47
  const query = `SELECT ${target} FROM ${tableName} ${conditions};`;
57
48
  const rows = await this.sqlQuery(query, values);
58
- return { rows, logs };
49
+ return {
50
+ rows,
51
+ logs
52
+ };
59
53
  }
60
54
  }
61
-
62
- module.exports = BaseDB;
55
+ module.exports = BaseDB;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ let JSONLoader;
4
+ try {
5
+ JSONLoader = require('../../../../../main/utils/data/JSONLoader');
6
+ } catch (e) {
7
+ throw new Error('[err] JSONLoader require error!');
8
+ }
9
+ module.exports = JSONLoader;
@@ -1,21 +1,22 @@
1
+ "use strict";
2
+
1
3
  const moment = require('moment');
2
- const { parseStringPromise } = require('xml2js');
4
+ const {
5
+ parseStringPromise
6
+ } = require('xml2js');
3
7
  const JSONLoader = require('./JSONLoader');
4
8
  const StrUtils = require('../str/strUtils');
5
9
  const TimeUtils = require('../time/timeUtils');
6
10
  const Randomizer = require('../random/randomizer');
7
-
8
11
  class DataUtils {
9
12
  static async XMLToJSON(xml) {
10
13
  return (await parseStringPromise(xml)).response;
11
14
  }
12
-
13
15
  static getFromRequests(url1, alias1, url2, alias2) {
14
16
  cy.intercept(url1).as(alias1);
15
17
  cy.intercept(url2).as(alias2);
16
18
  return cy.wait([`@${alias1}`, `@${alias2}`]).then(([interception1, interception2]) => [interception1.response.body, interception2.response.body]);
17
19
  }
18
-
19
20
  static interceptPolicyList({
20
21
  url,
21
22
  sortColumn,
@@ -25,53 +26,44 @@ class DataUtils {
25
26
  page,
26
27
  perPage,
27
28
  alias,
28
- raw = false,
29
+ raw = false
29
30
  } = {}) {
30
31
  if (raw) {
31
32
  cy.intercept('GET', url).as(alias);
32
33
  return;
33
34
  }
34
-
35
35
  const query = {};
36
-
37
36
  if (sortColumn) query['sort[column]'] = sortColumn;
38
37
  if (sortValue) query['sort[value]'] = sortValue;
39
-
40
38
  if (searchColumn && searchValue) {
41
39
  query['search[column]'] = searchColumn;
42
40
  query['search[value]'] = searchValue;
43
41
  }
44
-
45
42
  if (page) query.page = String(page);
46
43
  if (perPage) query.per_page = String(perPage);
47
-
48
44
  cy.intercept({
49
45
  method: 'GET',
50
46
  url,
51
- query,
47
+ query
52
48
  }).as(alias);
53
49
  }
54
-
55
50
  static extractDataArray(interception) {
56
51
  return interception.response.body.data || [];
57
52
  }
58
-
59
53
  static isSorted(arr, order = 'asc') {
60
- const sorted = [...arr].sort((a, b) => (order === 'asc' ? a - b : b - a));
54
+ const sorted = [...arr].sort((a, b) => order === 'asc' ? a - b : b - a);
61
55
  return JSON.stringify(arr) === JSON.stringify(sorted);
62
56
  }
63
-
64
57
  static waitForPolicyList(alias, path) {
65
- return cy.wait(`@${alias}`).then((interception) => {
58
+ return cy.wait(`@${alias}`).then(interception => {
66
59
  const parts = ['response', 'body', ...path.split('.')];
67
- const result = parts.reduce((acc, key) => (acc && typeof acc === 'object' ? acc[key] : {}), interception);
60
+ const result = parts.reduce((acc, key) => acc && typeof acc === 'object' ? acc[key] : {}, interception);
68
61
  return result;
69
62
  });
70
63
  }
71
-
72
64
  static getFromRequest(url, alias) {
73
65
  cy.intercept(url).as(alias);
74
- return cy.wait(`@${alias}`).then((interception) => interception.response.body);
66
+ return cy.wait(`@${alias}`).then(interception => interception.response.body);
75
67
  }
76
68
 
77
69
  /**
@@ -89,135 +81,116 @@ class DataUtils {
89
81
  * @param {boolean} options.isUnderSixtyYearsOld
90
82
  */
91
83
  static filterClients(clients, options = {}) {
92
- const { isResident } = options;
93
- const { hasPassport } = options;
94
- const { hasDriverLicence } = options;
95
- const { isUnderSixtyYearsOld } = options;
96
- const { isJuridical } = 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;
97
99
  let filteredClients = [...clients];
98
-
99
- filteredClients = filteredClients.filter((client) => {
100
+ filteredClients = filteredClients.filter(client => {
100
101
  if (isResident !== undefined) {
101
102
  return isResident ? client.resident_bool : !client.resident_bool;
102
103
  }
103
-
104
104
  return true;
105
105
  });
106
-
107
- filteredClients = filteredClients.filter((client) => {
106
+ filteredClients = filteredClients.filter(client => {
108
107
  if (hasDriverLicence !== undefined) {
109
108
  return hasDriverLicence ? client.driving_license : !client.driving_license;
110
109
  }
111
-
112
110
  return true;
113
111
  });
114
-
115
- filteredClients = filteredClients.filter((client) => {
112
+ filteredClients = filteredClients.filter(client => {
116
113
  if (hasPassport !== undefined) {
117
114
  const hasLetter = /[a-zA-Z]/.test(client.document_number);
118
- return hasPassport
119
- ? client.document_type_id === 11 && hasLetter
120
- : client.document_type_id !== 11;
115
+ return hasPassport ? client.document_type_id === 11 && hasLetter : client.document_type_id !== 11;
121
116
  }
122
-
123
117
  return true;
124
118
  });
125
-
126
- filteredClients = filteredClients.filter((client) => {
119
+ filteredClients = filteredClients.filter(client => {
127
120
  if (isUnderSixtyYearsOld !== undefined) {
128
- return isUnderSixtyYearsOld
129
- ? moment(client.born) > moment().subtract(60, 'years')
130
- : moment(client.born) <= moment().subtract(60, 'years');
121
+ return isUnderSixtyYearsOld ? moment(client.born) > moment().subtract(60, 'years') : moment(client.born) <= moment().subtract(60, 'years');
131
122
  }
132
-
133
123
  return true;
134
124
  });
135
-
136
- filteredClients = filteredClients.filter((client) => {
125
+ filteredClients = filteredClients.filter(client => {
137
126
  if (isJuridical !== undefined) {
138
127
  return isJuridical ? !client.natural_person_bool : client.natural_person_bool;
139
128
  }
140
-
141
129
  return true;
142
130
  });
143
-
144
131
  return filteredClients;
145
132
  }
146
-
147
133
  static createRandomCarStructure(carsArr) {
148
134
  const randomCarIndex = Randomizer.getRandomInteger(carsArr.length - 1);
149
135
  const tempCar = carsArr[randomCarIndex];
150
- const resultCar = { ...tempCar };
151
-
136
+ const resultCar = {
137
+ ...tempCar
138
+ };
152
139
  resultCar.dt_reg_cert = {};
153
140
  resultCar.dt_reg_cert.YMD = tempCar.dt_reg_cert;
154
141
  resultCar.dt_reg_cert.DMY = TimeUtils.reformatDateFromYMDToDMY(tempCar.dt_reg_cert);
155
-
156
142
  resultCar.year = tempCar.year.toString();
157
143
  resultCar.engine_volume = tempCar.engine_volume.toString();
158
-
159
144
  resultCar.model = {};
160
145
  resultCar.model.OGPO = tempCar.model;
161
146
  resultCar.model.KASKO = {};
162
147
  resultCar.model.KASKO.get = tempCar.model;
163
- resultCar.model.KASKO.set = tempCar.id !== 1
164
- ? StrUtils.toTitleCase(tempCar.model)
165
- : '5 серия';
166
-
148
+ resultCar.model.KASKO.set = tempCar.id !== 1 ? StrUtils.toTitleCase(tempCar.model) : '5 серия';
167
149
  resultCar.mark = {};
168
150
  resultCar.mark.OGPO = tempCar.mark;
169
151
  resultCar.mark.KASKO = {};
170
152
  resultCar.mark.KASKO.get = tempCar.mark;
171
153
  resultCar.mark.KASKO.set = tempCar.id !== 1 ? StrUtils.toTitleCase(tempCar.mark) : tempCar.mark;
172
-
173
154
  resultCar.region_id = JSONLoader.testData.carRegion;
174
155
  resultCar.type_id = JSONLoader.testData.carType;
175
-
176
156
  return resultCar;
177
157
  }
178
-
179
158
  static createRandomClientsStructures(clientsArr) {
180
159
  let randomHolderIndex = 0;
181
160
  let randomInsuredIndex = 0;
182
161
  let randomBeneficiaryIndex = 0;
183
-
184
162
  if (clientsArr.length > 1) {
185
163
  randomHolderIndex = Randomizer.getRandomInteger(clientsArr.length - 1);
186
-
187
164
  do {
188
165
  randomInsuredIndex = Randomizer.getRandomInteger(clientsArr.length - 1);
189
166
  } while (randomInsuredIndex === randomHolderIndex);
190
-
191
167
  do {
192
168
  randomBeneficiaryIndex = Randomizer.getRandomInteger(clientsArr.length - 1);
193
- } while (randomBeneficiaryIndex === randomHolderIndex
194
- || randomBeneficiaryIndex === randomInsuredIndex);
169
+ } while (randomBeneficiaryIndex === randomHolderIndex || randomBeneficiaryIndex === randomInsuredIndex);
195
170
  }
196
-
197
171
  const tempHolder = clientsArr[randomHolderIndex];
198
172
  const tempInsured = clientsArr[randomInsuredIndex];
199
173
  const tempBeneficiary = clientsArr[randomBeneficiaryIndex];
200
-
201
- const resultHolder = { ...tempHolder };
202
- const resultInsured = { ...tempInsured };
203
- const resultBeneficiary = { ...tempBeneficiary };
204
-
174
+ const resultHolder = {
175
+ ...tempHolder
176
+ };
177
+ const resultInsured = {
178
+ ...tempInsured
179
+ };
180
+ const resultBeneficiary = {
181
+ ...tempBeneficiary
182
+ };
205
183
  resultHolder.document_gived_date = {};
206
184
  resultHolder.document_gived_date.YMD = tempHolder.document_gived_date;
207
- resultHolder.document_gived_date.DMY = TimeUtils
208
- .reformatDateFromYMDToDMY(tempHolder.document_gived_date);
185
+ resultHolder.document_gived_date.DMY = TimeUtils.reformatDateFromYMDToDMY(tempHolder.document_gived_date);
209
186
  resultHolder.born = {};
210
187
  resultHolder.born.YMD = tempHolder.born;
211
188
  resultHolder.born.DMY = TimeUtils.reformatDateFromYMDToDMY(tempHolder.born);
212
189
  resultHolder.date_issue_license = {};
213
190
  resultHolder.date_issue_license.YMD = tempHolder.date_issue_license;
214
- resultHolder.date_issue_license.DMY = TimeUtils
215
- .reformatDateFromYMDToDMY(tempHolder.date_issue_license);
216
-
191
+ resultHolder.date_issue_license.DMY = TimeUtils.reformatDateFromYMDToDMY(tempHolder.date_issue_license);
217
192
  resultHolder.iin = tempHolder.iin.toString();
218
- resultHolder.document_type = JSONLoader
219
- .dictDocumentType[tempHolder.document_type_id.toString()];
220
-
193
+ resultHolder.document_type = JSONLoader.dictDocumentType[tempHolder.document_type_id.toString()];
221
194
  resultHolder.sex = JSONLoader.dictSexID[tempHolder.sex_id];
222
195
  resultHolder.address = JSONLoader.testData.holderAddress;
223
196
  resultHolder.email = JSONLoader.testData.holderEmail;
@@ -232,23 +205,17 @@ class DataUtils {
232
205
  resultHolder.phone = JSONLoader.testData.holderPhone;
233
206
  resultHolder.phoneTrimmed = JSONLoader.testData.holderPhoneTrimmed;
234
207
  resultHolder.phoneFormatted = JSONLoader.testData.holderPhoneFormatted;
235
-
236
208
  resultInsured.document_gived_date = {};
237
209
  resultInsured.document_gived_date.YMD = tempInsured.document_gived_date;
238
- resultInsured.document_gived_date.DMY = TimeUtils
239
- .reformatDateFromYMDToDMY(tempInsured.document_gived_date);
210
+ resultInsured.document_gived_date.DMY = TimeUtils.reformatDateFromYMDToDMY(tempInsured.document_gived_date);
240
211
  resultInsured.born = {};
241
212
  resultInsured.born.YMD = tempInsured.born;
242
213
  resultInsured.born.DMY = TimeUtils.reformatDateFromYMDToDMY(tempInsured.born);
243
214
  resultInsured.date_issue_license = {};
244
215
  resultInsured.date_issue_license.YMD = tempInsured.date_issue_license;
245
- resultInsured.date_issue_license.DMY = TimeUtils
246
- .reformatDateFromYMDToDMY(tempInsured.date_issue_license);
247
-
216
+ resultInsured.date_issue_license.DMY = TimeUtils.reformatDateFromYMDToDMY(tempInsured.date_issue_license);
248
217
  resultInsured.iin = tempInsured.iin.toString();
249
- resultInsured.document_type = JSONLoader
250
- .dictDocumentType[tempInsured.document_type_id.toString()];
251
-
218
+ resultInsured.document_type = JSONLoader.dictDocumentType[tempInsured.document_type_id.toString()];
252
219
  resultInsured.sex = JSONLoader.dictSexID[tempInsured.sex_id];
253
220
  resultInsured.address = JSONLoader.testData.insuredAddress;
254
221
  resultInsured.email = JSONLoader.testData.insuredEmail;
@@ -257,22 +224,17 @@ class DataUtils {
257
224
  resultInsured.driver_certificate_type_id = JSONLoader.testData.insuredDriverLicenceType;
258
225
  resultInsured.invalid_bool = JSONLoader.testData.insuredIsInvalid;
259
226
  resultInsured.pensioner_bool = JSONLoader.testData.insuredIsPensioner;
260
-
261
227
  resultBeneficiary.document_gived_date = {};
262
228
  resultBeneficiary.document_gived_date.YMD = tempBeneficiary.document_gived_date;
263
- resultBeneficiary.document_gived_date.DMY = TimeUtils
264
- .reformatDateFromYMDToDMY(tempBeneficiary.document_gived_date);
229
+ resultBeneficiary.document_gived_date.DMY = TimeUtils.reformatDateFromYMDToDMY(tempBeneficiary.document_gived_date);
265
230
  resultBeneficiary.born = {};
266
231
  resultBeneficiary.born.YMD = tempBeneficiary.born;
267
232
  resultBeneficiary.born.DMY = TimeUtils.reformatDateFromYMDToDMY(tempBeneficiary.born);
268
233
  resultBeneficiary.date_issue_license = {};
269
234
  resultBeneficiary.date_issue_license.YMD = tempBeneficiary.date_issue_license;
270
- resultBeneficiary.date_issue_license.DMY = TimeUtils
271
- .reformatDateFromYMDToDMY(tempBeneficiary.date_issue_license);
272
-
235
+ resultBeneficiary.date_issue_license.DMY = TimeUtils.reformatDateFromYMDToDMY(tempBeneficiary.date_issue_license);
273
236
  resultBeneficiary.iin = tempBeneficiary.iin.toString();
274
- resultBeneficiary.document_type = JSONLoader
275
- .dictDocumentType[tempBeneficiary.document_type_id.toString()];
237
+ resultBeneficiary.document_type = JSONLoader.dictDocumentType[tempBeneficiary.document_type_id.toString()];
276
238
  resultBeneficiary.sex = JSONLoader.dictSexID[tempBeneficiary.sex_id];
277
239
  resultBeneficiary.address = JSONLoader.testData.beneficiaryAddress;
278
240
  resultBeneficiary.email = JSONLoader.testData.beneficiaryEmail;
@@ -282,12 +244,16 @@ class DataUtils {
282
244
  resultBeneficiary.driver_certificate_type_id = JSONLoader.testData.beneficiaryDriverLicenceType;
283
245
  resultBeneficiary.invalid_bool = JSONLoader.testData.beneficiaryIsInvalid;
284
246
  resultBeneficiary.pensioner_bool = JSONLoader.testData.beneficiaryIsPensioner;
285
-
286
- return { holder: resultHolder, insured: resultInsured, beneficiary: resultBeneficiary };
247
+ return {
248
+ holder: resultHolder,
249
+ insured: resultInsured,
250
+ beneficiary: resultBeneficiary
251
+ };
287
252
  }
288
-
289
253
  static prepareSetClientRequestBody(getClientResponse, client) {
290
- const requestBody = { ...getClientResponse.data.data };
254
+ const requestBody = {
255
+ ...getClientResponse.data.data
256
+ };
291
257
  requestBody.first_name = client.first_name;
292
258
  requestBody.middle_name = client.middle_name;
293
259
  requestBody.last_name = client.last_name;
@@ -300,18 +266,12 @@ class DataUtils {
300
266
  requestBody.document_number = client.document_number;
301
267
  requestBody.document_gived_date = client.document_gived_date.DMY;
302
268
  requestBody.document_type_id = client.document_type_id;
303
- requestBody.verify_bool = requestBody.natural_person_bool
304
- ? Number(JSONLoader.configData.verification) : 0;
269
+ requestBody.verify_bool = requestBody.natural_person_bool ? Number(JSONLoader.configData.verification) : 0;
305
270
  requestBody.verify_type_id = requestBody.verify_bool ? 1 : 3;
306
- requestBody.activity_kind_id = requestBody.natural_person_bool
307
- ? 250 : client.activity_kind_id;
308
- requestBody.economics_sector_id = requestBody.natural_person_bool
309
- ? 10 : client.economics_sector_id;
310
- requestBody.juridical_person_name = requestBody.natural_person_bool
311
- ? '' : client.juridical_person_name;
312
-
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;
313
274
  return requestBody;
314
275
  }
315
276
  }
316
-
317
- module.exports = DataUtils;
277
+ module.exports = DataUtils;
@@ -1,7 +1,11 @@
1
+ "use strict";
2
+
1
3
  const fs = require('fs');
2
4
  const path = require('path');
3
- require('dotenv').config({ path: path.join(__dirname, '../../../../../../', '.env.test'), override: true });
4
-
5
+ require('dotenv').config({
6
+ path: path.join(__dirname, '../../../../../../', '.env.test'),
7
+ override: true
8
+ });
5
9
  const envDirectory = path.join(__dirname, '../../../../../../');
6
10
  const loaderFileLocation = path.join(envDirectory, './cypress/main/utils/data/', 'JSONLoader.js');
7
11
  const testClientsFileLocation = path.join(envDirectory, './cypress/resources/data/testClients.json');
@@ -11,34 +15,26 @@ const suitesDirectory = path.join(envDirectory, './cypress/tests/suites');
11
15
  const jsonExtension = '.json';
12
16
  const testExtension = '.test';
13
17
  const testSuitePattern = 'Suite.js';
14
-
15
18
  const getFiles = (directory, extension) => {
16
19
  const allFiles = fs.readdirSync(directory);
17
- const selectedFiles = allFiles.filter((file) => file.endsWith(extension));
18
- allFiles.forEach((file) => {
20
+ const selectedFiles = allFiles.filter(file => file.endsWith(extension));
21
+ allFiles.forEach(file => {
19
22
  const fullPath = path.join(directory, file);
20
23
  if (fs.statSync(fullPath).isDirectory()) {
21
24
  const nestedFiles = getFiles(fullPath, extension);
22
- selectedFiles.push(...nestedFiles.map((nestedFile) => path.join(file, nestedFile)));
25
+ selectedFiles.push(...nestedFiles.map(nestedFile => path.join(file, nestedFile)));
23
26
  }
24
27
  });
25
-
26
28
  return selectedFiles;
27
29
  };
28
-
29
- const generateClassInit = (selectedFiles, directory) => `class JSONLoader {\n${selectedFiles.map((file) => {
30
+ const generateClassInit = (selectedFiles, directory) => `class JSONLoader {\n${selectedFiles.map(file => {
30
31
  const variableName = path.parse(file).name;
31
32
  return `\tstatic get ${variableName}() {\n\t\tconst ${variableName} = require('${path.join(directory, file)}');\n\t\treturn JSON.parse(JSON.stringify(${variableName}));\n\t}\n\n`;
32
33
  }).join('')}`;
33
-
34
- const generateTestSuitesNames = (selectedFiles) => {
35
- const suiteNames = selectedFiles
36
- .map((file) => file.replace(testSuitePattern, ''))
37
- .map((name) => `'${name}'`)
38
- .join(', ');
34
+ const generateTestSuitesNames = selectedFiles => {
35
+ const suiteNames = selectedFiles.map(file => file.replace(testSuitePattern, '')).map(name => `'${name}'`).join(', ');
39
36
  return `\tstatic get testSuitesNames() {\n\t\treturn [${suiteNames}];\n\t}\n\n`;
40
37
  };
41
-
42
38
  const generateJSONLoader = (filePath, directory) => {
43
39
  const jsonFiles = getFiles(directory, jsonExtension);
44
40
  const testSuites = getFiles(suitesDirectory, testSuitePattern);
@@ -47,10 +43,9 @@ const generateJSONLoader = (filePath, directory) => {
47
43
  const classExport = '}\n\nmodule.exports = JSONLoader;';
48
44
  fs.writeFileSync(filePath, classInit + suitesNames + classExport);
49
45
  };
50
-
51
46
  const setConfigData = (directory, extension) => {
52
47
  const files = getFiles(directory, extension);
53
- const configFile = files.filter((file) => file.includes('config')).pop();
48
+ const configFile = files.filter(file => file.includes('config')).pop();
54
49
  if (configFile) {
55
50
  const filePath = `${directory}/${configFile}`;
56
51
  const data = JSON.parse(fs.readFileSync(filePath, 'utf8'));
@@ -58,37 +53,35 @@ const setConfigData = (directory, extension) => {
58
53
  data.setPolicyWaitingTWB = process.argv.includes('--setPolicyWaitingTWB');
59
54
  try {
60
55
  data.verification = Boolean(JSON.parse(process.env.VERIFICATION ?? data.verification));
61
- } catch (error) { // eslint-disable-next-line no-console
56
+ } catch (error) {
57
+ // eslint-disable-next-line no-console
62
58
  console.log(' [err] incorrect value of "VERIFICATION" .env variable!');
63
59
  }
64
-
65
60
  if (process.env.GATEWAY_URL) {
66
61
  const value = process.env.GATEWAY_URL.match(/\b(?:localhost|dev|staging)\b/g);
67
62
  if (value) {
68
63
  data.environment = value.pop();
69
- } else { // eslint-disable-next-line no-console
64
+ } else {
65
+ // eslint-disable-next-line no-console
70
66
  console.log(' [err] incorrect value of "GATEWAY_URL" .env variable!');
71
67
  }
72
- } else { // eslint-disable-next-line no-console
68
+ } else {
69
+ // eslint-disable-next-line no-console
73
70
  console.log(' [err] "GATEWAY_URL" .env variable not exists!');
74
71
  }
75
-
76
72
  fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');
77
73
  }
78
74
  };
79
-
80
75
  const checkEnvExists = (directory, extension) => {
81
76
  const files = getFiles(directory, extension);
82
77
  if (!files.length) throw new Error('[err] .env.test file not exists in root directory!');
83
78
  };
84
-
85
- const generateTestDataFile = (filePath) => {
79
+ const generateTestDataFile = filePath => {
86
80
  const emptyObj = {};
87
81
  if (!fs.existsSync(filePath)) fs.writeFileSync(filePath, JSON.stringify(emptyObj, null, 2), 'utf8');
88
82
  };
89
-
90
83
  checkEnvExists(envDirectory, testExtension);
91
84
  setConfigData(JSONDirectory, jsonExtension);
92
85
  generateTestDataFile(testCarsFileLocation);
93
86
  generateTestDataFile(testClientsFileLocation);
94
- generateJSONLoader(loaderFileLocation, JSONDirectory);
87
+ generateJSONLoader(loaderFileLocation, JSONDirectory);
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const YAML = require('js-yaml');
6
+ const JSONLoader = require('./JSONLoader');
7
+ const testSuites = JSONLoader.testSuitesNames;
8
+ const jobs = testSuites.map(suite => ({
9
+ [`e2e tests ${suite}`]: {
10
+ image: 'lines14/cypress-java-dind:latest',
11
+ stage: 'test',
12
+ variables: {
13
+ DOCKER_HOST: 'tcp://docker:2375',
14
+ DOCKER_TLS_CERTDIR: '',
15
+ DOCKER_DRIVER: 'overlay2',
16
+ DOCKER_DAEMON_TIMEOUT: 600
17
+ },
18
+ only: ['dev'],
19
+ services: [{
20
+ name: 'docker:dind',
21
+ command: ['--tls=false', '--host=tcp://0.0.0.0:2375']
22
+ }],
23
+ needs: [],
24
+ tags: ['k8s'],
25
+ before_script: [
26
+ // eslint-disable-next-line no-template-curly-in-string
27
+ 'echo "${ADP_NUXT_TEST}" | tr -d \'\\r\' > ./.env.test', 'docker login --username $USER --password $PASS registry.gitlab.com', 'service docker start', 'npm ci --prefix ./cypress', 'npm run lint --prefix ./cypress'],
28
+ script: ['npm run start:ci --prefix ./cypress', `file=${suite} npm run test --prefix ./cypress`],
29
+ artifacts: {
30
+ when: 'always',
31
+ expire_in: '1 month',
32
+ paths: ['cypress/artifacts', 'cypress/screenshots', 'cypress/videos', 'cypress/resources/data/configData.json', 'cypress/resources/data/testClients.json', 'cypress/resources/data/testCars.json']
33
+ }
34
+ }
35
+ }));
36
+ const gitlabCIConfig = Object.assign({}, ...jobs);
37
+ fs.writeFileSync(path.join(__dirname, '..', '..', '..', '..', '.split-config.yml'), YAML.dump(gitlabCIConfig));
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+
1
3
  // Auto-generated file
2
4
 
3
5
  exports.BaseAPI = require('./API/baseAPI');
@@ -9,4 +11,4 @@ exports.gitlabCIGenerator = require('./data/gitlabCIGenerator');
9
11
  exports.Logger = require('./log/logger');
10
12
  exports.Randomizer = require('./random/randomizer');
11
13
  exports.StrUtils = require('./str/strUtils');
12
- exports.TimeUtils = require('./time/timeUtils');
14
+ exports.TimeUtils = require('./time/timeUtils');
@@ -1,29 +1,31 @@
1
+ "use strict";
2
+
1
3
  const path = require('path');
2
4
  const moment = require('moment');
3
- const { createWriteStream } = require('fs');
5
+ const {
6
+ createWriteStream
7
+ } = require('fs');
4
8
  const JSONLoader = require('../data/JSONLoader');
5
-
6
9
  const filePath = path.join(path.resolve(), 'artifacts', 'log.txt');
7
10
  const timeList = [];
8
11
  const logList = [];
9
-
10
12
  class Logger {
11
13
  static #title;
12
-
13
14
  static log(step, title) {
14
15
  logList.push(` ${step}`);
15
16
  const timeStamp = moment().format().slice(0, 19).replace('T', ' ');
16
17
  timeList.push(`${timeStamp}`);
17
18
  if (title) this.#title = title;
18
19
  if (!JSONLoader.configData.parallel) {
19
- const stream = createWriteStream(filePath, { flags: 'a', autoClose: true });
20
+ const stream = createWriteStream(filePath, {
21
+ flags: 'a',
22
+ autoClose: true
23
+ });
20
24
  if (!title) stream.write(`${timeStamp} ${step}\n`);
21
25
  this.hideLogBodies(step);
22
26
  }
23
-
24
27
  return timeStamp;
25
28
  }
26
-
27
29
  static hideLogBodies(step) {
28
30
  if (JSONLoader.configData.hiddenLogBodies && step.includes('[req]')) {
29
31
  const words = step.split(' ');
@@ -34,24 +36,22 @@ class Logger {
34
36
  console.log(` ${step}`); // eslint-disable-line no-console
35
37
  }
36
38
  }
37
-
38
39
  static logParallel() {
39
- logList.forEach((step) => this.hideLogBodies(step.trim()));
40
+ logList.forEach(step => this.hideLogBodies(step.trim()));
40
41
  }
41
-
42
42
  static logToFileParallel() {
43
43
  const zip = (a, b) => a.map((k, i) => [k, b[i]]);
44
44
  const summaryList = zip(timeList, logList);
45
45
  summaryList.shift();
46
- const fileName = filePath.split('/')
47
- .map((part, index, array) => (index === array.length - 1 ? `${this.#title}.${part}` : part))
48
- .join('/');
49
- const stream = createWriteStream(fileName, { flags: 'a', autoClose: true });
50
- summaryList.forEach((logString) => logString.forEach((logSubString, index) => {
46
+ const fileName = filePath.split('/').map((part, index, array) => index === array.length - 1 ? `${this.#title}.${part}` : part).join('/');
47
+ const stream = createWriteStream(fileName, {
48
+ flags: 'a',
49
+ autoClose: true
50
+ });
51
+ summaryList.forEach(logString => logString.forEach((logSubString, index) => {
51
52
  /* eslint no-unused-expressions: ["error", { "allowTernary": true }] */
52
53
  index % 2 !== 0 ? stream.write(`${logSubString}\n`) : stream.write(`${logSubString}`);
53
54
  }));
54
55
  }
55
56
  }
56
-
57
- module.exports = Logger;
57
+ module.exports = Logger;
@@ -1,106 +1,72 @@
1
+ "use strict";
2
+
1
3
  const moment = require('moment');
2
4
  const JSONLoader = require('../data/JSONLoader');
3
-
4
5
  class Randomizer {
5
6
  static getRandomDatesIntervalFromTomorrow(count, unitOfTime) {
6
7
  const nextDayObject = moment().add(1, 'days').startOf('day');
7
8
  const unixOne = nextDayObject.unix();
8
9
  const unixTwo = moment(moment().add(1, 'days').startOf('day')).add(count, unitOfTime).unix();
9
-
10
10
  const startDateUnix = moment.unix(this.getRandomFloat(unixOne, unixTwo)).unix();
11
11
  let finishDateUnix;
12
12
  do {
13
13
  finishDateUnix = moment.unix(this.getRandomFloat(startDateUnix, unixTwo)).unix();
14
- } while ((finishDateUnix - startDateUnix) < 86400 * 2);
15
-
14
+ } while (finishDateUnix - startDateUnix < 86400 * 2);
16
15
  const startDateObject = moment.unix(startDateUnix).startOf('day');
17
16
  const finishDateObject = moment.unix(finishDateUnix).startOf('day');
18
17
  const startDate = startDateObject.format(JSONLoader.testData.datesFormatDMY);
19
18
  const finishDate = finishDateObject.format(JSONLoader.testData.datesFormatDMY);
20
-
21
19
  const daysDifferenceIncluded = finishDateObject.diff(startDateObject, 'days') + 1;
22
-
23
- const getAbsoluteMonth = (date) => {
20
+ const getAbsoluteMonth = date => {
24
21
  const months = Number(moment(date, JSONLoader.testData.datesFormatDMY).format('MM'));
25
22
  const years = Number(moment(date, JSONLoader.testData.datesFormatDMY).format('YYYY'));
26
- return months + (years * 12);
23
+ return months + years * 12;
27
24
  };
28
-
29
- const currentMonth = getAbsoluteMonth(moment.unix(unixOne)
30
- .format(JSONLoader.testData.datesFormatDMY));
25
+ const currentMonth = getAbsoluteMonth(moment.unix(unixOne).format(JSONLoader.testData.datesFormatDMY));
31
26
  const startMonth = getAbsoluteMonth(startDate);
32
27
  const finishMonth = getAbsoluteMonth(finishDate);
33
28
  let startMonthDifference = startMonth - currentMonth;
34
29
  let finishMonthDifference = finishMonth - currentMonth;
35
-
36
30
  if (nextDayObject.date() === 1) startMonthDifference += 1;
37
31
  if (nextDayObject.date() === 1) finishMonthDifference += 1;
38
-
39
32
  return {
40
33
  startDate,
41
34
  finishDate,
42
35
  startMonthDifference,
43
36
  finishMonthDifference,
44
- daysDifferenceIncluded,
37
+ daysDifferenceIncluded
45
38
  };
46
39
  }
47
-
48
- static getRandomString(
49
- hasLowerCase = false,
50
- hasUpperCase = false,
51
- hasNumber = false,
52
- hasCyrillic = false,
53
- chosenLetter = false,
54
- minLength = 1,
55
- maxLength = 10,
56
- ) {
40
+ static getRandomString(hasLowerCase = false, hasUpperCase = false, hasNumber = false, hasCyrillic = false, chosenLetter = false, minLength = 1, maxLength = 10) {
57
41
  const upperCaseLetters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
58
42
  const lowerCaseLetters = 'abcdefghijklmnopqrstuvwxyz';
59
43
  const numbers = '0123456789';
60
44
  const cyrillicLetters = 'абвгдеёжзийклмнопрстуфхцчшщъыьэюя';
61
-
62
45
  const length = this.getRandomInteger(maxLength, minLength);
63
-
64
46
  let randomString = '';
65
47
  if (chosenLetter) randomString += chosenLetter;
66
-
67
48
  let requiredCharacters = '';
68
49
  if (hasLowerCase) {
69
- requiredCharacters
70
- += lowerCaseLetters.charAt(Math.floor(Math.random() * lowerCaseLetters.length));
50
+ requiredCharacters += lowerCaseLetters.charAt(Math.floor(Math.random() * lowerCaseLetters.length));
71
51
  }
72
-
73
52
  if (hasUpperCase) {
74
- requiredCharacters
75
- += upperCaseLetters.charAt(Math.floor(Math.random() * upperCaseLetters.length));
53
+ requiredCharacters += upperCaseLetters.charAt(Math.floor(Math.random() * upperCaseLetters.length));
76
54
  }
77
-
78
55
  if (hasNumber) {
79
- requiredCharacters
80
- += numbers.charAt(Math.floor(Math.random() * numbers.length));
56
+ requiredCharacters += numbers.charAt(Math.floor(Math.random() * numbers.length));
81
57
  }
82
-
83
58
  if (hasCyrillic) {
84
- requiredCharacters
85
- += cyrillicLetters.charAt(Math.floor(Math.random() * cyrillicLetters.length));
59
+ requiredCharacters += cyrillicLetters.charAt(Math.floor(Math.random() * cyrillicLetters.length));
86
60
  }
87
-
88
61
  randomString += requiredCharacters;
89
-
90
- const characters = (hasLowerCase ? lowerCaseLetters : '')
91
- + (hasUpperCase ? upperCaseLetters : '')
92
- + (hasNumber ? numbers : '')
93
- + (hasCyrillic ? cyrillicLetters : '');
62
+ const characters = (hasLowerCase ? lowerCaseLetters : '') + (hasUpperCase ? upperCaseLetters : '') + (hasNumber ? numbers : '') + (hasCyrillic ? cyrillicLetters : '');
94
63
  const charactersLength = characters.length;
95
64
  const randomLength = length - randomString.length;
96
-
97
65
  for (let i = 0; i < randomLength; i += 1) {
98
66
  randomString += characters.charAt(Math.floor(Math.random() * charactersLength));
99
67
  }
100
-
101
68
  return this.stringShuffler(randomString);
102
69
  }
103
-
104
70
  static stringShuffler(inputString) {
105
71
  const array = inputString.split('');
106
72
  let currentIndex = array.length;
@@ -113,36 +79,32 @@ class Randomizer {
113
79
  array[currentIndex] = array[randomIndex];
114
80
  array[randomIndex] = temporaryValue;
115
81
  }
116
-
117
82
  return array.join('');
118
83
  }
119
-
120
84
  static getRandomInteger(max = 9, min = 0) {
121
85
  return Math.floor(Math.random() * (max - min + 1)) + min;
122
86
  }
123
-
124
87
  static getRandomFloat(min, max) {
125
88
  return Math.random() * (max - min) + min;
126
89
  }
127
-
128
90
  static getRandomElementByText(baseElements, exceptionsList = []) {
129
91
  const exceptions = exceptionsList ?? [];
130
92
  const baseElementsList = baseElements.slice(0, baseElements.length);
131
93
  let element;
132
94
  if (exceptions.length > 0) {
133
- while (true) { // eslint-disable-line no-constant-condition
95
+ while (true) {
96
+ // eslint-disable-line no-constant-condition
134
97
  element = baseElementsList[Math.floor(Math.random() * baseElementsList.length)];
135
- if (!exceptions.includes(element) && (element !== '')) break;
98
+ if (!exceptions.includes(element) && element !== '') break;
136
99
  }
137
100
  } else {
138
- while (true) { // eslint-disable-line no-constant-condition
101
+ while (true) {
102
+ // eslint-disable-line no-constant-condition
139
103
  element = baseElementsList[Math.floor(Math.random() * baseElementsList.length)];
140
104
  if (element !== '') break;
141
105
  }
142
106
  }
143
-
144
107
  return element;
145
108
  }
146
109
  }
147
-
148
- module.exports = Randomizer;
110
+ module.exports = Randomizer;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ class StrUtils {
4
+ static toTitleCase(str) {
5
+ return str.replace(/\w\S*/g, txt => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
6
+ }
7
+ static removeAllNonNumbersFromString(str) {
8
+ return str.replace(/\D/g, '');
9
+ }
10
+ }
11
+ module.exports = StrUtils;
@@ -1,53 +1,48 @@
1
+ "use strict";
2
+
1
3
  const moment = require('moment');
2
4
  const JSONLoader = require('../data/JSONLoader');
3
-
4
5
  class TimeUtils {
5
6
  static getDatesInterval(count, unitOfTime, options = {}) {
6
- const { dateBegin } = options;
7
+ const {
8
+ dateBegin
9
+ } = options;
7
10
  const startNextDay = options.startNextDay ?? true;
8
11
  const isNotIncluded = options.isNotIncluded ?? true;
9
12
  const reverseInterval = options.reverseInterval ?? false;
10
-
11
13
  let startDate;
12
14
  if (reverseInterval) {
13
15
  startDate = startNextDay ? moment().subtract(1, 'days') : moment();
14
16
  } else {
15
17
  startDate = startNextDay ? moment().add(1, 'days') : moment();
16
18
  }
17
-
18
19
  let finishDate;
19
20
  if (reverseInterval) {
20
- finishDate = dateBegin
21
- ? moment(dateBegin, JSONLoader.testData.datesFormatDMY).subtract(count, unitOfTime)
22
- : moment(startDate).subtract(count, unitOfTime);
21
+ finishDate = dateBegin ? moment(dateBegin, JSONLoader.testData.datesFormatDMY).subtract(count, unitOfTime) : moment(startDate).subtract(count, unitOfTime);
23
22
  if (isNotIncluded) {
24
23
  finishDate = moment(finishDate).add(1, 'days');
25
24
  }
26
25
  } else {
27
- finishDate = dateBegin
28
- ? moment(dateBegin, JSONLoader.testData.datesFormatDMY).add(count, unitOfTime)
29
- : moment(startDate).add(count, unitOfTime);
26
+ finishDate = dateBegin ? moment(dateBegin, JSONLoader.testData.datesFormatDMY).add(count, unitOfTime) : moment(startDate).add(count, unitOfTime);
30
27
  if (isNotIncluded) {
31
28
  finishDate = moment(finishDate).subtract(1, 'days');
32
29
  }
33
30
  }
34
-
35
31
  startDate = moment(startDate).format(JSONLoader.testData.datesFormatDMY);
36
32
  finishDate = moment(finishDate).format(JSONLoader.testData.datesFormatDMY);
37
- return reverseInterval
38
- ? { startDate: finishDate, finishDate: dateBegin ?? startDate }
39
- : { startDate: dateBegin ?? startDate, finishDate };
33
+ return reverseInterval ? {
34
+ startDate: finishDate,
35
+ finishDate: dateBegin ?? startDate
36
+ } : {
37
+ startDate: dateBegin ?? startDate,
38
+ finishDate
39
+ };
40
40
  }
41
-
42
41
  static reformatDateFromYMDToDMY(date) {
43
- return moment(date, JSONLoader.testData.datesFormatYMD)
44
- .format(JSONLoader.testData.datesFormatDMY);
42
+ return moment(date, JSONLoader.testData.datesFormatYMD).format(JSONLoader.testData.datesFormatDMY);
45
43
  }
46
-
47
44
  static reformatDateFromDMYToYMD(date) {
48
- return moment(date, JSONLoader.testData.datesFormatDMY)
49
- .format(JSONLoader.testData.datesFormatYMD);
45
+ return moment(date, JSONLoader.testData.datesFormatDMY).format(JSONLoader.testData.datesFormatYMD);
50
46
  }
51
47
  }
52
-
53
- module.exports = TimeUtils;
48
+ module.exports = TimeUtils;
package/package.json CHANGED
@@ -1,35 +1,44 @@
1
1
  {
2
2
  "name": "@amanat-qa/utils-frontend",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "type": "commonjs",
8
8
  "files": [
9
- "src"
9
+ "dist"
10
10
  ],
11
11
  "keywords": [],
12
12
  "license": "MIT",
13
- "main": "./src/index.js",
13
+ "main": "./dist/index.js",
14
14
  "exports": {
15
- ".": "./src/index.js",
16
- "./baseAPI": "./src/API/baseAPI.js",
17
- "./baseDB": "./src/DB/baseDB.js",
18
- "./JSONLoader": "./src/data/JSONLoader.js",
19
- "./dataUtils": "./src/data/dataUtils.js",
20
- "./filesParser": "./src/data/filesParser.js",
21
- "./gitlabCIGenerator": "./src/data/gitlabCIGenerator.js",
22
- "./logger": "./src/log/logger.js",
23
- "./randomizer": "./src/random/randomizer.js",
24
- "./strUtils": "./src/str/strUtils.js",
25
- "./timeUtils": "./src/time/timeUtils.js"
15
+ ".": "./dist/index.js",
16
+ "./baseAPI": "./dist/API/baseAPI.js",
17
+ "./baseDB": "./dist/DB/baseDB.js",
18
+ "./JSONLoader": "./dist/data/JSONLoader.js",
19
+ "./dataUtils": "./dist/data/dataUtils.js",
20
+ "./filesParser": "./dist/data/filesParser.js",
21
+ "./gitlabCIGenerator": "./dist/data/gitlabCIGenerator.js",
22
+ "./logger": "./dist/log/logger.js",
23
+ "./randomizer": "./dist/random/randomizer.js",
24
+ "./strUtils": "./dist/str/strUtils.js",
25
+ "./timeUtils": "./dist/time/timeUtils.js"
26
+ },
27
+ "scripts": {
28
+ "build": "babel src --out-dir dist --extensions .js",
29
+ "prepare": "npm run build"
26
30
  },
27
31
  "dependencies": {
28
32
  "axios": "*",
29
- "mysql2": "*",
30
- "moment": "*",
31
- "xml2js": "*",
32
33
  "dotenv": "*",
33
- "js-yaml": "*"
34
+ "js-yaml": "*",
35
+ "moment": "*",
36
+ "mysql2": "*",
37
+ "xml2js": "*"
38
+ },
39
+ "devDependencies": {
40
+ "@babel/cli": "^7.28.3",
41
+ "@babel/core": "^7.28.5",
42
+ "@babel/preset-env": "^7.28.5"
34
43
  }
35
44
  }
@@ -1,8 +0,0 @@
1
- let JSONLoader;
2
- try {
3
- JSONLoader = require('../../../../../test/main/utils/data/JSONLoader');
4
- } catch (e) {
5
- throw new Error('[err] JSONLoader require error!');
6
- }
7
-
8
- module.exports = JSONLoader;
@@ -1,62 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const YAML = require('js-yaml');
4
- const JSONLoader = require('./JSONLoader');
5
-
6
- const testSuites = JSONLoader.testSuitesNames;
7
- const jobs = testSuites.map((suite) => ({
8
- [`e2e tests ${suite}`]: {
9
- image: 'lines14/cypress-java-dind:latest',
10
- stage: 'test',
11
- variables: {
12
- DOCKER_HOST: 'tcp://docker:2375',
13
- DOCKER_TLS_CERTDIR: '',
14
- DOCKER_DRIVER: 'overlay2',
15
- DOCKER_DAEMON_TIMEOUT: 600,
16
- },
17
- only: [
18
- 'dev',
19
- ],
20
- services: [
21
- {
22
- name: 'docker:dind',
23
- command: ['--tls=false', '--host=tcp://0.0.0.0:2375'],
24
- },
25
- ],
26
- needs: [],
27
- tags: [
28
- 'k8s',
29
- ],
30
- before_script: [
31
- // eslint-disable-next-line no-template-curly-in-string
32
- 'echo "${ADP_NUXT_TEST}" | tr -d \'\\r\' > ./.env.test',
33
- 'docker login --username $USER --password $PASS registry.gitlab.com',
34
- 'service docker start',
35
- 'npm ci --prefix ./cypress',
36
- 'npm run lint --prefix ./cypress',
37
- ],
38
- script: [
39
- 'npm run start:ci --prefix ./cypress',
40
- `file=${suite} npm run test --prefix ./cypress`,
41
- ],
42
- artifacts: {
43
- when: 'always',
44
- expire_in: '1 month',
45
- paths: [
46
- 'cypress/artifacts',
47
- 'cypress/screenshots',
48
- 'cypress/videos',
49
- 'cypress/resources/data/configData.json',
50
- 'cypress/resources/data/testClients.json',
51
- 'cypress/resources/data/testCars.json',
52
- ],
53
- },
54
- },
55
- }));
56
-
57
- const gitlabCIConfig = Object.assign({}, ...jobs);
58
-
59
- fs.writeFileSync(
60
- path.join(__dirname, '..', '..', '..', '..', '.split-config.yml'),
61
- YAML.dump(gitlabCIConfig),
62
- );
@@ -1,14 +0,0 @@
1
- class StrUtils {
2
- static toTitleCase(str) {
3
- return str.replace(
4
- /\w\S*/g,
5
- (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(),
6
- );
7
- }
8
-
9
- static removeAllNonNumbersFromString(str) {
10
- return str.replace(/\D/g, '');
11
- }
12
- }
13
-
14
- module.exports = StrUtils;