@bigbinary/neeto-playwright-commons 1.22.34 → 1.22.36

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.d.ts CHANGED
@@ -1886,15 +1886,18 @@ type GooglePageParams = {
1886
1886
  neetoPlaywrightUtilities: CustomCommands;
1887
1887
  integration: string;
1888
1888
  integrationRouteIndex?: string;
1889
+ appName?: string;
1889
1890
  };
1890
1891
  declare class GooglePage extends IntegrationBase {
1891
1892
  totp: TOTP;
1892
1893
  t: TFunction;
1894
+ appName: string;
1893
1895
  constructor({
1894
1896
  page,
1895
1897
  neetoPlaywrightUtilities,
1896
1898
  integration,
1897
- integrationRouteIndex
1899
+ integrationRouteIndex,
1900
+ appName
1898
1901
  }: GooglePageParams);
1899
1902
  waitForGoogleAuthURL: () => Promise<void>;
1900
1903
  /**
@@ -1908,7 +1911,7 @@ declare class GooglePage extends IntegrationBase {
1908
1911
  * await googlePage.connectGoogleAccount("neetoForm");
1909
1912
  * @endexample
1910
1913
  */
1911
- connectGoogleAccount: (appName: string) => Promise<void>;
1914
+ connectGoogleAccount: (appName?: string) => Promise<void>;
1912
1915
  /**
1913
1916
  *
1914
1917
  * Selects the Google account to be used during the integration. If a verification code is required (e.g., for 2FA), it enters the TOTP code.
@@ -1920,7 +1923,7 @@ declare class GooglePage extends IntegrationBase {
1920
1923
  * await googlePage.selectGoogleAccount("neetoForm");
1921
1924
  * @endexample
1922
1925
  */
1923
- selectGoogleAccount: (appName: string) => Promise<void>;
1926
+ selectGoogleAccount: (appName?: string) => Promise<void>;
1924
1927
  /**
1925
1928
  *
1926
1929
  * Automates the login process to a Google account, filling in the email, password, and handling 2FA (Two-Factor Authentication) via TOTP.
@@ -1973,6 +1976,16 @@ declare class GooglePage extends IntegrationBase {
1973
1976
  allowPermissions
1974
1977
  }?: Partial<StagingConsentFlowParams>) => Promise<void>;
1975
1978
  private handleNotVerifiedPage;
1979
+ /**
1980
+ *
1981
+ * Revokes permissions for the Google integration by navigating to Google's connections page and removing the application connection. This method handles the complete flow of disconnecting the app from Google's side.
1982
+ *
1983
+ * @example
1984
+ *
1985
+ * await googlePage.revokePermissions();
1986
+ * @endexample
1987
+ */
1988
+ revokePermissions: () => Promise<void>;
1976
1989
  }
1977
1990
  type AsyncNoArgsFunction = () => Promise<void>;
1978
1991
  type RedirectUrl = string | RegExp | ((url: URL) => boolean);
@@ -3515,7 +3528,7 @@ declare class ApiKeysPage {
3515
3528
  deleteApiKey: (targetRow: Locator) => Promise<void>;
3516
3529
  }
