@bigbinary/neeto-playwright-commons 2.1.0 → 2.1.2

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
@@ -1041,15 +1041,41 @@ declare class Health {
1041
1041
  constructor(page: Page, neetoPlaywrightUtilities: CustomCommands);
1042
1042
  /**
1043
1043
  *
1044
- * Performs login, waits until the main application UI (floating
1044
+ * Navigates to the given route (default: /admin/admin-panel), waits for the page to
1045
1045
  *
1046
- * menu, logo, and heading) is present, and then executes your custom verification
1046
+ * load, then logs in via the authenticator app using the production email from the
1047
1047
  *
1048
- * steps.
1048
+ * environment.
1049
1049
  *
1050
- * customSteps (optional): An async function (no arguments) that runs after login and common
1050
+ * route (optional): Path to open. Defaults to ROUTES.adminPanel.index.
1051
1051
  *
1052
- * verification. Use it to perform additional assertions or navigation.
1052
+ * @example
1053
+ *
1054
+ * await health.loginToApp(ROUTES.dashboard);
1055
+ * @endexample
1056
+ */
1057
+ loginToApp: (route?: string) => Promise<void>;
1058
+ /**
1059
+ *
1060
+ * Waits for the floating menu and page load, then asserts that the Neeto logo and
1061
+ *
1062
+ * main heading test IDs are visible.
1063
+ *
1064
+ * @example
1065
+ *
1066
+ * await health.verifyAppUI();
1067
+ * @endexample
1068
+ */
1069
+ verifyAppUI: () => Promise<void>;
1070
+ /**
1071
+ *
1072
+ * Performs login, waits until the main application UI (floating menu, logo, and
1073
+ *
1074
+ * heading) is present, and then executes your custom verification steps.
1075
+ *
1076
+ * customSteps (optional): An async function (no arguments) that runs after login
1077
+ *
1078
+ * and common verification. Use it to perform additional assertions or navigation.
1053
1079
  *
1054
1080
  * @example
1055
1081
  *
@@ -8704,23 +8730,26 @@ declare const PROJECT_NAMES: {
8704
8730
  readonly webkit: "webkit";
8705
8731
  readonly lighthouseAudits: "lighthouse-audits";
8706
8732
  readonly cleanupCredentials: "cleanup credentials";
8733
+ readonly productionHealth: "production-health";
8707
8734
  };
8708
8735
  type ProjectName = ValueOf<typeof PROJECT_NAMES>;
8709
8736
  interface PlaydashOverrides {
8710
8737
  projectKey: string;
8711
8738
  }
8712
8739
  type WebServerConfig = Exclude<NonNullable<PlaywrightTestConfig["webServer"]>, readonly unknown[]>;
8740
+ type UnknownRecord = Record<string, unknown>;
8713
8741
  interface ProjectLaunchOptionsConfig extends LaunchOptions {
8714
8742
  mergeArgs?: boolean;
8715
8743
  }
8716
8744
  interface Overrides {
8717
- globalOverrides?: Record<string, unknown>;
8718
- useOverrides?: Record<string, unknown>;
8745
+ globalOverrides?: UnknownRecord;
8746
+ useOverrides?: UnknownRecord;
8719
8747
  useCustomProjects?: boolean;
8720
- projectOverrides?: Record<string, unknown>[];
8721
- playdashStagingOverrides?: PlaydashOverrides & Record<string, unknown>;
8722
- playdashProductionOverrides?: PlaydashOverrides & Record<string, unknown>;
8723
- playdashLighthouseOverrides?: PlaydashOverrides & Record<string, unknown>;
8748
+ projectOverrides?: UnknownRecord[];
8749
+ playdashStagingOverrides?: PlaydashOverrides & UnknownRecord;
8750
+ playdashProductionOverrides?: PlaydashOverrides & UnknownRecord;
8751
+ playdashLighthouseOverrides?: PlaydashOverrides & UnknownRecord;
8752
+ playdashProductionHealthOverrides?: PlaydashOverrides & UnknownRecord;
8724
8753
  webServerOverrides?: WebServerConfig[];
8725
8754
  projectLaunchOptionsOverrides?: Partial<Record<ProjectName, ProjectLaunchOptionsConfig>>;
8726
8755
  }
package/index.js CHANGED
@@ -8406,7 +8406,10 @@ class GooglePage extends IntegrationBase {
8406
8406
  await expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.showPassword)).toBeVisible({ timeout: 10_000 });
8407
8407
  await this.page
8408
8408
  .getByLabel(GOOGLE_LOGIN_TEXTS.enterYourPassword)
8409
- .pressSequentially(process.env.GOOGLE_LOGIN_PASSWORD, { delay: 10 });
8409
+ .pressSequentially(process.env.GOOGLE_LOGIN_PASSWORD, {
8410
+ delay: 10,
8411
+ timeout: 20_000,
8412
+ });
8410
8413
  await this.page.getByLabel(GOOGLE_LOGIN_TEXTS.showPassword).click();
8411
8414
  await this.page
8412
8415
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.next })
@@ -8660,8 +8663,8 @@ class OrganizationPage {
8660
8663
  await codeInput.fill(totpToken);
8661
8664
  expect(totp.validate({ token: totpToken })).not.toBeNull();
8662
8665
  await Promise.all([
8663
- expect(codeInput).toBeHidden(),
8664
- expect(this.page.getByTestId(LOGIN_SELECTORS.enterOtpInputError)).toBeHidden(),
8666
+ expect(codeInput).toBeHidden({ timeout: 10_000 }),
8667
+ expect(this.page.getByTestId(LOGIN_SELECTORS.enterOtpInputError)).toBeHidden({ timeout: 10_000 }),
8665
8668
  ]);
8666
8669
  }).toPass({ timeout: 2 * 60 * 1000 });
8667
8670
  };
@@ -8821,22 +8824,25 @@ class Health {
8821
8824
  constructor(page, neetoPlaywrightUtilities) {
8822
8825
  this.page = page;
8823
8826
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
8824
- if (!process.env.PLAYWRIGHT_PRODUCTION_EMAIL) {
8825
- throw new Error("PLAYWRIGHT_PRODUCTION_EMAIL is not set");
8827
+ if (!process.env.PLAYWRIGHT_PRODUCTION_EMAIL ||
8828
+ !process.env.PLAYWRIGHT_PRODUCTION_2FA_SECRET_KEY) {
8829
+ throw new Error("One or more required env variables are missing: PLAYWRIGHT_PRODUCTION_EMAIL, PLAYWRIGHT_PRODUCTION_2FA_SECRET_KEY");
8826
8830
  }
8827
8831
  this.loginPage = new OrganizationPage(page, neetoPlaywrightUtilities);
8828
8832
  }
8833
+ loginToApp = async (route = ROUTES.adminPanel.index) => {
8834
+ await this.page.goto(route);
8835
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
8836
+ await this.loginPage.loginViaAuthenticatorApp(this.email);
8837
+ };
8838
+ verifyAppUI = async () => {
8839
+ await this.neetoPlaywrightUtilities.waitForFloatingMenu();
8840
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
8841
+ await Promise.all([COMMON_SELECTORS.neetoLogo, COMMON_SELECTORS.heading].map(selector => expect(this.page.getByTestId(selector)).toBeVisible()));
8842
+ };
8829
8843
  verifyAppIsLive = async (customSteps) => {
8830
- await test.step("1: Login to the application", async () => {
8831
- await this.page.goto(ROUTES.adminPanel.index);
8832
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8833
- await this.loginPage.loginViaAuthenticatorApp(this.email);
8834
- });
8835
- await test.step("2: Verify application is live", async () => {
8836
- await this.neetoPlaywrightUtilities.waitForFloatingMenu();
8837
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8838
- await Promise.all([COMMON_SELECTORS.neetoLogo, COMMON_SELECTORS.heading].map(selector => expect(this.page.getByTestId(selector)).toBeVisible()));
8839
- });
8844
+ await test.step("1: Login to the application", () => this.loginToApp());
8845
+ await test.step("2: Verify application UI", this.verifyAppUI);
8840
8846
  await customSteps?.();
8841
8847
  };
8842
8848
  }
@@ -125293,19 +125299,13 @@ var mainExports = requireMain();
125293
125299
  var dotenvExpand = /*@__PURE__*/getDefaultExportFromCjs(mainExports);
125294
125300
 
125295
125301
  // @ts-check
125302
+ const loadEnv = (path) => dotenvExpand.expand(dotenv.config({ path, quiet: true }));
125303
+ const envBasePath = "./e2e/config/.env";
125304
+ const envLocalPath = `${envBasePath}.local`;
125305
+ const reporterPackageName = "@bigbinary/neeto-playwright-reporter";
125296
125306
  process.env.TEST_ENV = process.env.TEST_ENV ?? ENVIRONMENT.development;
125297
- const env = dotenv.config({
125298
- path: `./e2e/config/.env.${process.env.TEST_ENV}`,
125299
- quiet: true,
125300
- });
125301
- dotenvExpand.expand(env);
125302
- if (require$$0$3.existsSync("./e2e/config/.env.local")) {
125303
- const localEnv = dotenv.config({
125304
- path: "./e2e/config/.env.local",
125305
- quiet: true,
125306
- });
125307
- dotenvExpand.expand(localEnv);
125308
- }
125307
+ loadEnv(`${envBasePath}.${process.env.TEST_ENV}`);
125308
+ require$$0$3.existsSync(envLocalPath) && loadEnv(envLocalPath);
125309
125309
  const playdashStagingConfig = {
125310
125310
  apiKey: process.env.PLAYDASH_STAGING_API_KEY,
125311
125311
  ciBuildId: process.env.NEETO_CI_JOB_ID,
@@ -125322,6 +125322,11 @@ const playdashLighthouseConfig = {
125322
125322
  ciBuildId: process.env.NEETO_CI_JOB_ID,
125323
125323
  tags: process.env.TAG,
125324
125324
  };
125325
+ const playdashProductionHealthConfig = {
125326
+ apiKey: process.env.PLAYDASH_PRODUCTION_HEALTH_API_KEY,
125327
+ ciBuildId: process.env.NEETO_CI_JOB_ID,
125328
+ tags: process.env.TAG,
125329
+ };
125325
125330
  const isCI = isPresent(process.env.NEETO_CI_JOB_ID);
125326
125331
  const railsPort = process.env.RAILS_SERVER_PORT;
125327
125332
  const vitePort = process.env.VITE_PORT;
@@ -125331,9 +125336,10 @@ const PROJECT_NAMES = {
125331
125336
  webkit: "webkit",
125332
125337
  lighthouseAudits: "lighthouse-audits",
125333
125338
  cleanupCredentials: "cleanup credentials",
125339
+ productionHealth: "production-health",
125334
125340
  };
125335
125341
  const definePlaywrightConfig = (overrides) => {
125336
- const { globalOverrides = {}, useOverrides = {}, useCustomProjects = false, projectOverrides = [], playdashStagingOverrides = {}, playdashProductionOverrides = {}, playdashLighthouseOverrides = {}, webServerOverrides = [], projectLaunchOptionsOverrides = {}, } = overrides;
125342
+ const { globalOverrides = {}, useOverrides = {}, useCustomProjects = false, projectOverrides = [], playdashProductionHealthOverrides = {}, playdashStagingOverrides = {}, playdashProductionOverrides = {}, playdashLighthouseOverrides = {}, webServerOverrides = [], projectLaunchOptionsOverrides = {}, } = overrides;
125337
125343
  const getProjectLaunchOptions = (projectName, defaultLaunchOptions) => {
125338
125344
  const overrides = projectLaunchOptionsOverrides[projectName];
125339
125345
  if (!overrides)
@@ -125352,29 +125358,31 @@ const definePlaywrightConfig = (overrides) => {
125352
125358
  let reporter = !isEmpty(playdashStagingOverrides)
125353
125359
  ? [
125354
125360
  [
125355
- "@bigbinary/neeto-playwright-reporter",
125356
- {
125357
- ...playdashStagingConfig,
125358
- ...playdashStagingOverrides,
125359
- },
125361
+ reporterPackageName,
125362
+ { ...playdashStagingConfig, ...playdashStagingOverrides },
125360
125363
  ],
125361
125364
  ]
125362
125365
  : [
125363
125366
  [
125364
- "@bigbinary/neeto-playwright-reporter",
125365
- {
125366
- ...playdashProductionConfig,
125367
- ...playdashProductionOverrides,
125368
- },
125367
+ reporterPackageName,
125368
+ { ...playdashProductionConfig, ...playdashProductionOverrides },
125369
125369
  ],
125370
125370
  ];
125371
125371
  if (process.env.IS_LIGHTHOUSE_REPORT) {
125372
125372
  reporter = [
125373
125373
  [
125374
- "@bigbinary/neeto-playwright-reporter",
125374
+ reporterPackageName,
125375
+ { ...playdashLighthouseConfig, ...playdashLighthouseOverrides },
125376
+ ],
125377
+ ];
125378
+ }
125379
+ if (process.env.TAG?.includes("production")) {
125380
+ reporter = [
125381
+ [
125382
+ reporterPackageName,
125375
125383
  {
125376
- ...playdashLighthouseConfig,
125377
- ...playdashLighthouseOverrides,
125384
+ ...playdashProductionHealthConfig,
125385
+ ...playdashProductionHealthOverrides,
125378
125386
  },
125379
125387
  ],
125380
125388
  ];
@@ -125477,13 +125485,14 @@ const definePlaywrightConfig = (overrides) => {
125477
125485
  }),
125478
125486
  },
125479
125487
  {
125480
- name: "production-health",
125488
+ name: PROJECT_NAMES.productionHealth,
125481
125489
  testDir: "./e2e/health",
125482
125490
  testMatch: "production.health.ts",
125483
125491
  use: {
125484
125492
  ...devices["Desktop Chrome"],
125485
125493
  baseURL: process.env.PLAYWRIGHT_PRODUCTION_BASE_URL,
125486
- storageState: { cookies: [], origins: [] },
125494
+ screenshot: "on",
125495
+ trace: "on",
125487
125496
  },
125488
125497
  },
125489
125498
  ...projectOverrides,