@bigbinary/neeto-playwright-commons 1.4.0 → 1.4.2
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 +78 -16
- package/index.cjs.js.map +1 -1
- package/index.js +78 -16
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -159,15 +159,13 @@ class CustomCommands {
|
|
|
159
159
|
};
|
|
160
160
|
this.verifySuccessToast = async ({ message, closeAfterVerification = true, }) => {
|
|
161
161
|
if (message) {
|
|
162
|
-
await expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).
|
|
162
|
+
await expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toContainText(message);
|
|
163
163
|
}
|
|
164
164
|
else {
|
|
165
|
-
await expect(this.page.locator(COMMON_SELECTORS.toastIcon)).
|
|
166
|
-
closeAfterVerification &&
|
|
167
|
-
(await this.page
|
|
168
|
-
.getByTestId(COMMON_SELECTORS.toastCloseButton)
|
|
169
|
-
.click());
|
|
165
|
+
await expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toContainText("👍");
|
|
170
166
|
}
|
|
167
|
+
closeAfterVerification &&
|
|
168
|
+
(await this.page.getByTestId(COMMON_SELECTORS.toastCloseButton).click());
|
|
171
169
|
};
|
|
172
170
|
this.reloadAndWait = async (requestCount) => {
|
|
173
171
|
const reloadRequests = this.interceptMultipleResponses({
|
|
@@ -244,6 +242,62 @@ const generateStagingData = (product = "invoice") => {
|
|
|
244
242
|
};
|
|
245
243
|
};
|
|
246
244
|
|
|
245
|
+
const LOWERCASED = "__LOWERCASED__";
|
|
246
|
+
const FORMATS = {
|
|
247
|
+
boldList: "boldList",
|
|
248
|
+
list: "list",
|
|
249
|
+
anyCase: "anyCase",
|
|
250
|
+
};
|
|
251
|
+
const LIST_FORMATS = [FORMATS.boldList, FORMATS.list];
|
|
252
|
+
|
|
253
|
+
const cacheStore = new Map();
|
|
254
|
+
const fetchCachedOrInvoke = (func, lng, options) => {
|
|
255
|
+
var _a;
|
|
256
|
+
let cache = (_a = cacheStore.get(lng)) === null || _a === void 0 ? void 0 : _a.get(options);
|
|
257
|
+
if (cache)
|
|
258
|
+
return cache;
|
|
259
|
+
cache = func(lng, options);
|
|
260
|
+
const lngCache = cacheStore.get(lng);
|
|
261
|
+
if (lngCache)
|
|
262
|
+
lngCache.set(options, cache);
|
|
263
|
+
else
|
|
264
|
+
cacheStore.set(lng, new Map([[options, cache]]));
|
|
265
|
+
return cache;
|
|
266
|
+
};
|
|
267
|
+
const lowerCaseDynamicTextFormatter = (value, format) => {
|
|
268
|
+
if (!value || format === FORMATS.anyCase || typeof value !== "string") {
|
|
269
|
+
return value;
|
|
270
|
+
}
|
|
271
|
+
return LOWERCASED + value.toLocaleLowerCase();
|
|
272
|
+
};
|
|
273
|
+
const listFormatter = ({ value, format, lng, options, }) => {
|
|
274
|
+
const formatter = fetchCachedOrInvoke((lng, options) => new Intl.ListFormat(lng, options), lng, options);
|
|
275
|
+
let newValue = value;
|
|
276
|
+
if (format === FORMATS.boldList) {
|
|
277
|
+
newValue = value.map(item => `<strong>${item}</strong>`);
|
|
278
|
+
}
|
|
279
|
+
const items = newValue.toString().split(",");
|
|
280
|
+
return formatter.format(items);
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const sentenceCase = (value) => value.charAt(0).toLocaleUpperCase() + value.slice(1);
|
|
284
|
+
const sentenceCaseProcessor = {
|
|
285
|
+
type: "postProcessor",
|
|
286
|
+
name: "sentenceCaseProcessor",
|
|
287
|
+
process: (value) => {
|
|
288
|
+
const shouldSentenceCase = value.startsWith(LOWERCASED);
|
|
289
|
+
value = value.replaceAll(LOWERCASED, "");
|
|
290
|
+
return shouldSentenceCase ? sentenceCase(value) : value;
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
const removeTagsProcessor = {
|
|
294
|
+
type: "postProcessor",
|
|
295
|
+
name: "removeTagsProcessor",
|
|
296
|
+
process: function (value) {
|
|
297
|
+
return value.replace(/<\/?[^>]+(>|$)/g, "");
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
|
|
247
301
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
248
302
|
|
|
249
303
|
var tasks = {};
|
|
@@ -6988,19 +7042,27 @@ const i18nFixture = {
|
|
|
6988
7042
|
resources: { en: { translation } },
|
|
6989
7043
|
interpolation: {
|
|
6990
7044
|
defaultVariables: { taxonomies },
|
|
7045
|
+
escapeValue: false,
|
|
7046
|
+
skipOnVariables: false,
|
|
7047
|
+
alwaysFormat: true,
|
|
7048
|
+
format: (value, format, lng, options) => {
|
|
7049
|
+
let newValue = value;
|
|
7050
|
+
if (LIST_FORMATS.includes(format !== null && format !== void 0 ? format : "")) {
|
|
7051
|
+
newValue = listFormatter({
|
|
7052
|
+
value: newValue,
|
|
7053
|
+
format,
|
|
7054
|
+
lng,
|
|
7055
|
+
options,
|
|
7056
|
+
});
|
|
7057
|
+
return newValue;
|
|
7058
|
+
}
|
|
7059
|
+
return lowerCaseDynamicTextFormatter(newValue, format);
|
|
7060
|
+
},
|
|
6991
7061
|
},
|
|
6992
|
-
postProcess: "
|
|
7062
|
+
postProcess: ["removeTagsProcessor", "sentenceCaseProcessor"],
|
|
6993
7063
|
};
|
|
6994
7064
|
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
|
-
],
|
|
7065
|
+
plugins: [removeTagsProcessor, sentenceCaseProcessor],
|
|
7004
7066
|
options,
|
|
7005
7067
|
// Fetch translations in every test or fetch once
|
|
7006
7068
|
cache: true,
|