@bigbinary/neeto-playwright-commons 1.22.26 → 1.22.28

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
@@ -119,6 +119,7 @@ const THIRD_PARTY_ROUTES = {
119
119
  challengeSelection: "https://accounts.google.com/v3/signin/challenge/selection",
120
120
  myAccount: "https://myaccount.google.com/",
121
121
  chooseAccount: "accounts.google.com/o/oauth2/auth/oauthchooseaccount",
122
+ accountchooser: "accounts.google.com/v3/signin/accountchooser",
122
123
  consentScreen: "accounts.google.com/signin/oauth/consent",
123
124
  warningScreen: "accounts.google.com/signin/oauth/warning",
124
125
  additionalInfoScreen: "accounts.google.com/signin/oauth/id",
@@ -4515,18 +4516,20 @@ class CustomCommands {
4515
4516
  await test$1.expect(filtersSearchTermBlock).toBeHidden();
4516
4517
  }
4517
4518
  };
4518
- this.saveChanges = ({ isPane = false, customPageContext = this.page, closeAfterVerification = true, } = {}) => {
4519
+ this.saveChanges = ({ isPane = false, customPageContext = this.page, closeAfterVerification = true, toastMessage = "", } = {}) => {
4519
4520
  const pane = customPageContext.getByTestId(COMMON_SELECTORS.backdrop);
4520
4521
  const baseLocator = isPane ? pane : customPageContext;
4521
4522
  return Promise.all([
4522
- baseLocator
4523
- .getByTestId(COMMON_SELECTORS.saveChangesButton)
4524
- .click({ timeout: 10000 }),
4523
+ this.clickButtonAndAwaitLoad({
4524
+ locator: baseLocator.getByTestId(COMMON_SELECTORS.saveChangesButton),
4525
+ timeout: 10000,
4526
+ }),
4525
4527
  // eslint-disable-next-line playwright/missing-playwright-await
4526
4528
  isPane && test$1.expect(pane).toBeHidden({ timeout: 10000 }),
4527
4529
  this.verifyToast({
4528
4530
  closeAfterVerification,
4529
4531
  customPageContext,
4532
+ message: toastMessage,
4530
4533
  timeout: 20000,
4531
4534
  }),
4532
4535
  ]);
@@ -4608,6 +4611,17 @@ class CustomCommands {
4608
4611
  test$1.expect(cardLocator.getByTestId(ADMIN_PANEL_SELECTORS.settingsItemDescription)).toHaveText(description),
4609
4612
  test$1.expect(this.page.getByTestId(COMMON_SELECTORS.sidebarSubLink(title))).toHaveCSS("background-color", COLOR.transparent),
4610
4613
  ]);
4614
+ this.clickButtonAndAwaitLoad = async ({ locator, timeout, }) => {
4615
+ await locator.click({ timeout });
4616
+ await test$1.expect(locator.getByTestId(COMMON_SELECTORS.uiSpinner)).toBeHidden({
4617
+ timeout: 35000,
4618
+ });
4619
+ };
4620
+ this.toggleElement = ({ locator, shouldBeChecked = true }) => test$1.expect(async () => {
4621
+ const isChecked = await locator.isChecked();
4622
+ isChecked !== shouldBeChecked && (await locator.click());
4623
+ await test$1.expect(locator).toBeChecked({ checked: shouldBeChecked });
4624
+ }).toPass({ timeout: 15000 });
4611
4625
  this.page = page;
4612
4626
  this.responses = [];
4613
4627
  this.request = request;
@@ -179855,7 +179869,7 @@ const commands = {
179855
179869
  await use(commands);
179856
179870
  },
179857
179871
  page: async ({ page }, use) => {
179858
- await page.goto("/", { timeout: 20000 });
179872
+ await page.goto("/", { timeout: 35000 });
179859
179873
  await page.waitForLoadState();
179860
179874
  await use(page);
179861
179875
  },
@@ -191452,9 +191466,14 @@ class GooglePage extends IntegrationBase {
191452
191466
  integration,
191453
191467
  integrationRouteIndex,
191454
191468
  });
191469
+ this.waitForGoogleAuthURL = async () => {
191470
+ await this.page.waitForLoadState("load", { timeout: 25000 });
191471
+ await this.page.waitForURL(new RegExp(`${THIRD_PARTY_ROUTES.google.accountchooser}|${THIRD_PARTY_ROUTES.google.chooseAccount}`));
191472
+ };
191455
191473
  this.connectGoogleAccount = async (appName) => {
191456
- await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.chooseAccount));
191474
+ await this.waitForGoogleAuthURL();
191457
191475
  await this.selectGoogleAccount(appName);
191476
+ await this.page.waitForLoadState("load", { timeout: 25000 });
191458
191477
  await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.consentScreen));
191459
191478
  await this.page
191460
191479
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.allow })
@@ -191483,19 +191502,20 @@ class GooglePage extends IntegrationBase {
191483
191502
  await test$1.expect(signInHeading).toBeHidden({ timeout: 10000 });
191484
191503
  };
