gatsby-core-theme 6.1.6 → 6.1.7

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,18 @@
1
+ ## [6.1.7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v6.1.6...v6.1.7) (2022-04-19)
2
+
3
+
4
+ ### Code Refactoring
5
+
6
+ * update cards, cards_v2 filtering for operator pages ([08ecad7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/08ecad782f75f6f8105f203e06baf48951d68789))
7
+
8
+
9
+ * Merge branch 'tm-2805-cards-random-filter' into 'master' ([206b0e8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/206b0e89234188e5a0ad38ad1fd1aec3a1212e89))
10
+
11
+
12
+ ### refactoe
13
+
14
+ * update processor modules tests ([11fd5a0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/11fd5a0f7dcadf71a9550c58eeed383db35437e4))
15
+
1
16
  ## [6.1.6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v6.1.5...v6.1.6) (2022-04-18)
2
17
 
3
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "6.1.6",
3
+ "version": "6.1.7",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -18,9 +18,15 @@ export function processCardsModule(module, pages, pagesCloned, pagesMappedById)
18
18
  const numOfItems =
19
19
  Math.sign(module.num_of_items) === 0 ? pages[modelType].length : Number(module.num_of_items);
20
20
  if (sortBy === 'random') {
21
- const samplePages = pagesCloned[modelType].filter(
22
- (page) => !settings.filter_cards_modules[process.env.GATSBY_SITE_NAME].includes(page.status)
23
- );
21
+ const samplePages =
22
+ module.cards_page_type !== 'operator'
23
+ ? pagesCloned[modelType]
24
+ : pagesCloned[modelType].filter(
25
+ (page) =>
26
+ !settings.filter_cards_modules[process.env.GATSBY_SITE_NAME].includes(
27
+ page.relation && page.relation.status
28
+ )
29
+ );
24
30
  module.items = sampleSize(samplePages, numOfItems);
25
31
  } else {
26
32
  module.items = pagesCloned[modelType].slice(0, numOfItems);
@@ -180,10 +186,15 @@ export function processCardsV2(module, pagesCloned, pagesMappedById) {
180
186
 
181
187
  // Applying sorting
182
188
  if (sortType === 'random') {
183
- const samplePages = uniquePages.filter(
184
- (page) =>
185
- !settings.filter_cards_modules[process.env.GATSBY_SITE_NAME].includes(page.status)
186
- );
189
+ const samplePages =
190
+ module.cards_page_type !== 'operator'
191
+ ? uniquePages
192
+ : uniquePages.filter(
193
+ (page) =>
194
+ !settings.filter_cards_modules[process.env.GATSBY_SITE_NAME].includes(
195
+ page.relation && page.relation.status
196
+ )
197
+ );
187
198
  module.items = sampleSize(samplePages, itemLimit);
188
199
  } else if (sortType === 'latest') {
189
200
  if (uniquePages.length > 0) {
@@ -17,6 +17,11 @@ import {
17
17
  import { relationData, singleToplistData } from '../../../tests/factories/modules/toplist.factory';
18
18
 
19
19
  describe('Modules Helper', () => {
20
+ beforeEach(() => {
21
+ jest.resetModules();
22
+ process.env = { ...process.env };
23
+ delete process.env.NODE_ENV;
24
+ });
20
25
  test('Cards V2 Manual list', () => {
21
26
  const pagesNum = 10;
22
27
  const moduleData = getSampleCardsV2ModuleManual();
@@ -45,12 +50,14 @@ describe('Modules Helper', () => {
45
50
  const moduleData = getSampleCardsV2Filtered(false, 'Game');
46
51
  moduleData.cards_selector_filters_sort_by = 'random';
47
52
  moduleData.cards_selector_filters_limit = '3';
53
+ moduleData.cards_page_type = 'operator';
48
54
  const pageList = getPageDataList(pagesNum).map((page, i) =>
49
55
  i % 2
50
- ? { ...page, type: 'game', status: 'inactive' }
51
- : { ...page, type: 'game', status: 'active' }
56
+ ? { ...page, type: 'operator', relation: { ...page.relation, status: 'inactive' } }
57
+ : { ...page, type: 'operator', relation: { ...page.relation, status: 'active' } }
52
58
  );
53
- processCardsV2(moduleData, groupBy(pageList, 'type'));
59
+ const { processCardsV2: processCardsV2Clean } = require('./modules');
60
+ processCardsV2Clean(moduleData, groupBy(pageList, 'type'), groupBy(pageList, 'id'));
54
61
 
55
62
  expect(moduleData.items).toHaveLength(3);
56
63
  moduleData.items.forEach((item) => {