@bigbinary/neeto-playwright-commons 1.8.10 → 1.8.11
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 +210 -0
- package/index.cjs.js.map +1 -1
- package/index.d.ts +54 -1
- package/index.js +208 -1
- package/index.js.map +1 -1
- package/package.json +2 -1
package/index.cjs.js
CHANGED
|
@@ -14,6 +14,7 @@ var require$$0$2 = require('util');
|
|
|
14
14
|
var require$$0$3 = require('stream');
|
|
15
15
|
var require$$0$4 = require('events');
|
|
16
16
|
var playwrightI18nextFixture = require('playwright-i18next-fixture');
|
|
17
|
+
var neetoCist = require('@bigbinary/neeto-cist');
|
|
17
18
|
var require$$3 = require('crypto');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -63,6 +64,7 @@ const CREDENTIALS = {
|
|
|
63
64
|
password: "welcome",
|
|
64
65
|
};
|
|
65
66
|
const OTP_EMAIL_PATTERN = "is your login code";
|
|
67
|
+
const SLACK_DEFAULT_CHANNEL = "general";
|
|
66
68
|
|
|
67
69
|
/* eslint-disable playwright/no-skipped-test */
|
|
68
70
|
const joinString = (string1, string2, string3 = "", separator = " ") => {
|
|
@@ -172,6 +174,7 @@ const COMMON_SELECTORS = {
|
|
|
172
174
|
modalHeader: "modal-header",
|
|
173
175
|
nameInputError: "name-input-error",
|
|
174
176
|
selectContainer: "nui-select-container",
|
|
177
|
+
selectValueContainer: "nui-select-value-container",
|
|
175
178
|
dropdownMenu: "nui-select-menu",
|
|
176
179
|
sidebarToggle: "neeto-molecules-sidebar-toggler",
|
|
177
180
|
subheader: "subheader",
|
|
@@ -7213,6 +7216,9 @@ const API_ROUTES = {
|
|
|
7213
7216
|
};
|
|
7214
7217
|
const THIRD_PARTY_ROUTES = {
|
|
7215
7218
|
webhooks: { site: "https://webhook.site/" },
|
|
7219
|
+
slack: {
|
|
7220
|
+
loginWithPassword: (workspace) => `https://${workspace}.slack.com/sign_in_with_password`,
|
|
7221
|
+
},
|
|
7216
7222
|
};
|
|
7217
7223
|
|
|
7218
7224
|
const CHAT_WIDGET_TEXTS = {
|
|
@@ -7222,6 +7228,14 @@ const CHAT_WIDGET_TEXTS = {
|
|
|
7222
7228
|
const MEMBER_TEXTS = {
|
|
7223
7229
|
agent: "Agent",
|
|
7224
7230
|
};
|
|
7231
|
+
const INTEGRATIONS_TEXTS = {
|
|
7232
|
+
connectHeader: (integration) => `Connect your ${neetoCist.humanize(integration)} account`,
|
|
7233
|
+
connectedHeader: (integration) => `You are connected to ${neetoCist.humanize(integration)}`,
|
|
7234
|
+
};
|
|
7235
|
+
const SLACK_WEB_TEXTS = {
|
|
7236
|
+
signOut: "Sign out",
|
|
7237
|
+
allow: "Allow",
|
|
7238
|
+
};
|
|
7225
7239
|
|
|
7226
7240
|
const HELP_CENTER_SELECTORS = {
|
|
7227
7241
|
helpButton: "help-button",
|
|
@@ -7658,6 +7672,199 @@ class HelpAndProfilePage {
|
|
|
7658
7672
|
}
|
|
7659
7673
|
}
|
|
7660
7674
|
|
|
7675
|
+
const INTEGRATION_SELECTORS = {
|
|
7676
|
+
integrationCard: (integration) => `${integration}-integration-card`,
|
|
7677
|
+
connectButton: "connect-button",
|
|
7678
|
+
integrationStatusTag: "integration-status-tag",
|
|
7679
|
+
disconnectButton: "disconnect-button",
|
|
7680
|
+
manageButton: "manage-button",
|
|
7681
|
+
};
|
|
7682
|
+
|
|
7683
|
+
class IntegrationBase {
|
|
7684
|
+
constructor({ page, neetoPlaywrightUtilities, integration, integrationRouteIndex, connectHeader, connectedHeader, }) {
|
|
7685
|
+
this.disconnect = async (interceptMultipleResponsesParams = {}) => {
|
|
7686
|
+
await this.gotoIntegrationIndex();
|
|
7687
|
+
await this.clickOnIntegrationCard();
|
|
7688
|
+
await this.page.getByTestId(INTEGRATION_SELECTORS.disconnectButton).click();
|
|
7689
|
+
const disconnectPromise = this.neetoPlaywrightUtilities.interceptMultipleResponses({
|
|
7690
|
+
times: 0,
|
|
7691
|
+
...interceptMultipleResponsesParams,
|
|
7692
|
+
});
|
|
7693
|
+
await this.page
|
|
7694
|
+
.getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
|
|
7695
|
+
.click();
|
|
7696
|
+
await disconnectPromise;
|
|
7697
|
+
};
|
|
7698
|
+
this.connect = async (skipGoTo) => {
|
|
7699
|
+
!skipGoTo && (await this.gotoIntegrationIndex());
|
|
7700
|
+
await this.clickOnIntegrationCard();
|
|
7701
|
+
await test.expect(this.page.getByRole("heading", {
|
|
7702
|
+
name: this.connectHeader,
|
|
7703
|
+
})).toBeVisible();
|
|
7704
|
+
await this.page.getByTestId(INTEGRATION_SELECTORS.connectButton).click();
|
|
7705
|
+
};
|
|
7706
|
+
this.verifyIntegrationStatus = async (status = "connected") => {
|
|
7707
|
+
await this.gotoIntegrationIndex();
|
|
7708
|
+
if (status === "connected") {
|
|
7709
|
+
await test.expect(this.integrationCard.getByTestId(INTEGRATION_SELECTORS.integrationStatusTag)).toBeVisible({ timeout: 10000 });
|
|
7710
|
+
}
|
|
7711
|
+
await this.clickOnIntegrationCard();
|
|
7712
|
+
const header = status === "connected" ? this.connectedHeader : this.connectHeader;
|
|
7713
|
+
await test.expect(this.page.getByRole("heading", { name: header })).toBeVisible();
|
|
7714
|
+
};
|
|
7715
|
+
this.clickOnIntegrationCard = async () => {
|
|
7716
|
+
await test.expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toHaveCount(0);
|
|
7717
|
+
await this.integrationCard.scrollIntoViewIfNeeded();
|
|
7718
|
+
await this.integrationCard.click();
|
|
7719
|
+
await test.expect(this.page.getByTestId(COMMON_SELECTORS.pageLoader)).toBeHidden();
|
|
7720
|
+
};
|
|
7721
|
+
this.gotoIntegrationIndex = async () => {
|
|
7722
|
+
neetoCist.isNotEmpty(this.integrationRouteIndex) &&
|
|
7723
|
+
(await this.page.goto(this.integrationRouteIndex));
|
|
7724
|
+
};
|
|
7725
|
+
this.page = page;
|
|
7726
|
+
this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
|
|
7727
|
+
this.t = playwrightI18nextFixture.getI18nInstance().t;
|
|
7728
|
+
this.integration = integration;
|
|
7729
|
+
this.integrationCard = this.page.getByTestId(INTEGRATION_SELECTORS.integrationCard(integration));
|
|
7730
|
+
this.integrationRouteIndex = integrationRouteIndex || "";
|
|
7731
|
+
this.connectHeader =
|
|
7732
|
+
connectHeader || INTEGRATIONS_TEXTS.connectHeader(this.integration);
|
|
7733
|
+
this.connectedHeader =
|
|
7734
|
+
connectedHeader || INTEGRATIONS_TEXTS.connectedHeader(this.integration);
|
|
7735
|
+
}
|
|
7736
|
+
}
|
|
7737
|
+
|
|
7738
|
+
const SLACK_SELECTORS = {
|
|
7739
|
+
messageContainer: "[data-qa='message_container']",
|
|
7740
|
+
loginEmail: "[data-qa='login_email']",
|
|
7741
|
+
loginPassword: "[data-qa='login_password']",
|
|
7742
|
+
signInButton: "[data-qa='signin_button']",
|
|
7743
|
+
teamPicketButtonContent: "[data-qa='team-picker-button-content']",
|
|
7744
|
+
redirectOpenInBrowser: "[data-qa='ssb_redirect_open_in_browser']",
|
|
7745
|
+
workspaceActionsButton: "[data-qa='workspace_actions_button']",
|
|
7746
|
+
teamMenuTrigger: "[data-qa='team-menu-trigger']",
|
|
7747
|
+
menuItemButton: "[data-qa='menu_item_button']",
|
|
7748
|
+
threadsFlexpane: "[data-qa='threads_flexpane']",
|
|
7749
|
+
replyBar: "[data-qa='reply_bar']",
|
|
7750
|
+
markdownElement: "[data-qa='bk_markdown_element']",
|
|
7751
|
+
virtualListItem: "[data-qa='virtual-list-item']",
|
|
7752
|
+
};
|
|
7753
|
+
|
|
7754
|
+
/* eslint-disable playwright/no-raw-locators */
|
|
7755
|
+
class SlackPage extends IntegrationBase {
|
|
7756
|
+
constructor({ page, neetoPlaywrightUtilities, integrationRouteIndex, }) {
|
|
7757
|
+
super({
|
|
7758
|
+
page,
|
|
7759
|
+
neetoPlaywrightUtilities,
|
|
7760
|
+
integration: "slack",
|
|
7761
|
+
integrationRouteIndex,
|
|
7762
|
+
});
|
|
7763
|
+
this.connectAndVerifyIntegration = async (redirectUrl, customSteps) => {
|
|
7764
|
+
await this.connect();
|
|
7765
|
+
await this.page
|
|
7766
|
+
.getByRole("button", {
|
|
7767
|
+
name: this.t("neetoSlack.slack.connect.loginButton"),
|
|
7768
|
+
})
|
|
7769
|
+
.click({ delay: 5000 });
|
|
7770
|
+
await this.page.waitForURL(RegExp("(.*)slack.com/.*"));
|
|
7771
|
+
const allowButton = this.page.getByRole("button", {
|
|
7772
|
+
name: SLACK_WEB_TEXTS.allow,
|
|
7773
|
+
});
|
|
7774
|
+
await test.expect(allowButton).toBeEnabled({ timeout: 20000 });
|
|
7775
|
+
const currentWorkspace = (await this.page
|
|
7776
|
+
.locator(SLACK_SELECTORS.teamPicketButtonContent)
|
|
7777
|
+
.textContent()) || "";
|
|
7778
|
+
await allowButton.click();
|
|
7779
|
+
await this.page.waitForURL(redirectUrl);
|
|
7780
|
+
await test.expect(this.page.getByTestId(COMMON_SELECTORS.pageLoader)).toBeHidden({ timeout: 10000 });
|
|
7781
|
+
await test.expect(this.page.getByRole("heading", {
|
|
7782
|
+
name: this.t("neetoSlack.slack.configure.title", {
|
|
7783
|
+
teamName: currentWorkspace,
|
|
7784
|
+
}),
|
|
7785
|
+
})).toBeVisible();
|
|
7786
|
+
await test.expect(this.page.getByTestId(COMMON_SELECTORS.selectValueContainer)).toContainText(SLACK_DEFAULT_CHANNEL);
|
|
7787
|
+
await this.page
|
|
7788
|
+
.getByRole("button", { name: this.t("neetoSlack.common.continue") })
|
|
7789
|
+
.click();
|
|
7790
|
+
if (customSteps) {
|
|
7791
|
+
await customSteps();
|
|
7792
|
+
}
|
|
7793
|
+
else {
|
|
7794
|
+
await test.expect(this.page.getByRole("heading", {
|
|
7795
|
+
name: this.t("neetoSlack.slack.finish.title", {
|
|
7796
|
+
teamName: currentWorkspace,
|
|
7797
|
+
}),
|
|
7798
|
+
})).toBeVisible();
|
|
7799
|
+
await this.page
|
|
7800
|
+
.getByRole("button", { name: this.t("neetoSlack.common.done") })
|
|
7801
|
+
.click();
|
|
7802
|
+
}
|
|
7803
|
+
await this.verifyIntegrationStatus();
|
|
7804
|
+
};
|
|
7805
|
+
this.disconnectAndVerifyIntegration = async () => {
|
|
7806
|
+
await this.disconnect();
|
|
7807
|
+
await this.verifyIntegrationStatus("disconnected");
|
|
7808
|
+
};
|
|
7809
|
+
this.updateConfigureSlackChannel = async ({ newSlackChannel = "random", interceptMultipleResponsesParams = {}, }) => {
|
|
7810
|
+
await this.page.getByTestId(INTEGRATION_SELECTORS.manageButton).click();
|
|
7811
|
+
await this.page
|
|
7812
|
+
.getByRole("button", { name: this.t("neetoSlack.common.edit") })
|
|
7813
|
+
.click();
|
|
7814
|
+
await this.page.getByTestId(COMMON_SELECTORS.selectContainer).click();
|
|
7815
|
+
await this.page
|
|
7816
|
+
.getByTestId(COMMON_SELECTORS.dropdownMenu)
|
|
7817
|
+
.getByText(newSlackChannel)
|
|
7818
|
+
.click();
|
|
7819
|
+
const savePromise = this.neetoPlaywrightUtilities.interceptMultipleResponses({
|
|
7820
|
+
times: 0,
|
|
7821
|
+
...interceptMultipleResponsesParams,
|
|
7822
|
+
});
|
|
7823
|
+
await this.page
|
|
7824
|
+
.getByRole("button", { name: this.t("neetoSlack.common.save") })
|
|
7825
|
+
.click();
|
|
7826
|
+
await savePromise;
|
|
7827
|
+
};
|
|
7828
|
+
this.loginToSlackWebapp = async (slackWebappPage) => {
|
|
7829
|
+
this.slackWebappPage = slackWebappPage;
|
|
7830
|
+
if (ramda.isNotNil(process.env.SLACK_WORKSPACE) &&
|
|
7831
|
+
ramda.isNotNil(process.env.SLACK_LOGIN_PASSWORD) &&
|
|
7832
|
+
ramda.isNotNil(process.env.SLACK_LOGIN_EMAIL)) {
|
|
7833
|
+
await slackWebappPage.goto(THIRD_PARTY_ROUTES.slack.loginWithPassword(process.env.SLACK_WORKSPACE));
|
|
7834
|
+
await slackWebappPage
|
|
7835
|
+
.locator(SLACK_SELECTORS.loginEmail)
|
|
7836
|
+
.pressSequentially(process.env.SLACK_LOGIN_EMAIL, { delay: 10 });
|
|
7837
|
+
await slackWebappPage
|
|
7838
|
+
.locator(SLACK_SELECTORS.loginPassword)
|
|
7839
|
+
.pressSequentially(process.env.SLACK_LOGIN_PASSWORD, { delay: 10 });
|
|
7840
|
+
await slackWebappPage.locator(SLACK_SELECTORS.signInButton).click();
|
|
7841
|
+
await slackWebappPage
|
|
7842
|
+
.locator(SLACK_SELECTORS.redirectOpenInBrowser)
|
|
7843
|
+
.click();
|
|
7844
|
+
}
|
|
7845
|
+
else {
|
|
7846
|
+
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.");
|
|
7847
|
+
}
|
|
7848
|
+
};
|
|
7849
|
+
this.logoutFromSlackWebApp = async () => {
|
|
7850
|
+
await this.slackWebappPage
|
|
7851
|
+
.locator(SLACK_SELECTORS.workspaceActionsButton)
|
|
7852
|
+
.or(this.slackWebappPage.locator(SLACK_SELECTORS.teamMenuTrigger))
|
|
7853
|
+
.click();
|
|
7854
|
+
await this.slackWebappPage
|
|
7855
|
+
.locator(SLACK_SELECTORS.menuItemButton, {
|
|
7856
|
+
hasText: SLACK_WEB_TEXTS.signOut,
|
|
7857
|
+
})
|
|
7858
|
+
.click();
|
|
7859
|
+
};
|
|
7860
|
+
this.goToSlackChannel = async (slackChannel) => {
|
|
7861
|
+
await this.slackWebappPage
|
|
7862
|
+
.locator(SLACK_SELECTORS.virtualListItem, { hasText: slackChannel })
|
|
7863
|
+
.click();
|
|
7864
|
+
};
|
|
7865
|
+
}
|
|
7866
|
+
}
|
|
7867
|
+
|
|
7661
7868
|
const WEBHOOK_SELECTORS = {
|
|
7662
7869
|
addNewWebhook: "add-new-webhook-button",
|
|
7663
7870
|
endpointInputField: "endpoint-input-field",
|
|
@@ -8655,6 +8862,7 @@ exports.GLOBAL_TRANSLATIONS_PATTERN = GLOBAL_TRANSLATIONS_PATTERN;
|
|
|
8655
8862
|
exports.HELP_CENTER_SELECTORS = HELP_CENTER_SELECTORS;
|
|
8656
8863
|
exports.HelpAndProfilePage = HelpAndProfilePage;
|
|
8657
8864
|
exports.IS_STAGING_ENV = IS_STAGING_ENV;
|
|
8865
|
+
exports.IntegrationBase = IntegrationBase;
|
|
8658
8866
|
exports.KEYBOARD_SHORTCUTS_SELECTORS = KEYBOARD_SHORTCUTS_SELECTORS;
|
|
8659
8867
|
exports.LOGIN_SELECTORS = LOGIN_SELECTORS;
|
|
8660
8868
|
exports.MEMBER_FORM_SELECTORS = MEMBER_FORM_SELECTORS;
|
|
@@ -8671,7 +8879,9 @@ exports.PROJECT_TRANSLATIONS_PATH = PROJECT_TRANSLATIONS_PATH;
|
|
|
8671
8879
|
exports.ROLES_SELECTORS = ROLES_SELECTORS;
|
|
8672
8880
|
exports.ROUTES = ROUTES;
|
|
8673
8881
|
exports.SIGNUP_SELECTORS = SIGNUP_SELECTORS;
|
|
8882
|
+
exports.SLACK_DEFAULT_CHANNEL = SLACK_DEFAULT_CHANNEL;
|
|
8674
8883
|
exports.STORAGE_STATE = STORAGE_STATE;
|
|
8884
|
+
exports.SlackPage = SlackPage;
|
|
8675
8885
|
exports.TAGS_SELECTORS = TAGS_SELECTORS;
|
|
8676
8886
|
exports.THIRD_PARTY_ROUTES = THIRD_PARTY_ROUTES;
|
|
8677
8887
|
exports.USER_AGENTS = USER_AGENTS;
|