transit-core-taf 1.0.3 → 1.0.4

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.
Files changed (54) hide show
  1. package/README.md +286 -0
  2. package/package.json +4 -7
  3. package/dist/transit-core-taf/base/basepageactions.d.ts +0 -178
  4. package/dist/transit-core-taf/base/basepageactions.js +0 -288
  5. package/dist/transit-core-taf/base/basepagevalidations.d.ts +0 -296
  6. package/dist/transit-core-taf/base/basepagevalidations.js +0 -459
  7. package/dist/transit-core-taf/base/basepagewaits.d.ts +0 -54
  8. package/dist/transit-core-taf/base/basepagewaits.js +0 -169
  9. package/dist/transit-core-taf/base/commonpageactions.d.ts +0 -40
  10. package/dist/transit-core-taf/base/commonpageactions.js +0 -118
  11. package/dist/transit-core-taf/base/commonpagevalidations.d.ts +0 -10
  12. package/dist/transit-core-taf/base/commonpagevalidations.js +0 -21
  13. package/dist/transit-core-taf/base/commonpagewaits.d.ts +0 -28
  14. package/dist/transit-core-taf/base/commonpagewaits.js +0 -57
  15. package/dist/transit-core-taf/base/logger.d.ts +0 -10
  16. package/dist/transit-core-taf/base/logger.js +0 -42
  17. package/dist/transit-core-taf/baseapi/apiutils.d.ts +0 -9
  18. package/dist/transit-core-taf/baseapi/apiutils.js +0 -23
  19. package/dist/transit-core-taf/baseapi/baseapihelpers.d.ts +0 -10
  20. package/dist/transit-core-taf/baseapi/baseapihelpers.js +0 -45
  21. package/dist/transit-core-taf/constants/apiconstants.d.ts +0 -29
  22. package/dist/transit-core-taf/constants/apiconstants.js +0 -38
  23. package/dist/transit-core-taf/constants/test-tags.d.ts +0 -14
  24. package/dist/transit-core-taf/constants/test-tags.js +0 -17
  25. package/dist/transit-core-taf/fixtures.d.ts +0 -23
  26. package/dist/transit-core-taf/fixtures.js +0 -81
  27. package/dist/transit-core-taf/global-setup.d.ts +0 -2
  28. package/dist/transit-core-taf/global-setup.js +0 -103
  29. package/dist/transit-core-taf/index.d.ts +0 -23
  30. package/dist/transit-core-taf/index.js +0 -39
  31. package/dist/transit-core-taf/steps/basepageactions.steps.d.ts +0 -1
  32. package/dist/transit-core-taf/steps/basepageactions.steps.js +0 -78
  33. package/dist/transit-core-taf/steps/basepagevalidations.steps.d.ts +0 -1
  34. package/dist/transit-core-taf/steps/basepagevalidations.steps.js +0 -59
  35. package/dist/transit-core-taf/steps/basepagewaits.steps.d.ts +0 -1
  36. package/dist/transit-core-taf/steps/basepagewaits.steps.js +0 -29
  37. package/dist/transit-core-taf/steps/commonpageactions.steps.d.ts +0 -1
  38. package/dist/transit-core-taf/steps/commonpageactions.steps.js +0 -18
  39. package/dist/transit-core-taf/steps/commonpagevalidations.steps.d.ts +0 -1
  40. package/dist/transit-core-taf/steps/commonpagevalidations.steps.js +0 -16
  41. package/dist/transit-core-taf/steps/commonpagewaits.steps.d.ts +0 -1
  42. package/dist/transit-core-taf/steps/commonpagewaits.steps.js +0 -24
  43. package/dist/transit-core-taf/steps/hooks.d.ts +0 -1
  44. package/dist/transit-core-taf/steps/hooks.js +0 -10
  45. package/dist/transit-core-taf/steps/world.d.ts +0 -14
  46. package/dist/transit-core-taf/steps/world.js +0 -43
  47. package/dist/transit-core-taf/utils/Utils.d.ts +0 -114
  48. package/dist/transit-core-taf/utils/Utils.js +0 -219
  49. package/dist/transit-core-taf/utils/envutils.d.ts +0 -2
  50. package/dist/transit-core-taf/utils/envutils.js +0 -55
  51. package/dist/transit-core-taf/utils/excelUtils.d.ts +0 -1
  52. package/dist/transit-core-taf/utils/excelUtils.js +0 -51
  53. package/dist/transit-core-taf/utils/networkutils.d.ts +0 -24
  54. package/dist/transit-core-taf/utils/networkutils.js +0 -53
