@bigbinary/neeto-playwright-commons 1.9.21 → 1.9.22

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 CHANGED
@@ -27,6 +27,11 @@ interface VerifySuccessToastParams {
27
27
  message: string;
28
28
  closeAfterVerification: boolean;
29
29
  }
30
+ interface VerifyToastParams {
31
+ message: string;
32
+ closeAfterVerification: boolean;
33
+ toastType: "success" | "error";
34
+ }
30
35
  type ConditionProps = Record<string, string>[];
31
36
  type FilterProps = Record<string, ConditionProps>;
32
37
  type ParamFilters = FilterProps[];
@@ -119,9 +124,12 @@ declare class CustomCommands {
119
124
  * @endexample
120
125
  */
121
126
  executeRecursively: ExecuteRecursively;
127
+ /**
128
+ * @deprecated Use verifyToast instead.
129
+ */
122
130
  /**
123
131
  *
124
- * Command to assert the toastr message. It takes the following parameters:
132
+ * Command to assert the success toastr message. It takes the following parameters:
125
133
  *
126
134
  * closeAfterVerification(optional): Boolean to close the toast after verification. Default is true.
127
135
  *
@@ -139,6 +147,30 @@ declare class CustomCommands {
139
147
  message,
140
148
  closeAfterVerification
141
149
  }?: Partial<VerifySuccessToastParams>) => Promise<void>;
150
+ /**
151
+ *
152
+ * Command to assert the toastr message. It takes the following parameters:
153
+ *
154
+ * closeAfterVerification(optional): Boolean to close the toast after verification. Default is true.
155
+ *
156
+ * message(optional): Text that should be on toast.
157
+ *
158
+ * toastType(optional): Type of toast. It takes either success or error as it's value. Default is success.
159
+ *
160
+ * @example
161
+ *
162
+ * await neetoPlaywrightUtilities.verifyToast({
163
+ * message: "Toastr message",
164
+ * closeAfterVerification: false,
165
+ * toastType: "error"
166
+ * });
167
+ * @endexample
168
+ */
169
+ verifyToast: ({
170
+ message,
171
+ toastType,
172
+ closeAfterVerification
173
+ }?: Partial<VerifyToastParams>) => Promise<void>;
142
174
  /**
143
175
  *
144
176
  * Command to reload and wait for the API responses.
@@ -2733,6 +2765,7 @@ declare const COMMON_SELECTORS: {
2733
2765
  actionSelectIndicator: string;
2734
2766
  takeActionDropdown: string;
2735
2767
  columnsSearchInput: string;
2768
+ errorToastIcon: string;
2736
2769
  };
2737
2770
  /**
2738
2771
  *
package/index.js CHANGED
@@ -313,6 +313,7 @@ const COMMON_SELECTORS = {
313
313
  actionSelectIndicator: "action-select-indicator",
314
314
  takeActionDropdown: "take-action-dropdown-icon",
315
315
  columnsSearchInput: "neeto-ui-columns-search",
316
+ errorToastIcon: "error-toast-icon",
316
317
  };
317
318
 
318
319
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -3427,6 +3428,9 @@ class CustomCommands {
3427
3428
  const startTime = Date.now();
3428
3429
  await this.recursiveMethod(callback, condition, timeout, startTime);
3429
3430
  };
3431
+ /**
3432
+ * @deprecated Use verifyToast instead.
3433
+ */
3430
3434
  this.verifySuccessToast = async ({ message = "", closeAfterVerification = true, } = {}) => {
3431
3435
  if (!isEmpty$1(message)) {
3432
3436
  await expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toContainText(message);
@@ -3438,6 +3442,22 @@ class CustomCommands {
3438
3442
  (await this.page.getByTestId(COMMON_SELECTORS.toastCloseButton).click());
3439
3443
  await expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toBeHidden();
3440
3444
  };
3445
+ this.verifyToast = async ({ message = "", toastType = "success", closeAfterVerification = true, } = {}) => {
3446
+ if (toastType === "error") {
3447
+ await expect(this.page.getByTestId(COMMON_SELECTORS.errorToastIcon)).toBeVisible({ timeout: 10000 });
3448
+ }
3449
+ const toastrCloseButton = this.page.getByTestId(COMMON_SELECTORS.toastCloseButton);
3450
+ if (!isEmpty$1(message)) {
3451
+ await expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toContainText(message, { timeout: 10000 });
3452
+ }
3453
+ else {
3454
+ await expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toContainText("👍");
3455
+ }
3456
+ if (closeAfterVerification && (await toastrCloseButton.isVisible())) {
3457
+ await toastrCloseButton.click();
3458
+ await expect(toastrCloseButton).toBeHidden();
3459
+ }
3460
+ };
3441
3461
  this.reloadAndWait = async (requestCount, customPageContext, interceptMultipleResponsesProps = {}) => {
3442
3462
  const pageContext = customPageContext !== null && customPageContext !== void 0 ? customPageContext : this.page;
3443
3463
  const reloadRequests = this.interceptMultipleResponses({