@bigbinary/neeto-playwright-commons 3.1.6 → 3.2.1

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
@@ -998,6 +998,8 @@ declare class SlackApi {
998
998
  fetchMessages: (channelId: string, unixTimestamp: number) => Promise<playwright_core.APIResponse | undefined>;
999
999
  createChannel: (channelName: string) => Promise<playwright_core.APIResponse | undefined>;
1000
1000
  addUser: (channelId: string, userId: string) => Promise<playwright_core.APIResponse | undefined>;
1001
+ listChannels: () => Promise<playwright_core.APIResponse | undefined>;
1002
+ archiveChannel: (channelId: string) => Promise<playwright_core.APIResponse | undefined>;
1001
1003
  mockChannelDeleted: (channelId: string) => Promise<playwright_core.APIResponse | undefined>;
1002
1004
  }
1003
1005
  declare class WebhookSiteApi {
@@ -2917,6 +2919,7 @@ declare class SlackPage extends IntegrationBase {
2917
2919
  allowButton: Locator;
2918
2920
  callbackUrl: string;
2919
2921
  currentWorkspace: string;
2922
+ slackApi: SlackApi;
2920
2923
  constructor({
2921
2924
  page,
2922
2925
  neetoPlaywrightUtilities,
@@ -3088,18 +3091,25 @@ declare class SlackPage extends IntegrationBase {
3088
3091
  channelName,
3089
3092
  kind
3090
3093
  }: CreateNewSlackChannelParams) => Promise<void>;
3094
+ /**
3095
+ * @deprecated Use {@link SlackPage.archiveChannelViaAPI} instead. This flow
3096
+ * drives the Slack web UI to permanently delete a channel and is brittle;
3097
+ * `archiveChannelViaAPI` archives via the Slack Web API (requires
3098
+ * `SLACK_BOT_TOKEN`).
3099
+ */
3100
+ deleteSlackChannel: (channel: string) => Promise<void>;
3091
3101
  /**
3092
3102
  *
3093
- * Deletes a slack channel. It takes the following parameters:
3103
+ * Archives a Slack channel by name using the Slack Web API (conversations.list then conversations.archive). Requires SLACK_BOT_TOKEN with scopes that allow listing and archiving channels. Does not drive the Slack web UI; use when tests only need the channel removed or archived on the workspace.
3094
3104
  *
3095
- * channel: Name of the Slack channel to delete.
3105
+ * channel: Channel name to archive.
3096
3106
  *
3097
3107
  * @example
3098
3108
  *
3099
- * await slackPage.deleteSlackChannel("old-channel");
3109
+ * await slackPage.archiveChannelViaAPI("temp-test-channel");
3100
3110
  * @endexample
3101
3111
  */
3102
- deleteSlackChannel: (channel: string) => Promise<void>;
3112
+ archiveChannelViaAPI: (name: string) => Promise<void>;
3103
3113
  }
3104
3114
  interface WebhooksPageParams {
3105
3115
  page: Page;
@@ -4547,8 +4557,32 @@ declare class OrganizationPage {
4547
4557
  page: Page;
4548
4558
  neetoPlaywrightUtilities: CustomCommands;
4549
4559
  constructor(page: Page, neetoPlaywrightUtilities: CustomCommands);
4550
- private fillOTP;
4551
- private submitEmail;
4560
+ /**
4561
+ *
4562
+ * Waits for the page to load, fills the OTP field, and waits until the OTP input is hidden (up to 35s), indicating the code was accepted.
4563
+ *
4564
+ * otp (optional): One-time password to enter. Defaults to a random 6-digit string.
4565
+ *
4566
+ * @example
4567
+ *
4568
+ * await organizationPage.fillOTP();
4569
+ * // OR
4570
+ * await organizationPage.fillOTP("123456");
4571
+ * @endexample
4572
+ */
4573
+ fillOTP: (otp?: string) => Promise<void>;
4574
+ /**
4575
+ *
4576
+ * Waits for the page to load, fills the signup email field, clicks submit, and waits until the submit button is hidden (up to 35s). Use this as the first step when driving the email-based signup flow before entering an OTP.
4577
+ *
4578
+ * email: Address to enter in the signup email field.
4579
+ *
4580
+ * @example
4581
+ *
4582
+ * await organizationPage.submitEmail("jane@example.com");
4583
+ * @endexample
4584
+ */
4585
+ submitEmail: (email: string) => Promise<void>;
4552
4586
  private dismissAuthenticatorSetupPromptIfPresent;
4553
4587
  /**
4554
4588
  *
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { keysToSnakeCase, isPresent, hyphenate, isNotPresent, humanize, dynamicArray, findBy, truncate, isNotEmpty, isNotEqualDeep, randomPick } from '@bigbinary/neeto-cist';
1
+ import { keysToSnakeCase, isPresent, hyphenate, isNotPresent, humanize, findBy, dynamicArray, truncate, isNotEmpty, isNotEqualDeep, randomPick } from '@bigbinary/neeto-cist';
2
2
  import { faker } from '@faker-js/faker';
3
3
  import * as fs$4 from 'fs';
4
4
  import fs__default, { readFileSync, promises, existsSync, writeFileSync, unlinkSync, mkdirSync, rmSync, createWriteStream } from 'fs';
@@ -618,6 +618,8 @@ class SlackApi {
618
618
  fetchMessages = (channelId, unixTimestamp) => this.apiRequest("history", { channel: channelId, oldest: unixTimestamp });
619
619
  createChannel = (channelName) => this.apiRequest("create", { name: channelName });
620
620
  addUser = (channelId, userId) => this.apiRequest("invite", { channel: channelId, users: userId });
621
+ listChannels = () => this.apiRequest("list", { exclude_archived: 1, limit: 1000 });
622
+ archiveChannel = (channelId) => this.apiRequest("archive", { channel: channelId });
621
623
  mockChannelDeleted = (channelId) => this.neetoPlaywrightUtilities.apiRequest({
622
624
  url: "/neeto_slack/api/v1/testing/webhooks",
623
625
  method: "post",
@@ -119460,6 +119462,7 @@ class SlackPage extends IntegrationBase {
119460
119462
  allowButton;
119461
119463
  callbackUrl;
119462
119464
  currentWorkspace;
119465
+ slackApi;
119463
119466
  constructor({ page, neetoPlaywrightUtilities, integrationRouteIndex, }) {
119464
119467
  super({
119465
119468
  page,
@@ -119470,6 +119473,7 @@ class SlackPage extends IntegrationBase {
119470
119473
  this.allowButton = this.page.getByRole("button", {
119471
119474
  name: SLACK_WEB_TEXTS.allow,
119472
119475
  });
119476
+ this.slackApi = new SlackApi(this.neetoPlaywrightUtilities);
119473
119477
  }
119474
119478
  setupCloseHandlers = async (slackWebappPage = this.page) => {
119475
119479
  const slackWebappPageDataQa = getByDataQA(slackWebappPage);
@@ -119654,6 +119658,12 @@ class SlackPage extends IntegrationBase {
119654
119658
  await nextButton.click();
119655
119659
  await this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.inviteToWorkspaceSkipButton).click();
119656
119660
  };
119661
+ /**
119662
+ * @deprecated Use {@link SlackPage.archiveChannelViaAPI} instead. This flow
119663
+ * drives the Slack web UI to permanently delete a channel and is brittle;
119664
+ * `archiveChannelViaAPI` archives via the Slack Web API (requires
119665
+ * `SLACK_BOT_TOKEN`).
119666
+ */
119657
119667
  deleteSlackChannel = async (channel) => {
119658
119668
  const channelItem = this.slackWebappPage.locator(SLACK_SELECTORS.channelItems, { hasText: channel });
119659
119669
  await channelItem.click({ button: "right" });
@@ -119674,6 +119684,12 @@ class SlackPage extends IntegrationBase {
119674
119684
  .click();
119675
119685
  await expect(channelItem).toBeHidden();
119676
119686
  };
119687
+ archiveChannelViaAPI = async (name) => {
119688
+ const response = await this.slackApi.listChannels();
119689
+ const { channels } = (await response?.json());
119690
+ const channel = findBy({ name }, channels);
119691
+ channel?.id && (await this.slackApi.archiveChannel(channel.id));
119692
+ };
119677
119693
  }
119678
119694
 
119679
119695
  class WebhooksPage {
@@ -126725,6 +126741,7 @@ const definePlaywrightConfig = (overrides) => {
126725
126741
  name: PROJECT_NAMES.productionHealth,
126726
126742
  testDir: "./e2e/health",
126727
126743
  testMatch: "production.health.ts",
126744
+ retries: IS_CI ? 3 : 0,
126728
126745
  use: {
126729
126746
  ...devices["Desktop Chrome"],
126730
126747
  baseURL: process.env.PLAYWRIGHT_PRODUCTION_BASE_URL,