gatsby-core-theme 5.1.3 → 5.1.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## [5.1.4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v5.1.3...v5.1.4) (2022-03-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add default 12 items on archive module ([6c9edf9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6c9edf999f64825ba688bb0f35158d6d534aca9d))
7
+
8
+
9
+ ### Code Refactoring
10
+
11
+ * update build array func ([842477e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/842477eb0c04d6e123066c14609f0426b6802989))
12
+ * update generate array func ([ec69c52](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ec69c522f9ae7bba63e50368f849873349db0e9b))
13
+ * update generate array tests ([2edbfeb](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2edbfeb3ddad10d5043555b71c1ab69e11ee1638))
14
+ * update header component test ([3e191e7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3e191e70cc08fa132e36b3f84f0cf0b731ddc7b0))
15
+ * update prefilled module generation ([10365c7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/10365c722aee002d69c93db3db3e309c21e19e03))
16
+ * update prefilled module generation ([7eedb0d](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7eedb0d6de7baff62315c71284e20cb21228f30d))
17
+ * update prefilled module generation ([e76c655](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e76c655217a5b62d42bcf987aa3d641520a11030))
18
+ * update saved prefilled module func check ([adfcf82](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/adfcf82e738248ed51730445a29d60a9f3836eda))
19
+
20
+
21
+ * Merge branch 'tm-2795-update-build-array-func' into 'master' ([cc21cf2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/cc21cf288b0fb796e0b1afac1cebae1e7419006d))
22
+ * Merge branch 'tm-2729-update-prefilled-module-generation' into 'master' ([73a094c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/73a094c7b8fdd1e07f0469c8ef78eb2a4f617ace))
23
+
1
24
  ## [5.1.3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v5.1.2...v5.1.3) (2022-03-16)
2
25
 
3
26
 
