@bigbinary/neeto-playwright-commons 2.0.0 → 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();
@@ -57655,6 +57664,36 @@ const hexToRGB = (hex) => {
57655
57664
  return `rgb(${Number(r)}, ${Number(g)}, ${Number(b)})`;
57656
57665
  };
57657
57666
 
57667
+ const fillCredentialsAndSubmit = async ({ page, loginPath, email = CREDENTIALS.email, }) => {
57668
+ loginPath && (await page.goto(loginPath, { timeout: 30_000 }));
57669
+ await page.waitForLoadState("load", { timeout: 35_000 });
57670
+ await test.expect(page.getByTestId(COMMON_SELECTORS.pageLoader)).toBeHidden({
57671
+ timeout: 30_000,
57672
+ });
57673
+ const emailInput = page.getByTestId(LOGIN_SELECTORS.emailTextField);
57674
+ await emailInput.waitFor({ state: "visible", timeout: 30_000 });
57675
+ await emailInput.fill(email);
57676
+ await page
57677
+ .getByTestId(LOGIN_SELECTORS.passwordTextField)
57678
+ .fill(CREDENTIALS.password);
57679
+ const submitButton = page.getByTestId(LOGIN_SELECTORS.submitButton);
57680
+ await submitButton.click();
57681
+ await test.expect(submitButton).toBeHidden({ timeout: 20_000 });
57682
+ await test.expect(page.getByTestId(COMMON_SELECTORS.floatingActionMenuButton)).toBeVisible({ timeout: 60_000 });
57683
+ };
57684
+ const loginWithoutSSO = async ({ page, loginPath = "/", email = CREDENTIALS.email, }) => {
57685
+ if (shouldSkipSetupAndTeardown())
57686
+ return;
57687
+ await fillCredentialsAndSubmit({ page, loginPath, email });
57688
+ const userCredentials = readFileSyncIfExists();
57689
+ await page.context().storageState({ path: STORAGE_STATE });
57690
+ const mergedCredentials = ramda.mergeAll([readFileSyncIfExists(), userCredentials]);
57691
+ writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
57692
+ updateCredentials({ key: "isLoggedIn", value: "true" });
57693
+ };
57694
+ const login = async ({ page, loginPath, email }) => IS_DEV_ENV && (await loginWithoutSSO({ page, loginPath, email }));
57695
+ const generateRandomBypassEmail = () => `cpt${process.env.OTP_BYPASS_KEY}+${faker.faker.number.int()}@bigbinary.com`;
57696
+
57658
57697
  class RailsEmailUtils {
57659
57698
  neetoPlaywrightUtilities;
57660
57699
  railsEmailRakeClient;
@@ -57970,7 +58009,9 @@ class MailerUtils {
57970
58009
  const { html: { codes }, } = await this.findMessage({ to: email, subject: subjectSubstring }, { timeout, receivedAfter, expectedEmailCount });
57971
58010
  return codes?.[0];
57972
58011
  };
57973
- generateRandomEmail = () => faker.faker.internet.email({ provider: process.env.FASTMAIL_DOMAIN_NAME });
58012
+ generateRandomEmail = (shouldUseBypassEmail = false) => shouldUseBypassEmail
58013
+ ? generateRandomBypassEmail()
58014
+ : faker.faker.internet.email({ provider: process.env.FASTMAIL_DOMAIN_NAME });
57974
58015
  getEmailAttachment = async (attachmentName, messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
57975
58016
  if (IS_DEV_ENV) {
57976
58017
  return this.railsEmailUtils.getEmailAttachment(attachmentName, messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
@@ -117984,6 +118025,8 @@ class EditorPage {
117984
118025
  verifyFontSize = async () => {
117985
118026
  const fontsAndTexts = [];
117986
118027
  const fontSizeDropdownButton = this.page.getByTestId(NEETO_EDITOR_SELECTORS.neetoEditorFixedMenuFontSize);
118028
+ await this.contentField.focus();
118029
+ await this.contentField.press("Enter");
117987
118030
  await fontSizeDropdownButton.click();
117988
118031
  const headingButtons = await this.page
117989
118032
  .getByTestId(COMMON_SELECTORS.dropdownContainer)
@@ -118049,7 +118092,6 @@ class EditorPage {
118049
118092
  isButtonInMoreMenu && (await this.moreMenuSelector.click());
118050
118093
  await this.editorWrapper
118051
118094
  .getByTestId(NEETO_TEXT_MODIFIER_SELECTORS["highlight"])
118052
- .locator("svg")
118053
118095
  .click();
118054
118096
  await test.expect(this.page.getByTestId(COMMON_SELECTORS.customDropdownContainer())).toBeVisible({ timeout: 5_000 });
118055
118097
  }).toPass({ timeout: 30_000 });
@@ -118807,36 +118849,6 @@ class TeamMembers {
118807
118849
  };
118808
118850
  }
118809
118851
 
118810
- const fillCredentialsAndSubmit = async ({ page, loginPath, email = CREDENTIALS.email, }) => {
118811
- loginPath && (await page.goto(loginPath, { timeout: 30_000 }));
118812
- await page.waitForLoadState("load", { timeout: 35_000 });
118813
- await test.expect(page.getByTestId(COMMON_SELECTORS.pageLoader)).toBeHidden({
118814
- timeout: 30_000,
118815
- });
118816
- const emailInput = page.getByTestId(LOGIN_SELECTORS.emailTextField);
118817
- await emailInput.waitFor({ state: "visible", timeout: 30_000 });
118818
- await emailInput.fill(email);
118819
- await page
118820
- .getByTestId(LOGIN_SELECTORS.passwordTextField)
118821
- .fill(CREDENTIALS.password);
118822
- const submitButton = page.getByTestId(LOGIN_SELECTORS.submitButton);
118823
- await submitButton.click();
118824
- await test.expect(submitButton).toBeHidden({ timeout: 20_000 });
118825
- await test.expect(page.getByTestId(COMMON_SELECTORS.floatingActionMenuButton)).toBeVisible({ timeout: 60_000 });
118826
- };
118827
- const loginWithoutSSO = async ({ page, loginPath = "/", email = CREDENTIALS.email, }) => {
118828
- if (shouldSkipSetupAndTeardown())
118829
- return;
118830
- await fillCredentialsAndSubmit({ page, loginPath, email });
118831
- const userCredentials = readFileSyncIfExists();
118832
- await page.context().storageState({ path: STORAGE_STATE });
118833
- const mergedCredentials = ramda.mergeAll([readFileSyncIfExists(), userCredentials]);
118834
- writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
118835
- updateCredentials({ key: "isLoggedIn", value: "true" });
118836
- };
118837
- const login = async ({ page, loginPath, email }) => IS_DEV_ENV && (await loginWithoutSSO({ page, loginPath, email }));
118838
- const generateRandomBypassEmail = () => `cpt${process.env.OTP_BYPASS_KEY}+${faker.faker.number.int()}@bigbinary.com`;
118839
-
118840
118852
  const extractSubdomainFromError = (errorString) => {
118841
118853
  const regex = /cpt[a-zA-Z0-9-]+/g;
118842
118854
  const matches = errorString.match(regex);