@bigbinary/neeto-playwright-commons 1.11.14 → 1.11.16

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
@@ -9743,7 +9743,12 @@ const util$7 = require$$0__default["default"];
9743
9743
  const braces = braces_1;
9744
9744
  const picomatch = picomatch$1;
9745
9745
  const utils$c = utils$g;
9746
- const isEmptyString = val => val === '' || val === './';
9746
+
9747
+ const isEmptyString = v => v === '' || v === './';
9748
+ const hasBraces = v => {
9749
+ const index = v.indexOf('{');
9750
+ return index > -1 && v.indexOf('}', index) > -1;
9751
+ };
9747
9752
 
9748
9753
  /**
9749
9754
  * Returns an array of strings that match one or more glob patterns.
@@ -10184,7 +10189,7 @@ micromatch$1.parse = (patterns, options) => {
10184
10189
 
10185
10190
  micromatch$1.braces = (pattern, options) => {
10186
10191
  if (typeof pattern !== 'string') throw new TypeError('Expected a string');
10187
- if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) {
10192
+ if ((options && options.nobrace === true) || !hasBraces(pattern)) {
10188
10193
  return [pattern];
10189
10194
  }
10190
10195
  return braces(pattern, options);
@@ -10203,6 +10208,8 @@ micromatch$1.braceExpand = (pattern, options) => {
10203
10208
  * Expose micromatch
10204
10209
  */
10205
10210
 
10211
+ // exposed for tests
10212
+ micromatch$1.hasBraces = hasBraces;
10206
10213
  var micromatch_1 = micromatch$1;
10207
10214
 
10208
10215
  Object.defineProperty(pattern$1, "__esModule", { value: true });
@@ -13131,7 +13138,7 @@ const GOOGLE_LOGIN_TEXTS = {
13131
13138
  googleAccount: "Google Account:",
13132
13139
  connectYourGoogleAccount: "Connect your Google account",
13133
13140
  signInWithGoogle: "Sign in with Google",
13134
- signInHeading: "Sign in to neetocal.net",
13141
+ signInHeading: (appName) => `Sign in to ${appName}.net`,
13135
13142
  continue: "Continue",
13136
13143
  selectAll: "Select All",
13137
13144
  appNotVerified: "Google hasn’t verified this app",
@@ -13145,6 +13152,12 @@ const GOOGLE_LOGIN_TEXTS = {
13145
13152
  signOut: "Sign out",
13146
13153
  wrongCode: "Wrong code. Try again",
13147
13154
  verificationCode: "verification code",
13155
+ confirm: "Confirm",
13156
+ cancel: "Cancel",
13157
+ deleteConnections: "Delete all connections you",
13158
+ noLongerConnected: "You’re no longer connected to",
13159
+ backToSafety: "Back to safety",
13160
+ neetoAutomation: "neeto.automation",
13148
13161
  };
13149
13162
 
13150
13163
  const HELP_CENTER_SELECTORS = {
@@ -13420,14 +13433,6 @@ class HelpAndProfilePage {
13420
13433
  }
13421
13434
  }
13422
13435
 
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
13436
  const GOOGLE_LOGIN_SELECTORS = {
13432
13437
  totpNext: "#totpNext",
13433
13438
  form: "form",
@@ -15181,6 +15186,14 @@ const initializeTotp = ({ issuer, secret, }) => {
15181
15186
  });
15182
15187
  };
15183
15188
 
15189
+ const INTEGRATION_SELECTORS = {
15190
+ integrationCard: (integration) => `${integration}-integration-card`,
15191
+ connectButton: "connect-button",
15192
+ integrationStatusTag: "integration-status-tag",
15193
+ disconnectButton: "disconnect-button",
15194
+ manageButton: "manage-button",
15195
+ };
15196
+
15184
15197
  class IntegrationBase {
15185
15198
  constructor({ page, neetoPlaywrightUtilities, integration, connectHeader, connectedHeader, pageloaderTimeout, integrationRouteIndex, integrationRouteResponsesParams, }) {
15186
15199
  this.disconnect = async (interceptMultipleResponsesParams = {}) => {
@@ -15256,18 +15269,9 @@ class GooglePage extends IntegrationBase {
15256
15269
  integration,
15257
15270
  integrationRouteIndex,
15258
15271
  });
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();
15272
+ this.connectGoogleAccount = async (appName) => {
15269
15273
  await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.chooseAccount));
15270
- await this.selectGoogleAccount();
15274
+ await this.selectGoogleAccount(appName);
15271
15275
  if (process.env.TEST_ENV === ENVIRONMENT.staging) {
15272
15276
  await this.stagingConsentFlow();
15273
15277
  }
@@ -15277,22 +15281,26 @@ class GooglePage extends IntegrationBase {
15277
15281
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.allow })
15278
15282
  .click();
