@bigbinary/neeto-playwright-commons 1.27.1 → 1.27.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.cjs.js CHANGED
@@ -542,6 +542,14 @@ class SlackApi {
542
542
  this.fetchMessages = (channelId, unixTimestamp) => this.apiRequest("history", { channel: channelId, oldest: unixTimestamp });
543
543
  this.createChannel = (channelName) => this.apiRequest("create", { name: channelName });
544
544
  this.addUser = (channelId, userId) => this.apiRequest("invite", { channel: channelId, users: userId });
545
+ this.mockChannelDeleted = (channelId) => this.neetoPlaywrightUtilities.apiRequest({
546
+ url: "/neeto_slack/api/v1/testing/webhooks",
547
+ method: "post",
548
+ data: neetoCist.keysToSnakeCase({
549
+ eventType: "channel_deleted",
550
+ notificationChannelId: channelId,
551
+ }),
552
+ });
545
553
  if (!process.env.SLACK_BOT_TOKEN) {
546
554
  throw new Error("SLACK_BOT_TOKEN is not set");
547
555
  }
@@ -116908,11 +116916,17 @@ class GooglePage extends IntegrationBase {
116908
116916
  totpToken = this.totp.generate({ timestamp: Date.now() });
116909
116917
  }
116910
116918
  previousToken = totpToken;
116919
+ if (await codeInput.isHidden())
116920
+ return;
116911
116921
  await codeInput.fill(totpToken);
116912
116922
  test.expect(this.totp.validate({ token: totpToken })).not.toBeNull();
116913
116923
  await this.page.locator(GOOGLE_LOGIN_SELECTORS.totpNext).click();
116914
- await test.expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)).toBeHidden({ timeout: 10000 });
116915
- await test.expect(codeInput).toBeHidden({ timeout: 15000 });
116924
+ await Promise.all([
116925
+ test.expect(codeInput).toBeHidden({ timeout: 20000 }),
116926
+ test.expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)).toBeHidden({
116927
+ timeout: 20000,
116928
+ }),
116929
+ ]);
116916
116930
  }).toPass({ timeout: 2 * 60 * 1000 });
116917
116931
  };
116918
116932
  this.logoutFromGoogle = async () => {
@@ -117109,32 +117123,58 @@ class SlackPage extends IntegrationBase {
117109
117123
  await slackWebappPage.addLocatorHandler(slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.messagePaneBannerCloseIcon), locator => locator.click(), { times: 1 });
117110
117124
  await slackWebappPage.addLocatorHandler(slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.permissionBannerCloseIcon), locator => locator.click(), { noWaitAfter: true, times: 2 });
117111
117125
  };
