vita-playwright 1.2.1 → 1.2.3
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/README.md +175 -22
- package/dist/src/utils/date_utilitites.d.ts +9 -0
- package/dist/src/utils/date_utilitites.js +30 -0
- package/dist/src/utils/date_utilitites.js.map +1 -0
- package/dist/src/utils/pdf_utility.d.ts +1 -0
- package/dist/src/utils/pdf_utility.js +25 -0
- package/dist/src/utils/pdf_utility.js.map +1 -1
- package/dist/src/utils/test_data.d.ts +2 -7
- package/dist/src/utils/test_data.js +14 -12
- package/dist/src/utils/test_data.js.map +1 -1
- package/package.json +4 -3
- package/src/utils/date_utilitites.ts +28 -0
- package/src/utils/pdf_utility.ts +11 -10
- package/src/utils/test_data.ts +14 -12
package/README.md
CHANGED
|
@@ -34,10 +34,17 @@ VITA Playwright helpers are written in Typescript with playwright support and a
|
|
|
34
34
|
- [updateExcelData](#updateexceldata)
|
|
35
35
|
- [deleteAllFilesUnderDir](#deleteallfilesunderdir)
|
|
36
36
|
- [PDF Utilities](#pdf-utilities)
|
|
37
|
+
- [readPdfFile](#readpdffile)
|
|
37
38
|
- [Lighthouse Utilities](#lighthouse-utilities)
|
|
38
39
|
- [auditLightHouse](#auditlighthouse)
|
|
39
40
|
- [createLightHouseReport](#createlighthousereport)
|
|
40
41
|
- [Date Utilities](#date-utilities)
|
|
42
|
+
- [getDateInCustomFormat](#getdateincustomformat)
|
|
43
|
+
- [getPastDateInCustomFormat](#getpastdateincustomformat)
|
|
44
|
+
- [getFutureDateInCustomFormat](#getfuturedateincustomformat)
|
|
45
|
+
- [getMinDateFromMultipleDates](#getmindatefrommultipledates)
|
|
46
|
+
- [getMaxDateFromMultipleDates](#getmaxdatefrommultipledates)
|
|
47
|
+
- [calculateRelativeDate](#calculaterelativedate)
|
|
41
48
|
- [Database Utilities](#database-utilities)
|
|
42
49
|
- [sqlDBConnection](#sqldbconnection)
|
|
43
50
|
- [executeSqlQuery](#executesqlquery)
|
|
@@ -107,27 +114,59 @@ __Note__: getElementRefByRole() method will work for all types of roles, example
|
|
|
107
114
|
|
|
108
115
|
#### filltheData
|
|
109
116
|
```ts
|
|
110
|
-
|
|
117
|
+
/**
|
|
118
|
+
* @description: sets the text in inputbox.
|
|
119
|
+
* @param {string} locator - css selector/xpath of the inputbox.
|
|
120
|
+
* @param {string} data - Text to be set to inputbox
|
|
121
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
122
|
+
*/
|
|
123
|
+
async filltheData(locator: any, data: any)
|
|
111
124
|
```
|
|
112
125
|
#### clickonWebElement
|
|
113
126
|
```ts
|
|
114
|
-
|
|
127
|
+
/**
|
|
128
|
+
* @description: click the given locator element.
|
|
129
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
130
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
131
|
+
*/
|
|
132
|
+
async clickonWebElement(locator: any)
|
|
115
133
|
```
|
|
116
134
|
#### getInnerHTML
|
|
117
135
|
```ts
|
|
118
|
-
|
|
136
|
+
/**
|
|
137
|
+
* @description: returns inner html of locator element.
|
|
138
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
139
|
+
* @returns {string} - returns inner html string
|
|
140
|
+
*/
|
|
141
|
+
async getInnerHTML(locator: any)
|
|
119
142
|
```
|
|
120
143
|
#### getInnerText
|
|
121
144
|
```ts
|
|
122
|
-
|
|
145
|
+
/**
|
|
146
|
+
* @description: returns inner text of locator element.
|
|
147
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
148
|
+
* @returns {string} - returns inner text string
|
|
149
|
+
*/
|
|
150
|
+
async getInnerText(locator: any)
|
|
123
151
|
```
|
|
124
152
|
#### getText
|
|
125
153
|
```ts
|
|
126
|
-
|
|
154
|
+
/**
|
|
155
|
+
* @description: returns text of locator element.
|
|
156
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
157
|
+
* @returns {string} - returns text string
|
|
158
|
+
*/
|
|
159
|
+
async getText(locator: any)
|
|
127
160
|
```
|
|
128
161
|
#### getAttribute
|
|
129
162
|
```ts
|
|
130
|
-
|
|
163
|
+
/**
|
|
164
|
+
* @description: returns given attribute value of locator element.
|
|
165
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
166
|
+
* @param {string} attribute - html attribute to get value
|
|
167
|
+
* @returns {string} - returns text string
|
|
168
|
+
*/
|
|
169
|
+
async getAttribute(locator: any, attribute: any))
|
|
131
170
|
```
|
|
132
171
|
#### evaluateJS
|
|
133
172
|
```ts
|
|
@@ -135,31 +174,70 @@ __Note__: getElementRefByRole() method will work for all types of roles, example
|
|
|
135
174
|
```
|
|
136
175
|
#### isElementPresent
|
|
137
176
|
```ts
|
|
138
|
-
|
|
177
|
+
/**
|
|
178
|
+
* @description: verifies given locator element is displayed or not.
|
|
179
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
180
|
+
* @returns {boolean} - returns true/false
|
|
181
|
+
*/
|
|
182
|
+
async isElementPresent(locator: any)
|
|
139
183
|
```
|
|
140
184
|
#### isElementEnabled
|
|
141
185
|
```ts
|
|
142
|
-
|
|
186
|
+
/**
|
|
187
|
+
* @description: verifies given locator element is enabled or not.
|
|
188
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
189
|
+
* @returns {boolean} - returns true/false
|
|
190
|
+
*/
|
|
191
|
+
async isElementEnabled(locator: any)
|
|
143
192
|
```
|
|
144
193
|
#### waitTillElementIsVisible
|
|
145
194
|
```ts
|
|
146
|
-
|
|
195
|
+
/**
|
|
196
|
+
* @description: waits until locator element visibles.
|
|
197
|
+
* @param {elementReference} elementSelector - element reference.
|
|
198
|
+
* @param {number} wait time
|
|
199
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
200
|
+
*/
|
|
201
|
+
async waitTillElementIsVisible(elementSelector: any, waitTime = 60000)
|
|
147
202
|
```
|
|
148
203
|
#### getInputBoxValue
|
|
149
204
|
```ts
|
|
150
|
-
|
|
205
|
+
/**
|
|
206
|
+
* @description: returns value of inputbox.
|
|
207
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
208
|
+
* @returns {string} - returns text string
|
|
209
|
+
*/
|
|
210
|
+
async getInputBoxValue(locator: any)
|
|
151
211
|
```
|
|
152
212
|
#### downloadAFile
|
|
153
213
|
```ts
|
|
154
|
-
|
|
214
|
+
/**
|
|
215
|
+
* @description: wait untill download process completes and save file with custom name.
|
|
216
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
217
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
218
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
219
|
+
*/
|
|
220
|
+
async downloadAFile(downloadButton: String, filePath: string)
|
|
155
221
|
```
|
|
156
222
|
#### uploadAFile
|
|
157
223
|
```ts
|
|
158
|
-
|
|
224
|
+
/**
|
|
225
|
+
* @description: wait untill upload process completes and save file with custom name.
|
|
226
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
227
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
228
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
229
|
+
*/
|
|
230
|
+
async uploadAFile(uploadButton: String, uploadFilePath: String)
|
|
159
231
|
```
|
|
160
232
|
#### getElementRefByRole
|
|
161
233
|
```ts
|
|
162
|
-
|
|
234
|
+
/**
|
|
235
|
+
* @description: will perform click action.
|
|
236
|
+
* @param {string} roleType - example: "alert"|"alertdialog"|"application"|"article"|"banner"|"blockquote"|"button"|"caption"|"cell"|"checkbox"|"code"|"columnheader"|"combobox"|"complementary"|"contentinfo"|"definition"|"deletion"|"dialog"|"directory"|"document"|"emphasis"|"feed"|"figure"|"form"|"generic"|"grid"|"gridcell"|"group"|"heading"|"img"|"insertion"|"link"|"list"|"listbox"|"listitem"|"log"|"main"|"marquee"|"math"|"meter"|"menu"|"menubar"|"menuitem"|"menuitemcheckbox"|"menuitemradio"|"navigation"|"none"|"note"|"option"|"paragraph"|"presentation"|"progressbar"|"radio"|"radiogroup"|"region"|"row"|"rowgroup"|"rowheader"|"scrollbar"|"search"|"searchbox"|"separator"|"slider"|"spinbutton"|"status"|"strong"|"subscript"|"superscript"|"switch"|"tab"|"table"|"tablist"|"tabpanel"|"term"|"textbox"|"time"|"timer"|"toolbar"|"tooltip"|"tree"|"treegrid"|"treeitem".
|
|
237
|
+
* @param {string} roleName - name of the element.
|
|
238
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
239
|
+
*/
|
|
240
|
+
async getElementRefByRole(roleType: string, roleName: string)
|
|
163
241
|
```
|
|
164
242
|
|
|
165
243
|
## Utilities
|
|
@@ -222,10 +300,16 @@ static async updateExcelData(filePath: string, sheetname: string)
|
|
|
222
300
|
static async deleteAllFilesUnderDir(filePath: string, sheetname: string)
|
|
223
301
|
```
|
|
224
302
|
### PDF Utilities
|
|
225
|
-
|
|
303
|
+
PDF reading related utilities
|
|
226
304
|
|
|
305
|
+
#### readPdfFile
|
|
227
306
|
```ts
|
|
228
|
-
|
|
307
|
+
/**
|
|
308
|
+
* @description: it will take pdf file path as input and will return array of strings(each each line in pdf is each item in result array).
|
|
309
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.pdf.
|
|
310
|
+
* @returns { Array<string>} - returns array os string, each string represents each line in pdf
|
|
311
|
+
*/
|
|
312
|
+
static async readPdfFile(filePath: string)
|
|
229
313
|
```
|
|
230
314
|
### Lighthouse Utilities
|
|
231
315
|
Lighthouse utilities are used to perform Lighthouse performace testing provided by Google.
|
|
@@ -263,24 +347,93 @@ static async createLightHouseReport(filePath: string, sheetname: string)
|
|
|
263
347
|
```
|
|
264
348
|
|
|
265
349
|
### Date Utilities
|
|
266
|
-
|
|
350
|
+
Date related utilities
|
|
267
351
|
|
|
268
352
|
```ts
|
|
269
353
|
// will be added in next versions.
|
|
270
354
|
```
|
|
271
|
-
|
|
272
|
-
### Database Utilities
|
|
273
|
-
TODO: need to add Database Utilities
|
|
355
|
+
#### getDateInCustomFormat
|
|
274
356
|
```ts
|
|
275
|
-
|
|
357
|
+
/**
|
|
358
|
+
* @description: returns date in required format.
|
|
359
|
+
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
360
|
+
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
361
|
+
* @returns {string} - returns date in given format.
|
|
362
|
+
*/
|
|
363
|
+
static getDateInCustomFormat(date:any, format: string)
|
|
364
|
+
```
|
|
365
|
+
#### getPastDateInCustomFormat
|
|
366
|
+
```ts
|
|
367
|
+
/**
|
|
368
|
+
* @description: subtracts no of days|months|years|hours|minutes|seconds from given date.
|
|
369
|
+
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
370
|
+
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
371
|
+
* @param {string} durationType - example days, months, years, hours, minutes, seconds.
|
|
372
|
+
* @param {string} duration - no of days|months|years|hours|minutes|seconds.
|
|
373
|
+
* @returns {string} - returns date in given format.
|
|
374
|
+
*/
|
|
375
|
+
static getPastDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1)
|
|
376
|
+
```
|
|
377
|
+
#### getFutureDateInCustomFormat
|
|
378
|
+
```ts
|
|
379
|
+
/**
|
|
380
|
+
* @description: adds no of days|months|years|hours|minutes|seconds from given date.
|
|
381
|
+
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
382
|
+
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
383
|
+
* @param {string} durationType - example days, months, years, hours, minutes, seconds.
|
|
384
|
+
* @param {string} duration - no of days|months|years|hours|minutes|seconds.
|
|
385
|
+
* @returns {string} - returns date in given format.
|
|
386
|
+
*/
|
|
387
|
+
static getFutureDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1)
|
|
388
|
+
```
|
|
389
|
+
#### getMinDateFromMultipleDates
|
|
390
|
+
```ts
|
|
391
|
+
/**
|
|
392
|
+
* @description: return min date from given dates.
|
|
393
|
+
* @param {Array<object<date,format>>} datesArrayObject - array of dates in form of object example: [{date:10/01/2023, format: "DD/MM/YYYY"}, {date:20/01/2023, format: "DD/MM/YYYY"}].
|
|
394
|
+
* @returns {string} - return min date amount given dates example: 10/01/2023.
|
|
395
|
+
*/
|
|
396
|
+
static getMinDateFromMultipleDates(datesArrayObject: any)
|
|
397
|
+
```
|
|
398
|
+
#### getMaxDateFromMultipleDates
|
|
399
|
+
```ts
|
|
400
|
+
/**
|
|
401
|
+
* @description: return max date from given dates.
|
|
402
|
+
* @param {Array<object<date,format>>} datesArrayObject - array of dates in form of object example: [{date:10/01/2023, format: "DD/MM/YYYY"}, {date:20/01/2023, format: "DD/MM/YYYY"}].
|
|
403
|
+
* @returns {string} - return max date amount given dates example: 20/01/2023.
|
|
404
|
+
*/
|
|
276
405
|
```
|
|
406
|
+
#### calculateRelativeDate
|
|
407
|
+
```ts
|
|
408
|
+
/**
|
|
409
|
+
* @description: returns no of days "lessthan|Greaterthan" from given date.
|
|
410
|
+
* @param {string} fromDate - date in the form of string, example: 01/01/2023.
|
|
411
|
+
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
412
|
+
* @returns {string} - returns string which is no of days "lessthan|Greaterthan" from given date.
|
|
413
|
+
*/
|
|
414
|
+
static calculateRelativeDate(fromDate: any, format: string)
|
|
415
|
+
```
|
|
416
|
+
### Database Utilities
|
|
417
|
+
Utilities related SQL server utilities
|
|
418
|
+
|
|
277
419
|
#### sqlDBConnection
|
|
278
420
|
```ts
|
|
279
|
-
|
|
421
|
+
/**
|
|
422
|
+
* @description: establish the connection with database.
|
|
423
|
+
* @param {string} configuration - example: {server: string, database: string, username:string, password: string, portNumber: number}.
|
|
424
|
+
* @returns {Connection} - returns connection object.
|
|
425
|
+
*/
|
|
426
|
+
static sqlDBConnection(fromDate: any, format: string)
|
|
280
427
|
```
|
|
281
428
|
#### executeSqlQuery
|
|
282
429
|
```ts
|
|
283
|
-
|
|
430
|
+
/**
|
|
431
|
+
* @description: establish the connection with database.
|
|
432
|
+
* @param {string} connectionObj - connection object which will come from sqlDBConnection()
|
|
433
|
+
* @param {string} queryString - query to execute
|
|
434
|
+
* @returns {Connection} - returns connection object.
|
|
435
|
+
*/
|
|
436
|
+
static async executeSqlQuery(connectionObj: any, queryString: any)
|
|
284
437
|
```
|
|
285
438
|
|
|
286
439
|
### Data Comparisions
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import moment, { DurationInputArg1, DurationInputArg2 } from 'moment';
|
|
2
|
+
export declare class Dateutility {
|
|
3
|
+
static getDateInCustomFormat(date: any, format: string): string;
|
|
4
|
+
static getFutureDateInCustomFormat(date: any, format: string, durationType: DurationInputArg2, duration: DurationInputArg1): string;
|
|
5
|
+
static getPastDateInCustomFormat(date: any, format: string, durationType: DurationInputArg2, duration: DurationInputArg1): string;
|
|
6
|
+
static getMinDateFromMultipleDates(datesArrayObject: any): moment.Moment;
|
|
7
|
+
static getMaxDateFromMultipleDates(date1: any, date2: any): moment.Moment;
|
|
8
|
+
static calculateRelativeDate(fromDate: any, format: string): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Dateutility = void 0;
|
|
7
|
+
const lodash_1 = require("lodash");
|
|
8
|
+
const moment_1 = __importDefault(require("moment"));
|
|
9
|
+
class Dateutility {
|
|
10
|
+
static getDateInCustomFormat(date, format) {
|
|
11
|
+
return (0, moment_1.default)(date).format(format);
|
|
12
|
+
}
|
|
13
|
+
static getFutureDateInCustomFormat(date, format, durationType, duration) {
|
|
14
|
+
return (0, moment_1.default)(date).add(duration, durationType).format(format);
|
|
15
|
+
}
|
|
16
|
+
static getPastDateInCustomFormat(date, format, durationType, duration) {
|
|
17
|
+
return (0, moment_1.default)(date).subtract(duration, durationType).format(format);
|
|
18
|
+
}
|
|
19
|
+
static getMinDateFromMultipleDates(datesArrayObject) {
|
|
20
|
+
return moment_1.default.min((0, lodash_1.map)(datesArrayObject, (obj) => (0, moment_1.default)(obj.date, obj.format)));
|
|
21
|
+
}
|
|
22
|
+
static getMaxDateFromMultipleDates(date1, date2) {
|
|
23
|
+
return moment_1.default.max(date1, date2);
|
|
24
|
+
}
|
|
25
|
+
static calculateRelativeDate(fromDate, format) {
|
|
26
|
+
return (0, moment_1.default)(fromDate, format).fromNow();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.Dateutility = Dateutility;
|
|
30
|
+
//# sourceMappingURL=date_utilitites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date_utilitites.js","sourceRoot":"","sources":["../../../src/utils/date_utilitites.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA6B;AAC7B,oDAAsE;AACtE,MAAa,WAAW;IAEpB,MAAM,CAAC,qBAAqB,CAAC,IAAQ,EAAE,MAAc;QACjD,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,IAAS,EAAE,MAAc,EAAE,YAA8B,EAAE,QAA2B;QACrH,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,CAAC,yBAAyB,CAAC,IAAS,EAAE,MAAc,EAAE,YAA8B,EAAE,QAA2B;QACnH,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,gBAAqB;QACpD,OAAO,gBAAM,CAAC,GAAG,CAAC,IAAA,YAAG,EAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,gBAAM,EAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,KAAU,EAAE,KAAU;QACrD,OAAO,gBAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,qBAAqB,CAAC,QAAa,EAAE,MAAc;QACtD,OAAO,IAAA,gBAAM,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9C,CAAC;CACJ;AAzBD,kCAyBC"}
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.PDFUtility = void 0;
|
|
13
|
+
const pdfreader_1 = require("pdfreader");
|
|
4
14
|
class PDFUtility {
|
|
15
|
+
static readPdfFile(filePath) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const items = [];
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
new pdfreader_1.PdfReader().parseFileItems(filePath, (err, item) => {
|
|
20
|
+
if (err)
|
|
21
|
+
reject(err);
|
|
22
|
+
else if (!item)
|
|
23
|
+
resolve(items);
|
|
24
|
+
else if (item.text)
|
|
25
|
+
items.push(item.text);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
5
30
|
}
|
|
6
31
|
exports.PDFUtility = PDFUtility;
|
|
7
32
|
//# sourceMappingURL=pdf_utility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf_utility.js","sourceRoot":"","sources":["../../../src/utils/pdf_utility.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pdf_utility.js","sourceRoot":"","sources":["../../../src/utils/pdf_utility.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsC;AACtC,MAAa,UAAU;IAEnB,MAAM,CAAO,WAAW,CAAC,QAAgB;;YACrC,MAAM,KAAK,GAAG,EAAE,CAAC;YACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACnC,IAAI,qBAAS,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;oBACnD,IAAI,GAAG;wBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;yBAChB,IAAI,CAAC,IAAI;wBAAE,OAAO,CAAC,KAAK,CAAC,CAAC;yBAC1B,IAAI,IAAI,CAAC,IAAI;wBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC9C,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AAZD,gCAYC"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
export declare class TestData {
|
|
2
|
-
static sqlDBConnection(): Promise<any>;
|
|
3
|
-
static executeSqlQuery(
|
|
4
|
-
connect: () => any;
|
|
5
|
-
on: (arg0: string, arg1: (err: any) => void) => void;
|
|
6
|
-
request: () => any;
|
|
7
|
-
close: () => void;
|
|
8
|
-
}, queryString: any): Promise<any>;
|
|
2
|
+
static sqlDBConnection(configuration: any): Promise<any>;
|
|
3
|
+
static executeSqlQuery(connectionObj: any, queryString: any): Promise<any>;
|
|
9
4
|
static generateRandomUniqeIDNumber(): Promise<string>;
|
|
10
5
|
static getUTCTimeCustom24hrs(localTime: string): Promise<string>;
|
|
11
6
|
static waitFortimeOut(waitTime: any): Promise<void>;
|
|
@@ -13,15 +13,17 @@ exports.TestData = void 0;
|
|
|
13
13
|
// const cosmosClient = require("@azure/cosmos").CosmosClient;
|
|
14
14
|
const sql = require('mssql');
|
|
15
15
|
class TestData {
|
|
16
|
-
static sqlDBConnection() {
|
|
16
|
+
static sqlDBConnection(configuration) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
var server = "zwetrvl2sqd001.database.windows.net";
|
|
19
|
-
var database =
|
|
18
|
+
// var server = "zwetrvl2sqd001.database.windows.net";
|
|
19
|
+
// var database ="zwetrvl2sqd001-DB002";
|
|
20
20
|
var config = {
|
|
21
|
-
server: server,
|
|
22
|
-
user: "zwetrvl2sqd001-admin",
|
|
23
|
-
password: "SADJ+zyhcj2l(SY9",
|
|
24
|
-
|
|
21
|
+
server: configuration.server,
|
|
22
|
+
// user: "zwetrvl2sqd001-admin",
|
|
23
|
+
// password: "SADJ+zyhcj2l(SY9",
|
|
24
|
+
user: configuration.user,
|
|
25
|
+
password: configuration.password,
|
|
26
|
+
database: configuration.database,
|
|
25
27
|
requestTimeout: 600000,
|
|
26
28
|
port: 1433,
|
|
27
29
|
options: {
|
|
@@ -36,16 +38,16 @@ class TestData {
|
|
|
36
38
|
return conn;
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
|
-
static executeSqlQuery(
|
|
41
|
+
static executeSqlQuery(connectionObj, queryString) {
|
|
40
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
var pool1Connect = yield
|
|
42
|
-
|
|
43
|
+
var pool1Connect = yield connectionObj.connect();
|
|
44
|
+
connectionObj.on('error', err => {
|
|
43
45
|
console.log(err);
|
|
44
46
|
return;
|
|
45
47
|
});
|
|
46
48
|
yield pool1Connect;
|
|
47
49
|
try {
|
|
48
|
-
const request =
|
|
50
|
+
const request = connectionObj.request(); // or: new sql.Request(pool1)
|
|
49
51
|
const result = yield request.query(queryString);
|
|
50
52
|
return result;
|
|
51
53
|
}
|
|
@@ -53,7 +55,7 @@ class TestData {
|
|
|
53
55
|
console.error('SQL error', err);
|
|
54
56
|
return null;
|
|
55
57
|
}
|
|
56
|
-
|
|
58
|
+
connectionObj.close();
|
|
57
59
|
});
|
|
58
60
|
}
|
|
59
61
|
static generateRandomUniqeIDNumber() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_data.js","sourceRoot":"","sources":["../../../src/utils/test_data.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8DAA8D;AAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7B,MAAa,QAAQ;IAEjB,MAAM,CAAO,eAAe
|
|
1
|
+
{"version":3,"file":"test_data.js","sourceRoot":"","sources":["../../../src/utils/test_data.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8DAA8D;AAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7B,MAAa,QAAQ;IAEjB,MAAM,CAAO,eAAe,CAAC,aAAkB;;YAC3C,sDAAsD;YACtD,wCAAwC;YACxC,IAAI,MAAM,GAAG;gBACT,MAAM,EAAE,aAAa,CAAC,MAAM;gBAC5B,gCAAgC;gBAChC,gCAAgC;gBAChC,IAAI,EAAE,aAAa,CAAC,IAAI;gBACxB,QAAQ,EAAE,aAAa,CAAC,QAAQ;gBAChC,QAAQ,EAAE,aAAa,CAAC,QAAQ;gBAChC,cAAc,EAAE,MAAM;gBACtB,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE;oBACL,OAAO,EAAE,IAAI,CAAC,sCAAsC;iBACvD;gBACD,cAAc,EAAE;oBACZ,2DAA2D;oBAC3D,IAAI,E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
"name": "vita-playwright",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"email": "noreply_testautomation@vialto.com",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
"is-ci": "2.0.0",
|
|
33
33
|
"lighthouse": "^9.6.8",
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
|
+
"moment": "^2.29.4",
|
|
35
36
|
"mssql": "9.0.0",
|
|
36
37
|
"open": "8.4.0",
|
|
37
|
-
"
|
|
38
|
+
"pdfreader": "^3.0.0",
|
|
38
39
|
"playwright": "^1.25.0",
|
|
39
40
|
"playwright-lighthouse": "^2.2.2",
|
|
40
41
|
"prettier": "2.7.1",
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
},
|
|
48
49
|
"author": "Vialto QE",
|
|
49
50
|
"license": "ISC",
|
|
50
|
-
"description": "common functions for
|
|
51
|
+
"description": "common functions for playwright and nodejs",
|
|
51
52
|
"repository": {
|
|
52
53
|
"type": "git",
|
|
53
54
|
"url": "https://github.com/Vialto/vialto-test-automation/"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { map } from 'lodash';
|
|
2
|
+
import moment, { DurationInputArg1, DurationInputArg2 } from 'moment';
|
|
3
|
+
export class Dateutility{
|
|
4
|
+
|
|
5
|
+
static getDateInCustomFormat(date:any, format: string){
|
|
6
|
+
return moment(date).format(format);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static getFutureDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1){
|
|
10
|
+
return moment(date).add(duration, durationType).format(format);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static getPastDateInCustomFormat(date: any, format: string, durationType:DurationInputArg2, duration: DurationInputArg1){
|
|
14
|
+
return moment(date).subtract(duration, durationType).format(format);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static getMinDateFromMultipleDates(datesArrayObject: any){
|
|
18
|
+
return moment.min(map(datesArrayObject, (obj) => moment(obj.date, obj.format)));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static getMaxDateFromMultipleDates(date1: any, date2: any){
|
|
22
|
+
return moment.max(date1, date2);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static calculateRelativeDate(fromDate: any, format: string){
|
|
26
|
+
return moment(fromDate, format).fromNow();
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/utils/pdf_utility.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import fs from 'fs';
|
|
1
|
+
import { PdfReader } from "pdfreader";
|
|
3
2
|
export class PDFUtility {
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
static async readPdfFile(filePath: string) {
|
|
5
|
+
const items = [];
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
new PdfReader().parseFileItems(filePath, (err, item) => {
|
|
8
|
+
if (err) reject(err);
|
|
9
|
+
else if (!item) resolve(items);
|
|
10
|
+
else if (item.text) items.push(item.text);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
}
|
|
13
14
|
}
|
package/src/utils/test_data.ts
CHANGED
|
@@ -3,14 +3,16 @@ const sql = require('mssql');
|
|
|
3
3
|
|
|
4
4
|
export class TestData {
|
|
5
5
|
|
|
6
|
-
static async sqlDBConnection() {
|
|
7
|
-
var server = "zwetrvl2sqd001.database.windows.net";
|
|
8
|
-
var database ="zwetrvl2sqd001-DB002";
|
|
6
|
+
static async sqlDBConnection(configuration: any) {
|
|
7
|
+
// var server = "zwetrvl2sqd001.database.windows.net";
|
|
8
|
+
// var database ="zwetrvl2sqd001-DB002";
|
|
9
9
|
var config = {
|
|
10
|
-
server: server,
|
|
11
|
-
user: "zwetrvl2sqd001-admin",
|
|
12
|
-
password: "SADJ+zyhcj2l(SY9",
|
|
13
|
-
|
|
10
|
+
server: configuration.server,
|
|
11
|
+
// user: "zwetrvl2sqd001-admin",
|
|
12
|
+
// password: "SADJ+zyhcj2l(SY9",
|
|
13
|
+
user: configuration.user,
|
|
14
|
+
password: configuration.password,
|
|
15
|
+
database: configuration.database,
|
|
14
16
|
requestTimeout: 600000,
|
|
15
17
|
port: 1433,
|
|
16
18
|
options: {
|
|
@@ -26,22 +28,22 @@ export class TestData {
|
|
|
26
28
|
return conn;
|
|
27
29
|
|
|
28
30
|
}
|
|
29
|
-
static async executeSqlQuery(
|
|
30
|
-
var pool1Connect = await
|
|
31
|
-
|
|
31
|
+
static async executeSqlQuery(connectionObj: any, queryString: any) {
|
|
32
|
+
var pool1Connect = await connectionObj.connect();
|
|
33
|
+
connectionObj.on('error', err => {
|
|
32
34
|
console.log(err);
|
|
33
35
|
return;
|
|
34
36
|
})
|
|
35
37
|
await pool1Connect;
|
|
36
38
|
try {
|
|
37
|
-
const request =
|
|
39
|
+
const request = connectionObj.request(); // or: new sql.Request(pool1)
|
|
38
40
|
const result = await request.query(queryString)
|
|
39
41
|
return result;
|
|
40
42
|
} catch (err) {
|
|
41
43
|
console.error('SQL error', err);
|
|
42
44
|
return null;
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
connectionObj.close();
|
|
45
47
|
|
|
46
48
|
}
|
|
47
49
|
|