15279
15283
  }
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
15284
  };
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 });
15285
+ this.selectGoogleAccount = async (appName) => {
15286
+ const neetoAutomationLocator = this.page.getByRole("link", {
15287
+ name: GOOGLE_LOGIN_TEXTS.neetoAutomation,
15288
+ });
15289
+ await neetoAutomationLocator.click();
15290
+ await test$1.expect(neetoAutomationLocator).toBeHidden({ timeout: 10000 });
15291
+ const verificationCode = this.page
15292
+ .locator("form")
15293
+ .getByText(GOOGLE_LOGIN_TEXTS.verificationCode);
15294
+ if (this.page.url().includes(THIRD_PARTY_ROUTES.google.totpChallenge)) {
15292
15295
  await this.enterTotpCode(verificationCode);
15293
- // eslint-disable-next-line no-empty
15294
15296
  }
15295
- catch (error) { }
15297
+ await this.handleNotVerifiedPage();
15298
+ await test$1.expect(this.page.getByRole("heading", {
15299
+ name: GOOGLE_LOGIN_TEXTS.signInHeading(appName),
15300
+ })).toBeVisible();
15301
+ await this.page
15302
+ .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.continue })
15303
+ .click();
15296
15304
  };
15297
15305
  this.loginToGoogle = async () => {
15298
15306
  await this.page.goto(THIRD_PARTY_ROUTES.google.signin);
@@ -15315,17 +15323,20 @@ class GooglePage extends IntegrationBase {
15315
15323
  await this.page
15316
15324
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.next })
15317
15325
  .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();
15326
+ if (this.page.url().includes(THIRD_PARTY_ROUTES.google.challengeSelection)) {
15327
+ await this.page
15328
+ .locator(GOOGLE_LOGIN_SELECTORS.totpChallengeSelector)
15329
+ .click();
15330
+ }
15322
15331
  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);
15332
+ const twoStepVerification = this.page.locator("form").getByRole("heading", {
15333
+ name: GOOGLE_LOGIN_TEXTS.twoStepVerification,
15334
+ level: 2,
15335
+ exact: true,
15336
+ });
15326
15337
  await test$1.expect(twoStepVerification).toBeVisible();
15327
15338
  await this.enterTotpCode(twoStepVerification);
15328
- await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.myAccount));
15339
+ await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.myAccount), { waitUntil: "load" });
15329
15340
  };
15330
15341
  this.enterTotpCode = async (locator) => {
15331
15342
  await test$1.expect(async () => {
@@ -15333,8 +15344,8 @@ class GooglePage extends IntegrationBase {
15333
15344
  await this.page.getByLabel(GOOGLE_LOGIN_TEXTS.enterCode).fill(totpToken);
15334
15345
  test$1.expect(this.totp.validate({ token: totpToken })).not.toBeNull();
15335
15346
  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 });
15347
+ await test$1.expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)).toBeHidden({ timeout: 15000 });
15348
+ await test$1.expect(locator).toBeHidden({ timeout: 10000 });
15338
15349
  }).toPass({ timeout: 50000 });
15339
15350
  };
15340
15351
  this.logoutFromGoogle = async () => {
@@ -15349,28 +15360,39 @@ class GooglePage extends IntegrationBase {
15349
15360
  await this.disconnect();
15350
15361
  await this.verifyIntegrationStatus("disconnected");
15351
15362
  };
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();
15363
+ this.stagingConsentFlow = async ({ abortFlow = false, allowPermissions = true, } = {}) => {
15364
+ await this.handleNotVerifiedPage();
15365
+ if (this.page.url().includes(THIRD_PARTY_ROUTES.google.additionalInfoScreen)) {
15366
+ await this.page
15367
+ .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.continue })
15368
+ .click({ timeout: 20000 });
15369
+ }
15366
15370
  await this.page.waitForURL(new RegExp(THIRD_PARTY_ROUTES.google.consentSummary));
15371
+ if (abortFlow) {
15372
+ await this.page
15373
+ .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.cancel })
15374
+ .click({ timeout: 20000 });
15375
+ return;
15376
+ }
15367
15377
  const selectAllPermissions = this.page.getByLabel(GOOGLE_LOGIN_TEXTS.selectAll);
15368
- if (await selectAllPermissions.isVisible()) {
15378
+ if (allowPermissions && (await selectAllPermissions.isVisible())) {
15369
15379
  await selectAllPermissions.click();
15370
15380
  }
15371
15381
  await this.page
15372
15382
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.continue })
15373
- .click({ timeout: 15000 });
15383
+ .click({ timeout: 20000 });
15384
+ };
15385
+ this.handleNotVerifiedPage = async () => {
15386
+ const continueUnsafeButton = this.page.getByRole("button", {
15387
+ name: GOOGLE_LOGIN_TEXTS.continue,
15388
+ });
15389
+ const backToSafety = this.page.getByRole("button", {
15390
+ name: GOOGLE_LOGIN_TEXTS.backToSafety,
15391
+ });
15392
+ if (this.page.url().includes(THIRD_PARTY_ROUTES.google.warningScreen)) {
15393
+ await continueUnsafeButton.click();
15394
+ await test$1.expect(backToSafety).toBeHidden({ timeout: 10000 });
15395
+ }
15374
15396
  };
15375
15397
  this.totp = initializeTotp({
15376
15398
  issuer: "Google",