@@ -53,7 +53,7 @@ function createArchivePage(pageObject, marketSections, prefilledModules, createP
53
53
 
54
54
  if (archiveModule.pagination_type !== 'load_more') {
55
55
  const numOfColumns = archiveModule.desktop_num_of_columns;
56
- const calDefaultNrOfItems = (numOfColumns !== null ? numOfColumns : 3) * 3;
56
+ const calDefaultNrOfItems = (numOfColumns !== null ? numOfColumns : 4) * 3;
57
57
  const numOfItemsPerPage = Math.sign(archiveModule.num_of_items)
58
58
  ? archiveModule.num_of_items
59
59
  : calDefaultNrOfItems;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "5.1.3",
3
+ "version": "5.1.4",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -4,6 +4,11 @@ export default {
4
4
  'norskespilleautomater.com': true,
5
5
  'playcasino.co.za': true,
6
6
  },
7
+ dynamic_prefilled_modules: {
8
+ 'Irishluck.ie': ['cards', 'cards_v2'],
9
+ 'norskespilleautomater.com': ['cards', 'cards_v2'],
10
+ 'playcasino.co.za': ['cards', 'cards_v2'],
11
+ },
7
12
  keep_page_extra_fields: {
8
13
  operator: {
9
14
  'norskespilleautomater.com': true, // needed for inoperative / placeholder fields
@@ -43,3 +43,7 @@ export function generatePlaceholderString(string = '', translations, data) {
43
43
  }[match])
44
44
  );
45
45
  }
46
+
47
+ export function generateArray(obj) {
48
+ return obj !== null && obj !== undefined ? Object.keys(obj).map((key) => obj[key]) : [];
49
+ }
@@ -1,4 +1,4 @@
1
- import { generateTrackerLink, generatePlaceholderString } from './generators';
1
+ import { generateTrackerLink, generatePlaceholderString, generateArray } from './generators';
2
2
  import { months } from '~constants/common';
3
3
 
4
4
  describe('Generate Tracker Link Helper', () => {
@@ -14,13 +14,18 @@ describe('Generate Tracker Link Helper', () => {
14
14
  expect(typeof trackerLink).toEqual('string');
15
15
  expect(trackerLink).toEqual('/no/visit/bet365/casino/non_main');
16
16
  });
17
+ test('generateTrackerLink no tracker format', () => {
18
+ process.env.TRACKER_LINK_FORMAT_MAIN = '';
19
+ process.env.TRACKER_LINK_FORMAT_NON_MAIN = '';
20
+ const trackerLink = generateTrackerLink({ type: 'casino', short_name: 'bet365' }, 'main');
21
+ expect(trackerLink).not.toBeTruthy();
22
+ });
17
23
  });
18
24
 
19
25
  describe('Generate Placeholders String', () => {
20
26
  test('generatePlaceholderString uppercase', () => {
21
27
  const string = generatePlaceholderString('Some title [MONTH] [YEAR]');
22
28
  const date = new Date();
23
-
24
29
  expect(string).not.toContain('[MONTH]');
25
30
  expect(string).not.toContain('[YEAR]');
26
31
  expect(string).toContain(date.getFullYear());
@@ -36,7 +41,6 @@ describe('Generate Placeholders String', () => {
36
41
  }
37
42
  );
38
43
  const date = new Date();
39
-
40
44
  expect(string).not.toContain('[currentdate]');
41
45
  expect(string).not.toContain('[currentmonth]');
42
46
  expect(string).not.toContain('[currentyear]');
@@ -59,4 +63,30 @@ describe('Generate Placeholders String', () => {
59
63
  expect(string).not.toContain('[MONTH]');
60
64
  expect(string).toContain(translateMonths[months[date.getMonth()]]);
61
65
  });
66
+ test('generatePlaceholderString empty', () => {
67
+ const string = generatePlaceholderString();
68
+ expect(string).not.toBeTruthy();
69
+ });
70
+ });
71
+
72
+ describe('Generate Array From Object', () => {
73
+ test('generateArray empty', () => {
74
+ const output = generateArray();
75
+ expect(Object.prototype.toString.call(output)).toEqual('[object Array]');
76
+ expect(output.length).toEqual(0);
77
+ });
78
+ test('generateArray array', () => {
79
+ const output = generateArray(['a', 'b']);
80
+ expect(Object.prototype.toString.call(output)).toEqual('[object Array]');
81
+ expect(output.length).toEqual(2);
82
+ expect(output[0]).toEqual('a');
83
+ expect(output[1]).toEqual('b');
84
+ });
85
+ test('generateArray object', () => {
86
+ const output = generateArray({ a: 'a', b: 'b' });
87
+ expect(Object.prototype.toString.call(output)).toEqual('[object Array]');
88
+ expect(output.length).toEqual(2);
89
+ expect(output[0]).toEqual('a');
90
+ expect(output[1]).toEqual('b');
91
+ });
62
92
  });
@@ -10,7 +10,7 @@ import SearchTypesEnable from '../../constants/search-types-enable';
10
10
  import { pickHTMLSitemapPageKeys } from '../../constants/pick-keys';
11
11
  import { generatePlaceholderString } from '../generators';
12
12
  // eslint-disable-next-line import/no-cycle
13
- import { processModule } from './modules';
13
+ import { shouldSavePrefilled, processModule } from './modules';
14
14
  // eslint-disable-next-line import/no-cycle
15
15
  import { clonePageForCards, groupBy, removeTags } from './common';
16
16
  import { prepareSportsData, addSportsDataToPage, addExtraFieldsToShowcaseEvents } from './sports';
@@ -75,6 +75,7 @@ export function transform(response) {
75
75
  return transformed;
76
76
  }
77
77
 
78
+ const savedModules = {};
78
79
  export function processSections(sections, skipPost = false, page) {
79
80
  let minutes = 0;
80
81
  let seconds = 0;
@@ -88,15 +89,26 @@ export function processSections(sections, skipPost = false, page) {
88
89
  }
89
90
  if (sections[sectionKey] && sections[sectionKey].modules) {
90
91
  sections[sectionKey].modules.forEach((module, key) => {
91
- sections[sectionKey].modules[module[key]] = processModule(
92
- module,
93
- pages,
94
- pagesCloned,
95
- relations,
96
- pagesMappedById,
97
- menus,
98
- previewMode
99
- );
92
+ if (
93
+ shouldSavePrefilled(module, page && page.siteInfo && page.siteInfo.site_name) &&
94
+ savedModules[module.module_value_id]
95
+ ) {
96
+ module = savedModules[module.module_value_id];
97
+ } else {
98
+ sections[sectionKey].modules[module[key]] = processModule(
99
+ module,
100
+ pages,
101
+ pagesCloned,
102
+ relations,
103
+ pagesMappedById,
104
+ menus,
105
+ previewMode
106
+ );
107
+
108
+ if (shouldSavePrefilled(module, page && page.siteInfo && page.siteInfo.site_name)) {
109
+ savedModules[module.module_value_id] = module;
110
+ }
111
+ }
100
112
 
101
113
  // calculate reading time
102
114
  if (module.name === 'content') {
@@ -305,12 +317,13 @@ export default {
305
317
  // pre NSA launch dirty loop to add prefilled modules as normal modules (as actual value)
306
318
  Object.keys(page.sections).forEach((sectionKey) => {
307
319
  if (page.sections[sectionKey] && page.sections[sectionKey].modules) {
308
- page.sections[sectionKey].modules.forEach((sectionModule, index) => {
320
+ page.sections[sectionKey].modules.forEach((sectionModule, i) => {
309
321
  if (
310
322
  sectionModule.value_type === ModuleValue.VALUE_TYPE_PREFILLED_MODULE_MARKET
311
323
  ) {
312
324
  const rawValue = prefilledMarketModulesRaw[sectionModule.value_id];
313
- page.sections[sectionKey].modules[index] = rawValue;
325
+ rawValue.value_type = sectionModule.value_type;
326
+ page.sections[sectionKey].modules[i] = rawValue;
314
327
  }
315
328
  });
316
329
  }
@@ -1,4 +1,4 @@
1
- import { transform, processExtraFields } from './index';
1
+ import { transform, processExtraFields, processSections } from './index';
2
2
  import pages from '~tests/factories/pages/pages.factory.js';
3
3
 
4
4
  describe('Index Processor', () => {
@@ -18,4 +18,8 @@ describe('Index Processor', () => {
18
18
  const result = processExtraFields(false);
19
19
  expect(result).toBeFalsy();
20
20
  });
21
+ test('processSections', () => {
22
+ const result = processSections(pages.prefilled_market_modules);
23
+ expect(result).toBeTruthy();
24
+ });
21
25
  });
@@ -2,6 +2,8 @@ import { cloneDeep, pick, sampleSize } from 'lodash';
2
2
 
3
3
  // eslint-disable-next-line import/no-cycle
4
4
  import { clonePageForCards, groupBy, removeDuplicates } from './common';
5
+ import settings from '../../constants/settings';
6
+ import ModuleValue from '../../constants/module-value';
5
7
  import { topListPickKeys } from '../../constants/pick-keys';
6
8
 
7
9
  const pagesGroupedByTemplateId = [];
@@ -213,6 +215,12 @@ export function processTopListModule(module, relations) {
213
215
  });
214
216
  }
215
217
 
218
+ export function shouldSavePrefilled(module = {}, siteName) {
219
+ return module.value_type === ModuleValue.VALUE_TYPE_PREFILLED_MODULE_MARKET &&
220
+ ((settings.dynamic_prefilled_modules[siteName] && !settings.dynamic_prefilled_modules[siteName].includes(module.name)) ||
221
+ module.sort_by !== 'random');
222
+ }
223
+
216
224
  export function processModule(
217
225
  module,
218
226
  pages,
@@ -6,7 +6,9 @@ import {
6
6
  filterOperators,
7
7
  processBonus,
8
8
  processTopListModule,
9
+ shouldSavePrefilled,
9
10
  } from './modules';
11
+ import { objectsHolder } from '~tests/factories/modules/modules.factory';
10
12
  import getPageDataList from '~tests/factories/pages/list.factory';
11
13
  import {
12
14
  getSampleCardsV2ModuleManual,
@@ -93,4 +95,11 @@ describe('Modules Helper', () => {
93
95
  expect(singleToplistData.items[0].items[0].short_name).toEqual('slotum');
94
96
  expect(singleToplistData.items[0].items[0].bonus.deposit_methods).toHaveLength(1);
95
97
  });
98
+
99
+ test('Should Generate Prefilled', () => {
100
+ const objects = objectsHolder('prefilledModules');
101
+ objects.forEach((prefilled) => {
102
+ expect(shouldSavePrefilled(prefilled.module, prefilled.siteName)).toEqual(prefilled.expected);
103
+ });
104
+ });
96
105
  });
@@ -1,6 +1,4 @@
1
- export function buildArray(obj) {
2
- return Object.keys(obj).map((key) => obj[key]);
3
- }
1
+ import { generateArray } from './generators';
4
2
 
5
3
  export function reverseDate(date) {
6
4
  return date.split('-').reverse().join('-');
@@ -17,9 +15,9 @@ export function filterScheduleByTournaments(schedule, relationIds) {
17
15
  tournamentIds = [relationIds];
18
16
  }
19
17
 
20
- const scheduleArray = buildArray(schedule);
18
+ const scheduleArray = generateArray(schedule);
21
19
  for (let i = 0; i < scheduleArray.length; i += 1) {
22
- const tournaments = buildArray(scheduleArray[i].tournaments);
20
+ const tournaments = generateArray(scheduleArray[i].tournaments);
23
21
  const filteredByTournament = tournaments.filter((tournament) =>
24
22
  tournamentIds.includes(tournament.id)
25
23
  );
@@ -69,9 +67,9 @@ export function getSortedEvents(tournaments, sportEvents) {
69
67
  }
70
68
 
71
69
  export function filterScheduleByTeam(schedule, eventsArray) {
72
- const scheduleArray = buildArray(schedule);
70
+ const scheduleArray = generateArray(schedule);
73
71
  for (let i = 0; i < scheduleArray.length; i += 1) {
74
- const tournaments = buildArray(scheduleArray[i].tournaments);
72
+ const tournaments = generateArray(scheduleArray[i].tournaments);
75
73
 
76
74
  for (let j = 0; j < tournaments.length; j += 1) {
77
75
  const filteredByTeam = tournaments[j].events.filter((event) =>
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable no-console */
2
+ import ModuleValue from '../../../src/constants/module-value';
2
3
  import { getListContentData } from '~tests/factories/modules/content.factory';
3
4
  // import { sampleGameCards } from '~tests/factories/modules/card.factory.js';
4
5
  import { getSpotlightItems } from '~tests/factories/modules/spotlights.factory.js';
@@ -131,6 +132,44 @@ const imageProps = {
131
132
  },
132
133
  };
133
134
 
135
+ const prefilledModules = [
136
+ {
137
+ module: { name: 'cards_v2', sort_by: 'random' },
138
+ siteName: 'no_site',
139
+ expected: false,
140
+ },
141
+ {
142
+ module: { value_type: ModuleValue.VALUE_TYPE_PREFILLED_MODULE_MARKET, name: 'cards_v2', sort_by: 'random' },
143
+ siteName: 'playcasino.co.za',
144
+ expected: false,
145
+ },
146
+ {
147
+ module: { value_type: ModuleValue.VALUE_TYPE_PREFILLED_MODULE_MARKET, name: 'module', sort_by: 'asc' },
148
+ siteName: 'playcasino.co.za',
149
+ expected: true,
150
+ },
151
+ {
152
+ module: { value_type: ModuleValue.VALUE_TYPE_PREFILLED_MODULE_MARKET, name: 'module', sort_by: 'random' },
153
+ siteName: 'playcasino.co.za',
154
+ expected: true,
155
+ },
156
+ {
157
+ module: { value_type: ModuleValue.VALUE_TYPE_PREFILLED_MODULE_MARKET, name: 'cards', sort_by: 'asc' },
158
+ siteName: 'playcasino.co.za',
159
+ expected: true,
160
+ },
161
+ {
162
+ module: { value_type: ModuleValue.VALUE_TYPE_PREFILLED_MODULE_MARKET, name: 'cards', sort_by: 'random' },
163
+ siteName: 'playcasino.co.za',
164
+ expected: false,
165
+ },
166
+ {
167
+ module: { value_type: ModuleValue.VALUE_TYPE_PREFILLED_MODULE_MARKET, name: 'cards_v2', sort_by: 'random' },
168
+ siteName: 'playcasino.co.za',
169
+ expected: false,
170
+ },
171
+ ];
172
+
134
173
  // eslint-disable-next-line import/prefer-default-export
135
174
  export function objectsHolder(elm) {
136
175
  if (!elm || elm == null || undefined) {
@@ -147,6 +186,7 @@ export function objectsHolder(elm) {
147
186
  bonus: BonusProps,
148
187
  image: imageProps,
149
188
  spotlights: getSpotlightItems(2),
189
+ prefilledModules: prefilledModules,
150
190
  };
151
191
  return data[elm];
152
192
  }
@@ -189,4 +189,100 @@ export default {
189
189
  },
190
190
  },
191
191
  },
192
+ prefilled_market_modules: {
193
+ post_main: {
194
+ 1059: {
195
+ title: 'More casino reviews',
196
+ link_label: null,
197
+ link_value: null,
198
+ model_type: 'operator',
199
+ display_input: 'automatic',
200
+ display_type: 'default',
201
+ sort_by: 'random',
202
+ sort_order: 'ascending',
203
+ num_of_items: 3,
204
+ desktop_num_of_columns: 3,
205
+ tablet_num_of_columns: 3,
206
+ mobile_num_of_columns: 1,
207
+ featured_index: null,
208
+ show_load_more: false,
209
+ extra_data: null,
210
+ module_value_id: 1059,
211
+ name: 'cards',
212
+ anchored: 0,
213
+ anchor_label: null,
214
+ anchor_slug: null,
215
+ module_title: 'More Casino Reviews',
216
+ module_title_tag: null,
217
+ background_color: null,
218
+ style: null,
219
+ style_id: null,
220
+ see_more_link: {
221
+ type: 'page',
222
+ value: null,
223
+ title: null,
224
+ },
225
+ },
226
+ 1061: {
227
+ title: 'More slots reviews',
228
+ link_label: null,
229
+ link_value: null,
230
+ model_type: 'game',
231
+ display_input: 'automatic',
232
+ display_type: 'default',
233
+ sort_by: 'created_at',
234
+ sort_order: 'ascending',
235
+ num_of_items: 3,
236
+ desktop_num_of_columns: 3,
237
+ tablet_num_of_columns: 3,
238
+ mobile_num_of_columns: 1,
239
+ featured_index: null,
240
+ show_load_more: false,
241
+ extra_data: null,
242
+ module_value_id: 1061,
243
+ name: 'cards',
244
+ anchored: 0,
245
+ anchor_label: null,
246
+ anchor_slug: null,
247
+ module_title: 'More Game Reviews',
248
+ module_title_tag: null,
249
+ background_color: null,
250
+ style: null,
251
+ style_id: null,
252
+ see_more_link: {
253
+ type: 'page',
254
+ value: null,
255
+ title: null,
256
+ },
257
+ },
258
+ 1063: {
259
+ title: 'Latest news',
260
+ link_label: null,
261
+ link_value: null,
262
+ model_type: 'article',
263
+ display_input: 'automatic',
264
+ display_type: 'default',
265
+ sort_by: 'created_at',
266
+ sort_order: 'ascending',
267
+ num_of_items: 3,
268
+ desktop_num_of_columns: 3,
269
+ tablet_num_of_columns: 3,
270
+ mobile_num_of_columns: 1,
271
+ featured_index: null,
272
+ show_load_more: false,
273
+ extra_data: null,
274
+ module_value_id: 1063,
275
+ name: 'cards',
276
+ anchored: 0,
277
+ anchor_label: null,
278
+ anchor_slug: null,
279
+ module_title: null,
280
+ module_title_tag: null,
281
+ background_color: null,
282
+ style: null,
283
+ style_id: null,
284
+ see_more_link: null,
285
+ },
286
+ },
287
+ },
192
288
  };