@bigbinary/neeto-playwright-commons 1.8.39 → 1.8.41

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
@@ -172,6 +172,16 @@ const shouldSkipSetupAndTeardown = () => { var _a; return ((_a = getGlobalUserSt
172
172
  // trims and replaces multiple whitespace characters in a string with a single space
173
173
  const squish = (text) => text.trim().replace(/\s+/g, " ");
174
174
  const toCamelCase = (string) => string.toLowerCase().replace(/( \w)/g, letter => letter[1].toUpperCase());
175
+ const getByDataQA = ramda.curry((page, dataQa) => {
176
+ if (typeof dataQa === "string") {
177
+ // eslint-disable-next-line playwright/no-raw-locators
178
+ return page.locator(`[data-qa='${dataQa}']`);
179
+ }
180
+ // eslint-disable-next-line playwright/no-raw-locators
181
+ return page
182
+ .locator(`[data-qa='${dataQa[0]}']`)
183
+ .locator(`[data-qa='${dataQa[1]}']`);
184
+ });
175
185
 
176
186
  const COMMON_SELECTORS = {
177
187
  copyButton: "copy-button",
@@ -237,6 +247,8 @@ const COMMON_SELECTORS = {
237
247
  columnsDropdownButton: "columns-dropdown-button",
238
248
  breadcrumbHeader: "header-breadcrumb",
239
249
  header: "neeto-molecules-header",
250
+ sidebarSubLink: (label) => `${hyphenize(label)}-sub-link`,
251
+ sidebarGoBackButton: (label) => `${hyphenize(label)}-go-back-button`,
240
252
  };
241
253
 
242
254
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -12585,6 +12597,10 @@ const SLACK_WEB_TEXTS = {
12585
12597
  signOut: "Sign out",
12586
12598
  allow: "Allow",
12587
12599
  loadingThread: "Loading thread",
12600
+ name: "Name",
12601
+ deleteThisChannel: "Delete this channel",
12602
+ permanentlyDeleteTheChannel: "Yes, permanently delete the channel",
12603
+ deleteChannel: "Delete channel",
12588
12604
  };
12589
12605
 
12590
12606
  const HELP_CENTER_SELECTORS = {
@@ -12933,6 +12949,21 @@ const SLACK_SELECTORS = {
12933
12949
  replyBar: "[data-qa='reply_bar']",
12934
12950
  markdownElement: "[data-qa='bk_markdown_element']",
12935
12951
  virtualListItem: "[data-qa='virtual-list-item']",
12952
+ channelItems: '[role="treeitem"][data-qa="virtual-list-item"]',
12953
+ };
12954
+ const SLACK_DATA_QA_SELECTORS = {
12955
+ sectionHeadingButton: "section_heading_button__channels",
12956
+ channelSectionSubmenuCreate: "channel_section_submenu_create",
12957
+ channelSectionMenuCreateChannel: "channel_section_menu__create_channel",
12958
+ skModalContent: "sk-modal-content",
12959
+ infiniteSpinner: "infinite-spinner",
12960
+ channelNameOptionsList: "channel-name-options-list",
12961
+ channelNameInput: "channel-name-input",
12962
+ createChannelNextButton: "create-channel-next-button",
12963
+ inviteToWorkspaceSkipButton: "invite_to_workspace_skip_button",
12964
+ menuItems: "menu_items",
12965
+ channelDetailsModal: "channel_details_modal",
12966
+ channelDetailsSettingsTab: "channel_details_settings_tab",
12936
12967
  };
12937
12968
 
12938
12969
  /* eslint-disable playwright/no-raw-locators */
@@ -12944,7 +12975,7 @@ class SlackPage extends IntegrationBase {
12944
12975
  integration: "slack",
12945
12976
  integrationRouteIndex,
12946
12977
  });
12947
- this.connectAndVerifyIntegration = async (redirectUrl, customSteps) => {
12978
+ this.connectAndVerifyIntegration = async (redirectUrl, customSteps, channelToConfigure = SLACK_DEFAULT_CHANNEL) => {
12948
12979
  await this.connect();
12949
12980
  await this.page
12950
12981
  .getByRole("button", {
@@ -12967,7 +12998,11 @@ class SlackPage extends IntegrationBase {
12967
12998
  teamName: currentWorkspace,
12968
12999
  }),
12969
13000
  })).toBeVisible();
12970
- await test$1.expect(this.page.getByTestId(COMMON_SELECTORS.selectValueContainer)).toContainText(SLACK_DEFAULT_CHANNEL);
13001
+ await this.neetoPlaywrightUtilities.selectOptionFromDropdown({
13002
+ value: channelToConfigure,
13003
+ selectValueContainer: COMMON_SELECTORS.selectValueContainer,
13004
+ selectMenu: COMMON_SELECTORS.dropdownMenu,
13005
+ });
12971
13006
  await this.page
12972
13007
  .getByRole("button", { name: this.t("neetoSlack.common.continue") })
12973
13008
  .click();
@@ -12990,11 +13025,14 @@ class SlackPage extends IntegrationBase {
12990
13025
  await this.disconnect();
12991
13026
  await this.verifyIntegrationStatus("disconnected");
12992
13027
  };
12993
- this.updateConfigureSlackChannel = async ({ newSlackChannel = "random", interceptMultipleResponsesParams = {}, }) => {
13028
+ this.updateConfigureSlackChannel = async ({ newSlackChannel = "random", interceptMultipleResponsesParams = {}, refreshInterceptMultipleResponsesParams = {}, refreshChannelList = false, }) => {
12994
13029
  await this.page.getByTestId(INTEGRATION_SELECTORS.manageButton).click();
12995
13030
  await this.page
12996
13031
  .getByRole("button", { name: this.t("neetoSlack.common.edit") })
12997
13032
  .click();
13033
+ if (refreshChannelList) {
13034
+ await this.clickOnChannelListRefreshButton(refreshInterceptMultipleResponsesParams);
13035
+ }
12998
13036
  await this.page.getByTestId(COMMON_SELECTORS.selectContainer).click();
12999
13037
  await this.page
13000
13038
  .getByTestId(COMMON_SELECTORS.dropdownMenu)
@@ -13009,25 +13047,41 @@ class SlackPage extends IntegrationBase {
13009
13047
  .click();
13010
13048
  await savePromise;
13011
13049
  };
13012
- this.loginToSlackWebapp = async (slackWebappPage) => {
13050
+ this.clickOnChannelListRefreshButton = async (refreshInterceptMultipleResponsesParams) => {
13051
+ const refreshChannelPromise = this.neetoPlaywrightUtilities.interceptMultipleResponses({
13052
+ times: 0,
13053
+ ...refreshInterceptMultipleResponsesParams,
13054
+ });
13055
+ await this.page
13056
+ .getByRole("button", {
13057
+ name: this.t("neetoSlack.slack.channelListRefreshButton"),
13058
+ })
13059
+ .click();
13060
+ await refreshChannelPromise;
13061
+ };
13062
+ this.loginToSlackWebapp = async (slackWebappPage, customCredentials) => {
13013
13063
  this.slackWebappPage = slackWebappPage;
13014
- if (ramda.isNotNil(process.env.SLACK_WORKSPACE) &&
13015
- ramda.isNotNil(process.env.SLACK_LOGIN_PASSWORD) &&
13016
- ramda.isNotNil(process.env.SLACK_LOGIN_EMAIL)) {
13017
- await slackWebappPage.goto(THIRD_PARTY_ROUTES.slack.loginWithPassword(process.env.SLACK_WORKSPACE));
13064
+ this.slackWebappPageDataQa = getByDataQA(this.slackWebappPage);
13065
+ const slackWorkspace = (customCredentials === null || customCredentials === void 0 ? void 0 : customCredentials.workspace) || process.env.SLACK_WORKSPACE;
13066
+ const slackLoginPassword = (customCredentials === null || customCredentials === void 0 ? void 0 : customCredentials.loginPassword) || process.env.SLACK_LOGIN_PASSWORD;
13067
+ const slackLoginEmail = (customCredentials === null || customCredentials === void 0 ? void 0 : customCredentials.loginEmail) || process.env.SLACK_LOGIN_EMAIL;
13068
+ if (ramda.isNotNil(slackWorkspace) &&
13069
+ ramda.isNotNil(slackLoginPassword) &&
13070
+ ramda.isNotNil(slackLoginEmail)) {
13071
+ await slackWebappPage.goto(THIRD_PARTY_ROUTES.slack.loginWithPassword(slackWorkspace));
13018
13072
  await slackWebappPage
13019
13073
  .locator(SLACK_SELECTORS.loginEmail)
13020
- .pressSequentially(process.env.SLACK_LOGIN_EMAIL, { delay: 10 });
13074
+ .pressSequentially(slackLoginEmail, { delay: 10 });
13021
13075
  await slackWebappPage
13022
13076
  .locator(SLACK_SELECTORS.loginPassword)
13023
- .pressSequentially(process.env.SLACK_LOGIN_PASSWORD, { delay: 10 });
13077
+ .pressSequentially(slackLoginPassword, { delay: 10 });
13024
13078
  await slackWebappPage.locator(SLACK_SELECTORS.signInButton).click();
13025
13079
  await slackWebappPage
13026
13080
  .locator(SLACK_SELECTORS.redirectOpenInBrowser)
13027
13081
  .click();
13028
13082
  }
13029
13083
  else {
13030
- throw new Error("ENV variable SLACK_LOGIN_EMAIL or SLACK_LOGIN_PASSWORD or SLACK_WORKSPACE is not defined. Please add the API key to use this fixture.");
13084
+ throw new Error("ENV variable SLACK_LOGIN_EMAIL or SLACK_LOGIN_PASSWORD or SLACK_WORKSPACE is not defined.");
13031
13085
  }
13032
13086
  };
13033
13087
  this.logoutFromSlackWebApp = async () => {
@@ -13046,6 +13100,49 @@ class SlackPage extends IntegrationBase {
13046
13100
  .locator(SLACK_SELECTORS.virtualListItem, { hasText: slackChannel })
13047
13101
  .click();
13048
13102
  };
13103
+ this.createNewSlackChannel = async ({ channelName, kind = "public", }) => {
13104
+ await this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.sectionHeadingButton).click();
13105
+ await this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.channelSectionSubmenuCreate).click();
13106
+ await this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.channelSectionMenuCreateChannel).click();
13107
+ await test$1.expect(this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.skModalContent)).toBeVisible();
13108
+ await test$1.expect(this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.infiniteSpinner)).toBeHidden();
13109
+ await test$1.expect(this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.channelNameOptionsList)).toBeHidden({ timeout: 5000 });
13110
+ await this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.skModalContent)
13111
+ .getByText(SLACK_WEB_TEXTS.name, { exact: true })
13112
+ .click();
13113
+ await this.slackWebappPageDataQa([
13114
+ SLACK_DATA_QA_SELECTORS.skModalContent,
13115
+ SLACK_DATA_QA_SELECTORS.channelNameInput,
13116
+ ]).pressSequentially(channelName);
13117
+ await test$1.expect(this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.infiniteSpinner)).toBeHidden();
13118
+ await test$1.expect(this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.createChannelNextButton)).toBeEnabled();
13119
+ await this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.createChannelNextButton).click();
13120
+ await this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.skModalContent)
13121
+ .getByRole("radio", { name: kind })
13122
+ .check();
13123
+ await this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.createChannelNextButton).click();
13124
+ await this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.inviteToWorkspaceSkipButton).click();
13125
+ };
13126
+ this.deleteSlackChannel = async (channel) => {
13127
+ const channelItem = this.slackWebappPage.locator(SLACK_SELECTORS.channelItems, { hasText: channel });
13128
+ await channelItem.click({ button: "right" });
13129
+ await this.slackWebappPageDataQa([
13130
+ SLACK_DATA_QA_SELECTORS.menuItems,
13131
+ SLACK_DATA_QA_SELECTORS.channelDetailsModal,
13132
+ ]).click();
13133
+ await test$1.expect(this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.channelDetailsModal)).toBeVisible();
13134
+ await this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.channelDetailsSettingsTab).click();
13135
+ await this.slackWebappPageDataQa(SLACK_DATA_QA_SELECTORS.skModalContent)
13136
+ .getByRole("button", { name: SLACK_WEB_TEXTS.deleteThisChannel })
13137
+ .click();
13138
+ await this.slackWebappPage
13139
+ .getByLabel(SLACK_WEB_TEXTS.permanentlyDeleteTheChannel)
13140
+ .check();
13141
+ await this.slackWebappPage
13142
+ .getByRole("button", { name: SLACK_WEB_TEXTS.deleteChannel })
13143
+ .click();
13144
+ await test$1.expect(channelItem).toBeHidden();
13145
+ };
13049
13146
  }