117112
- this.connectAndVerifyIntegration = async (redirectUrl, customSteps, channelToConfigure = SLACK_DEFAULT_CHANNEL) => {
117126
+ this.initializeSlackPermissionPage = async () => {
117113
117127
  await this.connect();
117114
- const loginButton = this.page.getByRole("button", {
117115
- name: this.t("neetoSlack.slack.connect.loginButton"),
117116
- });
117117
- const installButton = this.page.locator(SLACK_SELECTORS.installButton);
117118
- const allowButton = this.page.getByRole("button", {
117119
- name: SLACK_WEB_TEXTS.allow,
117120
- });
117121
- const button = installButton.or(allowButton);
117122
- if (await loginButton.isVisible()) {
117123
- await loginButton.click({ delay: 5000 });
117124
- await this.page.waitForURL(RegExp("(.*)slack.com/.*"));
117125
- }
117126
117128
  await this.page.waitForLoadState("domcontentloaded", { timeout: 25000 });
117127
- await test.expect(button).toBeVisible({ timeout: 25000 });
117128
- await test.expect(button).toBeEnabled({ timeout: 25000 });
117129
- const currentWorkspace = (await this.page
117129
+ await test.expect(this.allowButton).toBeVisible({ timeout: 25000 });
117130
+ await test.expect(this.allowButton).toBeEnabled({ timeout: 25000 });
117131
+ return await this.page
117130
117132
  .locator(SLACK_SELECTORS.teamPicketButtonContent)
117131
- .textContent()) || "";
117132
- await button.click({ timeout: 25000 });
117133
- await this.page.waitForURL(redirectUrl);
117133
+ .textContent();
117134
+ };
117135
+ this.navigateToCallbackUrl = async () => {
117136
+ await this.page.goto(this.callbackUrl.replace(/^https:/, "http:"));
117137
+ await this.neetoPlaywrightUtilities.waitForPageLoad();
117138
+ };
117139
+ this.captureCallbackUrl = () => this.page.on("request", (request) => {
117140
+ const url = request.url();
117141
+ if (url.includes("/neeto_slack/api/v2/slack/callbacks") &&
117142
+ url.startsWith("https:")) {
117143
+ this.callbackUrl = url;
117144
+ }
117145
+ });
117146
+ this.connectAndVerifyInDev = async (redirectUrl, channelToConfigure, customSteps) => {
117147
+ this.currentWorkspace = (await this.initializeSlackPermissionPage()) || "";
117148
+ this.captureCallbackUrl();
117149
+ await this.allowButton.click({ timeout: 25000 });
117150
+ await test.expect(this.allowButton).toBeHidden({ timeout: 25000 });
117151
+ await this.page.waitForLoadState("domcontentloaded", { timeout: 20000 });
117152
+ await this.navigateToCallbackUrl();
117153
+ await this.page.waitForURL(redirectUrl, {
117154
+ timeout: 15000,
117155
+ });
117156
+ await this.completeSlackChannelSetup(channelToConfigure, customSteps);
117157
+ };
117158
+ this.connectAndVerifyInStaging = async (redirectUrl, channelToConfigure, customSteps) => {
117159
+ this.currentWorkspace = (await this.initializeSlackPermissionPage()) || "";
117160
+ await this.allowButton.click({ timeout: 25000 });
117161
+ await test.expect(this.allowButton).toBeHidden({ timeout: 25000 });
117162
+ await this.page.waitForLoadState("domcontentloaded", { timeout: 20000 });
117163
+ await this.page.waitForURL(redirectUrl, {
117164
+ timeout: 15000,
117165
+ });
117166
+ await this.completeSlackChannelSetup(channelToConfigure, customSteps);
117167
+ };
117168
+ this.connectAndVerifyIntegration = async (redirectUrl, customSteps, channelToConfigure = SLACK_DEFAULT_CHANNEL) => {
117169
+ IS_DEV_ENV
117170
+ ? await this.connectAndVerifyInDev(redirectUrl, channelToConfigure, customSteps)
117171
+ : await this.connectAndVerifyInStaging(redirectUrl, channelToConfigure, customSteps);
117172
+ };
117173
+ this.completeSlackChannelSetup = async (channelToConfigure, customSteps) => {
117134
117174
  await this.neetoPlaywrightUtilities.waitForPageLoad();
117135
117175
  await test.expect(this.page.getByRole("heading", {
117136
117176
  name: this.t("neetoSlack.slack.configure.title", {
117137
- teamName: currentWorkspace,
117177
+ teamName: this.currentWorkspace,
117138
117178
  }),
117139
117179
  })).toBeVisible({ timeout: 10000 });
117140
117180
  await this.neetoPlaywrightUtilities.selectOptionFromDropdown({
@@ -117143,14 +117183,17 @@ class SlackPage extends IntegrationBase {
117143
117183
  await this.page
117144
117184
  .getByRole("button", { name: this.t("neetoSlack.common.continue") })
117145
117185
  .click();
117146
- await this.neetoPlaywrightUtilities.waitForPageLoad();
117186
+ await Promise.all([
117187
+ this.neetoPlaywrightUtilities.waitForPageLoad(),
117188
+ this.neetoPlaywrightUtilities.verifyToast(),
117189
+ ]);
117147
117190
  if (customSteps) {
117148
117191
  await customSteps();
117149
117192
  }
117150
117193
  else {
117151
117194
  await test.expect(this.page.getByRole("heading", {
117152
117195
  name: this.t("neetoSlack.slack.finish.title", {
117153
- teamName: currentWorkspace,
117196
+ teamName: this.currentWorkspace,
117154
117197
  }),
117155
117198
  })).toBeVisible();
117156
117199
  await this.page
@@ -117277,6 +117320,9 @@ class SlackPage extends IntegrationBase {
117277
117320
  .click();
117278
117321
  await test.expect(channelItem).toBeHidden();
117279
117322
  };
117323
+ this.allowButton = this.page.getByRole("button", {
117324
+ name: SLACK_WEB_TEXTS.allow,
117325
+ });
117280
117326
  }
117281
117327
  }
117282
117328
 
@@ -119409,7 +119455,9 @@ class CustomDomainPage {
119409
119455
  ]);
119410
119456
  await this.neetoPlaywrightUtilities.waitForPageLoad();
119411
119457
  await validateButton.click();
119412
- await test.expect(this.page.getByTestId(COMMON_SELECTORS.calloutElement)).toBeVisible({ timeout: 15000 });
119458
+ await test.expect
119459
+ .soft(this.page.getByTestId(COMMON_SELECTORS.calloutElement))
119460
+ .toBeVisible({ timeout: 15000 });
119413
119461
  let isCertificateLimitExceeded = false;
119414
119462
  await test.expect(async () => {
119415
119463
  isCertificateLimitExceeded = await this.isCertificateLimitExceeded();