@bigbinary/neeto-playwright-commons 1.7.2 → 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 +50 -7
- package/index.cjs.js.map +1 -1
- package/index.d.ts +5 -1
- package/index.js +49 -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",
|
|
@@ -7442,6 +7449,8 @@ class HelpAndProfilePage {
|
|
|
7442
7449
|
}));
|
|
7443
7450
|
};
|
|
7444
7451
|
this.verifyLogout = async () => {
|
|
7452
|
+
if (shouldSkipSetupAndTeardown())
|
|
7453
|
+
return;
|
|
7445
7454
|
await test.test.step("Step 1: Open Profile popup and verify", this.openProfilePopup);
|
|
7446
7455
|
await test.test.step("Step 2: Click logout and verify", async () => {
|
|
7447
7456
|
await this.page
|
|
@@ -7487,9 +7496,15 @@ const extractSubdomainFromError = (errorString) => {
|
|
|
7487
7496
|
|
|
7488
7497
|
class OrganizationPage {
|
|
7489
7498
|
constructor(page, neetoPlaywrightUtilities) {
|
|
7499
|
+
this.baseUrlGenerator = (appName) => {
|
|
7500
|
+
const { subdomainName } = getGlobalUserState();
|
|
7501
|
+
return `https://${subdomainName}.${appName}.net`;
|
|
7502
|
+
};
|
|
7490
7503
|
this.createOrganization = async ({ email, businessName, subdomainName, firstName, lastName, appName, }) => {
|
|
7491
7504
|
if (!IS_STAGING_ENV)
|
|
7492
7505
|
return;
|
|
7506
|
+
if (shouldSkipSetupAndTeardown())
|
|
7507
|
+
return;
|
|
7493
7508
|
const defaultOtp = "123456";
|
|
7494
7509
|
const appNameInLowerCase = appName.toLowerCase();
|
|
7495
7510
|
const isNeetoAuth = appNameInLowerCase === "neetoauth";
|
|
@@ -7542,6 +7557,8 @@ class OrganizationPage {
|
|
|
7542
7557
|
this.setupOrganization = async (product) => {
|
|
7543
7558
|
if (!IS_STAGING_ENV)
|
|
7544
7559
|
return;
|
|
7560
|
+
if (shouldSkipSetupAndTeardown())
|
|
7561
|
+
return;
|
|
7545
7562
|
const { user } = readFileSyncIfExists();
|
|
7546
7563
|
await this.createOrganization({
|
|
7547
7564
|
businessName: user.businessName,
|
|
@@ -7559,6 +7576,11 @@ class OrganizationPage {
|
|
|
7559
7576
|
userCredentials,
|
|
7560
7577
|
]);
|
|
7561
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
|
+
});
|
|
7562
7584
|
};
|
|
7563
7585
|
this.updateSubdomainIfExists = async (appName) => {
|
|
7564
7586
|
const subdomainError = this.page.getByTestId(SIGNUP_SELECTORS.subdomainError);
|
|
@@ -7580,8 +7602,7 @@ class OrganizationPage {
|
|
|
7580
7602
|
key: "businessName",
|
|
7581
7603
|
value: newOrganizationName,
|
|
7582
7604
|
});
|
|
7583
|
-
|
|
7584
|
-
process.env.BASE_URL = newBaseUrl;
|
|
7605
|
+
process.env.BASE_URL = this.baseUrlGenerator(appName);
|
|
7585
7606
|
await this.page
|
|
7586
7607
|
.getByTestId(SIGNUP_SELECTORS.organizationNameTextField)
|
|
7587
7608
|
.fill(newOrganizationName);
|
|
@@ -7725,17 +7746,35 @@ const MERGE_TAGS_SELECTORS = {
|
|
|
7725
7746
|
};
|
|
7726
7747
|
|
|
7727
7748
|
const initializeCredentials = (product) => {
|
|
7728
|
-
|
|
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
|
+
}
|
|
7729
7767
|
const stagingData = generateStagingData(product);
|
|
7730
|
-
|
|
7731
|
-
writeDataToFile(JSON.stringify({ user: newUserState }, null, 2));
|
|
7768
|
+
writeDataToFile(JSON.stringify({ user: stagingData }, null, 2));
|
|
7732
7769
|
if (IS_STAGING_ENV) {
|
|
7733
|
-
const baseUrl = `https://${
|
|
7770
|
+
const baseUrl = `https://${stagingData.subdomainName}.${stagingData.domain}`;
|
|
7734
7771
|
process.env.BASE_URL = baseUrl;
|
|
7735
7772
|
}
|
|
7736
7773
|
};
|
|
7737
7774
|
|
|
7738
7775
|
const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/", }) => {
|
|
7776
|
+
if (shouldSkipSetupAndTeardown())
|
|
7777
|
+
return;
|
|
7739
7778
|
await page.goto(loginPath);
|
|
7740
7779
|
await page.getByTestId("login-email-text-field").fill(CREDENTIALS.email);
|
|
7741
7780
|
await page
|
|
@@ -7750,6 +7789,7 @@ const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/"
|
|
|
7750
7789
|
await page.context().storageState({ path: STORAGE_STATE });
|
|
7751
7790
|
const mergedCredentials = ramda.mergeAll([readFileSyncIfExists(), userCredentials]);
|
|
7752
7791
|
writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
|
|
7792
|
+
updateCredentials({ key: "isLoggedIn", value: "true" });
|
|
7753
7793
|
};
|
|
7754
7794
|
const login = async ({ page, neetoPlaywrightUtilities, loginPath, }) => !IS_STAGING_ENV &&
|
|
7755
7795
|
(await loginWithoutSSO({ page, neetoPlaywrightUtilities, loginPath }));
|
|
@@ -8372,6 +8412,7 @@ exports.commands = commands;
|
|
|
8372
8412
|
exports.definePlaywrightConfig = definePlaywrightConfig;
|
|
8373
8413
|
exports.extractSubdomainFromError = extractSubdomainFromError;
|
|
8374
8414
|
exports.generateStagingData = generateStagingData;
|
|
8415
|
+
exports.getGlobalUserState = getGlobalUserState;
|
|
8375
8416
|
exports.hyphenize = hyphenize;
|
|
8376
8417
|
exports.i18nFixture = i18nFixture;
|
|
8377
8418
|
exports.initializeCredentials = initializeCredentials;
|
|
@@ -8381,6 +8422,8 @@ exports.login = login;
|
|
|
8381
8422
|
exports.loginWithoutSSO = loginWithoutSSO;
|
|
8382
8423
|
exports.memberUtils = memberUtils;
|
|
8383
8424
|
exports.readFileSyncIfExists = readFileSyncIfExists;
|
|
8425
|
+
exports.removeCredentialFile = removeCredentialFile;
|
|
8426
|
+
exports.shouldSkipSetupAndTeardown = shouldSkipSetupAndTeardown;
|
|
8384
8427
|
exports.skipTest = skipTest;
|
|
8385
8428
|
exports.updateCredentials = updateCredentials;
|
|
8386
8429
|
exports.writeDataToFile = writeDataToFile;
|