@bigbinary/neeto-playwright-commons 1.7.1 → 1.8.0
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 +109 -7
- package/index.cjs.js.map +1 -1
- package/index.d.ts +40 -1
- package/index.js +106 -9
- package/index.js.map +1 -1
- package/package.json +2 -2
package/index.cjs.js
CHANGED
|
@@ -79,6 +79,7 @@ const readFileSyncIfExists = (path = STORAGE_STATE) => {
|
|
|
79
79
|
return {};
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
+
const getGlobalUserState = () => { var _a; return (_a = readFileSyncIfExists()) === null || _a === void 0 ? void 0 : _a.user; };
|
|
82
83
|
const writeDataToFile = data => {
|
|
83
84
|
try {
|
|
84
85
|
require$$0__namespace.writeFileSync(STORAGE_STATE, data, "utf8");
|
|
@@ -93,13 +94,18 @@ const updateCredentials = ({ key, value }) => {
|
|
|
93
94
|
data["user"][key] = value;
|
|
94
95
|
return writeDataToFile(JSON.stringify(data));
|
|
95
96
|
};
|
|
96
|
-
const
|
|
97
|
+
const removeCredentialFile = () => {
|
|
97
98
|
require$$0__namespace.unlink(STORAGE_STATE, error => {
|
|
98
99
|
if (!error)
|
|
99
100
|
return;
|
|
100
101
|
console.log(error); // eslint-disable-line
|
|
101
102
|
});
|
|
102
103
|
};
|
|
104
|
+
const clearCredentials = () => {
|
|
105
|
+
if (shouldSkipSetupAndTeardown())
|
|
106
|
+
return;
|
|
107
|
+
removeCredentialFile();
|
|
108
|
+
};
|
|
103
109
|
const hyphenize = input => {
|
|
104
110
|
const fallbackString = "";
|
|
105
111
|
if (typeof input === "number")
|
|
@@ -119,6 +125,7 @@ const skipTest = {
|
|
|
119
125
|
forReviewEnv: () => test__default["default"].skip(process.env.TEST_ENV === ENVIRONMENT.review),
|
|
120
126
|
forAllExceptStagingEnv: () => test__default["default"].skip(process.env.TEST_ENV !== ENVIRONMENT.staging),
|
|
121
127
|
};
|
|
128
|
+
const shouldSkipSetupAndTeardown = () => { var _a; return ((_a = getGlobalUserState()) === null || _a === void 0 ? void 0 : _a.isLoggedIn) && process.env.SKIP_SETUP === "true"; };
|
|
122
129
|
|
|
123
130
|
const COMMON_SELECTORS = {
|
|
124
131
|
spinner: ".neeto-ui-spinner",
|
|
@@ -7192,11 +7199,22 @@ const ROUTES = {
|
|
|
7192
7199
|
show: (id) => `/team_members/teams/${id}`,
|
|
7193
7200
|
},
|
|
7194
7201
|
};
|
|
7202
|
+
const API_ROUTES = {
|
|
7203
|
+
teamMembers: {
|
|
7204
|
+
all: "/team_members*/**",
|
|
7205
|
+
bulkUpdate: "/team_members/teams/bulk_update",
|
|
7206
|
+
index: "/team_members/teams",
|
|
7207
|
+
show: (id) => `/team_members/teams/${id}`,
|
|
7208
|
+
},
|
|
7209
|
+
};
|
|
7195
7210
|
|
|
7196
7211
|
const CHAT_WIDGET_TEXTS = {
|
|
7197
7212
|
newConversation: "New Conversation",
|
|
7198
7213
|
welcomeChatBubble: "Hi! I'm here to assist you with any questions you may have. What can I do for you?",
|
|
7199
7214
|
};
|
|
7215
|
+
const MEMBER_TEXTS = {
|
|
7216
|
+
agent: "Agent",
|
|
7217
|
+
};
|
|
7200
7218
|
|
|
7201
7219
|
const HELP_CENTER_SELECTORS = {
|
|
7202
7220
|
helpButton: "help-button",
|
|
@@ -7431,6 +7449,8 @@ class HelpAndProfilePage {
|
|
|
7431
7449
|
}));
|
|
7432
7450
|
};
|
|
7433
7451
|
this.verifyLogout = async () => {
|
|
7452
|
+
if (shouldSkipSetupAndTeardown())
|
|
7453
|
+
return;
|
|
7434
7454
|
await test.test.step("Step 1: Open Profile popup and verify", this.openProfilePopup);
|
|
7435
7455
|
await test.test.step("Step 2: Click logout and verify", async () => {
|
|
7436
7456
|
await this.page
|
|
@@ -7476,9 +7496,15 @@ const extractSubdomainFromError = (errorString) => {
|
|
|
7476
7496
|
|
|
7477
7497
|
class OrganizationPage {
|
|
7478
7498
|
constructor(page, neetoPlaywrightUtilities) {
|
|
7499
|
+
this.baseUrlGenerator = (appName) => {
|
|
7500
|
+
const { subdomainName } = getGlobalUserState();
|
|
7501
|
+
return `https://${subdomainName}.${appName}.net`;
|
|
7502
|
+
};
|
|
7479
7503
|
this.createOrganization = async ({ email, businessName, subdomainName, firstName, lastName, appName, }) => {
|
|
7480
7504
|
if (!IS_STAGING_ENV)
|
|
7481
7505
|
return;
|
|
7506
|
+
if (shouldSkipSetupAndTeardown())
|
|
7507
|
+
return;
|
|
7482
7508
|
const defaultOtp = "123456";
|
|
7483
7509
|
const appNameInLowerCase = appName.toLowerCase();
|
|
7484
7510
|
const isNeetoAuth = appNameInLowerCase === "neetoauth";
|
|
@@ -7531,6 +7557,8 @@ class OrganizationPage {
|
|
|
7531
7557
|
this.setupOrganization = async (product) => {
|
|
7532
7558
|
if (!IS_STAGING_ENV)
|
|
7533
7559
|
return;
|
|
7560
|
+
if (shouldSkipSetupAndTeardown())
|
|
7561
|
+
return;
|
|
7534
7562
|
const { user } = readFileSyncIfExists();
|
|
7535
7563
|
await this.createOrganization({
|
|
7536
7564
|
businessName: user.businessName,
|
|
@@ -7548,6 +7576,11 @@ class OrganizationPage {
|
|
|
7548
7576
|
userCredentials,
|
|
7549
7577
|
]);
|
|
7550
7578
|
writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
|
|
7579
|
+
updateCredentials({ key: "isLoggedIn", value: "true" });
|
|
7580
|
+
updateCredentials({
|
|
7581
|
+
key: "baseUrl",
|
|
7582
|
+
value: this.baseUrlGenerator(`neeto${product}`),
|
|
7583
|
+
});
|
|
7551
7584
|
};
|
|
7552
7585
|
this.updateSubdomainIfExists = async (appName) => {
|
|
7553
7586
|
const subdomainError = this.page.getByTestId(SIGNUP_SELECTORS.subdomainError);
|
|
@@ -7569,8 +7602,7 @@ class OrganizationPage {
|
|
|
7569
7602
|
key: "businessName",
|
|
7570
7603
|
value: newOrganizationName,
|
|
7571
7604
|
});
|
|
7572
|
-
|
|
7573
|
-
process.env.BASE_URL = newBaseUrl;
|
|
7605
|
+
process.env.BASE_URL = this.baseUrlGenerator(appName);
|
|
7574
7606
|
await this.page
|
|
7575
7607
|
.getByTestId(SIGNUP_SELECTORS.organizationNameTextField)
|
|
7576
7608
|
.fill(newOrganizationName);
|
|
@@ -7714,17 +7746,35 @@ const MERGE_TAGS_SELECTORS = {
|
|
|
7714
7746
|
};
|
|
7715
7747
|
|
|
7716
7748
|
const initializeCredentials = (product) => {
|
|
7717
|
-
|
|
7749
|
+
var _a;
|
|
7750
|
+
if (process.env.SKIP_SETUP === "true" && getGlobalUserState()) {
|
|
7751
|
+
const { email } = getGlobalUserState();
|
|
7752
|
+
if (IS_STAGING_ENV) {
|
|
7753
|
+
email.endsWith("example.com") && removeCredentialFile();
|
|
7754
|
+
}
|
|
7755
|
+
else {
|
|
7756
|
+
email.endsWith("bigbinary.com") && removeCredentialFile();
|
|
7757
|
+
}
|
|
7758
|
+
readFileSyncIfExists();
|
|
7759
|
+
}
|
|
7760
|
+
const skipSetup = shouldSkipSetupAndTeardown();
|
|
7761
|
+
if (skipSetup) {
|
|
7762
|
+
if (IS_STAGING_ENV) {
|
|
7763
|
+
process.env.BASE_URL = (_a = getGlobalUserState()) === null || _a === void 0 ? void 0 : _a.baseUrl;
|
|
7764
|
+
}
|
|
7765
|
+
return;
|
|
7766
|
+
}
|
|
7718
7767
|
const stagingData = generateStagingData(product);
|
|
7719
|
-
|
|
7720
|
-
writeDataToFile(JSON.stringify({ user: newUserState }, null, 2));
|
|
7768
|
+
writeDataToFile(JSON.stringify({ user: stagingData }, null, 2));
|
|
7721
7769
|
if (IS_STAGING_ENV) {
|
|
7722
|
-
const baseUrl = `https://${
|
|
7770
|
+
const baseUrl = `https://${stagingData.subdomainName}.${stagingData.domain}`;
|
|
7723
7771
|
process.env.BASE_URL = baseUrl;
|
|
7724
7772
|
}
|
|
7725
7773
|
};
|
|
7726
7774
|
|
|
7727
7775
|
const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/", }) => {
|
|
7776
|
+
if (shouldSkipSetupAndTeardown())
|
|
7777
|
+
return;
|
|
7728
7778
|
await page.goto(loginPath);
|
|
7729
7779
|
await page.getByTestId("login-email-text-field").fill(CREDENTIALS.email);
|
|
7730
7780
|
await page
|
|
@@ -7739,10 +7789,57 @@ const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/"
|
|
|
7739
7789
|
await page.context().storageState({ path: STORAGE_STATE });
|
|
7740
7790
|
const mergedCredentials = ramda.mergeAll([readFileSyncIfExists(), userCredentials]);
|
|
7741
7791
|
writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
|
|
7792
|
+
updateCredentials({ key: "isLoggedIn", value: "true" });
|
|
7742
7793
|
};
|
|
7743
7794
|
const login = async ({ page, neetoPlaywrightUtilities, loginPath, }) => !IS_STAGING_ENV &&
|
|
7744
7795
|
(await loginWithoutSSO({ page, neetoPlaywrightUtilities, loginPath }));
|
|
7745
7796
|
|
|
7797
|
+
const addMemberViaRequest = ({ email, role = MEMBER_TEXTS.agent, appName, neetoPlaywrightUtilities, }) => neetoPlaywrightUtilities.apiRequest({
|
|
7798
|
+
method: "post",
|
|
7799
|
+
url: API_ROUTES.teamMembers.index,
|
|
7800
|
+
body: {
|
|
7801
|
+
user: {
|
|
7802
|
+
emails: [email],
|
|
7803
|
+
organization_role: role,
|
|
7804
|
+
app_roles: [{ app_name: appName, active_role: role, is_enabled: true }],
|
|
7805
|
+
},
|
|
7806
|
+
},
|
|
7807
|
+
});
|
|
7808
|
+
const editMemberViaRequest = async ({ email, firstName, lastName, newRole, neetoPlaywrightUtilities, }) => {
|
|
7809
|
+
const response = await neetoPlaywrightUtilities.apiRequest({
|
|
7810
|
+
method: "get",
|
|
7811
|
+
url: API_ROUTES.teamMembers.index,
|
|
7812
|
+
params: { search: email },
|
|
7813
|
+
});
|
|
7814
|
+
if (response) {
|
|
7815
|
+
const responseBodyBuffer = await response.body();
|
|
7816
|
+
const responseBody = JSON.parse(responseBodyBuffer.toString());
|
|
7817
|
+
const memberDetails = responseBody === null || responseBody === void 0 ? void 0 : responseBody.members[0];
|
|
7818
|
+
await neetoPlaywrightUtilities.apiRequest({
|
|
7819
|
+
method: "put",
|
|
7820
|
+
url: API_ROUTES.teamMembers.show(memberDetails.id),
|
|
7821
|
+
body: {
|
|
7822
|
+
team: {
|
|
7823
|
+
active: true,
|
|
7824
|
+
first_name: firstName,
|
|
7825
|
+
last_name: lastName,
|
|
7826
|
+
organization_role: newRole,
|
|
7827
|
+
},
|
|
7828
|
+
},
|
|
7829
|
+
});
|
|
7830
|
+
}
|
|
7831
|
+
};
|
|
7832
|
+
const deactivateMemberViaRequest = ({ email, neetoPlaywrightUtilities, }) => neetoPlaywrightUtilities.apiRequest({
|
|
7833
|
+
method: "patch",
|
|
7834
|
+
url: API_ROUTES.teamMembers.bulkUpdate,
|
|
7835
|
+
body: { users: { active: false, emails: [email] } },
|
|
7836
|
+
});
|
|
7837
|
+
const memberUtils = {
|
|
7838
|
+
addMemberViaRequest,
|
|
7839
|
+
editMemberViaRequest,
|
|
7840
|
+
deactivateMemberViaRequest,
|
|
7841
|
+
};
|
|
7842
|
+
|
|
7746
7843
|
var main$2 = {exports: {}};
|
|
7747
7844
|
|
|
7748
7845
|
var name = "dotenv";
|
|
@@ -8279,6 +8376,7 @@ const definePlaywrightConfig = (overrides) => {
|
|
|
8279
8376
|
});
|
|
8280
8377
|
};
|
|
8281
8378
|
|
|
8379
|
+
exports.API_ROUTES = API_ROUTES;
|
|
8282
8380
|
exports.BASE_URL = BASE_URL;
|
|
8283
8381
|
exports.CHANGELOG_WIDGET_SELECTORS = CHANGELOG_WIDGET_SELECTORS;
|
|
8284
8382
|
exports.CHAT_WIDGET_SELECTORS = CHAT_WIDGET_SELECTORS;
|
|
@@ -8314,6 +8412,7 @@ exports.commands = commands;
|
|
|
8314
8412
|
exports.definePlaywrightConfig = definePlaywrightConfig;
|
|
8315
8413
|
exports.extractSubdomainFromError = extractSubdomainFromError;
|
|
8316
8414
|
exports.generateStagingData = generateStagingData;
|
|
8415
|
+
exports.getGlobalUserState = getGlobalUserState;
|
|
8317
8416
|
exports.hyphenize = hyphenize;
|
|
8318
8417
|
exports.i18nFixture = i18nFixture;
|
|
8319
8418
|
exports.initializeCredentials = initializeCredentials;
|
|
@@ -8321,7 +8420,10 @@ exports.joinHyphenCase = joinHyphenCase;
|
|
|
8321
8420
|
exports.joinString = joinString;
|
|
8322
8421
|
exports.login = login;
|
|
8323
8422
|
exports.loginWithoutSSO = loginWithoutSSO;
|
|
8423
|
+
exports.memberUtils = memberUtils;
|
|
8324
8424
|
exports.readFileSyncIfExists = readFileSyncIfExists;
|
|
8425
|
+
exports.removeCredentialFile = removeCredentialFile;
|
|
8426
|
+
exports.shouldSkipSetupAndTeardown = shouldSkipSetupAndTeardown;
|
|
8325
8427
|
exports.skipTest = skipTest;
|
|
8326
8428
|
exports.updateCredentials = updateCredentials;
|
|
8327
8429
|
exports.writeDataToFile = writeDataToFile;
|