@bigbinary/neeto-playwright-commons 1.26.10 → 1.26.12

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
@@ -4907,7 +4907,7 @@ const removeCredentialFile = () => {
4907
4907
  require$$0__namespace.unlink(STORAGE_STATE, error => {
4908
4908
  if (!error)
4909
4909
  return;
4910
- console.log(error);
4910
+ console.error(error);
4911
4911
  });
4912
4912
  };
4913
4913
  const clearCredentials = () => {
@@ -4976,7 +4976,43 @@ const getListCount = async ({ page, countSelector, }) => {
4976
4976
  return Number(countText === null || countText === void 0 ? void 0 : countText.trim().split(" ")[0]);
4977
4977
  };
4978
4978
  const getGlobalUserProps = async (page) => (await page.evaluate(() => window.globalProps.user));
4979
- const getClipboardContent = (page) => page.evaluate(() => navigator.clipboard.readText());
4979
+ const createTextareaAndEvaluateCopiedText = async (page) => {
4980
+ const textareaHandle = await page.evaluateHandle(() => {
4981
+ const textarea = document.createElement("textarea");
4982
+ Object.assign(textarea.style, {
4983
+ position: "fixed",
4984
+ top: "0",
4985
+ left: "0",
4986
+ opacity: "0",
4987
+ pointerEvents: "none",
4988
+ zIndex: "9999",
4989
+ });
4990
+ document.body.appendChild(textarea);
4991
+ textarea.focus();
4992
+ return textarea;
4993
+ });
4994
+ try {
4995
+ await page.keyboard.press("ControlOrMeta+v");
4996
+ return await page.evaluate(el => el.value, textareaHandle);
4997
+ }
4998
+ finally {
4999
+ await textareaHandle.evaluate(el => el.remove());
5000
+ await textareaHandle.dispose();
5001
+ }
5002
+ };
5003
+ const getClipboardContent = async (page) => {
5004
+ // Attempt 1: Native Clipboard API
5005
+ const clipboardText = await page.evaluate(async () => {
5006
+ var _a;
5007
+ if (!((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.readText))
5008
+ return null;
5009
+ return await navigator.clipboard.readText();
5010
+ });
5011
+ if (ramda.isNotNil(clipboardText))
5012
+ return clipboardText;
5013
+ // Attempt 2: Keyboard paste fallback
5014
+ return createTextareaAndEvaluateCopiedText(page);
5015
+ };
4980
5016
  const grantClipboardPermissions = (context) => context.grantPermissions(["clipboard-read", "clipboard-write"]);
4981
5017
  const getFullUrl = (path) => shouldSkipCustomDomainSetup() ? path : `${process.env.BASE_URL}${path}`;
4982
5018
  const globalShortcuts = (t) => [
@@ -5317,6 +5353,7 @@ const SIGNUP_SELECTORS = {
5317
5353
  signupViaEmailButton: "signup-via-email-button",
5318
5354
  submitButton: "signup-email-submit-button",
5319
5355
  subdomainNameTextField: "signup-organization-subdomain-text-field",
5356
+ subdomainAvailabilityMsg: "subdomain-availability-message",
5320
5357
  subdomainError: "subdomain-input-error",
5321
5358
  tryFreeButton: "neeto-auth-signup-link",
5322
5359
  /** @deprecated Use unregisteredEmailError instead. */
@@ -116440,7 +116477,7 @@ class GooglePage extends IntegrationBase {
116440
116477
  .click();
116441
116478
  await this.page.waitForLoadState("load", { timeout: 25000 });
116442
116479
  await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.password));
116443
- await test.expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.showPassword)).toBeVisible();
116480
+ await test.expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.showPassword)).toBeVisible({ timeout: 10000 });
116444
116481
  await this.page
116445
116482
  .getByLabel(GOOGLE_LOGIN_TEXTS.enterYourPassword)
116446
116483
  .pressSequentially(process.env.GOOGLE_LOGIN_PASSWORD, { delay: 10 });
