@bigbinary/neeto-playwright-commons 1.11.13 → 1.11.15

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
@@ -3599,23 +3599,23 @@ class CustomCommands {
3599
3599
  })}`;
3600
3600
  return await this.request[method](formattedUrl, requestOptions);
3601
3601
  };
3602
- this.selectOptionFromDropdown = async ({ selectValueContainer, selectMenu, value, options = {}, }) => {
3602
+ this.selectOptionFromDropdown = async ({ selectValueContainer = COMMON_SELECTORS.selectValueContainer, selectMenu = COMMON_SELECTORS.dropdownMenu, value, page = this.page, options = {}, }) => {
3603
3603
  Object.assign({
3604
3604
  visibilityTimeout: 2000,
3605
3605
  textAssertionTimeout: 1000,
3606
3606
  retryTimeout: 20000,
3607
3607
  }, options);
3608
3608
  await test$1.expect(async () => {
3609
- await this.page.getByTestId(selectValueContainer).click();
3610
- await test$1.expect(this.page.getByTestId(selectMenu)).toBeVisible({
3609
+ await page.getByTestId(selectValueContainer).click();
3610
+ await test$1.expect(page.getByTestId(selectMenu)).toBeVisible({
3611
3611
  timeout: options.visibilityTimeout,
3612
3612
  });
3613
- await this.page.keyboard.type(value);
3614
- await this.page
3613
+ await page.keyboard.type(value);
3614
+ await page
3615
3615
  .getByTestId(selectMenu)
3616
3616
  .getByText(value, { exact: true })
3617
3617
  .click();
3618
- await test$1.expect(this.page.getByTestId(selectValueContainer)).toContainText(value, { timeout: options.textAssertionTimeout });
3618
+ await test$1.expect(page.getByTestId(selectValueContainer)).toContainText(value, { timeout: options.textAssertionTimeout });
3619
3619
  }).toPass({ timeout: options.retryTimeout });
3620
3620
  };
3621
3621
  this.verifyFieldValue = values => {
@@ -13131,7 +13131,7 @@ const GOOGLE_LOGIN_TEXTS = {
13131
13131
  googleAccount: "Google Account:",
13132
13132
  connectYourGoogleAccount: "Connect your Google account",
13133
13133
  signInWithGoogle: "Sign in with Google",
13134
- signInHeading: "Sign in to neetocal.net",
13134
+ signInHeading: (appName) => `Sign in to ${appName}.net`,
13135
13135
  continue: "Continue",
13136
13136
  selectAll: "Select All",
13137
13137
  appNotVerified: "Google hasn’t verified this app",
@@ -13145,6 +13145,12 @@ const GOOGLE_LOGIN_TEXTS = {
13145
13145
  signOut: "Sign out",
13146
13146
  wrongCode: "Wrong code. Try again",
13147
13147
  verificationCode: "verification code",
13148
+ confirm: "Confirm",
13149
+ cancel: "Cancel",
13150
+ deleteConnections: "Delete all connections you",
13151
+ noLongerConnected: "You’re no longer connected to",
13152
+ backToSafety: "Back to safety",
13153
+ neetoAutomation: "neeto.automation",
13148
13154
  };
13149
13155
 
13150
13156
  const HELP_CENTER_SELECTORS = {
@@ -13420,14 +13426,6 @@ class HelpAndProfilePage {
13420
13426
  }
13421
13427
  }
13422
13428
 
13423
- const INTEGRATION_SELECTORS = {
13424
- integrationCard: (integration) => `${integration}-integration-card`,
13425
- connectButton: "connect-button",
13426
- integrationStatusTag: "integration-status-tag",
13427
- disconnectButton: "disconnect-button",
13428
- manageButton: "manage-button",
13429
- };
13430
-
13431
13429
  const GOOGLE_LOGIN_SELECTORS = {
13432
13430
  totpNext: "#totpNext",
13433
13431
  form: "form",
@@ -15181,6 +15179,14 @@ const initializeTotp = ({ issuer, secret, }) => {
15181
15179
  });
15182
15180
  };
15183
15181
 
15182
+ const INTEGRATION_SELECTORS = {
15183
+ integrationCard: (integration) => `${integration}-integration-card`,
15184
+ connectButton: "connect-button",
15185
+ integrationStatusTag: "integration-status-tag",
15186
+ disconnectButton: "disconnect-button",
15187
+ manageButton: "manage-button",
15188
+ };
15189
+
15184
15190
  class IntegrationBase {
15185
15191
  constructor({ page, neetoPlaywrightUtilities, integration, connectHeader, connectedHeader, pageloaderTimeout, integrationRouteIndex, integrationRouteResponsesParams, }) {
15186
15192
  this.disconnect = async (interceptMultipleResponsesParams = {}) => {
@@ -15256,18 +15262,9 @@ class GooglePage extends IntegrationBase {
15256
15262
  integration,
15257
15263
  integrationRouteIndex,
15258
15264
  });
15259
- this.connectAndVerifyIntegration = async () => {
15260
- await this.connect();
15261
- await test$1.expect(this.page.getByRole("heading", {
15262
- name: GOOGLE_LOGIN_TEXTS.connectYourGoogleAccount,
15263
- })).toBeVisible({ timeout: 15000 });
15264
- await this.page
15265
- .getByRole("link", {
15266
- name: GOOGLE_LOGIN_TEXTS.signInWithGoogle,
15267
- })
15268
- .click();
15265
+ this.connectGoogleAccount = async (appName) => {
15269
15266
  await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.chooseAccount));
15270
- await this.selectGoogleAccount();
15267
+ await this.selectGoogleAccount(appName);
15271
15268
  if (process.env.TEST_ENV === ENVIRONMENT.staging) {
15272
15269
  await this.stagingConsentFlow();
15273
15270
  }
@@ -15277,22 +15274,26 @@ class GooglePage extends IntegrationBase {
15277
15274
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.allow })
15278
15275
  .click();
15279
15276
  }
15280
- await Promise.all([
15281
- test$1.expect(this.page.getByRole("heading", { name: this.connectedHeader })).toBeVisible({ timeout: 20000 }),
15282
- test$1.expect(this.page.getByTestId(INTEGRATION_SELECTORS.manageButton)).toBeVisible({ timeout: 20000 }),
15283
- ]);
15284
15277
  };
15285
- this.selectGoogleAccount = async () => {
15286
- await this.page.getByRole("link", { name: "neeto.automation" }).click();
15287
- try {
15288
- const verificationCode = this.page
15289
- .locator(GOOGLE_LOGIN_SELECTORS.form)
15290
- .getByText(GOOGLE_LOGIN_TEXTS.verificationCode);
15291
- await test$1.expect(verificationCode).toBeVisible({ timeout: 10000 });
15278
+ this.selectGoogleAccount = async (appName) => {
15279
+ const neetoAutomationLocator = this.page.getByRole("link", {
15280
+ name: GOOGLE_LOGIN_TEXTS.neetoAutomation,
15281
+ });
15282
+ await neetoAutomationLocator.click();
15283
+ await test$1.expect(neetoAutomationLocator).toBeHidden({ timeout: 10000 });
15284
+ const verificationCode = this.page
15285
+ .locator("form")
15286
+ .getByText(GOOGLE_LOGIN_TEXTS.verificationCode);
15287
+ if (this.page.url().includes(THIRD_PARTY_ROUTES.google.totpChallenge)) {
15292
15288
  await this.enterTotpCode(verificationCode);
15293
- // eslint-disable-next-line no-empty
15294
15289
  }
15295
- catch (error) { }
15290
+ await this.handleNotVerifiedPage();
15291
+ await test$1.expect(this.page.getByRole("heading", {
15292
+ name: GOOGLE_LOGIN_TEXTS.signInHeading(appName),
15293
+ })).toBeVisible();
15294
+ await this.page
15295
+ .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.continue })
15296
+ .click();
15296
15297
  };
15297
15298
  this.loginToGoogle = async () => {
15298
15299
  await this.page.goto(THIRD_PARTY_ROUTES.google.signin);
@@ -15315,17 +15316,20 @@ class GooglePage extends IntegrationBase {
15315
15316
  await this.page
15316
15317
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.next })
15317
15318
  .click();
15318
- await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.challengeSelection));
15319
- await this.page
15320
- .locator(GOOGLE_LOGIN_SELECTORS.totpChallengeSelector)
15321
- .click();
15319
+ if (this.page.url().includes(THIRD_PARTY_ROUTES.google.challengeSelection)) {
15320
+ await this.page
15321
+ .locator(GOOGLE_LOGIN_SELECTORS.totpChallengeSelector)
15322
+ .click();
15323
+ }
15322
15324
  await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.totpChallenge));
15323
- const twoStepVerification = this.page
15324
- .locator(GOOGLE_LOGIN_SELECTORS.form)
15325
- .getByText(GOOGLE_LOGIN_TEXTS.twoStepVerification);
15325
+ const twoStepVerification = this.page.locator("form").getByRole("heading", {
15326
+ name: GOOGLE_LOGIN_TEXTS.twoStepVerification,
15327
+ level: 2,
15328
+ exact: true,
15329
+ });
15326
15330
  await test$1.expect(twoStepVerification).toBeVisible();
15327
15331
  await this.enterTotpCode(twoStepVerification);
15328
- await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.myAccount));
15332
+ await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.myAccount), { waitUntil: "load" });
15329
15333
  };
15330
15334
  this.enterTotpCode = async (locator) => {
15331
15335
  await test$1.expect(async () => {
@@ -15333,8 +15337,8 @@ class GooglePage extends IntegrationBase {
15333
15337
  await this.page.getByLabel(GOOGLE_LOGIN_TEXTS.enterCode).fill(totpToken);
15334
15338
  test$1.expect(this.totp.validate({ token: totpToken })).not.toBeNull();
15335
15339
  await this.page.locator(GOOGLE_LOGIN_SELECTORS.totpNext).click();
15336
- await test$1.expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)).toBeHidden();
15337
- await test$1.expect(locator).toBeHidden({ timeout: 20000 });
15340
+ await test$1.expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)).toBeHidden({ timeout: 15000 });
15341
+ await test$1.expect(locator).toBeHidden({ timeout: 10000 });
15338
15342
  }).toPass({ timeout: 50000 });
15339
15343
  };
15340
15344
  this.logoutFromGoogle = async () => {
@@ -15349,28 +15353,39 @@ class GooglePage extends IntegrationBase {
15349
15353
  await this.disconnect();
15350
15354
  await this.verifyIntegrationStatus("disconnected");
15351
15355
  };
15352
- this.stagingConsentFlow = async () => {
15353
- await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.warningScreen));
15354
- await test$1.expect(this.page.getByRole("heading", {
15355
- name: GOOGLE_LOGIN_TEXTS.appNotVerified,
15356
- })).toBeVisible();
15357
- await this.page
15358
- .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.continue })
15359
- .click();
15360
- await test$1.expect(this.page.getByRole("heading", {
15361
- name: GOOGLE_LOGIN_TEXTS.signInHeading,
15362
- })).toBeVisible();
15363
- await this.page
15364
- .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.continue })
15365
- .click();
15356
+ this.stagingConsentFlow = async ({ abortFlow = false, allowPermissions = true, } = {}) => {
15357
+ await this.handleNotVerifiedPage();
15358
+ if (this.page.url().includes(THIRD_PARTY_ROUTES.google.additionalInfoScreen)) {
15359
+ await this.page
15360
+ .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.continue })
15361
+ .click({ timeout: 20000 });
15362
+ }
15366
15363
  await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.consentSummary));
15364
+ if (abortFlow) {
15365
+ await this.page
15366
+ .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.cancel })
15367
+ .click({ timeout: 20000 });
15368
+ return;
15369
+ }
15367
15370
  const selectAllPermissions = this.page.getByLabel(GOOGLE_LOGIN_TEXTS.selectAll);
15368
- if (await selectAllPermissions.isVisible()) {
15371
+ if (allowPermissions && (await selectAllPermissions.isVisible())) {
15369
15372
  await selectAllPermissions.click();
15370
15373
  }
15371
15374
  await this.page
15372
15375
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.continue })
15373
- .click({ timeout: 15000 });
15376
+ .click({ timeout: 20000 });
15377
+ };
15378
+ this.handleNotVerifiedPage = async () => {
15379
+ const continueUnsafeButton = this.page.getByRole("button", {
15380
+ name: GOOGLE_LOGIN_TEXTS.continue,
15381
+ });
15382
+ const backToSafety = this.page.getByRole("button", {
15383
+ name: GOOGLE_LOGIN_TEXTS.backToSafety,
15384
+ });
15385
+ if (this.page.url().includes(THIRD_PARTY_ROUTES.google.warningScreen)) {
15386
+ await continueUnsafeButton.click();
15387
+ await test$1.expect(backToSafety).toBeHidden({ timeout: 10000 });
15388
+ }
15374
15389
  };
15375
15390
  this.totp = initializeTotp({
15376
15391
  issuer: "Google",