@bigbinary/neeto-playwright-commons 1.3.2 → 1.4.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/configs/eslint/common.js +1 -0
- package/index.cjs.js +317 -274
- package/index.cjs.js.map +1 -1
- package/index.d.ts +4 -6
- package/index.js +293 -249
- package/index.js.map +1 -1
- package/package.json +2 -2
package/configs/eslint/common.js
CHANGED
package/index.cjs.js
CHANGED
|
@@ -3,47 +3,280 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var test = require('@playwright/test');
|
|
6
|
-
var require$$0
|
|
6
|
+
var require$$0 = require('fs');
|
|
7
|
+
var dayjs = require('dayjs');
|
|
8
|
+
var playwrightI18nextFixture = require('playwright-i18next-fixture');
|
|
7
9
|
var require$$2 = require('os');
|
|
8
|
-
var require$$0 = require('path');
|
|
9
|
-
var require$$0$
|
|
10
|
-
var require$$0$
|
|
10
|
+
var require$$0$1 = require('path');
|
|
11
|
+
var require$$0$2 = require('util');
|
|
12
|
+
var require$$0$3 = require('stream');
|
|
11
13
|
var require$$0$4 = require('events');
|
|
12
14
|
var ramda = require('ramda');
|
|
13
|
-
var dayjs = require('dayjs');
|
|
14
|
-
var playwrightI18nextFixture = require('playwright-i18next-fixture');
|
|
15
15
|
var require$$3 = require('crypto');
|
|
16
16
|
|
|
17
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
18
|
|
|
19
19
|
function _interopNamespace(e) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
if (e && e.__esModule) return e;
|
|
21
|
+
var n = Object.create(null);
|
|
22
|
+
if (e) {
|
|
23
|
+
Object.keys(e).forEach(function (k) {
|
|
24
|
+
if (k !== 'default') {
|
|
25
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
26
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return e[k]; }
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
n["default"] = e;
|
|
34
|
+
return Object.freeze(n);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
var require$$
|
|
38
|
-
var require$$
|
|
37
|
+
var require$$0__namespace = /*#__PURE__*/_interopNamespace(require$$0);
|
|
38
|
+
var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
39
|
+
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
39
40
|
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
40
|
-
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
41
|
-
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$
|
|
42
|
-
var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$
|
|
41
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
42
|
+
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
|
43
|
+
var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
|
|
43
44
|
var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
|
|
44
|
-
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
45
45
|
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
|
|
46
46
|
|
|
47
|
+
const ENVIRONMENT = {
|
|
48
|
+
development: "development",
|
|
49
|
+
staging: "staging",
|
|
50
|
+
review: "review",
|
|
51
|
+
};
|
|
52
|
+
const IS_STAGING_ENV = process.env.TEST_ENV === "staging";
|
|
53
|
+
const STORAGE_STATE = "./e2e/auth/user.json";
|
|
54
|
+
const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
|
|
55
|
+
const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
|
|
56
|
+
const CREDENTIALS = {
|
|
57
|
+
name: "Oliver Smith",
|
|
58
|
+
email: "oliver@example.com",
|
|
59
|
+
password: "welcome",
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const joinString = (string1, string2, string3 = "", separator = " ") => {
|
|
63
|
+
if (string3 === "") {
|
|
64
|
+
return string1 + separator + string2;
|
|
65
|
+
}
|
|
66
|
+
return string1 + separator + string2 + separator + string3;
|
|
67
|
+
};
|
|
68
|
+
const readFileSyncIfExists = (path = STORAGE_STATE) => {
|
|
69
|
+
try {
|
|
70
|
+
return JSON.parse(require$$0__namespace.readFileSync(path, "utf8"));
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const writeDataToFile = data => {
|
|
77
|
+
try {
|
|
78
|
+
require$$0__namespace.writeFileSync(STORAGE_STATE, data, "utf8");
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.log(error); // eslint-disable-line
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
};
|
|
85
|
+
const updateCredentials = ({ key, value }) => {
|
|
86
|
+
const data = readFileSyncIfExists();
|
|
87
|
+
data["user"][key] = value;
|
|
88
|
+
return writeDataToFile(JSON.stringify(data));
|
|
89
|
+
};
|
|
90
|
+
const clearCredentials = () => {
|
|
91
|
+
require$$0__namespace.unlink(STORAGE_STATE, error => {
|
|
92
|
+
if (!error)
|
|
93
|
+
return;
|
|
94
|
+
console.log(error); // eslint-disable-line
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const hyphenize = input => {
|
|
98
|
+
const fallbackString = "";
|
|
99
|
+
if (typeof input === "number")
|
|
100
|
+
return String(input);
|
|
101
|
+
if (input && typeof input === "string" && input.replace) {
|
|
102
|
+
return input
|
|
103
|
+
.replace(/[\s_]/g, "-")
|
|
104
|
+
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
105
|
+
.replace(/-+/g, "-")
|
|
106
|
+
.toLowerCase();
|
|
107
|
+
}
|
|
108
|
+
return fallbackString;
|
|
109
|
+
};
|
|
110
|
+
const joinHyphenCase = (...args) => args.join(" ").replace(/\s+/g, "-").toLowerCase();
|
|
111
|
+
|
|
112
|
+
const COMMON_SELECTORS = {
|
|
113
|
+
spinner: ".neeto-ui-spinner",
|
|
114
|
+
subheaderText: "subheader-left",
|
|
115
|
+
alertTitle: "alert-title",
|
|
116
|
+
alertModalMessage: "alert-message",
|
|
117
|
+
alertModalSubmitButton: "alert-submit-button",
|
|
118
|
+
checkbox: "nui-checkbox-input",
|
|
119
|
+
checkboxLabel: "nui-checkbox-label",
|
|
120
|
+
dropdownContainer: "nui-dropdown-container",
|
|
121
|
+
dropdownIcon: "nui-dropdown-icon",
|
|
122
|
+
heading: "main-header",
|
|
123
|
+
paneBody: "pane-body",
|
|
124
|
+
paneHeader: "pane-header",
|
|
125
|
+
profileSidebar: "profile-section",
|
|
126
|
+
selectOption: (label) => `${hyphenize(label)}-select-option`,
|
|
127
|
+
toastMessage: "toastr-message-container",
|
|
128
|
+
toastCloseButton: "toastr-close-button",
|
|
129
|
+
windowAlert: "#alert-box",
|
|
130
|
+
body: "body",
|
|
131
|
+
toastIcon: ".Toastify__toast-icon",
|
|
132
|
+
paneModalCrossIcon: "pane-close-button",
|
|
133
|
+
inputField: "nui-input-field",
|
|
134
|
+
alertConfirmationText: "alert-confirmation-text",
|
|
135
|
+
alertCancelButton: "alert-cancel-button",
|
|
136
|
+
alertModalCrossIcon: "modal-close-button",
|
|
137
|
+
saveChangesButton: "save-changes-button",
|
|
138
|
+
cancelButton: "cancel-button",
|
|
139
|
+
inputFieldError: "nui-input-error",
|
|
140
|
+
selectDropDownError: "nui-select-error",
|
|
141
|
+
subTitleHeading: "menubar-subtitle-heading",
|
|
142
|
+
noDataTitle: "no-data-title",
|
|
143
|
+
noDataDescription: "no-data-description",
|
|
144
|
+
backdrop: "neeto-backdrop",
|
|
145
|
+
menuBarHeading: "menubar-heading",
|
|
146
|
+
dropdownWrapper: "nui-select-container-wrapper",
|
|
147
|
+
toggleButton: "menubar-toggle-button",
|
|
148
|
+
tooltip: "tooltip-box",
|
|
149
|
+
articlePageTitle: ".serene-article__title",
|
|
150
|
+
tabItem: "tab-item",
|
|
151
|
+
labelInputError: "label-input-error",
|
|
152
|
+
urlInputError: "url-input-error",
|
|
153
|
+
noDataPrimaryButton: "no-data-primary-button",
|
|
154
|
+
modalHeader: "modal-header",
|
|
155
|
+
nameInputError: "name-input-error",
|
|
156
|
+
selectContainer: "nui-select-container",
|
|
157
|
+
dropdownMenu: "nui-select-menu",
|
|
158
|
+
sidebarToggle: "neeto-molecules-sidebar-toggler",
|
|
159
|
+
subheader: "subheader",
|
|
160
|
+
settingsLink: "Settings",
|
|
161
|
+
ticketFieldTextInput: (label) => `${hyphenize(label)}-text-input`,
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
class CustomCommands {
|
|
165
|
+
constructor(page, request) {
|
|
166
|
+
this.interceptMultipleResponses = ({ responseUrl = "", times = 1, baseUrl, }) => Promise.all([...new Array(times)].map(() => this.page.waitForResponse((response) => {
|
|
167
|
+
var _a, _b, _c;
|
|
168
|
+
if (response.request().resourceType() === "xhr" &&
|
|
169
|
+
response.status() === 200 &&
|
|
170
|
+
response.url().includes(responseUrl) &&
|
|
171
|
+
response
|
|
172
|
+
.url()
|
|
173
|
+
.startsWith((_a = baseUrl !== null && baseUrl !== void 0 ? baseUrl : process.env.BASE_URL) !== null && _a !== void 0 ? _a : "") &&
|
|
174
|
+
!this.responses.includes((_b = response.headers()) === null || _b === void 0 ? void 0 : _b["x-request-id"])) {
|
|
175
|
+
this.responses.push((_c = response.headers()) === null || _c === void 0 ? void 0 : _c["x-request-id"]);
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}, { timeout: 10000 })));
|
|
180
|
+
this.recursiveMethod = async (callback, condition, timeout, startTime) => {
|
|
181
|
+
if (Date.now() - timeout >= startTime) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
else if (await condition()) {
|
|
185
|
+
return await callback();
|
|
186
|
+
}
|
|
187
|
+
return await this.recursiveMethod(callback, condition, timeout, startTime);
|
|
188
|
+
};
|
|
189
|
+
this.executeRecursively = async ({ callback, condition, timeout = 5000, }) => {
|
|
190
|
+
const startTime = Date.now();
|
|
191
|
+
await this.recursiveMethod(callback, condition, timeout, startTime);
|
|
192
|
+
};
|
|
193
|
+
this.verifySuccessToast = async ({ message, closeAfterVerification = true, }) => {
|
|
194
|
+
if (message) {
|
|
195
|
+
await test.expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toHaveValue(message);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
await test.expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toHaveValue("👍");
|
|
199
|
+
closeAfterVerification &&
|
|
200
|
+
(await this.page
|
|
201
|
+
.getByTestId(COMMON_SELECTORS.toastCloseButton)
|
|
202
|
+
.click());
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
this.reloadAndWait = async (requestCount) => {
|
|
206
|
+
const reloadRequests = this.interceptMultipleResponses({
|
|
207
|
+
times: requestCount,
|
|
208
|
+
});
|
|
209
|
+
await this.page.reload();
|
|
210
|
+
await reloadRequests;
|
|
211
|
+
};
|
|
212
|
+
this.apiRequest = async ({ url, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
|
|
213
|
+
const csrfToken = await this.page
|
|
214
|
+
.locator("[name='csrf-token']")
|
|
215
|
+
.getAttribute("content");
|
|
216
|
+
const requestOptions = {
|
|
217
|
+
headers: {
|
|
218
|
+
...additionalHeaders,
|
|
219
|
+
"accept-encoding": "gzip",
|
|
220
|
+
"x-csrf-token": csrfToken !== null && csrfToken !== void 0 ? csrfToken : "",
|
|
221
|
+
},
|
|
222
|
+
data,
|
|
223
|
+
params,
|
|
224
|
+
...otherOptions,
|
|
225
|
+
};
|
|
226
|
+
const httpMethodsHandlers = {
|
|
227
|
+
get: () => this.request.get(url, requestOptions),
|
|
228
|
+
post: () => this.request.post(url, requestOptions),
|
|
229
|
+
put: () => this.request.put(url, requestOptions),
|
|
230
|
+
delete: () => this.request.delete(url, requestOptions),
|
|
231
|
+
};
|
|
232
|
+
return await httpMethodsHandlers[method]();
|
|
233
|
+
};
|
|
234
|
+
this.verifyFieldValue = values => {
|
|
235
|
+
const verifyEachFieldValue = ({ field, value, }) => test.expect(this.page.getByTestId(field)).toHaveValue(value);
|
|
236
|
+
return Array.isArray(values)
|
|
237
|
+
? Promise.all(values.map(value => verifyEachFieldValue(value)))
|
|
238
|
+
: verifyEachFieldValue(values);
|
|
239
|
+
};
|
|
240
|
+
this.page = page;
|
|
241
|
+
this.responses = [];
|
|
242
|
+
this.request = request;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const commands = {
|
|
247
|
+
neetoPlaywrightUtilities: async ({ page, request }, use) => {
|
|
248
|
+
const commands = new CustomCommands(page, request);
|
|
249
|
+
await use(commands);
|
|
250
|
+
},
|
|
251
|
+
page: async ({ page }, use) => {
|
|
252
|
+
await page.goto("/");
|
|
253
|
+
await page.waitForLoadState();
|
|
254
|
+
await use(page);
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const generateStagingData = (product = "invoice") => {
|
|
259
|
+
const timestamp = dayjs__default["default"]().format("YYYYMMDDHH");
|
|
260
|
+
const firstName = "André";
|
|
261
|
+
const lastName = "O'Reilly";
|
|
262
|
+
const otpBypassKey = process.env.OTP_BYPASS_KEY;
|
|
263
|
+
const stagingOrganization = `cypresstest-${product}-${timestamp}`;
|
|
264
|
+
return {
|
|
265
|
+
firstName,
|
|
266
|
+
lastName,
|
|
267
|
+
otp: 111111,
|
|
268
|
+
domain: `neeto${product}.net`,
|
|
269
|
+
currentUserName: IS_STAGING_ENV
|
|
270
|
+
? joinString(firstName, lastName)
|
|
271
|
+
: CREDENTIALS.name,
|
|
272
|
+
businessName: stagingOrganization,
|
|
273
|
+
subdomainName: IS_STAGING_ENV ? stagingOrganization : "spinkart",
|
|
274
|
+
email: IS_STAGING_ENV
|
|
275
|
+
? `cypresstest${otpBypassKey}+${product}+${timestamp}-playwright@bigbinary.com`
|
|
276
|
+
: "oliver@example.com",
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
|
|
47
280
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
48
281
|
|
|
49
282
|
var tasks = {};
|
|
@@ -6742,56 +6975,6 @@ function assertPatternsInput(input) {
|
|
|
6742
6975
|
}
|
|
6743
6976
|
var out = FastGlob;
|
|
6744
6977
|
|
|
6745
|
-
const ENVIRONMENT = {
|
|
6746
|
-
development: "development",
|
|
6747
|
-
staging: "staging",
|
|
6748
|
-
review: "review",
|
|
6749
|
-
};
|
|
6750
|
-
const IS_STAGING_ENV = process.env.TEST_ENV === "staging";
|
|
6751
|
-
const STORAGE_STATE = "./e2e/auth/user.json";
|
|
6752
|
-
const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
|
|
6753
|
-
const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
|
|
6754
|
-
const CREDENTIALS = {
|
|
6755
|
-
name: "Oliver Smith",
|
|
6756
|
-
email: "oliver@example.com",
|
|
6757
|
-
password: "welcome",
|
|
6758
|
-
};
|
|
6759
|
-
|
|
6760
|
-
const joinString = (string1, string2, string3 = "", separator = " ") => {
|
|
6761
|
-
if (string3 === "") {
|
|
6762
|
-
return string1 + separator + string2;
|
|
6763
|
-
}
|
|
6764
|
-
return string1 + separator + string2 + separator + string3;
|
|
6765
|
-
};
|
|
6766
|
-
const readFileSyncIfExists = (path = STORAGE_STATE) => {
|
|
6767
|
-
try {
|
|
6768
|
-
return JSON.parse(require$$0__namespace.readFileSync(path, "utf8"));
|
|
6769
|
-
}
|
|
6770
|
-
catch (error) {
|
|
6771
|
-
return {};
|
|
6772
|
-
}
|
|
6773
|
-
};
|
|
6774
|
-
const writeDataToFile = data => {
|
|
6775
|
-
try {
|
|
6776
|
-
require$$0__namespace.writeFileSync(STORAGE_STATE, data, "utf8");
|
|
6777
|
-
}
|
|
6778
|
-
catch (error) {
|
|
6779
|
-
console.log(error); // eslint-disable-line
|
|
6780
|
-
}
|
|
6781
|
-
return true;
|
|
6782
|
-
};
|
|
6783
|
-
const updateCredentials = ({ key, value }) => {
|
|
6784
|
-
const data = readFileSyncIfExists();
|
|
6785
|
-
data["user"][key] = value;
|
|
6786
|
-
return writeDataToFile(JSON.stringify(data));
|
|
6787
|
-
};
|
|
6788
|
-
const clearCredentials = () => {
|
|
6789
|
-
require$$0__namespace.unlink(STORAGE_STATE, error => {
|
|
6790
|
-
if (!error)
|
|
6791
|
-
return;
|
|
6792
|
-
console.log(error); // eslint-disable-line
|
|
6793
|
-
});
|
|
6794
|
-
};
|
|
6795
6978
|
const readTranslations = () => {
|
|
6796
6979
|
let translations = readFileSyncIfExists(PROJECT_TRANSLATIONS_PATH);
|
|
6797
6980
|
const paths = out.sync(GLOBAL_TRANSLATIONS_PATTERN);
|
|
@@ -6801,204 +6984,70 @@ const readTranslations = () => {
|
|
|
6801
6984
|
});
|
|
6802
6985
|
return translations;
|
|
6803
6986
|
};
|
|
6804
|
-
const
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
.
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6987
|
+
const getter = (key) => () => playwrightI18nextFixture.getI18nInstance().t(`taxonomyDefaultLabels.${key}`);
|
|
6988
|
+
const replaceNullValuesWithGetter = (inputObject, parentKey = "") => {
|
|
6989
|
+
const result = {};
|
|
6990
|
+
for (const [key, value] of Object.entries(inputObject)) {
|
|
6991
|
+
const transKey = parentKey ? `${parentKey}.${key}` : key;
|
|
6992
|
+
if (value === null) {
|
|
6993
|
+
Object.defineProperty(result, key, {
|
|
6994
|
+
get: getter(transKey),
|
|
6995
|
+
});
|
|
6996
|
+
}
|
|
6997
|
+
else if (typeof value === "object") {
|
|
6998
|
+
result[key] = replaceNullValuesWithGetter(value, transKey);
|
|
6999
|
+
}
|
|
7000
|
+
else {
|
|
7001
|
+
result[key] = value;
|
|
7002
|
+
}
|
|
6814
7003
|
}
|
|
6815
|
-
return
|
|
7004
|
+
return result;
|
|
6816
7005
|
};
|
|
6817
|
-
const
|
|
6818
|
-
|
|
6819
|
-
const
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
alertTitle: "alert-title",
|
|
6823
|
-
alertModalMessage: "alert-message",
|
|
6824
|
-
alertModalSubmitButton: "alert-submit-button",
|
|
6825
|
-
checkbox: "nui-checkbox-input",
|
|
6826
|
-
checkboxLabel: "nui-checkbox-label",
|
|
6827
|
-
dropdownContainer: "nui-dropdown-container",
|
|
6828
|
-
dropdownIcon: "nui-dropdown-icon",
|
|
6829
|
-
heading: "main-header",
|
|
6830
|
-
paneBody: "pane-body",
|
|
6831
|
-
paneHeader: "pane-header",
|
|
6832
|
-
profileSidebar: "profile-section",
|
|
6833
|
-
selectOption: (label) => `${hyphenize(label)}-select-option`,
|
|
6834
|
-
toastMessage: "toastr-message-container",
|
|
6835
|
-
toastCloseButton: "toastr-close-button",
|
|
6836
|
-
windowAlert: "#alert-box",
|
|
6837
|
-
body: "body",
|
|
6838
|
-
toastIcon: ".Toastify__toast-icon",
|
|
6839
|
-
paneModalCrossIcon: "pane-close-button",
|
|
6840
|
-
inputField: "nui-input-field",
|
|
6841
|
-
alertConfirmationText: "alert-confirmation-text",
|
|
6842
|
-
alertCancelButton: "alert-cancel-button",
|
|
6843
|
-
alertModalCrossIcon: "modal-close-button",
|
|
6844
|
-
saveChangesButton: "save-changes-button",
|
|
6845
|
-
cancelButton: "cancel-button",
|
|
6846
|
-
inputFieldError: "nui-input-error",
|
|
6847
|
-
selectDropDownError: "nui-select-error",
|
|
6848
|
-
subTitleHeading: "menubar-subtitle-heading",
|
|
6849
|
-
noDataTitle: "no-data-title",
|
|
6850
|
-
noDataDescription: "no-data-description",
|
|
6851
|
-
backdrop: "neeto-backdrop",
|
|
6852
|
-
menuBarHeading: "menubar-heading",
|
|
6853
|
-
dropdownWrapper: "nui-select-container-wrapper",
|
|
6854
|
-
toggleButton: "menubar-toggle-button",
|
|
6855
|
-
tooltip: "tooltip-box",
|
|
6856
|
-
articlePageTitle: ".serene-article__title",
|
|
6857
|
-
tabItem: "tab-item",
|
|
6858
|
-
labelInputError: "label-input-error",
|
|
6859
|
-
urlInputError: "url-input-error",
|
|
6860
|
-
noDataPrimaryButton: "no-data-primary-button",
|
|
6861
|
-
modalHeader: "modal-header",
|
|
6862
|
-
nameInputError: "name-input-error",
|
|
6863
|
-
selectContainer: "nui-select-container",
|
|
6864
|
-
dropdownMenu: "nui-select-menu",
|
|
6865
|
-
sidebarToggle: "neeto-molecules-sidebar-toggler",
|
|
6866
|
-
subheader: "subheader",
|
|
6867
|
-
settingsLink: "Settings",
|
|
6868
|
-
ticketFieldTextInput: (label) => `${hyphenize(label)}-text-input`,
|
|
7006
|
+
const mergeTaxonomies = async (translations, page) => {
|
|
7007
|
+
const defaultTaxonomyKeys = Object.keys(translations.taxonomyDefaultLabels || {});
|
|
7008
|
+
const defaultTaxonomies = Object.fromEntries(defaultTaxonomyKeys.map(key => [key, { singular: null, plural: null }]));
|
|
7009
|
+
const hostTaxonomies = (await page.evaluate(() => { var _a; return (_a = window.globalProps) === null || _a === void 0 ? void 0 : _a.taxonomies; }));
|
|
7010
|
+
return replaceNullValuesWithGetter(ramda.mergeDeepLeft(hostTaxonomies, defaultTaxonomies));
|
|
6869
7011
|
};
|
|
6870
7012
|
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
this.responses.push((_c = response.headers()) === null || _c === void 0 ? void 0 : _c["x-request-id"]);
|
|
6883
|
-
return true;
|
|
6884
|
-
}
|
|
6885
|
-
return false;
|
|
6886
|
-
}, { timeout: 10000 })));
|
|
6887
|
-
this.recursiveMethod = async (callback, condition, timeout, startTime) => {
|
|
6888
|
-
if (Date.now() - timeout >= startTime) {
|
|
6889
|
-
return false;
|
|
6890
|
-
}
|
|
6891
|
-
else if (await condition()) {
|
|
6892
|
-
return await callback();
|
|
6893
|
-
}
|
|
6894
|
-
return await this.recursiveMethod(callback, condition, timeout, startTime);
|
|
6895
|
-
};
|
|
6896
|
-
this.executeRecursively = async ({ callback, condition, timeout = 5000, }) => {
|
|
6897
|
-
const startTime = Date.now();
|
|
6898
|
-
await this.recursiveMethod(callback, condition, timeout, startTime);
|
|
6899
|
-
};
|
|
6900
|
-
this.verifySuccessToast = async ({ message, closeAfterVerification = true, }) => {
|
|
6901
|
-
if (message) {
|
|
6902
|
-
await test.expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toHaveValue(message);
|
|
6903
|
-
}
|
|
6904
|
-
else {
|
|
6905
|
-
await test.expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toHaveValue("👍");
|
|
6906
|
-
closeAfterVerification &&
|
|
6907
|
-
(await this.page
|
|
6908
|
-
.getByTestId(COMMON_SELECTORS.toastCloseButton)
|
|
6909
|
-
.click());
|
|
6910
|
-
}
|
|
6911
|
-
};
|
|
6912
|
-
this.reloadAndWait = async (requestCount) => {
|
|
6913
|
-
const reloadRequests = this.interceptMultipleResponses({
|
|
6914
|
-
times: requestCount,
|
|
6915
|
-
});
|
|
6916
|
-
await this.page.reload();
|
|
6917
|
-
await reloadRequests;
|
|
6918
|
-
};
|
|
6919
|
-
this.apiRequest = async ({ url, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
|
|
6920
|
-
const csrfToken = await this.page
|
|
6921
|
-
.locator("[name='csrf-token']")
|
|
6922
|
-
.getAttribute("content");
|
|
6923
|
-
const requestOptions = {
|
|
6924
|
-
headers: {
|
|
6925
|
-
...additionalHeaders,
|
|
6926
|
-
"accept-encoding": "gzip",
|
|
6927
|
-
"x-csrf-token": csrfToken !== null && csrfToken !== void 0 ? csrfToken : "",
|
|
7013
|
+
const i18nFixture = {
|
|
7014
|
+
i18n: [
|
|
7015
|
+
async ({ page }, use) => {
|
|
7016
|
+
const translation = readTranslations();
|
|
7017
|
+
const taxonomies = await mergeTaxonomies(translation, page);
|
|
7018
|
+
const options = {
|
|
7019
|
+
debug: false,
|
|
7020
|
+
fallbackLng: "en",
|
|
7021
|
+
resources: { en: { translation } },
|
|
7022
|
+
interpolation: {
|
|
7023
|
+
defaultVariables: { taxonomies },
|
|
6928
7024
|
},
|
|
6929
|
-
|
|
6930
|
-
params,
|
|
6931
|
-
...otherOptions,
|
|
7025
|
+
postProcess: "removeTags",
|
|
6932
7026
|
};
|
|
6933
|
-
const
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
:
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
neetoPlaywrightUtilities: async ({ page, request }, use) => {
|
|
6955
|
-
const commands = new CustomCommands(page, request);
|
|
6956
|
-
await use(commands);
|
|
6957
|
-
},
|
|
6958
|
-
page: async ({ page }, use) => {
|
|
6959
|
-
await page.goto("/");
|
|
6960
|
-
await page.waitForLoadState();
|
|
6961
|
-
await use(page);
|
|
7027
|
+
const i18nInitialized = await playwrightI18nextFixture.initI18n({
|
|
7028
|
+
plugins: [
|
|
7029
|
+
{
|
|
7030
|
+
type: "postProcessor",
|
|
7031
|
+
name: "removeTags",
|
|
7032
|
+
process: function (value) {
|
|
7033
|
+
return value.replace(/<\/?[^>]+(>|$)/g, "");
|
|
7034
|
+
},
|
|
7035
|
+
},
|
|
7036
|
+
],
|
|
7037
|
+
options,
|
|
7038
|
+
// Fetch translations in every test or fetch once
|
|
7039
|
+
cache: true,
|
|
7040
|
+
});
|
|
7041
|
+
await use(i18nInitialized);
|
|
7042
|
+
},
|
|
7043
|
+
// Run as auto fixture to be available through all tests by getI18nInstance()
|
|
7044
|
+
{ auto: true },
|
|
7045
|
+
],
|
|
7046
|
+
t: async ({ i18n }, use) => {
|
|
7047
|
+
await use(i18n.t);
|
|
6962
7048
|
},
|
|
6963
7049
|
};
|
|
6964
7050
|
|
|
6965
|
-
const generateStagingData = (product = "invoice") => {
|
|
6966
|
-
const timestamp = dayjs__default["default"]().format("YYYYMMDDHH");
|
|
6967
|
-
const firstName = "André";
|
|
6968
|
-
const lastName = "O'Reilly";
|
|
6969
|
-
const otpBypassKey = process.env.OTP_BYPASS_KEY;
|
|
6970
|
-
const stagingOrganization = `cypresstest-${product}-${timestamp}`;
|
|
6971
|
-
return {
|
|
6972
|
-
firstName,
|
|
6973
|
-
lastName,
|
|
6974
|
-
otp: 111111,
|
|
6975
|
-
domain: `neeto${product}.net`,
|
|
6976
|
-
currentUserName: IS_STAGING_ENV
|
|
6977
|
-
? joinString(firstName, lastName)
|
|
6978
|
-
: CREDENTIALS.name,
|
|
6979
|
-
businessName: stagingOrganization,
|
|
6980
|
-
subdomainName: IS_STAGING_ENV ? stagingOrganization : "spinkart",
|
|
6981
|
-
email: IS_STAGING_ENV
|
|
6982
|
-
? `cypresstest${otpBypassKey}+${product}+${timestamp}-playwright@bigbinary.com`
|
|
6983
|
-
: "oliver@example.com",
|
|
6984
|
-
};
|
|
6985
|
-
};
|
|
6986
|
-
|
|
6987
|
-
const i18nFixture = playwrightI18nextFixture.createI18nFixture({
|
|
6988
|
-
// i18n configuration options
|
|
6989
|
-
options: {
|
|
6990
|
-
debug: false,
|
|
6991
|
-
fallbackLng: "en",
|
|
6992
|
-
resources: { en: { translation: readTranslations() } },
|
|
6993
|
-
},
|
|
6994
|
-
// Fetch translations in every test or fetch once
|
|
6995
|
-
// Default: true
|
|
6996
|
-
cache: true,
|
|
6997
|
-
// Run as auto fixture to be available through all tests by getI18nInstance()
|
|
6998
|
-
// Default: true
|
|
6999
|
-
auto: true,
|
|
7000
|
-
});
|
|
7001
|
-
|
|
7002
7051
|
const BASE_URL = "/api/v1";
|
|
7003
7052
|
const ROUTES = {
|
|
7004
7053
|
neetoAuth: "https://app.neetoauth.net",
|
|
@@ -7311,8 +7360,7 @@ const initializeCredentials = (product) => {
|
|
|
7311
7360
|
};
|
|
7312
7361
|
|
|
7313
7362
|
const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/", }) => {
|
|
7314
|
-
|
|
7315
|
-
await page.goto((_a = `${process.env.BASE_URL}${loginPath}`) !== null && _a !== void 0 ? _a : "");
|
|
7363
|
+
await page.goto(loginPath);
|
|
7316
7364
|
await page.getByTestId("login-email-text-field").fill(CREDENTIALS.email);
|
|
7317
7365
|
await page
|
|
7318
7366
|
.getByTestId("login-password-text-field")
|
|
@@ -7324,10 +7372,7 @@ const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/"
|
|
|
7324
7372
|
await login;
|
|
7325
7373
|
const userCredentials = readFileSyncIfExists();
|
|
7326
7374
|
await page.context().storageState({ path: STORAGE_STATE });
|
|
7327
|
-
const mergedCredentials = ramda.mergeAll([
|
|
7328
|
-
readFileSyncIfExists(),
|
|
7329
|
-
userCredentials,
|
|
7330
|
-
]);
|
|
7375
|
+
const mergedCredentials = ramda.mergeAll([readFileSyncIfExists(), userCredentials]);
|
|
7331
7376
|
writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
|
|
7332
7377
|
};
|
|
7333
7378
|
const login = async ({ page, neetoPlaywrightUtilities, loginPath, }) => !IS_STAGING_ENV &&
|
|
@@ -7751,7 +7796,6 @@ const definePlaywrightConfig = (overrides) => {
|
|
|
7751
7796
|
forbidOnly: isCI,
|
|
7752
7797
|
retries: isCI ? 1 : 0,
|
|
7753
7798
|
timeout: 0,
|
|
7754
|
-
workers: 1,
|
|
7755
7799
|
reporter: isCI
|
|
7756
7800
|
? [["@currents/playwright", { ...currentsConfig, ...currentsOverrides }]]
|
|
7757
7801
|
: [["line"]],
|
|
@@ -7815,7 +7859,6 @@ exports.joinString = joinString;
|
|
|
7815
7859
|
exports.login = login;
|
|
7816
7860
|
exports.loginWithoutSSO = loginWithoutSSO;
|
|
7817
7861
|
exports.readFileSyncIfExists = readFileSyncIfExists;
|
|
7818
|
-
exports.readTranslations = readTranslations;
|
|
7819
7862
|
exports.updateCredentials = updateCredentials;
|
|
7820
7863
|
exports.writeDataToFile = writeDataToFile;
|
|
7821
7864
|
//# sourceMappingURL=index.cjs.js.map
|