@@ -1,219 +0,0 @@
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.generateRandomString = generateRandomString;
7
- exports.generateFirstName = generateFirstName;
8
- exports.generateLastName = generateLastName;
9
- exports.generateHouseholdName = generateHouseholdName;
10
- exports.generateUSAddress = generateUSAddress;
11
- exports.generatePhoneNumber = generatePhoneNumber;
12
- exports.generateYopmailEmail = generateYopmailEmail;
13
- exports.getTimestamp = getTimestamp;
14
- exports.getTimeDifference = getTimeDifference;
15
- exports.readAccountApiResponse = readAccountApiResponse;
16
- exports.getRandomNumber = getRandomNumber;
17
- exports.generateRandomFutureDate = generateRandomFutureDate;
18
- exports.getDate = getDate;
19
- exports.getParsedDate = getParsedDate;
20
- const faker_1 = require("@faker-js/faker");
21
- const fs_1 = __importDefault(require("fs"));
22
- const path_1 = __importDefault(require("path"));
23
- /**
24
- * Generates a random alphanumeric string of specified length.
25
- * @param {number} length - The number of characters in the generated string.
26
- * @returns {string} - Randomly generated string.
27
- */
28
- function generateRandomString(length) {
29
- // Define the characters to choose from: uppercase, lowercase, and digits
30
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
31
- let result = ''; // Initialize the result string
32
- const charsLength = chars.length; // Total number of characters available
33
- // Loop 'length' times to build the result string
34
- for (let i = 0; i < length; i++) {
35
- // Pick a random index and append the corresponding character to the result
36
- result += chars.charAt(Math.floor(Math.random() * charsLength));
37
- }
38
- return result; // Return the generated string
39
- }
40
- /**
41
- * Generates a random first name.
42
- * @returns A random first name.
43
- */
44
- function generateFirstName() {
45
- const firstName = faker_1.faker.person.firstName();
46
- return firstName;
47
- }
48
- /**
49
- * Generates a random last name.
50
- * @returns A random last name.
51
- */
52
- function generateLastName() {
53
- const lastName = faker_1.faker.person.lastName();
54
- return lastName;
55
- }
56
- /**
57
- * Generates a random household name.
58
- * @returns A random household name, typically in the format "[LastName] Household".
59
- */
60
- function generateHouseholdName() {
61
- const householdName = `${faker_1.faker.person.lastName()} Household`;
62
- console.log(`Generated household name: ${householdName}`);
63
- return householdName;
64
- }
65
- /**
66
- * Generates a dynamic US address.
67
- * @returns An object containing a full US address.
68
- */
69
- function generateUSAddress() {
70
- const state = faker_1.faker.location.state({ abbreviated: true });
71
- const city = faker_1.faker.location.city();
72
- const zipCode = faker_1.faker.location.zipCode();
73
- const streetAddress = faker_1.faker.location.streetAddress();
74
- const secondaryAddress = faker_1.faker.location.secondaryAddress();
75
- console.log(`Generated US address: ${streetAddress}, ${secondaryAddress}, ${city}, ${state} ${zipCode}`);
76
- return {
77
- streetAddressLine1: streetAddress,
78
- streetAddressLine2: secondaryAddress,
79
- city,
80
- state,
81
- zipCode,
82
- country: 'United States',
83
- };
84
- }
85
- /**
86
- * Generates a random phone number for a given country.
87
- * @param country - The country for which to generate the phone number.
88
- * @returns A random phone number.
89
- */
90
- function generatePhoneNumber(country) {
91
- // Note: Faker's phone number generation is not strictly country-specific for all locales.
92
- // It generates a number in a format common to the locale.
93
- return faker_1.faker.phone.number();
94
- }
95
- /**
96
- * Generates a random email address with the yopmail.com domain.
97
- * @returns A random email address.
98
- */
99
- function generateYopmailEmail() {
100
- return `${faker_1.faker.internet.userName()}@yopmail.com`;
101
- }
102
- /**
103
- * Returns the current timestamp.
104
- * @returns The current timestamp in milliseconds.
105
- */
106
- function getTimestamp() {
107
- return Date.now();
108
- }
109
- /**
110
- * Calculates the time difference between two timestamps and returns a formatted string.
111
- * @param startTime - The starting timestamp in milliseconds.
112
- * @param endTime - The ending timestamp in milliseconds.
113
- * @returns A formatted string like "5 sec 34 ms".
114
- */
115
- function getTimeDifference(startTime, endTime) {
116
- const diff = endTime - startTime;
117
- const seconds = Math.floor(diff / 1000);
118
- const milliseconds = diff % 1000;
119
- return `${seconds} sec ${milliseconds}ms`;
120
- }
121
- function readAccountApiResponse(accountId) {
122
- try {
123
- const filePath = path_1.default.join(__dirname, `../resources/apiresponses/accounts/${process.env.ENV}/${accountId}.json`);
124
- const fileContent = fs_1.default.readFileSync(filePath, 'utf-8');
125
- return JSON.parse(fileContent);
126
- }
127
- catch (error) {
128
- console.error(`Error loading account API response for accountId: ${accountId}`, error);
129
- throw new Error(`Could not find or load API response for accountId: ${accountId}`);
130
- }
131
- }
132
- /**
133
- * Generates a random integer between 0 (inclusive) and the given length (exclusive).
134
- * @param {number} length - The upper bound (non-inclusive) for the random number.
135
- * If less than or equal to 0, the function returns 0.
136
- * @returns {number} A random integer between 0 and length - 1, or 0 if length <= 0.
137
- */
138
- function getRandomNumber(length) {
139
- if (length <= 0)
140
- return 0;
141
- return Math.floor(Math.random() * length);
142
- }
143
- /**
144
- * Generates a random future date.
145
- * @returns An object containing the day, month, and year of a random future date.
146
- */
147
- function generateRandomFutureDate() {
148
- const today = new Date();
149
- const futureDate = new Date(today);
150
- futureDate.setDate(today.getDate() + Math.floor(Math.random() * 365) + 1);
151
- return {
152
- day: futureDate.getDate(),
153
- month: futureDate.getMonth() + 1,
154
- year: futureDate.getFullYear(),
155
- };
156
- }
157
- /**
158
- * @description
159
- * This function provides flexible date formatting similar to moment.js.
160
- * It supports both padded (e.g., 03) and unpadded (e.g., 3) date/time tokens.
161
- * Ideal for logs, filenames, UI display, or readable timestamps.
162
- *
163
- * 🧩 Supported format tokens:
164
- * ┌────────┬────────────────────────────┐
165
- * │ Token │ Description │
166
- * ├────────┼────────────────────────────┤
167
- * │ YYYY │ 4-digit year (e.g. 2025) │
168
- * │ M │ Month (1–12) │
169
- * │ MM │ Month (01–12) │
170
- * │ D │ Day of month (1–31) │
171
- * │ DD │ Day of month (01–31) │
172
- * │ h │ Hour (0–23) │
173
- * │ hh │ Hour (00–23) │
174
- * │ m │ Minute (0–59) │
175
- * │ mm │ Minute (00–59) │
176
- * │ s │ Second (0–59) │
177
- * │ ss │ Second (00–59) │
178
- * └────────┴────────────────────────────┘
179
- *
180
- * @examples
181
- * getDate("YYYY-MM-DD hh:mm:ss") → "2025-11-03 04:05:09"
182
- * getDate("YYYY-M-D h:m:s") → "2025-11-3 4:5:9"
183
- * getDate("D/M/YYYY") → "3/11/2025"
184
- *
185
- * @param format - (Optional) The desired date format string. Defaults to "YYYY-MM-DD".
186
- * @returns A formatted date/time string.
187
- */
188
- function getDate(format = "YYYY-MM-DD") {
189
- const date = new Date();
190
- const parts = {
191
- YYYY: date.getFullYear().toString(),
192
- M: (date.getMonth() + 1).toString(),
193
- MM: String(date.getMonth() + 1).padStart(2, "0"),
194
- D: date.getDate().toString(),
195
- DD: String(date.getDate()).padStart(2, "0"),
196
- h: date.getHours().toString(),
197
- hh: String(date.getHours()).padStart(2, "0"),
198
- m: date.getMinutes().toString(),
199
- mm: String(date.getMinutes()).padStart(2, "0"),
200
- s: date.getSeconds().toString(),
201
- ss: String(date.getSeconds()).padStart(2, "0"),
202
- };
203
- return format.replace(/(YYYY|MM|M|DD|D|hh|h|mm|m|ss|s)/g, (token) => parts[token]);
204
- }
205
- /**
206
- * Normalizes a date input to a timestamp (ms since epoch).
207
- * - If input is a string, it will be parsed with Date.parse().
208
- * - If input is a number (timestamp), it will be used directly.
209
- *
210
- * @param input Date as a timestamp (ms) or string
211
- * @returns timestamp in milliseconds
212
- */
213
- function getParsedDate(input) {
214
- if (input == null)
215
- return NaN;
216
- if (typeof input === "number")
217
- return input;
218
- return Date.parse(input);
219
- }
@@ -1,2 +0,0 @@
1
- export declare function getEnvFilePath(): string;
2
- export declare function updateEnvFile(key: string, value: string): void;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getEnvFilePath = getEnvFilePath;
37
- exports.updateEnvFile = updateEnvFile;
38
- const fs = __importStar(require("fs"));
39
- const path = __importStar(require("path"));
40
- function getEnvFilePath() {
41
- const env = process.env.ENV || 'stage';
42
- return path.resolve(process.cwd(), `.env.${env}`);
43
- }
44
- function updateEnvFile(key, value) {
45
- const envFilePath = getEnvFilePath();
46
- let content = fs.readFileSync(envFilePath, { encoding: 'utf8' });
47
- const keyPattern = new RegExp(`^${key}=.*$`, 'm');
48
- if (keyPattern.test(content)) {
49
- content = content.replace(keyPattern, `${key}=${value}`);
50
- }
51
- else {
52
- content += `\n${key}=${value}`;
53
- }
54
- fs.writeFileSync(envFilePath, content);
55
- }
@@ -1 +0,0 @@
1
- export declare function getExcelDataSync(filePath: string, sheetName: string): unknown[];
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getExcelDataSync = getExcelDataSync;
37
- const XLSX = __importStar(require("xlsx"));
38
- function getExcelDataSync(filePath, sheetName) {
39
- try {
40
- const workbook = XLSX.readFile(filePath);
41
- const worksheet = workbook.Sheets[sheetName];
42
- if (!worksheet) {
43
- throw new Error(`Sheet "${sheetName}" not found in the Excel file.`);
44
- }
45
- return XLSX.utils.sheet_to_json(worksheet);
46
- }
47
- catch (error) {
48
- console.error(`Error reading Excel file at ${filePath}:`, error);
49
- return [];
50
- }
51
- }
@@ -1,24 +0,0 @@
1
- import { Page } from "playwright";
2
- import { Logger } from "../base/logger";
3
- export declare class NetworkUtils {
4
- private page;
5
- private logger;
6
- constructor(page: Page, logger: Logger);
7
- /** Intercept the API call and abort it to simulate a failure */
8
- abortRoute(urlPattern: string): Promise<void>;
9
- /**
10
- * Waits for a specific network response with a given status code.
11
- * @param urlPattern The URL pattern to match.
12
- * @param expectedStatusCode The expected HTTP status code.
13
- * @param timeout The timeout in milliseconds.
14
- * @returns A promise that resolves with the response object if successful, otherwise null.
15
- */
16
- waitForApiResponse(urlPattern: string, expectedStatusCode: number, timeout?: number): Promise<import("playwright-core").Response | null>;
17
- /**
18
- * Waits for a specific network response and returns its body.
19
- * @param urlPattern The URL pattern to match.
20
- * @param timeout The timeout in milliseconds.
21
- * @returns A promise that resolves with the response body if successful, otherwise null.
22
- */
23
- getResponseBody(urlPattern: string, timeout?: number): Promise<any>;
24
- }
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NetworkUtils = void 0;
4
- class NetworkUtils {
5
- page;
6
- logger;
7
- constructor(page, logger) {
8
- this.page = page;
9
- this.logger = logger;
10
- }
11
- /** Intercept the API call and abort it to simulate a failure */
12
- async abortRoute(urlPattern) {
13
- await this.page.route(urlPattern, async (route) => {
14
- try {
15
- await route.abort();
16
- }
17
- catch (error) {
18
- this.logger.error(`Abort error message:${error}`);
19
- }
20
- });
21
- }
22
- /**
23
- * Waits for a specific network response with a given status code.
24
- * @param urlPattern The URL pattern to match.
25
- * @param expectedStatusCode The expected HTTP status code.
26
- * @param timeout The timeout in milliseconds.
27
- * @returns A promise that resolves with the response object if successful, otherwise null.
28
- */
29
- waitForApiResponse(urlPattern, expectedStatusCode, timeout = 60000) {
30
- return this.page.waitForResponse((response) => response.request().url().includes(urlPattern) &&
31
- response.status() === expectedStatusCode, { timeout }).catch(error => {
32
- this.logger.error(`Failed to receive response from ${urlPattern} with status ${expectedStatusCode} within ${timeout}ms. Error: ${error}`);
33
- return null;
34
- });
35
- }
36
- /**
37
- * Waits for a specific network response and returns its body.
38
- * @param urlPattern The URL pattern to match.
39
- * @param timeout The timeout in milliseconds.
40
- * @returns A promise that resolves with the response body if successful, otherwise null.
41
- */
42
- async getResponseBody(urlPattern, timeout = 60000) {
43
- try {
44
- const response = await this.page.waitForResponse((response) => response.request().url().includes(urlPattern), { timeout });
45
- return await response.json();
46
- }
47
- catch (error) {
48
- this.logger.error(`Failed to receive response from ${urlPattern} within ${timeout}ms. Error: ${error}`);
49
- return null;
50
- }
51
- }
52
- }
53
- exports.NetworkUtils = NetworkUtils;