@@ -116459,7 +116496,7 @@ class GooglePage extends IntegrationBase {
116459
116496
  level: 2,
116460
116497
  exact: true,
116461
116498
  });
116462
- await test.expect(twoStepVerification).toBeVisible();
116499
+ await test.expect(twoStepVerification).toBeVisible({ timeout: 15000 });
116463
116500
  await this.enterTotpCode(twoStepVerification);
116464
116501
  await this.page.waitForLoadState("load", { timeout: 25000 });
116465
116502
  await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.myAccount));
@@ -118506,22 +118543,29 @@ class OrganizationPage {
118506
118543
  const { subdomainName } = getGlobalUserState();
118507
118544
  return `https://${subdomainName}.${appName}.net`;
118508
118545
  };
118546
+ this.fillOTP = async (otp = faker.faker.string.numeric(6)) => {
118547
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
118548
+ const otpTextBox = this.page.getByTestId(SIGNUP_SELECTORS.otpTextBox);
118549
+ await otpTextBox.fill(otp);
118550
+ await test.expect(otpTextBox).toBeHidden({ timeout: 35000 });
118551
+ };
118552
+ this.submitEmail = async (email) => {
118553
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
118554
+ await this.page.getByTestId(SIGNUP_SELECTORS.emailTextField).fill(email);
118555
+ const submitButton = this.page.getByTestId(SIGNUP_SELECTORS.submitButton);
118556
+ await submitButton.click();
118557
+ await test.expect(submitButton).toBeHidden({ timeout: 35000 });
118558
+ };
118509
118559
  this.createOrganization = async ({ email, businessName, subdomainName, firstName, lastName, appName, }) => {
118510
118560
  if (!IS_STAGING_ENV || shouldSkipSetupAndTeardown())
118511
118561
  return;
118512
- const defaultOtp = "123456";
118513
118562
  const appNameInLowerCase = appName.toLowerCase();
118514
118563
  const isNeetoAuth = appNameInLowerCase === "neetoauth";
118515
118564
  isNeetoAuth
118516
118565
  ? await this.page.goto(ROUTES.neetoAuthSignup, { timeout: 20000 })
118517
118566
  : await this.page.goto(`${ROUTES.neetoAuthSignup}?redirect_uri=${appNameInLowerCase}.net/admin`, { timeout: 20000 });
118518
- await this.neetoPlaywrightUtilities.waitForPageLoad();
118519
- const submitButton = this.page.getByTestId(SIGNUP_SELECTORS.submitButton);
118520
- await this.page.getByTestId(SIGNUP_SELECTORS.emailTextField).fill(email);
118521
- await submitButton.click();
118522
- await test.expect(submitButton).toBeHidden({ timeout: 30000 });
118523
- await this.neetoPlaywrightUtilities.waitForPageLoad();
118524
- await this.page.getByTestId(SIGNUP_SELECTORS.otpTextBox).fill(defaultOtp);
118567
+ await this.submitEmail(email);
118568
+ await this.fillOTP();
118525
118569
  await this.fillOrganizationDetails({
118526
118570
  credentials: {
118527
118571
  firstName,
@@ -118595,6 +118639,7 @@ class OrganizationPage {
118595
118639
  }
118596
118640
  };
118597
118641
  this.fillEmailAndSubmit = async (email, loginTimeout) => {
118642
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
118598
118643
  await this.page.getByTestId(LOGIN_SELECTORS.emailTextField).fill(email);
118599
118644
  const unregisteredEmailError = this.page.getByTestId(SIGNUP_SELECTORS.unregisteredEmailError);
118600
118645
  await test.expect(async () => {
@@ -118605,19 +118650,15 @@ class OrganizationPage {
118605
118650
  };
118606
118651
  this.loginViaSSO = async (email = generateRandomBypassEmail(), loginTimeout = 2 * 60 * 1000) => {
118607
118652
  await this.fillEmailAndSubmit(email, loginTimeout);
118608
- await this.page
118609
- .getByTestId(SIGNUP_SELECTORS.otpTextBox)
118610
- .fill(faker.faker.string.numeric(6));
118653
+ await this.fillOTP();
118611
118654
  };
118612
118655
  this.loginWithFastmailEmail = async ({ email, loginTimeout = 2 * 60 * 1000, fetchOtpFromEmail, }) => {
118613
118656
  await this.fillEmailAndSubmit(email, loginTimeout);
118614
- const otp = await fetchOtpFromEmail({
118615
- email,
118616
- timeout: 4 * 60 * 1000,
118617
- });
118618
- await this.page.getByTestId(SIGNUP_SELECTORS.otpTextBox).fill(otp);
118657
+ const otp = await fetchOtpFromEmail({ email, timeout: 4 * 60 * 1000 });
118658
+ await this.fillOTP(otp);
118619
118659
  };
118620
118660
  this.setupProfile = async ({ firstName = faker.faker.person.firstName(), lastName = faker.faker.person.lastName(), country, } = {}) => {
118661
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
118621
118662
  await this.page
118622
118663
  .getByTestId(SIGNUP_SELECTORS.firstNameTextField)
118623
118664
  .fill(firstName);
@@ -118647,19 +118688,14 @@ class OrganizationPage {
118647
118688
  this.signUp = async ({ credentials, fetchOtpFromEmail, appName, }) => {
118648
118689
  let otp = "123456";
118649
118690
  await this.page.goto(`${ROUTES.neetoAuthSignup}?redirect_uri=${credentials.domain}`, { timeout: 20000 });
118650
- await this.page
118651
- .getByTestId(SIGNUP_SELECTORS.emailTextField)
118652
- .fill(credentials.email);
118653
- const submitButton = this.page.getByTestId(SIGNUP_SELECTORS.submitButton);
118654
- await submitButton.click();
118655
- await test.expect(submitButton).toBeHidden({ timeout: 10000 });
118691
+ await this.submitEmail(credentials.email);
118656
118692
  if (fetchOtpFromEmail !== undefined) {
118657
118693
  otp = await fetchOtpFromEmail({
118658
118694
  email: credentials.email,
118659
118695
  timeout: 4 * 60 * 1000,
118660
118696
  });
118661
118697
  }
118662
- await this.page.getByTestId(SIGNUP_SELECTORS.otpTextBox).fill(otp);
118698
+ await this.fillOTP(otp);
118663
118699
  await this.fillOrganizationDetails({
118664
118700
  credentials,
118665
118701
  appName,
@@ -118671,6 +118707,7 @@ class OrganizationPage {
118671
118707
  this.fillOrganizationDetails = async ({ credentials, appName, }) => {
118672
118708
  const subdomainError = this.page.getByTestId(SIGNUP_SELECTORS.subdomainError);
118673
118709
  const organizationSubmitButton = this.page.getByTestId(SIGNUP_SELECTORS.organizationSubmitButton);
118710
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
118674
118711
  await this.page
118675
118712
  .getByTestId(SIGNUP_SELECTORS.organizationNameTextField)
118676
118713
  .fill(neetoCist.humanize(credentials.businessName));
@@ -118679,10 +118716,7 @@ class OrganizationPage {
118679
118716
  .fill(credentials.subdomainName);
118680
118717
  const subdomainErrorCount = await subdomainError.count();
118681
118718
  subdomainErrorCount !== 0 && (await this.updateSubdomainIfExists(appName));
118682
- //TODO: Use getByTestId when this issue https://github.com/bigbinary/neeto-auth-web/issues/6460 is resolved
118683
- await test.expect(this.page.getByTitle(ORGANIZATION_TEXTS.subdomainAvailable)).toBeVisible({
118684
- timeout: 45000,
118685
- });
118719
+ await test.expect(this.page.getByTestId(SIGNUP_SELECTORS.subdomainAvailabilityMsg)).toBeVisible({ timeout: 45000 });
118686
118720
  await organizationSubmitButton.click();
118687
118721
  await Promise.all([
118688
118722
  test.expect(organizationSubmitButton).toBeHidden({ timeout: 45 * 1000 }),