13050
13147
  }
13051
13148
 
@@ -13279,6 +13376,16 @@ class OrganizationPage {
13279
13376
  }
13280
13377
  }
13281
13378
 
13379
+ class SidebarSection {
13380
+ constructor(page, neetoPlaywrightUtilities) {
13381
+ this.clickOnSubLink = (label) => this.page.getByTestId(COMMON_SELECTORS.sidebarSubLink(label)).click();
13382
+ this.clickOnGoBackButton = (label) => this.page.getByTestId(COMMON_SELECTORS.sidebarGoBackButton(label)).click();
13383
+ this.page = page;
13384
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
13385
+ this.t = playwrightI18nextFixture.getI18nInstance().t;
13386
+ }
13387
+ }
13388
+
13282
13389
  const USER_AGENTS = {
13283
13390
  windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36",
13284
13391
  mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
@@ -147085,10 +147192,12 @@ exports.PROJECT_TRANSLATIONS_PATH = PROJECT_TRANSLATIONS_PATH;
147085
147192
  exports.ROLES_SELECTORS = ROLES_SELECTORS;
147086
147193
  exports.ROUTES = ROUTES;
147087
147194
  exports.SIGNUP_SELECTORS = SIGNUP_SELECTORS;
147195
+ exports.SLACK_DATA_QA_SELECTORS = SLACK_DATA_QA_SELECTORS;
147088
147196
  exports.SLACK_DEFAULT_CHANNEL = SLACK_DEFAULT_CHANNEL;
147089
147197
  exports.SLACK_SELECTORS = SLACK_SELECTORS;
147090
147198
  exports.SLACK_WEB_TEXTS = SLACK_WEB_TEXTS;
147091
147199
  exports.STORAGE_STATE = STORAGE_STATE;
147200
+ exports.SidebarSection = SidebarSection;
147092
147201
  exports.SlackPage = SlackPage;
147093
147202
  exports.TAGS_SELECTORS = TAGS_SELECTORS;
147094
147203
  exports.THIRD_PARTY_ROUTES = THIRD_PARTY_ROUTES;
@@ -147102,6 +147211,7 @@ exports.definePlaywrightConfig = definePlaywrightConfig;
147102
147211
  exports.executeWithThrottledResources = executeWithThrottledResources;
147103
147212
  exports.extractSubdomainFromError = extractSubdomainFromError;
147104
147213
  exports.generateStagingData = generateStagingData;
147214
+ exports.getByDataQA = getByDataQA;
147105
147215
  exports.getGlobalUserState = getGlobalUserState;
147106
147216
  exports.headerUtils = headerUtils;
147107
147217
  exports.hyphenize = hyphenize;