@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 CHANGED
@@ -192,15 +192,13 @@ class CustomCommands {
192
192
  };
193
193
  this.verifySuccessToast = async ({ message, closeAfterVerification = true, }) => {
194
194
  if (message) {
195
- await test.expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toHaveValue(message);
195
+ await test.expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toContainText(message);
196
196
  }
197
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());
198
+ await test.expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toContainText("👍");
203
199
  }
200
+ closeAfterVerification &&
201
+ (await this.page.getByTestId(COMMON_SELECTORS.toastCloseButton).click());
204
202
  };
205
203
  this.reloadAndWait = async (requestCount) => {
206
204
  const reloadRequests = this.interceptMultipleResponses({
@@ -277,6 +275,62 @@ const generateStagingData = (product = "invoice") => {
277
275
  };
278
276
  };
279
277
 
278
+ const LOWERCASED = "__LOWERCASED__";
279
+ const FORMATS = {
280
+ boldList: "boldList",
281
+ list: "list",
282
+ anyCase: "anyCase",
283
+ };
284
+ const LIST_FORMATS = [FORMATS.boldList, FORMATS.list];
285
+
286
+ const cacheStore = new Map();
287
+ const fetchCachedOrInvoke = (func, lng, options) => {
288
+ var _a;
289
+ let cache = (_a = cacheStore.get(lng)) === null || _a === void 0 ? void 0 : _a.get(options);
290
+ if (cache)
291
+ return cache;
292
+ cache = func(lng, options);
293
+ const lngCache = cacheStore.get(lng);
294
+ if (lngCache)
295
+ lngCache.set(options, cache);
296
+ else
297
+ cacheStore.set(lng, new Map([[options, cache]]));
298
+ return cache;
299
+ };
300
+ const lowerCaseDynamicTextFormatter = (value, format) => {
301
+ if (!value || format === FORMATS.anyCase || typeof value !== "string") {
302
+ return value;
303
+ }
304
+ return LOWERCASED + value.toLocaleLowerCase();
305
+ };
306
+ const listFormatter = ({ value, format, lng, options, }) => {
307
+ const formatter = fetchCachedOrInvoke((lng, options) => new Intl.ListFormat(lng, options), lng, options);
308
+ let newValue = value;
309
+ if (format === FORMATS.boldList) {
310
+ newValue = value.map(item => `<strong>${item}</strong>`);
311
+ }
312
+ const items = newValue.toString().split(",");
313
+ return formatter.format(items);
314
+ };
315
+
316
+ const sentenceCase = (value) => value.charAt(0).toLocaleUpperCase() + value.slice(1);
317
+ const sentenceCaseProcessor = {
318
+ type: "postProcessor",
319
+ name: "sentenceCaseProcessor",
320
+ process: (value) => {
321
+ const shouldSentenceCase = value.startsWith(LOWERCASED);
322
+ value = value.replaceAll(LOWERCASED, "");
323
+ return shouldSentenceCase ? sentenceCase(value) : value;
324
+ },
325
+ };
326
+ const removeTagsProcessor = {
327
+ type: "postProcessor",
328
+ name: "removeTagsProcessor",
329
+ process: function (value) {
330
+ return value.replace(/<\/?[^>]+(>|$)/g, "");
331
+ },
332
+ };
333
+
280
334
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
281
335
 
282
336
  var tasks = {};
@@ -7021,19 +7075,27 @@ const i18nFixture = {
7021
7075
  resources: { en: { translation } },
7022
7076
  interpolation: {
7023
7077
  defaultVariables: { taxonomies },
7078
+ escapeValue: false,
7079
+ skipOnVariables: false,
7080
+ alwaysFormat: true,
7081
+ format: (value, format, lng, options) => {
7082
+ let newValue = value;
7083
+ if (LIST_FORMATS.includes(format !== null && format !== void 0 ? format : "")) {
7084
+ newValue = listFormatter({
7085
+ value: newValue,
7086
+ format,
7087
+ lng,
7088
+ options,
7089
+ });
7090
+ return newValue;
7091
+ }
7092
+ return lowerCaseDynamicTextFormatter(newValue, format);
7093
+ },
7024
7094
  },
7025
- postProcess: "removeTags",
7095
+ postProcess: ["removeTagsProcessor", "sentenceCaseProcessor"],
7026
7096
  };
7027
7097
  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
- ],
7098
+ plugins: [removeTagsProcessor, sentenceCaseProcessor],
7037
7099
  options,
7038
7100
  // Fetch translations in every test or fetch once
7039
7101
  cache: true,