@bigbinary/neeto-playwright-commons 4.1.10 → 4.1.11
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/index.d.ts +45 -3
- package/index.js +30 -3
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ interface VerifyToastParams {
|
|
|
33
33
|
timeout?: number;
|
|
34
34
|
toastCloseTimeout?: number;
|
|
35
35
|
closeAfterVerification: boolean;
|
|
36
|
-
toastType: "success" | "error";
|
|
36
|
+
toastType: "success" | "error" | "info" | "warning";
|
|
37
37
|
customPageContext?: Page;
|
|
38
38
|
}
|
|
39
39
|
interface AssertCardDetailsProps {
|
|
@@ -212,6 +212,12 @@ declare class CustomCommands {
|
|
|
212
212
|
condition,
|
|
213
213
|
timeout
|
|
214
214
|
}: ExecuteRecursivelyParams) => Promise<unknown>;
|
|
215
|
+
/**
|
|
216
|
+
* @deprecated Targets the react-toastify-based Toastr from
|
|
217
|
+
* @bigbinary/neetoui. Use verifyToastV2 instead for apps whose Toastr
|
|
218
|
+
* comes from @bigbinary/neeto-atoms (sonner-based, e.g. neeto-engage-web).
|
|
219
|
+
* Kept only for apps still on the legacy neetoui Toastr.
|
|
220
|
+
*/
|
|
215
221
|
/**
|
|
216
222
|
*
|
|
217
223
|
* Command to assert the toastr message. It takes the following parameters:
|
|
@@ -220,7 +226,7 @@ declare class CustomCommands {
|
|
|
220
226
|
*
|
|
221
227
|
* message(optional): Text that should be on toast.
|
|
222
228
|
*
|
|
223
|
-
* toastType(optional): Type of toast. It takes
|
|
229
|
+
* toastType(optional): Type of toast. It takes success, error, info or warning as it's value. Default is success.
|
|
224
230
|
*
|
|
225
231
|
* timeout(optional): Timeout in milliseconds to wait for the toast to appear. Default is 10_000.
|
|
226
232
|
*
|
|
@@ -248,6 +254,42 @@ declare class CustomCommands {
|
|
|
248
254
|
toastCloseTimeout,
|
|
249
255
|
customPageContext
|
|
250
256
|
}?: Partial<VerifyToastParams>) => Promise<void>;
|
|
257
|
+
/**
|
|
258
|
+
*
|
|
259
|
+
* Command to assert the toastr message rendered by @bigbinary/neeto-atoms's sonner-based Toastr. Use this instead of verifyToast for apps that have moved to @bigbinary/neeto-atoms (e.g. neeto-engage-web). It takes the following parameters:
|
|
260
|
+
*
|
|
261
|
+
* closeAfterVerification(optional): Boolean to close the toast after verification. Default is true.
|
|
262
|
+
*
|
|
263
|
+
* message(optional): Text that should be on toast.
|
|
264
|
+
*
|
|
265
|
+
* toastType(optional): Type of toast. It takes success, error, info or warning as it's value. Default is success.
|
|
266
|
+
*
|
|
267
|
+
* timeout(optional): Timeout in milliseconds to wait for the toast to appear. Default is 10_000.
|
|
268
|
+
*
|
|
269
|
+
* toastCloseTimeout(optional): Timeout in milliseconds to wait for the toast to disappear after closing. Default is 10_000.
|
|
270
|
+
*
|
|
271
|
+
* customPageContext(optional): Custom page context on which to verify the toast.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
*
|
|
275
|
+
* await neetoPlaywrightUtilities.verifyToastV2({
|
|
276
|
+
* message: "Toastr message",
|
|
277
|
+
* closeAfterVerification: false,
|
|
278
|
+
* toastType: "error",
|
|
279
|
+
* timeout: 20_000,
|
|
280
|
+
* toastCloseTimeout: 15_000,
|
|
281
|
+
* customPageContext: this.page,
|
|
282
|
+
* });
|
|
283
|
+
* @endexample
|
|
284
|
+
*/
|
|
285
|
+
verifyToastV2: ({
|
|
286
|
+
message,
|
|
287
|
+
toastType,
|
|
288
|
+
closeAfterVerification,
|
|
289
|
+
timeout,
|
|
290
|
+
toastCloseTimeout,
|
|
291
|
+
customPageContext
|
|
292
|
+
}?: Partial<VerifyToastParams>) => Promise<void>;
|
|
251
293
|
/**
|
|
252
294
|
*
|
|
253
295
|
* Command to wait until the page has no loaders or spinners.
|
|
@@ -255,7 +297,7 @@ declare class CustomCommands {
|
|
|
255
297
|
* @example
|
|
256
298
|
*
|
|
257
299
|
* await neetoPlaywrightUtilities.waitForPageLoad({
|
|
258
|
-
*
|
|
300
|
+
* visibilityTimeout: 35_000,
|
|
259
301
|
* customPageContext,
|
|
260
302
|
* });
|
|
261
303
|
* @endexample
|
package/index.js
CHANGED
|
@@ -1988,6 +1988,7 @@ const getImagePathAndName = (localImagePath) => {
|
|
|
1988
1988
|
};
|
|
1989
1989
|
|
|
1990
1990
|
const __dirname$5 = getDirname(import.meta.url);
|
|
1991
|
+
const TOAST_DEFAULT_MESSAGE = "👍";
|
|
1991
1992
|
class CustomCommands {
|
|
1992
1993
|
page;
|
|
1993
1994
|
t;
|
|
@@ -2048,8 +2049,13 @@ class CustomCommands {
|
|
|
2048
2049
|
const startTime = Date.now();
|
|
2049
2050
|
return await this.recursiveMethod(callback, condition, timeout, startTime, 1);
|
|
2050
2051
|
};
|
|
2052
|
+
/**
|
|
2053
|
+
* @deprecated Targets the react-toastify-based Toastr from
|
|
2054
|
+
* @bigbinary/neetoui. Use verifyToastV2 instead for apps whose Toastr
|
|
2055
|
+
* comes from @bigbinary/neeto-atoms (sonner-based, e.g. neeto-engage-web).
|
|
2056
|
+
* Kept only for apps still on the legacy neetoui Toastr.
|
|
2057
|
+
*/
|
|
2051
2058
|
verifyToast = async ({ message = "", toastType = "success", closeAfterVerification = true, timeout = 10_000, toastCloseTimeout = 10_000, customPageContext = this.page, } = {}) => {
|
|
2052
|
-
// React-toastify does not support adding data-* attributes to toast DOM elements: https://github.com/fkhadra/react-toastify/issues/1106
|
|
2053
2059
|
const toastrLocator = customPageContext
|
|
2054
2060
|
.locator(COMMON_SELECTORS.neetoUiToastr)
|
|
2055
2061
|
.filter({
|
|
@@ -2060,10 +2066,10 @@ class CustomCommands {
|
|
|
2060
2066
|
: toastrLocator.filter({ hasText: message }))
|
|
2061
2067
|
// eslint-disable-next-line playwright/no-nth-methods
|
|
2062
2068
|
.first();
|
|
2063
|
-
await expect(filteredToastrLocator).toContainText(isEmpty(message) ?
|
|
2064
|
-
const toastrCloseButton = filteredToastrLocator.getByTestId(COMMON_SELECTORS.toastCloseButton);
|
|
2069
|
+
await expect(filteredToastrLocator).toContainText(isEmpty(message) ? TOAST_DEFAULT_MESSAGE : message, { timeout });
|
|
2065
2070
|
if (!closeAfterVerification)
|
|
2066
2071
|
return;
|
|
2072
|
+
const toastrCloseButton = filteredToastrLocator.getByTestId(COMMON_SELECTORS.toastCloseButton);
|
|
2067
2073
|
const buttonHandle = await toastrCloseButton.elementHandle();
|
|
2068
2074
|
if (buttonHandle) {
|
|
2069
2075
|
await customPageContext.evaluate(button => {
|
|
@@ -2074,6 +2080,27 @@ class CustomCommands {
|
|
|
2074
2080
|
});
|
|
2075
2081
|
}
|
|
2076
2082
|
};
|
|
2083
|
+
verifyToastV2 = async ({ message = "", toastType = "success", closeAfterVerification = true, timeout = 10_000, toastCloseTimeout = 10_000, customPageContext = this.page, } = {}) => {
|
|
2084
|
+
const toastLocator = customPageContext.getByTestId(COMMON_SELECTORS.toastMessage(toastType));
|
|
2085
|
+
const filteredToastLocator = (isEmpty(message)
|
|
2086
|
+
? toastLocator
|
|
2087
|
+
: toastLocator.filter({ hasText: message }))
|
|
2088
|
+
// eslint-disable-next-line playwright/no-nth-methods
|
|
2089
|
+
.first();
|
|
2090
|
+
await expect(filteredToastLocator).toContainText(isEmpty(message) ? TOAST_DEFAULT_MESSAGE : message, { timeout });
|
|
2091
|
+
if (!closeAfterVerification)
|
|
2092
|
+
return;
|
|
2093
|
+
const toastCloseButton = filteredToastLocator.getByTestId(COMMON_SELECTORS.toastCloseButton);
|
|
2094
|
+
const buttonHandle = await toastCloseButton.elementHandle();
|
|
2095
|
+
if (buttonHandle) {
|
|
2096
|
+
await customPageContext.evaluate(button => {
|
|
2097
|
+
button.dispatchEvent(new Event("click", { bubbles: true }));
|
|
2098
|
+
}, buttonHandle);
|
|
2099
|
+
await expect(toastCloseButton).toBeHidden({
|
|
2100
|
+
timeout: toastCloseTimeout,
|
|
2101
|
+
});
|
|
2102
|
+
}
|
|
2103
|
+
};
|
|
2077
2104
|
waitForPageLoad = async ({ visibilityTimeout = 35_000, customPageContext = this.page, waitForOption = "serial", } = {}) => {
|
|
2078
2105
|
await customPageContext.waitForLoadState();
|
|
2079
2106
|
const loaders = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-playwright-commons",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.11",
|
|
4
4
|
"description": "A package encapsulating common playwright code across neeto projects.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-playwright-commons.git",
|
|
6
6
|
"license": "apache-2.0",
|