@bigbinary/neeto-playwright-commons 1.4.5 → 1.5.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 +157 -18
- package/index.cjs.js.map +1 -1
- package/index.d.ts +27 -1
- package/index.js +153 -20
- package/index.js.map +1 -1
- package/package.json +4 -1
package/index.cjs.js
CHANGED
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var test = require('@playwright/test');
|
|
6
6
|
var require$$0 = require('fs');
|
|
7
|
+
var faker = require('@faker-js/faker');
|
|
8
|
+
var ramda = require('ramda');
|
|
9
|
+
var MailosaurClient = require('mailosaur');
|
|
7
10
|
var dayjs = require('dayjs');
|
|
8
11
|
var playwrightI18nextFixture = require('playwright-i18next-fixture');
|
|
9
12
|
var require$$2 = require('os');
|
|
@@ -11,7 +14,6 @@ var require$$0$1 = require('path');
|
|
|
11
14
|
var require$$0$2 = require('util');
|
|
12
15
|
var require$$0$3 = require('stream');
|
|
13
16
|
var require$$0$4 = require('events');
|
|
14
|
-
var ramda = require('ramda');
|
|
15
17
|
var require$$3 = require('crypto');
|
|
16
18
|
|
|
17
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -34,8 +36,10 @@ function _interopNamespace(e) {
|
|
|
34
36
|
return Object.freeze(n);
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
var test__default = /*#__PURE__*/_interopDefaultLegacy(test);
|
|
37
40
|
var require$$0__namespace = /*#__PURE__*/_interopNamespace(require$$0);
|
|
38
41
|
var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
42
|
+
var MailosaurClient__default = /*#__PURE__*/_interopDefaultLegacy(MailosaurClient);
|
|
39
43
|
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
40
44
|
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
41
45
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
@@ -58,7 +62,9 @@ const CREDENTIALS = {
|
|
|
58
62
|
email: "oliver@example.com",
|
|
59
63
|
password: "welcome",
|
|
60
64
|
};
|
|
65
|
+
const OTP_EMAIL_PATTERN = "is your login code";
|
|
61
66
|
|
|
67
|
+
/* eslint-disable playwright/no-skipped-test */
|
|
62
68
|
const joinString = (string1, string2, string3 = "", separator = " ") => {
|
|
63
69
|
if (string3 === "") {
|
|
64
70
|
return string1 + separator + string2;
|
|
@@ -108,6 +114,11 @@ const hyphenize = input => {
|
|
|
108
114
|
return fallbackString;
|
|
109
115
|
};
|
|
110
116
|
const joinHyphenCase = (...args) => args.join(" ").replace(/\s+/g, "-").toLowerCase();
|
|
117
|
+
const skipTest = {
|
|
118
|
+
forDevelopmentEnv: () => test__default["default"].skip(process.env.TEST_ENV === ENVIRONMENT.development),
|
|
119
|
+
forReviewEnv: () => test__default["default"].skip(process.env.TEST_ENV === ENVIRONMENT.review),
|
|
120
|
+
forAllExceptStagingEnv: () => test__default["default"].skip(process.env.TEST_ENV !== ENVIRONMENT.staging),
|
|
121
|
+
};
|
|
111
122
|
|
|
112
123
|
const COMMON_SELECTORS = {
|
|
113
124
|
spinner: ".neeto-ui-spinner",
|
|
@@ -241,16 +252,53 @@ class CustomCommands {
|
|
|
241
252
|
}
|
|
242
253
|
}
|
|
243
254
|
|
|
255
|
+
class MailosaurUtils {
|
|
256
|
+
constructor(mailosaur) {
|
|
257
|
+
this.fetchOtpFromEmail = async ({ email, subjectSubstring = OTP_EMAIL_PATTERN, timeout = 2 * 60 * 1000, receivedAfter = new Date(), }) => {
|
|
258
|
+
var _a, _b, _c;
|
|
259
|
+
const receivedEmail = await this.mailosaur.messages.get(this.serverId, { sentTo: email, subject: subjectSubstring }, { timeout, receivedAfter });
|
|
260
|
+
const otp = (_c = (_b = (_a = receivedEmail === null || receivedEmail === void 0 ? void 0 : receivedEmail.text) === null || _a === void 0 ? void 0 : _a.codes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.value;
|
|
261
|
+
if (ramda.isNil(otp)) {
|
|
262
|
+
throw new Error(`No codes found in the email with subject: ${receivedEmail.subject}. Please re-evaluate the filtering parameters.`);
|
|
263
|
+
}
|
|
264
|
+
return otp;
|
|
265
|
+
};
|
|
266
|
+
this.generateRandomMailosaurEmail = () => faker.faker.internet.email({ provider: `${this.serverId}.mailosaur.net` });
|
|
267
|
+
this.mailosaur = mailosaur;
|
|
268
|
+
if (ramda.isNotNil(process.env.MAILOSAUR_SERVER_ID)) {
|
|
269
|
+
this.serverId = process.env.MAILOSAUR_SERVER_ID;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
throw new Error("ENV variable MAILOSAUR_SERVER_ID is not defined. Please add the Server ID to use this method. Please visit https://mailosaur.com/app/servers to find the Server ID.");
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
244
277
|
const commands = {
|
|
245
278
|
neetoPlaywrightUtilities: async ({ page, request }, use) => {
|
|
246
279
|
const commands = new CustomCommands(page, request);
|
|
247
280
|
await use(commands);
|
|
248
281
|
},
|
|
282
|
+
mailosaur: async ({}, use) => {
|
|
283
|
+
skipTest.forAllExceptStagingEnv();
|
|
284
|
+
if (ramda.isNotNil(process.env.MAILOSAUR_API_KEY)) {
|
|
285
|
+
const mailosaur = new MailosaurClient__default["default"](process.env.MAILOSAUR_API_KEY);
|
|
286
|
+
await use(mailosaur);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
throw new Error("ENV variable MAILOSAUR_API_KEY is not defined. Please add the API key to use this fixture. Please visit https://mailosaur.com/app/account/keys to find the API key.");
|
|
290
|
+
}
|
|
291
|
+
},
|
|
249
292
|
page: async ({ page }, use) => {
|
|
250
293
|
await page.goto("/");
|
|
251
294
|
await page.waitForLoadState();
|
|
252
295
|
await use(page);
|
|
253
296
|
},
|
|
297
|
+
mailosaurUtils: async ({ mailosaur }, use) => {
|
|
298
|
+
skipTest.forAllExceptStagingEnv();
|
|
299
|
+
const mailosaurUtils = new MailosaurUtils(mailosaur);
|
|
300
|
+
await use(mailosaurUtils);
|
|
301
|
+
},
|
|
254
302
|
};
|
|
255
303
|
|
|
256
304
|
const generateStagingData = (product = "invoice") => {
|
|
@@ -1460,7 +1508,7 @@ const append = (queue = '', stash = '', enclose = false) => {
|
|
|
1460
1508
|
return utils$g.flatten(result);
|
|
1461
1509
|
};
|
|
1462
1510
|
|
|
1463
|
-
const expand$
|
|
1511
|
+
const expand$2 = (ast, options = {}) => {
|
|
1464
1512
|
let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
|
|
1465
1513
|
|
|
1466
1514
|
let walk = (node, parent = {}) => {
|
|
@@ -1540,7 +1588,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
1540
1588
|
return utils$g.flatten(walk(ast));
|
|
1541
1589
|
};
|
|
1542
1590
|
|
|
1543
|
-
var expand_1 = expand$
|
|
1591
|
+
var expand_1 = expand$2;
|
|
1544
1592
|
|
|
1545
1593
|
var constants$4 = {
|
|
1546
1594
|
MAX_LENGTH: 1024 * 64,
|
|
@@ -1929,7 +1977,7 @@ var parse_1$1 = parse$4;
|
|
|
1929
1977
|
|
|
1930
1978
|
const stringify = stringify$4;
|
|
1931
1979
|
const compile = compile_1;
|
|
1932
|
-
const expand = expand_1;
|
|
1980
|
+
const expand$1 = expand_1;
|
|
1933
1981
|
const parse$3 = parse_1$1;
|
|
1934
1982
|
|
|
1935
1983
|
/**
|
|
@@ -2049,7 +2097,7 @@ braces$1.expand = (input, options = {}) => {
|
|
|
2049
2097
|
input = braces$1.parse(input, options);
|
|
2050
2098
|
}
|
|
2051
2099
|
|
|
2052
|
-
let result = expand(input, options);
|
|
2100
|
+
let result = expand$1(input, options);
|
|
2053
2101
|
|
|
2054
2102
|
// filter out empty strings if specified
|
|
2055
2103
|
if (options.noempty === true) {
|
|
@@ -7440,12 +7488,12 @@ const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/"
|
|
|
7440
7488
|
const login = async ({ page, neetoPlaywrightUtilities, loginPath, }) => !IS_STAGING_ENV &&
|
|
7441
7489
|
(await loginWithoutSSO({ page, neetoPlaywrightUtilities, loginPath }));
|
|
7442
7490
|
|
|
7443
|
-
var main$
|
|
7491
|
+
var main$2 = {exports: {}};
|
|
7444
7492
|
|
|
7445
7493
|
var name = "dotenv";
|
|
7446
7494
|
var version$1 = "16.3.1";
|
|
7447
7495
|
var description = "Loads environment variables from .env file";
|
|
7448
|
-
var main = "lib/main.js";
|
|
7496
|
+
var main$1 = "lib/main.js";
|
|
7449
7497
|
var types = "lib/main.d.ts";
|
|
7450
7498
|
var exports$1 = {
|
|
7451
7499
|
".": {
|
|
@@ -7508,7 +7556,7 @@ var require$$4 = {
|
|
|
7508
7556
|
name: name,
|
|
7509
7557
|
version: version$1,
|
|
7510
7558
|
description: description,
|
|
7511
|
-
main: main,
|
|
7559
|
+
main: main$1,
|
|
7512
7560
|
types: types,
|
|
7513
7561
|
exports: exports$1,
|
|
7514
7562
|
scripts: scripts,
|
|
@@ -7827,21 +7875,108 @@ const DotenvModule = {
|
|
|
7827
7875
|
populate
|
|
7828
7876
|
};
|
|
7829
7877
|
|
|
7830
|
-
main$
|
|
7831
|
-
main$
|
|
7832
|
-
main$
|
|
7833
|
-
main$
|
|
7834
|
-
main$
|
|
7835
|
-
main$
|
|
7836
|
-
main$
|
|
7878
|
+
main$2.exports.configDotenv = DotenvModule.configDotenv;
|
|
7879
|
+
main$2.exports._configVault = DotenvModule._configVault;
|
|
7880
|
+
main$2.exports._parseVault = DotenvModule._parseVault;
|
|
7881
|
+
main$2.exports.config = DotenvModule.config;
|
|
7882
|
+
main$2.exports.decrypt = DotenvModule.decrypt;
|
|
7883
|
+
main$2.exports.parse = DotenvModule.parse;
|
|
7884
|
+
main$2.exports.populate = DotenvModule.populate;
|
|
7885
|
+
|
|
7886
|
+
main$2.exports = DotenvModule;
|
|
7887
|
+
|
|
7888
|
+
var main = {};
|
|
7889
|
+
|
|
7890
|
+
// like String.prototype.search but returns the last index
|
|
7891
|
+
function _searchLast (str, rgx) {
|
|
7892
|
+
const matches = Array.from(str.matchAll(rgx));
|
|
7893
|
+
return matches.length > 0 ? matches.slice(-1)[0].index : -1
|
|
7894
|
+
}
|
|
7895
|
+
|
|
7896
|
+
function _interpolate (envValue, environment, config) {
|
|
7897
|
+
// find the last unescaped dollar sign in the
|
|
7898
|
+
// value so that we can evaluate it
|
|
7899
|
+
const lastUnescapedDollarSignIndex = _searchLast(envValue, /(?!(?<=\\))\$/g);
|
|
7837
7900
|
|
|
7838
|
-
|
|
7901
|
+
// If we couldn't match any unescaped dollar sign
|
|
7902
|
+
// let's return the string as is
|
|
7903
|
+
if (lastUnescapedDollarSignIndex === -1) return envValue
|
|
7904
|
+
|
|
7905
|
+
// This is the right-most group of variables in the string
|
|
7906
|
+
const rightMostGroup = envValue.slice(lastUnescapedDollarSignIndex);
|
|
7907
|
+
|
|
7908
|
+
/**
|
|
7909
|
+
* This finds the inner most variable/group divided
|
|
7910
|
+
* by variable name and default value (if present)
|
|
7911
|
+
* (
|
|
7912
|
+
* (?!(?<=\\))\$ // only match dollar signs that are not escaped
|
|
7913
|
+
* {? // optional opening curly brace
|
|
7914
|
+
* ([\w]+) // match the variable name
|
|
7915
|
+
* (?::-([^}\\]*))? // match an optional default value
|
|
7916
|
+
* }? // optional closing curly brace
|
|
7917
|
+
* )
|
|
7918
|
+
*/
|
|
7919
|
+
const matchGroup = /((?!(?<=\\))\${?([\w]+)(?::-([^}\\]*))?}?)/;
|
|
7920
|
+
const match = rightMostGroup.match(matchGroup);
|
|
7921
|
+
|
|
7922
|
+
if (match != null) {
|
|
7923
|
+
const [, group, variableName, defaultValue] = match;
|
|
7924
|
+
|
|
7925
|
+
return _interpolate(
|
|
7926
|
+
envValue.replace(
|
|
7927
|
+
group,
|
|
7928
|
+
environment[variableName] ||
|
|
7929
|
+
defaultValue ||
|
|
7930
|
+
config.parsed[variableName] ||
|
|
7931
|
+
''
|
|
7932
|
+
),
|
|
7933
|
+
environment,
|
|
7934
|
+
config
|
|
7935
|
+
)
|
|
7936
|
+
}
|
|
7937
|
+
|
|
7938
|
+
return envValue
|
|
7939
|
+
}
|
|
7940
|
+
|
|
7941
|
+
function _resolveEscapeSequences (value) {
|
|
7942
|
+
return value.replace(/\\\$/g, '$')
|
|
7943
|
+
}
|
|
7944
|
+
|
|
7945
|
+
function expand (config) {
|
|
7946
|
+
// if ignoring process.env, use a blank object
|
|
7947
|
+
const environment = config.ignoreProcessEnv ? {} : process.env;
|
|
7948
|
+
|
|
7949
|
+
for (const configKey in config.parsed) {
|
|
7950
|
+
const value = Object.prototype.hasOwnProperty.call(environment, configKey)
|
|
7951
|
+
? environment[configKey]
|
|
7952
|
+
: config.parsed[configKey];
|
|
7953
|
+
|
|
7954
|
+
config.parsed[configKey] = _resolveEscapeSequences(
|
|
7955
|
+
_interpolate(value, environment, config)
|
|
7956
|
+
);
|
|
7957
|
+
}
|
|
7958
|
+
|
|
7959
|
+
for (const processKey in config.parsed) {
|
|
7960
|
+
environment[processKey] = config.parsed[processKey];
|
|
7961
|
+
}
|
|
7962
|
+
|
|
7963
|
+
return config
|
|
7964
|
+
}
|
|
7965
|
+
|
|
7966
|
+
main.expand = expand;
|
|
7839
7967
|
|
|
7840
7968
|
// @ts-check
|
|
7841
7969
|
var _a, _b;
|
|
7842
|
-
main$
|
|
7970
|
+
const env = main$2.exports.config({
|
|
7843
7971
|
path: `./e2e/config/.env.${(_a = process.env.TEST_ENV) !== null && _a !== void 0 ? _a : "development"}`,
|
|
7844
7972
|
});
|
|
7973
|
+
main.expand(env);
|
|
7974
|
+
if (require$$0__namespace.existsSync("./e2e/config/.env.local")) {
|
|
7975
|
+
const localEnv = main$2.exports.config({
|
|
7976
|
+
path: "./e2e/config/.env.local",
|
|
7977
|
+
});
|
|
7978
|
+
main.expand(localEnv);
|
|
7979
|
+
}
|
|
7845
7980
|
const currentsConfig = {
|
|
7846
7981
|
ciBuildId: process.env.NEETO_CI_JOB_ID,
|
|
7847
7982
|
recordKey: "PVHNwxEOySsdAeTc",
|
|
@@ -7855,7 +7990,7 @@ const definePlaywrightConfig = (overrides) => {
|
|
|
7855
7990
|
fullyParallel: true,
|
|
7856
7991
|
forbidOnly: isCI,
|
|
7857
7992
|
retries: isCI ? 1 : 0,
|
|
7858
|
-
timeout:
|
|
7993
|
+
timeout: 5 * 60 * 1000,
|
|
7859
7994
|
reporter: isCI
|
|
7860
7995
|
? [["@currents/playwright", { ...currentsConfig, ...currentsOverrides }]]
|
|
7861
7996
|
: [["line"]],
|
|
@@ -7900,8 +8035,10 @@ exports.LOGIN_SELECTORS = LOGIN_SELECTORS;
|
|
|
7900
8035
|
exports.MEMBER_FORM_SELECTORS = MEMBER_FORM_SELECTORS;
|
|
7901
8036
|
exports.MEMBER_SELECTORS = MEMBER_SELECTORS;
|
|
7902
8037
|
exports.MERGE_TAGS_SELECTORS = MERGE_TAGS_SELECTORS;
|
|
8038
|
+
exports.MailosaurUtils = MailosaurUtils;
|
|
7903
8039
|
exports.NEETO_EDITOR_SELECTORS = NEETO_EDITOR_SELECTORS;
|
|
7904
8040
|
exports.NEETO_FILTERS_SELECTORS = NEETO_FILTERS_SELECTORS;
|
|
8041
|
+
exports.OTP_EMAIL_PATTERN = OTP_EMAIL_PATTERN;
|
|
7905
8042
|
exports.OrganizationPage = OrganizationPage;
|
|
7906
8043
|
exports.PROJECT_TRANSLATIONS_PATH = PROJECT_TRANSLATIONS_PATH;
|
|
7907
8044
|
exports.ROLES_SELECTORS = ROLES_SELECTORS;
|
|
@@ -7912,6 +8049,7 @@ exports.TAGS_SELECTORS = TAGS_SELECTORS;
|
|
|
7912
8049
|
exports.clearCredentials = clearCredentials;
|
|
7913
8050
|
exports.commands = commands;
|
|
7914
8051
|
exports.definePlaywrightConfig = definePlaywrightConfig;
|
|
8052
|
+
exports.extractSubdomainFromError = extractSubdomainFromError;
|
|
7915
8053
|
exports.generateStagingData = generateStagingData;
|
|
7916
8054
|
exports.hyphenize = hyphenize;
|
|
7917
8055
|
exports.i18nFixture = i18nFixture;
|
|
@@ -7921,6 +8059,7 @@ exports.joinString = joinString;
|
|
|
7921
8059
|
exports.login = login;
|
|
7922
8060
|
exports.loginWithoutSSO = loginWithoutSSO;
|
|
7923
8061
|
exports.readFileSyncIfExists = readFileSyncIfExists;
|
|
8062
|
+
exports.skipTest = skipTest;
|
|
7924
8063
|
exports.updateCredentials = updateCredentials;
|
|
7925
8064
|
exports.writeDataToFile = writeDataToFile;
|
|
7926
8065
|
//# sourceMappingURL=index.cjs.js.map
|