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