transit-core-taf 1.0.2

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 +0 -0
  2. package/dist/transit-core-taf/base/basepageactions.d.ts +178 -0
  3. package/dist/transit-core-taf/base/basepageactions.js +288 -0
  4. package/dist/transit-core-taf/base/basepagevalidations.d.ts +296 -0
  5. package/dist/transit-core-taf/base/basepagevalidations.js +459 -0
  6. package/dist/transit-core-taf/base/basepagewaits.d.ts +54 -0
  7. package/dist/transit-core-taf/base/basepagewaits.js +169 -0
  8. package/dist/transit-core-taf/base/commonpageactions.d.ts +40 -0
  9. package/dist/transit-core-taf/base/commonpageactions.js +118 -0
  10. package/dist/transit-core-taf/base/commonpagevalidations.d.ts +10 -0
  11. package/dist/transit-core-taf/base/commonpagevalidations.js +21 -0
  12. package/dist/transit-core-taf/base/commonpagewaits.d.ts +28 -0
  13. package/dist/transit-core-taf/base/commonpagewaits.js +57 -0
  14. package/dist/transit-core-taf/base/logger.d.ts +10 -0
  15. package/dist/transit-core-taf/base/logger.js +42 -0
  16. package/dist/transit-core-taf/baseapi/apiutils.d.ts +9 -0
  17. package/dist/transit-core-taf/baseapi/apiutils.js +23 -0
  18. package/dist/transit-core-taf/baseapi/baseapihelpers.d.ts +10 -0
  19. package/dist/transit-core-taf/baseapi/baseapihelpers.js +45 -0
  20. package/dist/transit-core-taf/constants/apiconstants.d.ts +29 -0
  21. package/dist/transit-core-taf/constants/apiconstants.js +38 -0
  22. package/dist/transit-core-taf/constants/test-tags.d.ts +14 -0
  23. package/dist/transit-core-taf/constants/test-tags.js +17 -0
  24. package/dist/transit-core-taf/fixtures.d.ts +23 -0
  25. package/dist/transit-core-taf/fixtures.js +81 -0
  26. package/dist/transit-core-taf/global-setup.d.ts +2 -0
  27. package/dist/transit-core-taf/global-setup.js +103 -0
  28. package/dist/transit-core-taf/index.d.ts +23 -0
  29. package/dist/transit-core-taf/index.js +39 -0
  30. package/dist/transit-core-taf/steps/basepageactions.steps.d.ts +1 -0
  31. package/dist/transit-core-taf/steps/basepageactions.steps.js +92 -0
  32. package/dist/transit-core-taf/steps/basepagevalidations.steps.d.ts +1 -0
  33. package/dist/transit-core-taf/steps/basepagevalidations.steps.js +59 -0
  34. package/dist/transit-core-taf/steps/basepagewaits.steps.d.ts +1 -0
  35. package/dist/transit-core-taf/steps/basepagewaits.steps.js +29 -0
  36. package/dist/transit-core-taf/steps/commonpageactions.steps.d.ts +1 -0
  37. package/dist/transit-core-taf/steps/commonpageactions.steps.js +18 -0
  38. package/dist/transit-core-taf/steps/commonpagevalidations.steps.d.ts +1 -0
  39. package/dist/transit-core-taf/steps/commonpagevalidations.steps.js +16 -0
  40. package/dist/transit-core-taf/steps/commonpagewaits.steps.d.ts +1 -0
  41. package/dist/transit-core-taf/steps/commonpagewaits.steps.js +24 -0
  42. package/dist/transit-core-taf/steps/hooks.d.ts +1 -0
  43. package/dist/transit-core-taf/steps/hooks.js +10 -0
  44. package/dist/transit-core-taf/steps/world.d.ts +12 -0
  45. package/dist/transit-core-taf/steps/world.js +37 -0
  46. package/dist/transit-core-taf/utils/Utils.d.ts +114 -0
  47. package/dist/transit-core-taf/utils/Utils.js +219 -0
  48. package/dist/transit-core-taf/utils/envutils.d.ts +2 -0
  49. package/dist/transit-core-taf/utils/envutils.js +55 -0
  50. package/dist/transit-core-taf/utils/excelUtils.d.ts +1 -0
  51. package/dist/transit-core-taf/utils/excelUtils.js +51 -0
  52. package/dist/transit-core-taf/utils/networkutils.d.ts +24 -0
  53. package/dist/transit-core-taf/utils/networkutils.js +53 -0
  54. package/package.json +32 -0
