@bigbinary/neeto-playwright-commons 2.0.1 → 2.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.
package/index.cjs.js CHANGED
@@ -4894,6 +4894,7 @@ const COMMON_SELECTORS = {
4894
4894
  profileSidebar: "profile-section",
4895
4895
  selectOption: (label) => `${neetoCist.hyphenate(label)}-select-option`,
4896
4896
  radioLabel: (embedLabel) => `${neetoCist.hyphenate(embedLabel)}-radio-label`,
4897
+ neetoUiToastr: ".neeto-ui-toastr",
4897
4898
  toastMessage: (type) => `toastr-${type}-container`,
4898
4899
  toastCloseButton: "toastr-close-button",
4899
4900
  windowAlert: "#alert-box",
@@ -5942,11 +5943,19 @@ class CustomCommands {
5942
5943
  return await this.recursiveMethod(callback, condition, timeout, startTime, 1);
5943
5944
  };
5944
5945
  verifyToast = async ({ message = "", toastType = "success", closeAfterVerification = true, timeout = 10_000, customPageContext = this.page, } = {}) => {
5945
- const toastrCloseButton = customPageContext.getByTestId(COMMON_SELECTORS.toastCloseButton);
5946
- const toastrLocator = ramda.isEmpty(message)
5947
- ? customPageContext.locator(COMMON_SELECTORS.toastIcon)
5948
- : customPageContext.getByTestId(COMMON_SELECTORS.toastMessage(toastType));
5949
- await test.expect(toastrLocator).toContainText(ramda.isEmpty(message) ? "👍" : message, { timeout });
5946
+ // React-toastify does not support adding data-* attributes to toast DOM elements: https://github.com/fkhadra/react-toastify/issues/1106
5947
+ const toastrLocator = customPageContext
5948
+ .locator(COMMON_SELECTORS.neetoUiToastr)
5949
+ .filter({
5950
+ has: customPageContext.getByTestId(COMMON_SELECTORS.toastMessage(toastType)),
5951
+ });
5952
+ const filteredToastrLocator = (ramda.isEmpty(message)
5953
+ ? toastrLocator
5954
+ : toastrLocator.filter({ hasText: message }))
5955
+ // eslint-disable-next-line playwright/no-nth-methods
5956
+ .first();
5957
+ await test.expect(filteredToastrLocator).toContainText(ramda.isEmpty(message) ? "👍" : message, { timeout });
5958
+ const toastrCloseButton = filteredToastrLocator.getByTestId(COMMON_SELECTORS.toastCloseButton);
5950
5959
  if (!closeAfterVerification && (await toastrCloseButton.isHidden()))
5951
5960
  return;
5952
5961
  const buttonHandle = await toastrCloseButton.elementHandle();