@bigbinary/neeto-playwright-commons 1.8.45 → 1.8.46

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
@@ -12568,6 +12568,7 @@ const ROUTES = {
12568
12568
  neetoAuth: NEETO_AUTH_BASE_URL(),
12569
12569
  loginLink: "/login",
12570
12570
  profile: "/profile",
12571
+ admin: "/admin",
12571
12572
  myProfile: "/my/profile",
12572
12573
  authSettings: "/settings",
12573
12574
  webhooks: "/webhooks",
@@ -13492,6 +13493,18 @@ class ZapierPage extends IntegrationBase {
13492
13493
  }
13493
13494
  }
13494
13495
 
13496
+ const LOGIN_SELECTORS = {
13497
+ appleAuthenticationButton: "apple-authentication-button",
13498
+ emailTextField: "login-email-text-field",
13499
+ googleAuthenticationButton: "google-authentication-button",
13500
+ githubAuthenticationButton: "github-authentication-button",
13501
+ loginViaEmailButton: "login-via-email-button",
13502
+ passwordTextField: "login-password-text-field",
13503
+ rememberMeCheckBox: "login-remember-me-check-box",
13504
+ submitButton: "login-submit-button",
13505
+ twitterAuthenticationButton: "twitter-authentication-button",
13506
+ };
13507
+
13495
13508
  const SIGNUP_SELECTORS = {
13496
13509
  emailTextField: "signup-email-text-field",
13497
13510
  firstNameTextField: "signup-profile-first-name-text-field",
@@ -13508,6 +13521,29 @@ const SIGNUP_SELECTORS = {
13508
13521
  unregisterdEmailError: "unregisterd-email-error",
13509
13522
  };
13510
13523
 
13524
+ const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/", }) => {
13525
+ if (shouldSkipSetupAndTeardown())
13526
+ return;
13527
+ await page.goto(loginPath);
13528
+ await page.getByTestId("login-email-text-field").fill(CREDENTIALS.email);
13529
+ await page
13530
+ .getByTestId("login-password-text-field")
13531
+ .fill(CREDENTIALS.password);
13532
+ const login = neetoPlaywrightUtilities.interceptMultipleResponses({
13533
+ times: 1,
13534
+ });
13535
+ await page.getByTestId(LOGIN_SELECTORS.submitButton).click();
13536
+ await login;
13537
+ const userCredentials = readFileSyncIfExists();
13538
+ await page.context().storageState({ path: STORAGE_STATE });
13539
+ const mergedCredentials = ramda.mergeAll([readFileSyncIfExists(), userCredentials]);
13540
+ writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
13541
+ updateCredentials({ key: "isLoggedIn", value: "true" });
13542
+ };
13543
+ const login = async ({ page, neetoPlaywrightUtilities, loginPath, }) => !IS_STAGING_ENV &&
13544
+ (await loginWithoutSSO({ page, neetoPlaywrightUtilities, loginPath }));
13545
+ const generateRandomBypassEmail = () => `cpt${process.env.OTP_BYPASS_KEY}+${faker.faker.number.int()}@bigbinary.com`;
13546
+
13511
13547
  const extractSubdomainFromError = (errorString) => {
13512
13548
  const regex = /cpt[a-zA-Z0-9-]+/g;
13513
13549
  const matches = errorString.match(regex);
@@ -13540,47 +13576,18 @@ class OrganizationPage {
13540
13576
  await this.page.getByTestId(SIGNUP_SELECTORS.submitButton).click();
13541
13577
  await signup;
13542
13578
  await this.page.getByTestId(SIGNUP_SELECTORS.otpTextBox).fill(defaultOtp);
13543
- await this.page
13544
- .getByTestId(SIGNUP_SELECTORS.organizationNameTextField)
13545
- .fill(businessName);
13546
- const fetchSubdomainAvailability = this.neetoPlaywrightUtilities.interceptMultipleResponses({
13547
- responseUrl: ROUTES.subdomainAvailability,
13548
- timeout: 60 * 1000,
13549
- baseUrl: NEETO_AUTH_BASE_URL(),
13550
- });
13551
- await this.page
13552
- .getByTestId(SIGNUP_SELECTORS.subdomainNameTextField)
13553
- .fill(subdomainName);
13554
- await fetchSubdomainAvailability;
13555
- const subdomainError = this.page.getByTestId(SIGNUP_SELECTORS.subdomainError);
13556
- const subdomainErrorCount = await subdomainError.count();
13557
- if (subdomainErrorCount !== 0) {
13558
- await this.updateSubdomainIfExists(appNameInLowerCase);
13559
- }
13560
- const fetchProfile = this.neetoPlaywrightUtilities.interceptMultipleResponses({
13561
- times: 2,
13562
- timeout: 60 * 1000,
13563
- baseUrl: NEETO_AUTH_BASE_URL(),
13564
- });
13565
- await this.page
13566
- .getByTestId(SIGNUP_SELECTORS.organizationSubmitButton)
13567
- .click();
13568
- await fetchProfile;
13569
- await this.page.waitForURL(`**${ROUTES.profile}`, { timeout: 60 * 1000 });
13570
- await this.page
13571
- .getByTestId(SIGNUP_SELECTORS.firstNameTextField)
13572
- .fill(firstName);
13573
- await this.page
13574
- .getByTestId(SIGNUP_SELECTORS.lastNameTextField)
13575
- .fill(lastName);
13576
- await this.page.getByTestId(COMMON_SELECTORS.checkbox).click();
13577
- const submitProfile = this.neetoPlaywrightUtilities.interceptMultipleResponses({
13578
- responseUrl: ROUTES.signup,
13579
- timeout: 1000 * 60,
13580
- baseUrl: NEETO_AUTH_BASE_URL(),
13579
+ await this.fillOrganizationDetails({
13580
+ credentials: {
13581
+ firstName,
13582
+ lastName,
13583
+ email,
13584
+ currentUserName: email,
13585
+ businessName,
13586
+ subdomainName,
13587
+ domain: appNameInLowerCase,
13588
+ },
13589
+ appName: appNameInLowerCase,
13581
13590
  });
13582
- await this.page.getByTestId(SIGNUP_SELECTORS.profileSubmitButton).click();
13583
- await submitProfile;
13584
13591
  await this.page.waitForURL(new RegExp(getGlobalUserState().domain), {
13585
13592
  waitUntil: "load",
13586
13593
  });
@@ -13649,6 +13656,106 @@ class OrganizationPage {
13649
13656
  }
13650
13657
  }
13651
13658
  };
13659
+ this.loginViaSSO = async (email = generateRandomBypassEmail()) => {
13660
+ await this.page.getByTestId(LOGIN_SELECTORS.emailTextField).fill(email);
13661
+ await test$1.expect(async () => {
13662
+ await this.page.getByTestId(LOGIN_SELECTORS.submitButton).click();
13663
+ await test$1.expect(this.page.getByTestId(SIGNUP_SELECTORS.unregisterdEmailError)).toBeHidden();
13664
+ }).toPass({ timeout: 15000 });
13665
+ await this.page
13666
+ .getByTestId(SIGNUP_SELECTORS.otpTextBox)
13667
+ .fill(faker.faker.string.numeric(6));
13668
+ };
13669
+ this.setupProfile = async ({ firstName = faker.faker.person.firstName(), lastName = faker.faker.person.lastName(), } = {}) => {
13670
+ await this.page
13671
+ .getByTestId(SIGNUP_SELECTORS.firstNameTextField)
13672
+ .fill(firstName);
13673
+ await this.page
13674
+ .getByTestId(SIGNUP_SELECTORS.lastNameTextField)
13675
+ .fill(lastName);
13676
+ await this.page.getByTestId(COMMON_SELECTORS.checkbox).click();
13677
+ const submitProfile = this.neetoPlaywrightUtilities.interceptMultipleResponses({
13678
+ customPageContext: this.page,
13679
+ responseUrl: ROUTES.signup,
13680
+ baseUrl: NEETO_AUTH_BASE_URL(),
13681
+ timeout: 60000,
13682
+ });
13683
+ await this.page.getByTestId(SIGNUP_SELECTORS.profileSubmitButton).click();
13684
+ await submitProfile;
13685
+ await test$1.expect(this.page.getByTestId(COMMON_SELECTORS.pageLoader)).toBeHidden();
13686
+ };
13687
+ this.loginAndOnboard = async ({ email, firstName, lastName, handleOnboarding, }) => {
13688
+ await this.page.goto(ROUTES.admin);
13689
+ await this.loginViaSSO(email);
13690
+ await this.setupProfile({ firstName, lastName });
13691
+ await this.page.waitForURL(new RegExp(getGlobalUserState().domain), {
13692
+ waitUntil: "load",
13693
+ });
13694
+ await handleOnboarding();
13695
+ };
13696
+ this.signUp = async ({ credentials, fetchOtpFromEmail, appName, }) => {
13697
+ let otp = "123456";
13698
+ await this.page.goto(`${ROUTES.neetoAuthSignup}?redirect_uri=${credentials.domain}`);
13699
+ await this.page
13700
+ .getByTestId(SIGNUP_SELECTORS.emailTextField)
13701
+ .fill(credentials.email);
13702
+ const signup = this.neetoPlaywrightUtilities.interceptMultipleResponses({
13703
+ responseUrl: ROUTES.signup,
13704
+ timeout: 60 * 1000,
13705
+ baseUrl: NEETO_AUTH_BASE_URL(),
13706
+ });
13707
+ await this.page.getByTestId(SIGNUP_SELECTORS.submitButton).click();
13708
+ await signup;
13709
+ if (fetchOtpFromEmail !== undefined) {
13710
+ otp = await fetchOtpFromEmail({
13711
+ email: credentials.email,
13712
+ timeout: 4 * 60 * 1000,
13713
+ });
13714
+ }
13715
+ await this.page.getByTestId(SIGNUP_SELECTORS.otpTextBox).fill(otp);
13716
+ await this.fillOrganizationDetails({
13717
+ credentials,
13718
+ appName,
13719
+ });
13720
+ await this.page.waitForURL(new RegExp(credentials.domain));
13721
+ const STORAGE_STATE = await this.page.context().storageState();
13722
+ return { STORAGE_STATE, baseURL: process.env.BASE_URL };
13723
+ };
13724
+ this.fillOrganizationDetails = async ({ credentials, appName, }) => {
13725
+ await this.page
13726
+ .getByTestId(SIGNUP_SELECTORS.organizationNameTextField)
13727
+ .fill(credentials.businessName);
13728
+ const fetchSubdomainAvailability = this.neetoPlaywrightUtilities.interceptMultipleResponses({
13729
+ responseUrl: ROUTES.subdomainAvailability,
13730
+ timeout: 60 * 1000,
13731
+ baseUrl: NEETO_AUTH_BASE_URL(),
13732
+ });
13733
+ await this.page
13734
+ .getByTestId(SIGNUP_SELECTORS.subdomainNameTextField)
13735
+ .fill(credentials.subdomainName);
13736
+ await fetchSubdomainAvailability;
13737
+ const subdomainError = this.page.getByTestId(SIGNUP_SELECTORS.subdomainError);
13738
+ const subdomainErrorCount = await subdomainError.count();
13739
+ if (subdomainErrorCount !== 0) {
13740
+ await this.updateSubdomainIfExists(appName);
13741
+ }
13742
+ const fetchProfile = this.neetoPlaywrightUtilities.interceptMultipleResponses({
13743
+ times: 2,
13744
+ timeout: 60 * 1000,
13745
+ baseUrl: NEETO_AUTH_BASE_URL(),
13746
+ });
13747
+ await this.page
13748
+ .getByTestId(SIGNUP_SELECTORS.organizationSubmitButton)
13749
+ .click();
13750
+ await fetchProfile;
13751
+ await this.page.waitForURL(`**${ROUTES.profile}`, {
13752
+ timeout: 60 * 1000,
13753
+ });
13754
+ await this.setupProfile({
13755
+ firstName: credentials.firstName,
13756
+ lastName: credentials.lastName,
13757
+ });
13758
+ };
13652
13759
  this.page = page;
13653
13760
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
13654
13761
  }
@@ -13732,18 +13839,6 @@ const NEETO_FILTERS_SELECTORS = {
13732
13839
  paneModalCrossIcon: "neeto-filters-close-button",
13733
13840
  };
13734
13841
 
13735
- const LOGIN_SELECTORS = {
13736
- appleAuthenticationButton: "apple-authentication-button",
13737
- emailTextField: "login-email-text-field",
13738
- googleAuthenticationButton: "google-authentication-button",
13739
- githubAuthenticationButton: "github-authentication-button",
13740
- loginViaEmailButton: "login-via-email-button",
13741
- passwordTextField: "login-password-text-field",
13742
- rememberMeCheckBox: "login-remember-me-check-box",
13743
- submitButton: "login-submit-button",
13744
- twitterAuthenticationButton: "twitter-authentication-button",
13745
- };
13746
-
13747
13842
  const MEMBER_SELECTORS = {
13748
13843
  membersTab: "members-nav-tab",
13749
13844
  newButton: "ntm-add-member-button",
@@ -13847,29 +13942,6 @@ const initializeCredentials = (product) => {
13847
13942
  }
13848
13943
  };
13849
13944
 
13850
- const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/", }) => {
13851
- if (shouldSkipSetupAndTeardown())
13852
- return;
13853
- await page.goto(loginPath);
13854
- await page.getByTestId("login-email-text-field").fill(CREDENTIALS.email);
13855
- await page
13856
- .getByTestId("login-password-text-field")
13857
- .fill(CREDENTIALS.password);
13858
- const login = neetoPlaywrightUtilities.interceptMultipleResponses({
13859
- times: 1,
13860
- });
13861
- await page.getByTestId(LOGIN_SELECTORS.submitButton).click();
13862
- await login;
13863
- const userCredentials = readFileSyncIfExists();
13864
- await page.context().storageState({ path: STORAGE_STATE });
13865
- const mergedCredentials = ramda.mergeAll([readFileSyncIfExists(), userCredentials]);
13866
- writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
13867
- updateCredentials({ key: "isLoggedIn", value: "true" });
13868
- };
13869
- const login = async ({ page, neetoPlaywrightUtilities, loginPath, }) => !IS_STAGING_ENV &&
13870
- (await loginWithoutSSO({ page, neetoPlaywrightUtilities, loginPath }));
13871
- const generateRandomBypassEmail = () => `cpt${process.env.OTP_BYPASS_KEY}+${faker.faker.number.int()}@bigbinary.com`;
13872
-
13873
13945
  const addMemberViaRequest = ({ email, role = MEMBER_TEXTS.agent, appName, neetoPlaywrightUtilities, }) => neetoPlaywrightUtilities.apiRequest({
13874
13946
  method: "post",
13875
13947
  url: API_ROUTES.teamMembers.index,