191485
191504
  this.loginToGoogle = async () => {
191505
+ if (ramda.isNil(process.env.GOOGLE_LOGIN_EMAIL) ||
191506
+ ramda.isNil(process.env.GOOGLE_LOGIN_PASSWORD)) {
191507
+ throw new Error("ENV variable GOOGLE_LOGIN_EMAIL or GOOGLE_LOGIN_PASSWORD is not properly configured");
191508
+ }
191486
191509
  await this.page.goto(THIRD_PARTY_ROUTES.google.signin, { timeout: 20000 });
191487
- if (!ramda.isNotNil(process.env.GOOGLE_LOGIN_EMAIL))
191488
- return;
191489
191510
  await this.page
191490
191511
  .getByLabel(GOOGLE_LOGIN_TEXTS.emailOrPhone)
191491
191512
  .pressSequentially(process.env.GOOGLE_LOGIN_EMAIL, { delay: 10 });
191492
191513
  await this.page
191493
191514
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.next })
191494
191515
  .click();
191516
+ await this.page.waitForLoadState("load", { timeout: 25000 });
191495
191517
  await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.password));
191496
191518
  await test$1.expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.showPassword)).toBeVisible();
191497
- if (!ramda.isNotNil(process.env.GOOGLE_LOGIN_PASSWORD))
191498
- return;
191499
191519
  await this.page
191500
191520
  .getByLabel(GOOGLE_LOGIN_TEXTS.enterYourPassword)
191501
191521
  .pressSequentially(process.env.GOOGLE_LOGIN_PASSWORD, { delay: 10 });
@@ -191507,6 +191527,7 @@ class GooglePage extends IntegrationBase {
191507
191527
  (await this.page
191508
191528
  .locator(GOOGLE_LOGIN_SELECTORS.totpChallengeSelector)
191509
191529
  .click());
191530
+ await this.page.waitForLoadState("load", { timeout: 25000 });
191510
191531
  await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.totpChallenge));
191511
191532
  const twoStepVerification = this.page.locator("form").getByRole("heading", {
191512
191533
  name: GOOGLE_LOGIN_TEXTS.twoStepVerification,
@@ -191515,18 +191536,17 @@ class GooglePage extends IntegrationBase {
191515
191536
  });
191516
191537
  await test$1.expect(twoStepVerification).toBeVisible();
191517
191538
  await this.enterTotpCode(twoStepVerification);
191518
- await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.myAccount), { waitUntil: "load" });
191519
- };
191520
- this.enterTotpCode = async (locator) => {
191521
- await test$1.expect(async () => {
191522
- const totpToken = this.totp.generate({ timestamp: Date.now() + 5000 });
191523
- await this.page.getByLabel(GOOGLE_LOGIN_TEXTS.enterCode).fill(totpToken);
191524
- test$1.expect(this.totp.validate({ token: totpToken })).not.toBeNull();
191525
- await this.page.locator(GOOGLE_LOGIN_SELECTORS.totpNext).click();
191526
- await test$1.expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)).toBeHidden({ timeout: 15000 });
191527
- await test$1.expect(locator).toBeHidden({ timeout: 10000 });
191528
- }).toPass({ timeout: 50000 });
191539
+ await this.page.waitForLoadState("load", { timeout: 25000 });
191540
+ await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.myAccount));
191529
191541
  };
