@bigbinary/neeto-playwright-commons 1.4.1 → 1.4.3

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.d.ts CHANGED
@@ -365,6 +365,7 @@ interface CurrentsOverrides {
365
365
  interface Overrides {
366
366
  globalOverrides?: Record<string, unknown>;
367
367
  useOverrides?: Record<string, unknown>;
368
+ useCustomProjects?: boolean;
368
369
  projectOverrides?: Record<string, unknown>[];
369
370
  currentsOverrides: CurrentsOverrides & Record<string, unknown>;
370
371
  }
package/index.js CHANGED
@@ -242,6 +242,62 @@ const generateStagingData = (product = "invoice") => {
242
242
  };
243
243
  };
244
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
+
245
301
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
246
302
 
247
303
  var tasks = {};
@@ -6986,19 +7042,27 @@ const i18nFixture = {
6986
7042
  resources: { en: { translation } },
6987
7043
  interpolation: {
6988
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
+ },
6989
7061
  },
6990
- postProcess: "removeTags",
7062
+ postProcess: ["removeTagsProcessor", "sentenceCaseProcessor"],
6991
7063
  };
6992
7064
  const i18nInitialized = await initI18n({
6993
- plugins: [
6994
- {
6995
- type: "postProcessor",
6996
- name: "removeTags",
6997
- process: function (value) {
6998
- return value.replace(/<\/?[^>]+(>|$)/g, "");
6999
- },
7000
- },
7001
- ],
7065
+ plugins: [removeTagsProcessor, sentenceCaseProcessor],
7002
7066
  options,
7003
7067
  // Fetch translations in every test or fetch once
7004
7068
  cache: true,
@@ -7754,7 +7818,7 @@ const currentsConfig = {
7754
7818
  const isCI = ["staging", "review"].includes((_b = process.env.TEST_ENV) !== null && _b !== void 0 ? _b : "development") &&
7755
7819
  !!process.env.NEETO_CI_JOB_ID;
7756
7820
  const definePlaywrightConfig = (overrides) => {
7757
- const { globalOverrides = {}, useOverrides = {}, projectOverrides = [], currentsOverrides = {}, } = overrides;
7821
+ const { globalOverrides = {}, useOverrides = {}, useCustomProjects = false, projectOverrides = [], currentsOverrides = {}, } = overrides;
7758
7822
  return defineConfig({
7759
7823
  testDir: "./e2e/tests",
7760
7824
  fullyParallel: true,
@@ -7773,20 +7837,22 @@ const definePlaywrightConfig = (overrides) => {
7773
7837
  screenshot: "on",
7774
7838
  ...useOverrides,
7775
7839
  },
7776
- projects: [
7777
- {
7778
- name: "setup",
7779
- testMatch: "global.setup.ts",
7780
- teardown: "cleanup credentials",
7781
- },
7782
- {
7783
- name: "chromium",
7784
- use: { ...devices["Desktop Chrome"], storageState },
7785
- dependencies: ["setup"],
7786
- },
7787
- { name: "cleanup credentials", testMatch: "global.teardown.ts" },
7788
- ...projectOverrides,
7789
- ],
7840
+ projects: useCustomProjects
7841
+ ? projectOverrides
7842
+ : [
7843
+ {
7844
+ name: "setup",
7845
+ testMatch: "global.setup.ts",
7846
+ teardown: "cleanup credentials",
7847
+ },
7848
+ {
7849
+ name: "chromium",
7850
+ use: { ...devices["Desktop Chrome"], storageState },
7851
+ dependencies: ["setup"],
7852
+ },
7853
+ { name: "cleanup credentials", testMatch: "global.teardown.ts" },
7854
+ ...projectOverrides,
7855
+ ],
7790
7856
  });
7791
7857
  };
7792
7858