@bigbinary/neeto-playwright-commons 1.3.1 → 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 -354
- package/index.cjs.js.map +1 -1
- package/index.d.ts +4 -6
- package/index.js +293 -328
- package/index.js.map +1 -1
- package/package.json +2 -1
package/index.cjs.js
CHANGED
|
@@ -3,48 +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 require$$0$5 = require('i18next');
|
|
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
|
-
var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
|
|
46
45
|
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
|
|
47
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
|
+
|
|
48
280
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
49
281
|
|
|
50
282
|
var tasks = {};
|
|
@@ -6743,56 +6975,6 @@ function assertPatternsInput(input) {
|
|
|
6743
6975
|
}
|
|
6744
6976
|
var out = FastGlob;
|
|
6745
6977
|
|
|
6746
|
-
const ENVIRONMENT = {
|
|
6747
|
-
development: "development",
|
|
6748
|
-
staging: "staging",
|
|
6749
|
-
review: "review",
|
|
6750
|
-
};
|
|
6751
|
-
const IS_STAGING_ENV = process.env.TEST_ENV === "staging";
|
|
6752
|
-
const STORAGE_STATE = "./e2e/auth/user.json";
|
|
6753
|
-
const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
|
|
6754
|
-
const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
|
|
6755
|
-
const CREDENTIALS = {
|
|
6756
|
-
name: "Oliver Smith",
|
|
6757
|
-
email: "oliver@example.com",
|
|
6758
|
-
password: "welcome",
|
|
6759
|
-
};
|
|
6760
|
-
|
|
6761
|
-
const joinString = (string1, string2, string3 = "", separator = " ") => {
|
|
6762
|
-
if (string3 === "") {
|
|
6763
|
-
return string1 + separator + string2;
|
|
6764
|
-
}
|
|
6765
|
-
return string1 + separator + string2 + separator + string3;
|
|
6766
|
-
};
|
|
6767
|
-
const readFileSyncIfExists = (path = STORAGE_STATE) => {
|
|
6768
|
-
try {
|
|
6769
|
-
return JSON.parse(require$$0__namespace.readFileSync(path, "utf8"));
|
|
6770
|
-
}
|
|
6771
|
-
catch (error) {
|
|
6772
|
-
return {};
|
|
6773
|
-
}
|
|
6774
|
-
};
|
|
6775
|
-
const writeDataToFile = data => {
|
|
6776
|
-
try {
|
|
6777
|
-
require$$0__namespace.writeFileSync(STORAGE_STATE, data, "utf8");
|
|
6778
|
-
}
|
|
6779
|
-
catch (error) {
|
|
6780
|
-
console.log(error); // eslint-disable-line
|
|
6781
|
-
}
|
|
6782
|
-
return true;
|
|
6783
|
-
};
|
|
6784
|
-
const updateCredentials = ({ key, value }) => {
|
|
6785
|
-
const data = readFileSyncIfExists();
|
|
6786
|
-
data["user"][key] = value;
|
|
6787
|
-
return writeDataToFile(JSON.stringify(data));
|
|
6788
|
-
};
|
|
6789
|
-
const clearCredentials = () => {
|
|
6790
|
-
require$$0__namespace.unlink(STORAGE_STATE, error => {
|
|
6791
|
-
if (!error)
|
|
6792
|
-
return;
|
|
6793
|
-
console.log(error); // eslint-disable-line
|
|
6794
|
-
});
|
|
6795
|
-
};
|
|
6796
6978
|
const readTranslations = () => {
|
|
6797
6979
|
let translations = readFileSyncIfExists(PROJECT_TRANSLATIONS_PATH);
|
|
6798
6980
|
const paths = out.sync(GLOBAL_TRANSLATIONS_PATTERN);
|
|
@@ -6802,282 +6984,69 @@ const readTranslations = () => {
|
|
|
6802
6984
|
});
|
|
6803
6985
|
return translations;
|
|
6804
6986
|
};
|
|
6805
|
-
const
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
.
|
|
6812
|
-
|
|
6813
|
-
.replace(/-+/g, "-")
|
|
6814
|
-
.toLowerCase();
|
|
6815
|
-
}
|
|
6816
|
-
return fallbackString;
|
|
6817
|
-
};
|
|
6818
|
-
const joinHyphenCase = (...args) => args.join(" ").replace(/\s+/g, "-").toLowerCase();
|
|
6819
|
-
|
|
6820
|
-
const COMMON_SELECTORS = {
|
|
6821
|
-
spinner: ".neeto-ui-spinner",
|
|
6822
|
-
subheaderText: "subheader-left",
|
|
6823
|
-
alertTitle: "alert-title",
|
|
6824
|
-
alertModalMessage: "alert-message",
|
|
6825
|
-
alertModalSubmitButton: "alert-submit-button",
|
|
6826
|
-
checkbox: "nui-checkbox-input",
|
|
6827
|
-
checkboxLabel: "nui-checkbox-label",
|
|
6828
|
-
dropdownContainer: "nui-dropdown-container",
|
|
6829
|
-
dropdownIcon: "nui-dropdown-icon",
|
|
6830
|
-
heading: "main-header",
|
|
6831
|
-
paneBody: "pane-body",
|
|
6832
|
-
paneHeader: "pane-header",
|
|
6833
|
-
profileSidebar: "profile-section",
|
|
6834
|
-
selectOption: (label) => `${hyphenize(label)}-select-option`,
|
|
6835
|
-
toastMessage: "toastr-message-container",
|
|
6836
|
-
toastCloseButton: "toastr-close-button",
|
|
6837
|
-
windowAlert: "#alert-box",
|
|
6838
|
-
body: "body",
|
|
6839
|
-
toastIcon: ".Toastify__toast-icon",
|
|
6840
|
-
paneModalCrossIcon: "pane-close-button",
|
|
6841
|
-
inputField: "nui-input-field",
|
|
6842
|
-
alertConfirmationText: "alert-confirmation-text",
|
|
6843
|
-
alertCancelButton: "alert-cancel-button",
|
|
6844
|
-
alertModalCrossIcon: "modal-close-button",
|
|
6845
|
-
saveChangesButton: "save-changes-button",
|
|
6846
|
-
cancelButton: "cancel-button",
|
|
6847
|
-
inputFieldError: "nui-input-error",
|
|
6848
|
-
selectDropDownError: "nui-select-error",
|
|
6849
|
-
subTitleHeading: "menubar-subtitle-heading",
|
|
6850
|
-
noDataTitle: "no-data-title",
|
|
6851
|
-
noDataDescription: "no-data-description",
|
|
6852
|
-
backdrop: "neeto-backdrop",
|
|
6853
|
-
menuBarHeading: "menubar-heading",
|
|
6854
|
-
dropdownWrapper: "nui-select-container-wrapper",
|
|
6855
|
-
toggleButton: "menubar-toggle-button",
|
|
6856
|
-
tooltip: "tooltip-box",
|
|
6857
|
-
articlePageTitle: ".serene-article__title",
|
|
6858
|
-
tabItem: "tab-item",
|
|
6859
|
-
labelInputError: "label-input-error",
|
|
6860
|
-
urlInputError: "url-input-error",
|
|
6861
|
-
noDataPrimaryButton: "no-data-primary-button",
|
|
6862
|
-
modalHeader: "modal-header",
|
|
6863
|
-
nameInputError: "name-input-error",
|
|
6864
|
-
selectContainer: "nui-select-container",
|
|
6865
|
-
dropdownMenu: "nui-select-menu",
|
|
6866
|
-
sidebarToggle: "neeto-molecules-sidebar-toggler",
|
|
6867
|
-
subheader: "subheader",
|
|
6868
|
-
settingsLink: "Settings",
|
|
6869
|
-
ticketFieldTextInput: (label) => `${hyphenize(label)}-text-input`,
|
|
6870
|
-
};
|
|
6871
|
-
|
|
6872
|
-
class CustomCommands {
|
|
6873
|
-
constructor(page, request) {
|
|
6874
|
-
this.interceptMultipleResponses = ({ responseUrl = "", times = 1, baseUrl, }) => Promise.all([...new Array(times)].map(() => this.page.waitForResponse((response) => {
|
|
6875
|
-
var _a, _b, _c;
|
|
6876
|
-
if (response.request().resourceType() === "xhr" &&
|
|
6877
|
-
response.status() === 200 &&
|
|
6878
|
-
response.url().includes(responseUrl) &&
|
|
6879
|
-
response
|
|
6880
|
-
.url()
|
|
6881
|
-
.startsWith((_a = baseUrl !== null && baseUrl !== void 0 ? baseUrl : process.env.BASE_URL) !== null && _a !== void 0 ? _a : "") &&
|
|
6882
|
-
!this.responses.includes((_b = response.headers()) === null || _b === void 0 ? void 0 : _b["x-request-id"])) {
|
|
6883
|
-
this.responses.push((_c = response.headers()) === null || _c === void 0 ? void 0 : _c["x-request-id"]);
|
|
6884
|
-
return true;
|
|
6885
|
-
}
|
|
6886
|
-
return false;
|
|
6887
|
-
}, { timeout: 10000 })));
|
|
6888
|
-
this.recursiveMethod = async (callback, condition, timeout, startTime) => {
|
|
6889
|
-
if (Date.now() - timeout >= startTime) {
|
|
6890
|
-
return false;
|
|
6891
|
-
}
|
|
6892
|
-
else if (await condition()) {
|
|
6893
|
-
return await callback();
|
|
6894
|
-
}
|
|
6895
|
-
return await this.recursiveMethod(callback, condition, timeout, startTime);
|
|
6896
|
-
};
|
|
6897
|
-
this.executeRecursively = async ({ callback, condition, timeout = 5000, }) => {
|
|
6898
|
-
const startTime = Date.now();
|
|
6899
|
-
await this.recursiveMethod(callback, condition, timeout, startTime);
|
|
6900
|
-
};
|
|
6901
|
-
this.verifySuccessToast = async ({ message, closeAfterVerification = true, }) => {
|
|
6902
|
-
if (message) {
|
|
6903
|
-
await test.expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toHaveValue(message);
|
|
6904
|
-
}
|
|
6905
|
-
else {
|
|
6906
|
-
await test.expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toHaveValue("👍");
|
|
6907
|
-
closeAfterVerification &&
|
|
6908
|
-
(await this.page
|
|
6909
|
-
.getByTestId(COMMON_SELECTORS.toastCloseButton)
|
|
6910
|
-
.click());
|
|
6911
|
-
}
|
|
6912
|
-
};
|
|
6913
|
-
this.reloadAndWait = async (requestCount) => {
|
|
6914
|
-
const reloadRequests = this.interceptMultipleResponses({
|
|
6915
|
-
times: requestCount,
|
|
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),
|
|
6916
6995
|
});
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
const requestOptions = {
|
|
6925
|
-
headers: {
|
|
6926
|
-
...additionalHeaders,
|
|
6927
|
-
"accept-encoding": "gzip",
|
|
6928
|
-
"x-csrf-token": csrfToken !== null && csrfToken !== void 0 ? csrfToken : "",
|
|
6929
|
-
},
|
|
6930
|
-
data,
|
|
6931
|
-
params,
|
|
6932
|
-
...otherOptions,
|
|
6933
|
-
};
|
|
6934
|
-
const httpMethodsHandlers = {
|
|
6935
|
-
get: () => this.request.get(url, requestOptions),
|
|
6936
|
-
post: () => this.request.post(url, requestOptions),
|
|
6937
|
-
put: () => this.request.put(url, requestOptions),
|
|
6938
|
-
delete: () => this.request.delete(url, requestOptions),
|
|
6939
|
-
};
|
|
6940
|
-
return await httpMethodsHandlers[method]();
|
|
6941
|
-
};
|
|
6942
|
-
this.verifyFieldValue = values => {
|
|
6943
|
-
const verifyEachFieldValue = ({ field, value, }) => test.expect(this.page.getByTestId(field)).toHaveValue(value);
|
|
6944
|
-
return Array.isArray(values)
|
|
6945
|
-
? Promise.all(values.map(value => verifyEachFieldValue(value)))
|
|
6946
|
-
: verifyEachFieldValue(values);
|
|
6947
|
-
};
|
|
6948
|
-
this.page = page;
|
|
6949
|
-
this.responses = [];
|
|
6950
|
-
this.request = request;
|
|
6996
|
+
}
|
|
6997
|
+
else if (typeof value === "object") {
|
|
6998
|
+
result[key] = replaceNullValuesWithGetter(value, transKey);
|
|
6999
|
+
}
|
|
7000
|
+
else {
|
|
7001
|
+
result[key] = value;
|
|
7002
|
+
}
|
|
6951
7003
|
}
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
const commands = {
|
|
6955
|
-
neetoPlaywrightUtilities: async ({ page, request }, use) => {
|
|
6956
|
-
const commands = new CustomCommands(page, request);
|
|
6957
|
-
await use(commands);
|
|
6958
|
-
},
|
|
6959
|
-
page: async ({ page }, use) => {
|
|
6960
|
-
await page.goto("/");
|
|
6961
|
-
await page.waitForLoadState();
|
|
6962
|
-
await use(page);
|
|
6963
|
-
},
|
|
7004
|
+
return result;
|
|
6964
7005
|
};
|
|
6965
|
-
|
|
6966
|
-
const
|
|
6967
|
-
const
|
|
6968
|
-
const
|
|
6969
|
-
|
|
6970
|
-
const otpBypassKey = process.env.OTP_BYPASS_KEY;
|
|
6971
|
-
const stagingOrganization = `cypresstest-${product}-${timestamp}`;
|
|
6972
|
-
return {
|
|
6973
|
-
firstName,
|
|
6974
|
-
lastName,
|
|
6975
|
-
otp: 111111,
|
|
6976
|
-
domain: `neeto${product}.net`,
|
|
6977
|
-
currentUserName: IS_STAGING_ENV
|
|
6978
|
-
? joinString(firstName, lastName)
|
|
6979
|
-
: CREDENTIALS.name,
|
|
6980
|
-
businessName: stagingOrganization,
|
|
6981
|
-
subdomainName: IS_STAGING_ENV ? stagingOrganization : "spinkart",
|
|
6982
|
-
email: IS_STAGING_ENV
|
|
6983
|
-
? `cypresstest${otpBypassKey}+${product}+${timestamp}-playwright@bigbinary.com`
|
|
6984
|
-
: "oliver@example.com",
|
|
6985
|
-
};
|
|
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));
|
|
6986
7011
|
};
|
|
6987
7012
|
|
|
6988
|
-
|
|
6989
|
-
var __defProp = Object.defineProperty;
|
|
6990
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6991
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6992
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6993
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6994
|
-
var __export = (target, all) => {
|
|
6995
|
-
for (var name in all)
|
|
6996
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6997
|
-
};
|
|
6998
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6999
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7000
|
-
for (let key of __getOwnPropNames(from))
|
|
7001
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
7002
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
7003
|
-
}
|
|
7004
|
-
return to;
|
|
7005
|
-
};
|
|
7006
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
7007
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
7008
|
-
mod
|
|
7009
|
-
));
|
|
7010
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
7011
|
-
|
|
7012
|
-
// src/index.ts
|
|
7013
|
-
var src_exports = {};
|
|
7014
|
-
__export(src_exports, {
|
|
7015
|
-
createI18nFixture: () => createI18nFixture,
|
|
7016
|
-
getI18nInstance: () => getI18nInstance,
|
|
7017
|
-
initI18n: () => initI18n
|
|
7018
|
-
});
|
|
7019
|
-
var dist = __toCommonJS(src_exports);
|
|
7020
|
-
|
|
7021
|
-
// src/i18n.ts
|
|
7022
|
-
var import_i18next = __toESM(require$$0__default$5["default"]);
|
|
7023
|
-
var storedI18n;
|
|
7024
|
-
async function initI18n({
|
|
7025
|
-
plugins,
|
|
7026
|
-
options,
|
|
7027
|
-
cache
|
|
7028
|
-
}) {
|
|
7029
|
-
if (!cache || !storedI18n || !storedI18n.isInitialized) {
|
|
7030
|
-
const i18n2 = plugins.reduce(
|
|
7031
|
-
(i18n3, plugin) => i18n3 = i18n3.use(plugin),
|
|
7032
|
-
import_i18next.default.createInstance()
|
|
7033
|
-
);
|
|
7034
|
-
await i18n2.init(options);
|
|
7035
|
-
storedI18n = i18n2;
|
|
7036
|
-
}
|
|
7037
|
-
return storedI18n;
|
|
7038
|
-
}
|
|
7039
|
-
function getI18nInstance() {
|
|
7040
|
-
if (!storedI18n) {
|
|
7041
|
-
throw new Error("No i18n instance initialized");
|
|
7042
|
-
}
|
|
7043
|
-
return storedI18n;
|
|
7044
|
-
}
|
|
7045
|
-
|
|
7046
|
-
// src/fixture.ts
|
|
7047
|
-
var createI18nFixture = ({
|
|
7048
|
-
plugins = [],
|
|
7049
|
-
options = {},
|
|
7050
|
-
cache = true,
|
|
7051
|
-
auto = true
|
|
7052
|
-
}) => {
|
|
7053
|
-
return {
|
|
7013
|
+
const i18nFixture = {
|
|
7054
7014
|
i18n: [
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
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 },
|
|
7024
|
+
},
|
|
7025
|
+
postProcess: "removeTags",
|
|
7026
|
+
};
|
|
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 },
|
|
7060
7045
|
],
|
|
7061
|
-
t: async ({ i18n
|
|
7062
|
-
|
|
7063
|
-
}
|
|
7064
|
-
};
|
|
7065
|
-
};
|
|
7066
|
-
|
|
7067
|
-
const i18nFixture = dist.createI18nFixture({
|
|
7068
|
-
// i18n configuration options
|
|
7069
|
-
options: {
|
|
7070
|
-
debug: false,
|
|
7071
|
-
fallbackLng: "en",
|
|
7072
|
-
resources: { en: { translation: readTranslations() } },
|
|
7046
|
+
t: async ({ i18n }, use) => {
|
|
7047
|
+
await use(i18n.t);
|
|
7073
7048
|
},
|
|
7074
|
-
|
|
7075
|
-
// Default: true
|
|
7076
|
-
cache: true,
|
|
7077
|
-
// Run as auto fixture to be available through all tests by getI18nInstance()
|
|
7078
|
-
// Default: true
|
|
7079
|
-
auto: true,
|
|
7080
|
-
});
|
|
7049
|
+
};
|
|
7081
7050
|
|
|
7082
7051
|
const BASE_URL = "/api/v1";
|
|
7083
7052
|
const ROUTES = {
|
|
@@ -7391,8 +7360,7 @@ const initializeCredentials = (product) => {
|
|
|
7391
7360
|
};
|
|
7392
7361
|
|
|
7393
7362
|
const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/", }) => {
|
|
7394
|
-
|
|
7395
|
-
await page.goto((_a = `${process.env.BASE_URL}${loginPath}`) !== null && _a !== void 0 ? _a : "");
|
|
7363
|
+
await page.goto(loginPath);
|
|
7396
7364
|
await page.getByTestId("login-email-text-field").fill(CREDENTIALS.email);
|
|
7397
7365
|
await page
|
|
7398
7366
|
.getByTestId("login-password-text-field")
|
|
@@ -7404,10 +7372,7 @@ const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, loginPath = "/"
|
|
|
7404
7372
|
await login;
|
|
7405
7373
|
const userCredentials = readFileSyncIfExists();
|
|
7406
7374
|
await page.context().storageState({ path: STORAGE_STATE });
|
|
7407
|
-
const mergedCredentials = ramda.mergeAll([
|
|
7408
|
-
readFileSyncIfExists(),
|
|
7409
|
-
userCredentials,
|
|
7410
|
-
]);
|
|
7375
|
+
const mergedCredentials = ramda.mergeAll([readFileSyncIfExists(), userCredentials]);
|
|
7411
7376
|
writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
|
|
7412
7377
|
};
|
|
7413
7378
|
const login = async ({ page, neetoPlaywrightUtilities, loginPath, }) => !IS_STAGING_ENV &&
|
|
@@ -7831,7 +7796,6 @@ const definePlaywrightConfig = (overrides) => {
|
|
|
7831
7796
|
forbidOnly: isCI,
|
|
7832
7797
|
retries: isCI ? 1 : 0,
|
|
7833
7798
|
timeout: 0,
|
|
7834
|
-
workers: 1,
|
|
7835
7799
|
reporter: isCI
|
|
7836
7800
|
? [["@currents/playwright", { ...currentsConfig, ...currentsOverrides }]]
|
|
7837
7801
|
: [["line"]],
|
|
@@ -7895,7 +7859,6 @@ exports.joinString = joinString;
|
|
|
7895
7859
|
exports.login = login;
|
|
7896
7860
|
exports.loginWithoutSSO = loginWithoutSSO;
|
|
7897
7861
|
exports.readFileSyncIfExists = readFileSyncIfExists;
|
|
7898
|
-
exports.readTranslations = readTranslations;
|
|
7899
7862
|
exports.updateCredentials = updateCredentials;
|
|
7900
7863
|
exports.writeDataToFile = writeDataToFile;
|
|
7901
7864
|
//# sourceMappingURL=index.cjs.js.map
|