191542
+ this.enterTotpCode = (locator) => test$1.expect(async () => {
191543
+ const totpToken = this.totp.generate({ timestamp: Date.now() + 5000 });
191544
+ await this.page.getByLabel(GOOGLE_LOGIN_TEXTS.enterCode).fill(totpToken);
191545
+ test$1.expect(this.totp.validate({ token: totpToken })).not.toBeNull();
191546
+ await this.page.locator(GOOGLE_LOGIN_SELECTORS.totpNext).click();
191547
+ await test$1.expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)).toBeHidden({ timeout: 15000 });
191548
+ await test$1.expect(locator).toBeHidden({ timeout: 10000 });
191549
+ }).toPass({ timeout: 50000 });
191530
191550
  this.logoutFromGoogle = async () => {
191531
191551
  await this.page.goto(THIRD_PARTY_ROUTES.google.myAccount, {
191532
191552
  timeout: 20000,
@@ -191564,16 +191584,16 @@ class GooglePage extends IntegrationBase {
191564
191584
  .click({ timeout: 20000 });
191565
191585
  };
191566
191586
  this.handleNotVerifiedPage = async () => {
191567
- const continueUnsafeButton = this.page.getByRole("button", {
191587
+ if (!this.page.url().includes(THIRD_PARTY_ROUTES.google.warningScreen))
191588
+ return;
191589
+ await this.page
191590
+ .getByRole("button", {
191568
191591
  name: GOOGLE_LOGIN_TEXTS.continue,
191569
- });
191570
- const backToSafety = this.page.getByRole("button", {
191592
+ })
191593
+ .click();
191594
+ await test$1.expect(this.page.getByRole("button", {
191571
191595
  name: GOOGLE_LOGIN_TEXTS.backToSafety,
191572
- });
191573
- if (this.page.url().includes(THIRD_PARTY_ROUTES.google.warningScreen)) {
191574
- await continueUnsafeButton.click();
191575
- await test$1.expect(backToSafety).toBeHidden({ timeout: 10000 });
191576
- }
191596
+ })).toBeHidden({ timeout: 10000 });
191577
191597
  };
191578
191598
  this.totp = initializeTotp({
191579
191599
  issuer: "Google",
@@ -192864,13 +192884,13 @@ class TeamMembers {
192864
192884
  };
192865
192885
  this.addMemberViaUI = async ({ emails = [faker.faker.internet.exampleEmail()], role = "standard", } = {}) => {
192866
192886
  await this.page.getByTestId(MEMBER_SELECTORS.newButton).click();
192887
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
192867
192888
  await this.page
192868
192889
  .getByTestId(MEMBER_FORM_SELECTORS.emailTextField)
192869
192890
  .fill(emails.join(", "));
192870
- await test$1.expect(async () => {
192871
- await this.page.getByTestId(MEMBER_SELECTORS.roleLabel(role)).click();
192872
- await test$1.expect(this.page.getByTestId(MEMBER_SELECTORS.roleLabel(role))).toBeChecked();
192873
- }).toPass({ timeout: 20000 });
192891
+ await this.neetoPlaywrightUtilities.toggleElement({
192892
+ locator: this.page.getByTestId(MEMBER_SELECTORS.roleLabel(role)),
192893
+ });
192874
192894
  await this.page.getByTestId(MEMBER_SELECTORS.continueButton).click();
192875
192895
  if (IS_STAGING_ENV) {
192876
192896
  await this.page
@@ -192879,20 +192899,23 @@ class TeamMembers {
192879
192899
  .click();
192880
192900
  await this.page.getByTestId(MEMBER_SELECTORS.continueButton).click();
192881
192901
  }
192902
+ await this.submit();
192903
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
192904
+ };
192905
+ this.submit = async () => {
192882
192906
  await test$1.expect(async () => {
192883
- const submitButton = this.page.getByTestId(MEMBER_SELECTORS.submitButton);
192884
- await submitButton.click();
192885
- await test$1.expect(submitButton.locator(COMMON_SELECTORS.buttonSpinner)).toBeHidden({
192886
- timeout: 15000,
192907
+ await this.neetoPlaywrightUtilities.clickButtonAndAwaitLoad({
192908
+ locator: this.page.getByTestId(MEMBER_SELECTORS.submitButton),
192909
+ timeout: 10000,
192887
192910
  });
192888
192911
  await test$1.expect(this.page.getByTestId(COMMON_SELECTORS.paneBody)).toBeHidden();
192889
192912
  }).toPass({ timeout: 40000 });
192890
- await this.neetoPlaywrightUtilities.waitForPageLoad();
192891
192913
  await this.neetoPlaywrightUtilities.verifyToast();
192892
192914
  };
192893
192915
  this.searchAndVerifyMemberByEmail = async ({ email,
192894
192916
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
192895
192917
  interceptOptions = {}, }) => {
192918
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
192896
192919
  await this.page.getByTestId(MEMBER_SELECTORS.searchTextField).fill(email);
192897
192920
  const emailSubstr = email.length > 20 ? email.substring(0, 20) : email;
192898
192921
  await test$1.expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.searchTermBlock)).toContainText(emailSubstr);
@@ -192903,6 +192926,7 @@ class TeamMembers {
192903
192926
  this.editMemberViaUI = async ({ email = "", firstName = "", lastName = "", role = "standard", } = {}) => {
192904
192927
  await this.page.getByTestId(MEMBER_SELECTORS.dropDownIcon).click();
192905
192928
  await this.page.getByTestId(MEMBER_SELECTORS.editButton).click();
192929
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
192906
192930
  neetoCist.isPresent(email) &&
192907
192931
  (await this.page
192908
192932
  .getByTestId(MEMBER_FORM_SELECTORS.emailInput)
@@ -192915,9 +192939,10 @@ class TeamMembers {
192915
192939
  (await this.page
192916
192940
  .getByTestId(MEMBER_FORM_SELECTORS.lastNameTextField)
192917
192941
  .fill(lastName));
192918
- await this.page.getByTestId(MEMBER_SELECTORS.roleLabel(role)).click();
192919
- await this.page.getByTestId(MEMBER_SELECTORS.submitButton).click();
192920
- await this.neetoPlaywrightUtilities.verifyToast();
192942
+ await this.neetoPlaywrightUtilities.toggleElement({
192943
+ locator: this.page.getByTestId(MEMBER_SELECTORS.roleLabel(role)),
192944
+ });
192945
+ await this.submit();
192921
192946
  await this.neetoPlaywrightUtilities.waitForPageLoad();
192922
192947
  };
192923
192948
  this.removeMemberViaUI = async () => {
@@ -198817,6 +198842,7 @@ const definePlaywrightConfig = (overrides) => {
198817
198842
  testIdAttribute: "data-cy",
198818
198843
  trace: "on",
198819
198844
  screenshot: "on",
198845
+ navigationTimeout: 35000,
198820
198846
  video: "on",
198821
198847
  actionTimeout: 10 * 1000,
198822
198848
  timezoneId: "Asia/Calcutta",