3517
3530
  interface VerifyAuditLogProps {
3518
- targetRow: Locator;
3531
+ targetRow?: Locator;
3519
3532
  action: string;
3520
3533
  date: string;
3521
3534
  adminName: string;
@@ -3528,12 +3541,58 @@ interface VerifyDataInPaneProps {
3528
3541
  lastName?: string;
3529
3542
  roleName?: string;
3530
3543
  }
3544
+ interface VerifyAuditLogEntryProps {
3545
+ page?: Page;
3546
+ tableDetails: VerifyAuditLogProps;
3547
+ paneDetails: {
3548
+ values: string[];
3549
+ userDetails?: {
3550
+ firstName?: string;
3551
+ lastName?: string;
3552
+ roleName?: string;
3553
+ };
3554
+ };
3555
+ }
3531
3556
  declare class AuditLogsPage {
3532
3557
  page: Page;
3533
3558
  neetoPlaywrightUtilities: CustomCommands;
3534
3559
  t: TFunction;
3535
3560
  targetRow: Locator;
3536
3561
  constructor(page: Page, neetoPlaywrightUtilities: CustomCommands);
3562
+ /**
3563
+ *
3564
+ * Used to verify both the audit log table entry and the detailed information in the pane. This method combines verifyAuditLog and verifyDataInPane for comprehensive verification.
3565
+ *
3566
+ * page (optional): The custom page context. Default is POM's page.
3567
+ *
3568
+ * tableDetails (required): Object containing details for table verification.
3569
+ *
3570
+ * @example
3571
+ *
3572
+ * await auditLogsPage.verifyAuditLogEntry({
3573
+ * page,
3574
+ * tableDetails: {
3575
+ * targetRow: page.getByRole("row"),
3576
+ * action: "Updated user",
3577
+ * date: "Nov 27, 2024",
3578
+ * adminName: "Oliver Smith"
3579
+ * },
3580
+ * paneDetails: {
3581
+ * values: ["johnluther@example.com"],
3582
+ * userDetails: {
3583
+ * firstName: "John",
3584
+ * lastName: "Luther",
3585
+ * roleName: "Agent"
3586
+ * }
3587
+ * }
3588
+ * });
3589
+ * @endexample
3590
+ */
3591
+ verifyAuditLogEntry: ({
3592
+ page,
3593
+ tableDetails,
3594
+ paneDetails
3595
+ }: VerifyAuditLogEntryProps) => Promise<void>;
3537
3596
  /**
3538
3597
  *
3539
3598
  * Used to verify the values in the audit logs table.
@@ -4424,6 +4483,7 @@ declare const THIRD_PARTY_ROUTES: {
4424
4483
  signin: string;
4425
4484
  password: string;
4426
4485
  totpChallenge: string;
4486
+ connections: string;
4427
4487
  challengeSelection: string;
4428
4488
  myAccount: string;
4429
4489
  chooseAccount: string;
@@ -4681,6 +4741,7 @@ declare const GOOGLE_LOGIN_TEXTS: {
4681
4741
  connectYourGoogleAccount: string;
4682
4742
  signInWithGoogle: string;
4683
4743
  signInHeading: (appName: string) => RegExp;
4744
+ stagingAppName: (appName: string) => string;
4684
4745
  continue: string;
4685
4746
  selectAll: string;
4686
4747
  appNotVerified: string;
package/index.js CHANGED
@@ -96,6 +96,7 @@ const THIRD_PARTY_ROUTES = {
96
96
  signin: "https://accounts.google.com/v3/signin/identifier?hl=en-gb&ifkv=ASKXGp0nW770RS7xin2puSwbGDpGCeaVKDtCgfpEU73fYmhMKbqUjukBQ5x8kdvEVxQ7OvcrnUo8sg&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S688843923%3A1704795906762870&theme=glif",
97
97
  password: "https://accounts.google.com/v3/signin/challenge/pwd",
98
98
  totpChallenge: "https://accounts.google.com/v3/signin/challenge/totp",
99
+ connections: "https://myaccount.google.com/connections",
99
100
  challengeSelection: "https://accounts.google.com/v3/signin/challenge/selection",
100
101
  myAccount: "https://myaccount.google.com/",
101
102
  chooseAccount: "accounts.google.com/o/oauth2/auth/oauthchooseaccount",
@@ -189403,6 +189404,7 @@ const GOOGLE_LOGIN_TEXTS = {
189403
189404
  connectYourGoogleAccount: "Connect your Google account",
189404
189405
  signInWithGoogle: "Sign in with Google",
189405
189406
  signInHeading: (appName) => new RegExp(`(You’re signing back in to ${appName}\\.net|Sign in to ${appName}\\.net)`, "i"),
189407
+ stagingAppName: (appName) => `${appName} - Staging`,
189406
189408
  continue: "Continue",
189407
189409
  selectAll: "Select All",
189408
189410
  appNotVerified: "Google hasn’t verified this app",
@@ -191679,7 +191681,7 @@ class IntegrationBase {
191679
191681
  }
191680
191682
 
191681
191683
  class GooglePage extends IntegrationBase {
191682
- constructor({ page, neetoPlaywrightUtilities, integration, integrationRouteIndex, }) {
191684
+ constructor({ page, neetoPlaywrightUtilities, integration, integrationRouteIndex, appName, }) {
191683
191685
  var _a;
191684
191686
  super({
191685
191687
  page,
@@ -191691,7 +191693,7 @@ class GooglePage extends IntegrationBase {
191691
191693
  await this.page.waitForLoadState("load", { timeout: 25000 });
191692
191694
  await this.page.waitForURL(new RegExp(`${THIRD_PARTY_ROUTES.google.accountchooser}|${THIRD_PARTY_ROUTES.google.chooseAccount}`));
191693
191695
  };
191694
- this.connectGoogleAccount = async (appName) => {
191696
+ this.connectGoogleAccount = async (appName = this.appName) => {
191695
191697
  await this.waitForGoogleAuthURL();
191696
191698
  await this.selectGoogleAccount(appName);
191697
191699
  await this.page.waitForLoadState("load", { timeout: 25000 });
@@ -191700,7 +191702,7 @@ class GooglePage extends IntegrationBase {
191700
191702
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.allow })
191701
191703
  .click();
191702
191704
  };
191703
- this.selectGoogleAccount = async (appName) => {
191705
+ this.selectGoogleAccount = async (appName = this.appName) => {
191704
191706
  const chooseAnAccountHeading = this.page.getByText(GOOGLE_LOGIN_TEXTS.chooseAnAccount, { exact: true });
191705
191707
  await expect(chooseAnAccountHeading).toBeVisible({ timeout: 10000 });
191706
191708
  await this.page
@@ -191816,11 +191818,28 @@ class GooglePage extends IntegrationBase {
191816
191818
  name: GOOGLE_LOGIN_TEXTS.backToSafety,
191817
191819
  })).toBeHidden({ timeout: 10000 });
191818
191820
  };
191821
+ this.revokePermissions = async () => {
191822
+ const stagingAppName = GOOGLE_LOGIN_TEXTS.stagingAppName(this.appName);
191823
+ await this.page.goto(THIRD_PARTY_ROUTES.google.connections);
191824
+ await this.page.waitForLoadState("load", { timeout: 15000 });
191825
+ const app = this.page.getByRole("link", { name: stagingAppName });
191826
+ if (await app.isHidden())
191827
+ return;
191828
+ await app.click();
191829
+ await this.page
191830
+ .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.deleteConnections })
191831
+ .click();
191832
+ await this.page
191833
+ .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.confirm })
191834
+ .click();
191835
+ await expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.noLongerConnected)).toBeVisible();
191836
+ };
191837
+ this.t = getI18nInstance().t;
191838
+ this.appName = appName !== null && appName !== void 0 ? appName : "";
191819
191839
  this.totp = initializeTotp({
191820
191840
  issuer: "Google",
191821
191841
  secret: (_a = process.env.GOOGLE_2FA_SECRET_KEY) !== null && _a !== void 0 ? _a : "",
191822
191842
  });
191823
- this.t = getI18nInstance().t;
191824
191843
  }
191825
191844
  }
191826
191845
 
@@ -193579,36 +193598,46 @@ class ApiKeysPage {
193579
193598
 
193580
193599
  class AuditLogsPage {
193581
193600
  constructor(page, neetoPlaywrightUtilities) {
193601
+ this.page = page;
193602
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
193603
+ this.verifyAuditLogEntry = async ({ page = this.page, tableDetails, paneDetails, }) => {
193604
+ await this.verifyAuditLog(tableDetails);
193605
+ await this.verifyDataInPane({
193606
+ ...paneDetails,
193607
+ page,
193608
+ action: tableDetails.action,
193609
+ });
193610
+ };
193582
193611
  this.verifyAuditLog = async ({ targetRow, action, date, adminName, }) => {
193583
- this.targetRow = targetRow;
193584
- await expect(targetRow.getByRole("cell", { name: action })).toBeVisible();
193585
- await expect(targetRow.getByRole("cell", {
193586
- name: this.t("neetoMolecules.common.success"),
193587
- })).toBeVisible();
193588
- await expect(targetRow.getByRole("cell", { name: adminName })).toBeVisible();
193589
- await expect(targetRow.getByRole("cell", { name: date })).toBeVisible();
193612
+ if (targetRow) {
193613
+ this.targetRow = targetRow;
193614
+ }
193615
+ await Promise.all([action, this.t("neetoMolecules.common.success"), adminName, date].map(name => expect(this.targetRow.getByRole("cell", { name })).toBeVisible()));
193590
193616
  };
193591
193617
  this.verifyDataInPane = async ({ page = this.page, action, values, firstName, lastName, roleName, }) => {
193592
- await this.targetRow.getByText(action).click();
193593
- await Promise.all(values.map(value => expect(page.getByTestId(COMMON_SELECTORS.paneBody).getByText(value)).toBeVisible()));
193594
193618
  const rowInPane = page
193595
193619
  .getByTestId(COMMON_SELECTORS.paneBody)
193596
193620
  .getByRole("row");
193597
- firstName &&
193598
- (await expect(rowInPane
193599
- .filter({ hasText: this.t("neetoTeamMembers.labels.firstName") })
193600
- .getByText(firstName)).toBeVisible());
193601
- lastName &&
193602
- (await expect(rowInPane
193603
- .filter({ hasText: this.t("neetoTeamMembers.labels.lastName") })
193604
- .getByText(lastName)).toBeVisible());
193605
- roleName &&
193606
- (await expect(rowInPane
193607
- .filter({ hasText: AUDIT_LOGS_TEXTS.organizationRole })
193608
- .getByText(roleName)).toBeVisible());
193621
+ await this.targetRow.getByText(action).click();
193622
+ await Promise.all([
193623
+ ...values.map(value => expect(page.getByTestId(COMMON_SELECTORS.paneBody).getByText(value)).toBeVisible()),
193624
+ firstName &&
193625
+ // eslint-disable-next-line playwright/missing-playwright-await
193626
+ expect(rowInPane
193627
+ .filter({ hasText: this.t("neetoTeamMembers.labels.firstName") })
193628
+ .getByText(firstName)).toBeVisible(),
193629
+ lastName &&
193630
+ // eslint-disable-next-line playwright/missing-playwright-await
193631
+ expect(rowInPane
193632
+ .filter({ hasText: this.t("neetoTeamMembers.labels.lastName") })
193633
+ .getByText(lastName)).toBeVisible(),
193634
+ roleName &&
193635
+ // eslint-disable-next-line playwright/missing-playwright-await
193636
+ expect(rowInPane
193637
+ .filter({ hasText: AUDIT_LOGS_TEXTS.organizationRole })
193638
+ .getByText(roleName)).toBeVisible(),
193639
+ ]);
193609
193640
  };
193610
- this.page = page;
193611
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
193612
193641
  this.t = getI18nInstance().t;
193613
193642
  }
193614
193643
  }