@@ -0,0 +1,296 @@
1
+ import { Locator, Page } from '@playwright/test';
2
+ import { Logger } from './logger';
3
+ export declare class BasePageValidations {
4
+ private page;
5
+ private logger;
6
+ constructor(page: Page, logger: Logger);
7
+ /**
8
+ * Validates that a given element is visible.
9
+ * @param element The locator of the element to validate.
10
+ */
11
+ validateElementToBeVisible(element: Locator): Promise<void>;
12
+ /**
13
+ * Validates that a given element is not visible.
14
+ * This method asserts that the element exists in the DOM but is not currently visible.
15
+ * Visibility is determined based on factors such as CSS properties like `display: none`,
16
+ * `visibility: hidden`, or being off-screen.
17
+ * @param element The locator of the element to validate.
18
+ * @throws Will throw an assertion error if the element is visible.
19
+ */
20
+ validateElementNotToBeVisible(element: Locator): Promise<void>;
21
+ /**
22
+ * Validates that the number of elements matching the locator is equal to the expected count.
23
+ * @param locator - The Playwright Locator pointing to the elements.
24
+ * @param expectedCount - The expected number of elements.
25
+ * Example:
26
+ * await validateElementCountToBe(page.locator('.item'), 3);
27
+ * */
28
+ validateElementCountToBe(locator: Locator, expectedCount: number): Promise<void>;
29
+ /**
30
+ * Validates that two elements are not overlapping.
31
+ * @param element1 The first locator.
32
+ * @param element2 The second locator.
33
+ */
34
+ validateElementsDoNotOverlap(element1: Locator, element2: Locator): Promise<void>;
35
+ /**
36
+ * Waits for an element with the given ID to appear in the DOM within the specified timeout,
37
+ * and then validates that the element is visible.
38
+ *
39
+ * @param id - The ID of the element to validate visibility for.
40
+ * @param timeout - Maximum time to wait for the element to appear (in milliseconds). Defaults to 10 seconds.
41
+ */
42
+ validateElementToBeVisibleById(id: string, timeout?: number): Promise<void>;
43
+ /** Validates that a given element is visible and contains the expected text.
44
+ * @param element - The Playwright Locator for the element to validate.
45
+ * @param expectedText - The exact text expected to be present in the element.
46
+ * @param timeout - Optional timeout (in ms) to wait for visibility and text match. Default is 60 seconds.
47
+ * await validations.validateElementToHaveText(page.locator('.success-message'), 'Upload Complete');
48
+ */
49
+ validateElementToHaveText(element: Locator | string, expectedText: string, timeout?: number): Promise<void>;
50
+ /**
51
+ * Validates that a given element has the expected text.
52
+ * @param element The locator of the element to validate.
53
+ * @param expectedText The expected text of the element.
54
+ */
55
+ validateText(actualText?: string, expectedText?: string | number): Promise<void>;
56
+ /**
57
+ * Validates that a given element has the expected text.
58
+ * @param element The locator of the element to validate.
59
+ * @param expectedText The expected text of the element.
60
+ */
61
+ validateTextNotToBe(actualText?: string, expectedText?: string | number): Promise<void>;
62
+ /**
63
+ * Validates that a given element is enabled.
64
+ * @param element The locator of the element to validate.
65
+ */
66
+ validateElementToBeEnabled(element: Locator): Promise<void>;
67
+ /**
68
+ * Validates that a given element is hidden.
69
+ * @param element The locator of the element to validate.
70
+ */
71
+ validateElementToBeHidden(element: Locator): Promise<void>;
72
+ /**
73
+ * Validates that multiple elements are hidden.
74
+ * @param elements Array of Playwright locators to validate.
75
+ */
76
+ validateElementsToBeHidden(elements: Locator[]): Promise<void>;
77
+ /**
78
+ * Validates that a given element (Locator or string ID) has a specific attribute with a specific value.
79
+ * @param element - The element to validate (Playwright Locator or string ID).
80
+ * @param attr - The attribute to check.
81
+ * @param value - The expected value of the attribute.
82
+ * @param timeout - Optional timeout in milliseconds (default: 10s).
83
+ */
84
+ validateElementToHaveAttribute(element: Locator | string, attr: string, value: string, timeout?: number): Promise<void>;
85
+ /**
86
+ * Validates that a given element contains the expected text (partial or regex).
87
+ * @param element The locator or string ID of the element.
88
+ * @param expectedText The expected partial text or RegExp to be found in the element.
89
+ * @param timeout Maximum time to wait for the element to become visible and contain the text (default: 60s).
90
+ */
91
+ validateElementToContainText(element: Locator | string, expectedText: string | RegExp, timeout?: number): Promise<void>;
92
+ /**
93
+ * Checks if an element with the given ID is visible on the page.
94
+ * This method runs inside the browser context using `page.evaluate` to:
95
+ * - Find the DOM element using `getElementById`.
96
+ * - Return false if the element doesn't exist.
97
+ * - Otherwise, check if the element's `display` style is not set to `"none"`,
98
+ * which indicates whether the element is visible or hidden via CSS.
99
+ * @param elementId - The ID of the element to check visibility for.
100
+ * @returns A promise that resolves to `true` if the element is visible,
101
+ * or `false` if it's hidden or not found.
102
+ */
103
+ isElementVisible(elementId: string): Promise<boolean>;
104
+ /**
105
+ * Checks if an element with the given ID is visible on the page using Playwright commands.
106
+ * It asserts that the element is visible within the given timeout.
107
+ *
108
+ * @param elementId - The ID of the element to check.
109
+ * @param timeout - The maximum time to wait for the element to become visible (in ms). Default is 5000 ms.
110
+ */
111
+ validateElementVisibleById(elementId: string, timeout?: number): Promise<void>;
112
+ /**
113
+ * Validates that a value is null.
114
+ * @param actual The actual value to check.
115
+ */
116
+ validateValueToBeNull(actual: any): Promise<void>;
117
+ /**
118
+ * Validates that a value is not null.
119
+ * @param actual The actual value to check.
120
+ */
121
+ validateValueNotToBeNull(actual: any): Promise<void>;
122
+ /**
123
+ * Validates that a value is greater than the expected value.
124
+ * @param actual The actual number.
125
+ * @param expected The number to compare against.
126
+ */
127
+ validateValueToBeGreaterThan(actual: number, expected: number): Promise<void>;
128
+ /**
129
+ * Validates that a value is less than or equal to the expected value.
130
+ * @param actual The actual number.
131
+ * @param expected The number to compare against.
132
+ */
133
+ validateValueToBeLessThanOrEqual(actual: number, expected: number): Promise<void>;
134
+ /**
135
+ * Validates that the actual value is equal to the expected value.
136
+ * @param actual - The actual value.
137
+ * @param expected - The expected value to compare.
138
+ * @param message - Optional custom message for assertion failure.
139
+ */
140
+ validateValueToEqual(actual: any, expected: any, message?: string): Promise<void>;
141
+ /**
142
+ * Validates that the actual value is NOT equal to the expected value.
143
+ * @param actual - The actual value.
144
+ * @param expected - The value that should not match.
145
+ * @param message - Optional custom message for assertion failure.
146
+ */
147
+ validateValueNotToEqual(actual: any, expected: any, message?: string): Promise<void>;
148
+ /**
149
+ * Validates that the actual number is less than the expected number.
150
+ * @param actual - The actual number.
151
+ * @param expected - The number to compare against.
152
+ */
153
+ validateValueToBeLessThan(actual: number, expected: number): Promise<void>;
154
+ /**
155
+ * Validates that the actual value is truthy.
156
+ * @param actual - The value to validate.
157
+ */
158
+ validateValueToBeTruthy(actual: any): Promise<void>;
159
+ /**
160
+ * Validates that the actual value is falsy.
161
+ * @param actual - The value to validate.
162
+ */
163
+ validateValueToBeFalsy(actual: any): Promise<void>;
164
+ /**
165
+ * Validates that the actual array or string contains the expected item or substring.
166
+ * @param actual - The array or string.
167
+ * @param expected - The item or substring to check for.
168
+ */
169
+ validateValueToContain(actual: any[] | string, expected: any): Promise<void>;
170
+ /**
171
+ * Validates that the actual string matches the given regular expression or substring.
172
+ * @param actual - The string to validate.
173
+ * @param expected - The regular expression or substring.
174
+ */
175
+ validateValueToMatch(actual: string, expected: string | RegExp): Promise<void>;
176
+ /**
177
+ * Compares two arrays for equality (order-sensitive) using Playwright's expect.
178
+ * @param expected The expected array values.
179
+ * @param actual The actual array values.
180
+ * @param message Optional message for error context.
181
+ */
182
+ validateArrayTextValues(expected: any[], actual: any[], message?: string): Promise<void>;
183
+ /**
184
+ * Compares two objects containing arrays (order-sensitive) using Playwright's expect.
185
+ * Each key in the object is compared individually with soft assertions.
186
+ * @param expected The expected object with array values.
187
+ * @param actual The actual object with array values.
188
+ * @param message Optional message for error context.
189
+ */
190
+ validateObjectOfArrayTextValues(expected: {
191
+ [key: string]: string[];
192
+ }, actual: {
193
+ [key: string]: string[];
194
+ }, message?: string): Promise<void>;
195
+ /**
196
+ * Validates that the current page URL contains the expected string.
197
+ * Useful when the URL may include dynamic query parameters or fragments.
198
+ * @param expectedUrl - The expected substring to be present in the current URL.
199
+ */
200
+ validateUrlToMatch(endpoint: RegExp): Promise<void>;
201
+ /**
202
+ * Validates that the current page URL starts with the expected string.
203
+ * Useful when the URL has dynamic query parameters.
204
+ * @param expectedUrl - The expected base URL (without query params).
205
+ */
206
+ validateUrlToContain(expectedUrl: string): Promise<void>;
207
+ /**
208
+ * Validates that the element has the expected class name.
209
+ * @param locator - The element locator.
210
+ * @param expected - The class name to match (string or RegExp).
211
+ */
212
+ validateLocatorToHaveClass(locator: Locator, expected: string | RegExp): Promise<void>;
213
+ /** Validates all visible crop drag handles have correct accessibility attributes.
214
+ * Skips any handles that are not currently visible.
215
+ * @param page - Playwright Page instance
216
+ */
217
+ validateCropDragHandles(page: Page): Promise<void>;
218
+ /**
219
+ * Validates if a given value is true or false.
220
+ * @param actual - The actual boolean value or a function that returns a boolean.
221
+ * @param expected - Expected boolean value (true or false).
222
+ * @param message - Optional custom error message on failure.
223
+ */
224
+ validateToBeBoolean(actual: boolean | (() => Promise<boolean> | boolean), expected: boolean, message?: string): Promise<void>;
225
+ /**
226
+ * Validates that a given element has the specified class or matches the given class pattern.
227
+ * @param element The locator of the element to validate.
228
+ * @param expectedClass The expected class name or regex pattern.
229
+ */
230
+ validateElementToHaveClass(element: Locator | string, expected: string | RegExp): Promise<void>;
231
+ /**
232
+ * Validates that a given element has the expected CSS class.
233
+ * @param element The locator of the element to validate.
234
+ * @param expectedClass The class name expected to be present on the element.
235
+ */
236
+ validateElementToContainClass(element: Locator, expectedClass: string): Promise<void>;
237
+ /**
238
+ * Validates that an asynchronous condition passes within a given timeout.
239
+ * @param condition A function that returns a promise to be resolved.
240
+ * @param timeout The timeout for the condition to pass.
241
+ */
242
+ validateAsyncCondition(condition: () => Promise<void>, timeout: number): Promise<void>;
243
+ /**
244
+ * Validates that a given element has the expected CSS property and value.
245
+ * @param locator The locator of the element to validate.
246
+ * @param cssProperty The CSS property to check.
247
+ * @param expectedValue The expected value of the CSS property.
248
+ */
249
+ validateElementToHaveCSS(locator: Locator, cssProperty: string, expectedValue: string | RegExp): Promise<void>;
250
+ /**
251
+ * Validates that the actual value is equal to the expected value.
252
+ * @param actual - The actual value.
253
+ * @param expected - The expected value to compare.
254
+ */
255
+ validateValueToBe(actual: any, expected: any): Promise<void>;
256
+ /**
257
+ * Gets the value of a given attribute from a locator.
258
+ * @param locator - Playwright Locator for the element.
259
+ * @param attributeName - The attribute name to fetch (e.g., "aria-checked", "data-id").
260
+ * @returns Promise resolving to the attribute value or null if not present.
261
+ */
262
+ getAttributeValueByLocator(locator: Locator, attributeName: string): Promise<string | null>;
263
+ /**
264
+ * Validates that the given element does NOT have the specified attribute value.
265
+ * If the attribute is missing, the check passes.
266
+ * If the attribute exists, its value must not equal the provided one.
267
+ * @param element Locator of the element to validate
268
+ * @param attr Attribute name to check (e.g., "class", "disabled")
269
+ * @param value Attribute value that should NOT be present
270
+ */
271
+ validateElementNotToHaveAttributeValue(element: Locator, attr: string, value: string): Promise<void>;
272
+ /**
273
+ * Validates that all layered file names exist in the photo tray file names.
274
+ * @param photoTrayFileNames - Array of file names currently available in the photo tray.
275
+ * @param layeredFileNames - Array of file names that are layered/applied on the canvas.
276
+ * The function ensures integrity between the canvas and the photo tray,
277
+ * by checking that every layered file originates from the photo tray.
278
+ */
279
+ validateValuesToContain(photoTrayFileNames: string[], layeredFileNames: string[]): Promise<void>;
280
+ /**
281
+ * Validates that multiple elements are visible on the page.
282
+ * @param {Locator[]} elements - Array of Playwright locators to validate.
283
+ * @returns {Promise<void>} Resolves when all elements are confirmed visible.
284
+ */
285
+ validateElementsToBeVisible(elements: Locator[]): Promise<void>;
286
+ /** Waits until a given element is visible in the DOM.
287
+ * @param element - The Playwright Locator of the element to wait for.
288
+ * @param timeout - Optional timeout in ms (default: 10s).
289
+ */
290
+ waitForElementVisible(element: Locator, timeout?: number): Promise<void>;
291
+ /**
292
+ * Checks if given elements have expected text.
293
+ * Accepts either locator or string ID.
294
+ */
295
+ validateElementsToHaveText(locators: any[], expectedTexts: string[]): Promise<void>;
296
+ }