@bigbinary/neeto-playwright-commons 1.22.29 → 1.22.31
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.cjs.js +13 -13
- package/index.cjs.js.map +1 -1
- package/index.d.ts +39 -0
- package/index.js +13 -13
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -45,6 +45,15 @@ interface AssertCardDetailsProps {
|
|
|
45
45
|
title: string;
|
|
46
46
|
description: string;
|
|
47
47
|
}
|
|
48
|
+
type ErrorHandlingResult<T> = {
|
|
49
|
+
success: true;
|
|
50
|
+
result: T;
|
|
51
|
+
};
|
|
52
|
+
type ErrorHandlingFailure = {
|
|
53
|
+
success: false;
|
|
54
|
+
error: string;
|
|
55
|
+
};
|
|
56
|
+
type ErrorHandlingResponse<T> = ErrorHandlingResult<T> | ErrorHandlingFailure;
|
|
48
57
|
interface VerifyHelpPopoverProps {
|
|
49
58
|
triggerElement?: Locator;
|
|
50
59
|
title?: string;
|
|
@@ -638,6 +647,36 @@ declare class CustomCommands {
|
|
|
638
647
|
title,
|
|
639
648
|
description
|
|
640
649
|
}: AssertCardDetailsProps) => Promise<[void, void, void]>;
|
|
650
|
+
/**
|
|
651
|
+
*
|
|
652
|
+
* Method to execute an asynchronous function and safely handle any exceptions that occur. This method provides a simple and type-safe way to handle errors in tests by returning a result object that indicates success or failure.
|
|
653
|
+
*
|
|
654
|
+
* asyncFn: The asynchronous function to execute.
|
|
655
|
+
*
|
|
656
|
+
* Promise<ErrorHandlingResponse<T>> - A result object with either:
|
|
657
|
+
*
|
|
658
|
+
* { success: true, result: T } - When the function executes successfully
|
|
659
|
+
*
|
|
660
|
+
* { success: false, error: string } - When an error occurs
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
*
|
|
664
|
+
* const userResult = await neetoPlaywrightUtilities.executeWithErrorHandling(async (): Promise<UserData> => {
|
|
665
|
+
* const response = await page.evaluate(() => {
|
|
666
|
+
* return fetch('/api/v1/user').then(r => r.json());
|
|
667
|
+
* });
|
|
668
|
+
*
|
|
669
|
+
* return response;
|
|
670
|
+
* });
|
|
671
|
+
*
|
|
672
|
+
* if (userResult.success === true) {
|
|
673
|
+
* expect(userResult.result.name).toBeTruthy();
|
|
674
|
+
* } else {
|
|
675
|
+
* console.error("Failed to fetch user data:", userResult.error);
|
|
676
|
+
* }
|
|
677
|
+
* @endexample
|
|
678
|
+
*/
|
|
679
|
+
executeWithErrorHandling: <T>(asyncFn: () => Promise<T>) => Promise<ErrorHandlingResponse<T>>;
|
|
641
680
|
/**
|
|
642
681
|
*
|
|
643
682
|
* Method to click a button and wait for any loading spinners to disappear.
|
package/index.js
CHANGED
|
@@ -4591,6 +4591,16 @@ class CustomCommands {
|
|
|
4591
4591
|
expect(cardLocator.getByTestId(ADMIN_PANEL_SELECTORS.settingsItemDescription)).toHaveText(description),
|
|
4592
4592
|
expect(this.page.getByTestId(COMMON_SELECTORS.sidebarSubLink(title))).toHaveCSS("background-color", COLOR.transparent),
|
|
4593
4593
|
]);
|
|
4594
|
+
this.executeWithErrorHandling = async (asyncFn) => {
|
|
4595
|
+
try {
|
|
4596
|
+
const result = await asyncFn();
|
|
4597
|
+
return { success: true, result };
|
|
4598
|
+
}
|
|
4599
|
+
catch (error) {
|
|
4600
|
+
const errorInstance = error instanceof Error ? error : new Error(String(error));
|
|
4601
|
+
return { success: false, error: errorInstance.message };
|
|
4602
|
+
}
|
|
4603
|
+
};
|
|
4594
4604
|
this.clickButtonAndAwaitLoad = async ({ locator, timeout, }) => {
|
|
4595
4605
|
await locator.click({ timeout });
|
|
4596
4606
|
await expect(locator.getByTestId(COMMON_SELECTORS.uiSpinner)).toBeHidden({
|
|
@@ -179852,6 +179862,7 @@ const commands = {
|
|
|
179852
179862
|
await page.goto("/", { timeout: 35000 });
|
|
179853
179863
|
await page.waitForLoadState();
|
|
179854
179864
|
await use(page);
|
|
179865
|
+
await page.close();
|
|
179855
179866
|
},
|
|
179856
179867
|
mailerUtils: async ({ neetoPlaywrightUtilities }, use) => {
|
|
179857
179868
|
const mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
|
|
@@ -192438,9 +192449,10 @@ class EditorPage {
|
|
|
192438
192449
|
this.verifyImageUploadOption = async ({ imageUrl, filePath, isButtonInMoreMenu, shouldRemoveImage = false, }) => {
|
|
192439
192450
|
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
192440
192451
|
await this.imageUploadOption.click();
|
|
192452
|
+
await expect(this.page.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.restrictionMessage)).toBeVisible();
|
|
192441
192453
|
const fileUploaderPromise = this.page.waitForEvent("filechooser");
|
|
192442
192454
|
await this.page
|
|
192443
|
-
.getByTestId(
|
|
192455
|
+
.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.browseText)
|
|
192444
192456
|
.click();
|
|
192445
192457
|
const fileUploader = await fileUploaderPromise;
|
|
192446
192458
|
const imagePath = Path.join(__dirname, filePath);
|
|
@@ -192451,18 +192463,6 @@ class EditorPage {
|
|
|
192451
192463
|
await expect(this.imageWrapper).toBeHidden({
|
|
192452
192464
|
timeout: 15000,
|
|
192453
192465
|
});
|
|
192454
|
-
isButtonInMoreMenu && (await this.moreMenuSelector.click());
|
|
192455
|
-
await this.imageUploadOption.click();
|
|
192456
|
-
await this.page
|
|
192457
|
-
.getByTestId(NEETO_EDITOR_SELECTORS.imageUploadLinkButton)
|
|
192458
|
-
.click();
|
|
192459
|
-
await this.page
|
|
192460
|
-
.getByTestId(NEETO_EDITOR_SELECTORS.imageUploadLinkInput)
|
|
192461
|
-
.fill(imageUrl);
|
|
192462
|
-
await this.page
|
|
192463
|
-
.getByTestId(NEETO_EDITOR_SELECTORS.imageUploadLinkSubmitButton)
|
|
192464
|
-
.click();
|
|
192465
|
-
await expect(this.imageWrapper).toBeVisible({ timeout: 15000 });
|
|
192466
192466
|
if (shouldRemoveImage) {
|
|
192467
192467
|
await this.imageWrapper
|
|
192468
192468
|
.getByTestId(COMMON_SELECTORS.dropdownIcon)
|