@bigbinary/neeto-playwright-commons 1.8.24 → 1.8.26

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
@@ -137,13 +137,16 @@ declare class HelpAndProfilePage {
137
137
 
138
138
  type Integration = "dailyco" | "github" | "google-calendar" | "google-analytics" | "google-sheets" | "microsoft-teams" | "neeto-chat" | "neeto-crm" | "slack" | "twilio" | "whereby" | "zapier" | "zoom";
139
139
  type IntegrationStatus = "connected" | "disconnected";
140
+ type PartialInterceptMultipleResponsesParams = Partial<InterceptMultipleResponsesParams>;
140
141
  interface IntegrationBaseParams {
141
142
  page: Page;
142
143
  neetoPlaywrightUtilities: CustomCommands;
143
144
  integration: Integration;
144
- integrationRouteIndex?: string;
145
145
  connectedHeader?: string;
146
146
  connectHeader?: string;
147
+ pageloaderTimeout?: number;
148
+ integrationRouteIndex?: string;
149
+ integrationRouteResponsesParams?: PartialInterceptMultipleResponsesParams;
147
150
  }
148
151
  declare class IntegrationBase {
149
152
  readonly page: Page;
@@ -153,9 +156,11 @@ declare class IntegrationBase {
153
156
  readonly integrationCard: Locator;
154
157
  readonly connectHeader: string;
155
158
  readonly connectedHeader: string;
159
+ pageloaderTimeout: number;
156
160
  integrationRouteIndex: string;
157
- constructor({ page, neetoPlaywrightUtilities, integration, integrationRouteIndex, connectHeader, connectedHeader, }: IntegrationBaseParams);
158
- disconnect: (interceptMultipleResponsesParams?: Partial<InterceptMultipleResponsesParams>) => Promise<void>;
161
+ integrationRouteResponsesParams: PartialInterceptMultipleResponsesParams;
162
+ constructor({ page, neetoPlaywrightUtilities, integration, connectHeader, connectedHeader, pageloaderTimeout, integrationRouteIndex, integrationRouteResponsesParams, }: IntegrationBaseParams);
163
+ disconnect: (interceptMultipleResponsesParams?: PartialInterceptMultipleResponsesParams) => Promise<void>;
159
164
  connect: (skipGoTo?: boolean) => Promise<void>;
160
165
  verifyIntegrationStatus: (status?: IntegrationStatus) => Promise<void>;
161
166
  clickOnIntegrationCard: () => Promise<void>;
@@ -614,6 +619,7 @@ declare const skipTest: {
614
619
  forDevelopmentEnv: () => void;
615
620
  forReviewEnv: () => void;
616
621
  forAllExceptStagingEnv: () => void;
622
+ forNonNightlyRun: () => void;
617
623
  };
618
624
  declare const shouldSkipSetupAndTeardown: () => boolean | "";
619
625
 
package/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import test$1, { expect, test as test$2, defineConfig, devices } from '@playwright/test';
2
+ import { execSync } from 'child_process';
2
3
  import * as require$$0$1 from 'fs';
3
4
  import require$$0__default from 'fs';
5
+ import { not, isEmpty as isEmpty$1, isNil, isNotNil, mergeDeepLeft, mergeAll } from 'ramda';
4
6
  import require$$0$2 from 'util';
5
- import { isEmpty as isEmpty$1, isNil, isNotNil, mergeDeepLeft, mergeAll } from 'ramda';
6
7
  import { faker } from '@faker-js/faker';
7
8
  import MailosaurClient from 'mailosaur';
8
9
  import dayjs from 'dayjs';
@@ -33,6 +34,9 @@ const OTP_EMAIL_PATTERN = "is your login code";
33
34
  const SLACK_DEFAULT_CHANNEL = "general";
34
35
 
35
36
  /* eslint-disable playwright/no-skipped-test */
37
+ const execCommand = (command) => execSync(command)
38
+ .toString("utf-8")
39
+ .replace(/[\n\r\s]+$/, "");
36
40
  const joinString = (string1, string2, string3 = "", separator = " ") => {
37
41
  if (string3 === "") {
38
42
  return string1 + separator + string2;
@@ -92,6 +96,11 @@ const skipTest = {
92
96
  forDevelopmentEnv: () => test$1.skip(process.env.TEST_ENV === ENVIRONMENT.development),
93
97
  forReviewEnv: () => test$1.skip(process.env.TEST_ENV === ENVIRONMENT.review),
94
98
  forAllExceptStagingEnv: () => test$1.skip(process.env.TEST_ENV !== ENVIRONMENT.staging),
99
+ forNonNightlyRun: () => {
100
+ const currentBranch = execCommand("git rev-parse --abbrev-ref HEAD");
101
+ const isNightlyRun = currentBranch === "main" && process.env.TEST_ENV === ENVIRONMENT.staging;
102
+ return test$1.skip(not(isNightlyRun), "Run test only in playwright-nightly");
103
+ },
95
104
  };
96
105
  const shouldSkipSetupAndTeardown = () => { var _a; return ((_a = getGlobalUserState()) === null || _a === void 0 ? void 0 : _a.isLoggedIn) && process.env.SKIP_SETUP === "true"; };
97
106
 
@@ -12520,7 +12529,7 @@ const INTEGRATION_SELECTORS = {
12520
12529
  };
12521
12530
 
12522
12531
  class IntegrationBase {
12523
- constructor({ page, neetoPlaywrightUtilities, integration, integrationRouteIndex, connectHeader, connectedHeader, }) {
12532
+ constructor({ page, neetoPlaywrightUtilities, integration, connectHeader, connectedHeader, pageloaderTimeout, integrationRouteIndex, integrationRouteResponsesParams, }) {
12524
12533
  this.disconnect = async (interceptMultipleResponsesParams = {}) => {
12525
12534
  await this.gotoIntegrationIndex();
12526
12535
  await this.clickOnIntegrationCard();
@@ -12555,18 +12564,27 @@ class IntegrationBase {
12555
12564
  await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toHaveCount(0);
12556
12565
  await this.integrationCard.scrollIntoViewIfNeeded();
12557
12566
  await this.integrationCard.click();
12558
- await expect(this.page.getByTestId(COMMON_SELECTORS.pageLoader)).toBeHidden();
12567
+ await expect(this.page.getByTestId(COMMON_SELECTORS.pageLoader)).toBeHidden({ timeout: this.pageloaderTimeout });
12559
12568
  };
12560
12569
  this.gotoIntegrationIndex = async () => {
12561
- isNotEmpty(this.integrationRouteIndex) &&
12562
- (await this.page.goto(this.integrationRouteIndex));
12570
+ if (isNotEmpty(this.integrationRouteIndex)) {
12571
+ const integrationIndexPromise = this.neetoPlaywrightUtilities.interceptMultipleResponses({
12572
+ times: 0,
12573
+ ...this.integrationRouteResponsesParams,
12574
+ });
12575
+ await this.page.goto(this.integrationRouteIndex);
12576
+ await integrationIndexPromise;
12577
+ }
12563
12578
  };
12564
12579
  this.page = page;
12565
12580
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
12566
12581
  this.t = getI18nInstance().t;
12567
12582
  this.integration = integration;
12568
12583
  this.integrationCard = this.page.getByTestId(INTEGRATION_SELECTORS.integrationCard(integration));
12584
+ this.pageloaderTimeout = pageloaderTimeout || 10000;
12569
12585
  this.integrationRouteIndex = integrationRouteIndex || "";
12586
+ this.integrationRouteResponsesParams =
12587
+ integrationRouteResponsesParams || {};
12570
12588
  this.connectHeader =
12571
12589
  connectHeader ||
12572
12590
  INTEGRATIONS_TEXTS.connectHeader(humanize(this.integration));