@quintype/framework 7.8.1-upgrade-R18.0 → 7.8.1

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [7.8.1](https://github.com/quintype/quintype-node-framework/compare/v7.10.0...v7.8.1) (2022-10-04)
6
+
5
7
  ## [7.8.0](https://github.com/quintype/quintype-node-framework/compare/v7.7.7...v7.8.0) (2022-09-19)
6
8
 
7
9
 
@@ -1,17 +1,17 @@
1
1
  import { SERVICE_WORKER_UPDATED } from "@quintype/components";
2
2
 
3
3
  export function registerServiceWorker({
4
- enableServiceWorker = false,
5
- serviceWorkerLocation = "/service-worker.js",
6
- navigator = global.navigator,
7
- mountAt = global.qtMountAt || "",
8
- version = 0,
9
- }) {
4
+ enableServiceWorker = false,
5
+ serviceWorkerLocation = "/service-worker.js",
6
+ navigator = global.navigator,
7
+ mountAt = global.qtMountAt || "",
8
+ version = 0,
9
+ }) {
10
10
  if (enableServiceWorker && navigator.serviceWorker) {
11
11
  const location =
12
- serviceWorkerLocation === "/OneSignalSDKWorker.js"
13
- ? `${serviceWorkerLocation}?version=${version}`
14
- : serviceWorkerLocation;
12
+ serviceWorkerLocation === "/OneSignalSDKWorker.js"
13
+ ? `${serviceWorkerLocation}?version=${version}`
14
+ : serviceWorkerLocation;
15
15
  return navigator.serviceWorker.register(`${mountAt}${location}`);
16
16
  }
17
17
  return Promise.resolve(null);
@@ -22,7 +22,7 @@ function updateOneSignalWorker(appVersion, page, opts) {
22
22
  const version = pageThemeAttributes["cache-burst"] || appVersion;
23
23
 
24
24
  registerServiceWorker({ ...opts, serviceWorkerLocation: "/OneSignalSDKWorker.js", version }).then(() =>
25
- console.log("Updated OneSignal Worker")
25
+ console.log("Updated OneSignal Worker")
26
26
  );
27
27
  }
28
28
 
@@ -34,7 +34,7 @@ export function setupServiceWorkerUpdates(serviceWorkerPromise, app, store, page
34
34
 
35
35
  if (registration.update) {
36
36
  app.updateServiceWorker = () =>
37
- registration.update().then(() => store.dispatch({ type: SERVICE_WORKER_UPDATED }));
37
+ registration.update().then(() => store.dispatch({ type: SERVICE_WORKER_UPDATED }));
38
38
 
39
39
  if (global.OneSignal) {
40
40
  const appVersion = app.getAppVersion();
@@ -56,9 +56,20 @@ function updateServiceWorker(app) {
56
56
  }
57
57
  }
58
58
 
59
+ function clearServiceWorkerCache() {
60
+ if ('serviceWorker' in navigator) {
61
+ caches.keys().then(function(cacheNames) {
62
+ cacheNames.forEach(function(cacheName) {
63
+ caches.delete(cacheName);
64
+ });
65
+ });
66
+ }
67
+ }
68
+
59
69
  export function checkForServiceWorkerUpdates(app, page = {}) {
60
70
  if (page.appVersion && app.getAppVersion && app.getAppVersion() < page.appVersion) {
61
71
  console && console.log("Updating the Service Worker");
72
+ clearServiceWorkerCache();
62
73
  updateServiceWorker(app);
63
74
  } else if (global && global.qtVersion) {
64
75
  /* Check if the config is updated and update the service worker if true */
@@ -66,6 +77,7 @@ export function checkForServiceWorkerUpdates(app, page = {}) {
66
77
  const { config: { "theme-attributes": pageThemeAttributes = {} } = {} } = page;
67
78
  if ((pageThemeAttributes["cache-burst"] || 0) > parseInt(configVersion)) {
68
79
  console.log(`Updating service worker due to config change`);
80
+ clearServiceWorkerCache();
69
81
  updateServiceWorker(app);
70
82
  }
71
83
  }
package/client/start.js CHANGED
@@ -55,20 +55,20 @@ function getRouteData(path, { location = global.location, existingFetch, mountAt
55
55
  const [routeDataPath, relativePath] = getRouteDataAndPath(path, mountAt);
56
56
  const url = new URL(relativePath, location.origin);
57
57
  return (
58
- existingFetch ||
59
- fetch(`${routeDataPath}?path=${encodeURIComponent(url.pathname)}${url.search ? `&${url.search.slice(1)}` : ""}`, {
60
- credentials: "same-origin",
61
- })
58
+ existingFetch ||
59
+ fetch(`${routeDataPath}?path=${encodeURIComponent(url.pathname)}${url.search ? `&${url.search.slice(1)}` : ""}`, {
60
+ credentials: "same-origin",
61
+ })
62
62
  )
63
- .then((response) => {
64
- if (response.status == 404) {
65
- // There is a chance this might abort
66
- maybeBypassServiceWorker();
67
- }
63
+ .then((response) => {
64
+ if (response.status == 404) {
65
+ // There is a chance this might abort
66
+ maybeBypassServiceWorker();
67
+ }
68
68
 
69
- return response.json();
70
- })
71
- .then(maybeRedirect);
69
+ return response.json();
70
+ })
71
+ .then(maybeRedirect);
72
72
 
73
73
  function maybeRedirect(page) {
74
74
  // This next line aborts the entire load
@@ -123,7 +123,7 @@ export function navigateToPage(dispatch, path, doNotPushPath) {
123
123
  }
124
124
 
125
125
  Promise.resolve(
126
- pickComponentWrapper && pickComponentWrapper.preloadComponent(page.pageType, page.subPageType)
126
+ pickComponentWrapper && pickComponentWrapper.preloadComponent(page.pageType, page.subPageType)
127
127
  ).then(() => {
128
128
  dispatch({
129
129
  type: NAVIGATE_TO_PAGE,
@@ -181,10 +181,17 @@ export function maybeSetUrl(path, title) {
181
181
  export function renderComponent(clazz, container, store, props = {}, callback) {
182
182
  const component = React.createElement(Provider, { store }, React.createElement(clazz, props || {}));
183
183
 
184
+ const containerEle = document.getElementById(container);
185
+
186
+ if(!containerEle){
187
+ console && console.log(`Rendering component on DOM id ${container} FAILED, node not available`);
188
+ return null;
189
+ }
190
+
184
191
  if (props.hydrate) {
185
- return ReactDOM.hydrate(component, document.getElementById(container), callback);
192
+ return ReactDOM.hydrate(component, containerEle, callback);
186
193
  }
187
- return ReactDOM.render(component, document.getElementById(container), callback);
194
+ return ReactDOM.render(component, containerEle, callback);
188
195
  }
189
196
 
190
197
  /**
@@ -199,16 +206,16 @@ export function renderIsomorphicComponent(container, store, pickComponent, props
199
206
  if (!store.getState().qt.disableIsomorphicComponent) {
200
207
  pickComponentWrapper = makePickComponentSync(pickComponent);
201
208
  return pickComponentWrapper
202
- .preloadComponent(store.getState().qt.pageType, store.getState().qt.subPageType)
203
- .then(() =>
204
- renderComponent(
205
- IsomorphicComponent,
206
- container,
207
- store,
208
- Object.assign({ pickComponent: pickComponentWrapper }, props),
209
- () => store.dispatch({ type: CLIENT_SIDE_RENDERED })
210
- )
211
- );
209
+ .preloadComponent(store.getState().qt.pageType, store.getState().qt.subPageType)
210
+ .then(() =>
211
+ renderComponent(
212
+ IsomorphicComponent,
213
+ container,
214
+ store,
215
+ Object.assign({ pickComponent: pickComponentWrapper }, props),
216
+ () => store.dispatch({ type: CLIENT_SIDE_RENDERED })
217
+ )
218
+ );
212
219
  }
213
220
  console && console.log("IsomorphicComponent is disabled");
214
221
  }
@@ -257,15 +264,15 @@ export function startApp(renderApplication, reducers, opts) {
257
264
  const path = `${location.pathname}${location.search || ""}`;
258
265
  const staticData = global.staticPageStoreContent || getJsonContent("static-page");
259
266
  const dataPromise = staticData
260
- ? Promise.resolve(staticData.qt)
261
- : getRouteData(path, { existingFetch: global.initialFetch });
267
+ ? Promise.resolve(staticData.qt)
268
+ : getRouteData(path, { existingFetch: global.initialFetch });
262
269
 
263
270
  startAnalytics();
264
271
 
265
272
  const store = createQtStore(
266
- reducers,
267
- (staticData && staticData.qt) || global.initialPage || getJsonContent("initial-page") || {},
268
- {}
273
+ reducers,
274
+ (staticData && staticData.qt) || global.initialPage || getJsonContent("initial-page") || {},
275
+ {}
269
276
  );
270
277
 
271
278
  if (opts.preRenderApplication) {
@@ -307,9 +314,9 @@ export function startApp(renderApplication, reducers, opts) {
307
314
 
308
315
  if (page.title) {
309
316
  global.document.title = get(
310
- page,
311
- ["data", "customSeo", "title"],
312
- get(page, ["data", "story", "seo", "meta-title"], page.title)
317
+ page,
318
+ ["data", "customSeo", "title"],
319
+ get(page, ["data", "story", "seo", "meta-title"], page.title)
313
320
  );
314
321
  }
315
322
  return store;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/framework",
3
- "version": "7.8.1-upgrade-R18.0",
3
+ "version": "7.8.1",
4
4
  "description": "Libraries to help build Quintype Node.js apps",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -31,9 +31,8 @@
31
31
  "homepage": "https://github.com/quintype/quintype-node-framework#readme",
32
32
  "dependencies": {
33
33
  "@ampproject/toolbox-optimizer": "2.8.3",
34
- "@grpc/grpc-js": "^1.7.1",
35
- "@quintype/amp": "^2.5.1-upgrade-R18.0",
36
- "@quintype/backend": "^2.3.1",
34
+ "@quintype/amp": "^2.6.0",
35
+ "@quintype/backend": "^2.3.2",
37
36
  "@quintype/components": "^3.0.0",
38
37
  "@quintype/prerender-node": "^3.2.26",
39
38
  "@quintype/seo": "^1.39.0",
@@ -53,8 +52,8 @@
53
52
  "mocha-snapshots": "^4.2.0",
54
53
  "morgan": "^1.10.0",
55
54
  "path-to-regexp": "^6.2.0",
56
- "react": "^18.2.0",
57
- "react-dom": "^18.2.0",
55
+ "react": "^16.14.0",
56
+ "react-dom": "^16.14.0",
58
57
  "react-redux": "^7.2.5",
59
58
  "react-router": "^5.2.1",
60
59
  "redux": "^4.1.1",
@@ -1,18 +1,23 @@
1
1
  const { AmpConfig } = require("../../impl/api-client-impl");
2
2
  const InfiniteScrollAmp = require("../helpers/infinite-scroll");
3
3
  const { setCorsHeaders } = require("../helpers");
4
+ const get = require("lodash/get");
5
+ const cloneDeep = require("lodash/cloneDeep");
4
6
 
5
7
  // eslint-disable-next-line consistent-return
6
- async function storyPageInfiniteScrollHandler(req, res, next, { client, config }) {
8
+ async function storyPageInfiniteScrollHandler(req, res, next, { client, config, ...rest }) {
7
9
  const ampConfig = await config.memoizeAsync("amp-config", async () => await AmpConfig.getAmpConfig(client));
10
+ const opts = cloneDeep(rest);
11
+ const infiniteScrollSource = get(opts, ["featureConfig", "infiniteScroll", "source"], "collection");
8
12
 
9
13
  const infiniteScrollAmp = new InfiniteScrollAmp({
10
14
  ampConfig,
11
15
  publisherConfig: config,
12
16
  client,
13
17
  queryParams: req.query,
18
+ infiniteScrollSource,
14
19
  });
15
- const jsonResponse = await infiniteScrollAmp.getResponse({ itemsTaken: 5 }); // itemsTaken has to match with itemsToTake in ampStoryPageHandler
20
+ const jsonResponse = await infiniteScrollAmp.getResponse();
16
21
  if (jsonResponse instanceof Error) return next(jsonResponse);
17
22
  res.set("Content-Type", "application/json; charset=utf-8");
18
23
  setCorsHeaders({ req, res, next, publisherConfig: config });
@@ -86,15 +86,28 @@ async function ampStoryPageHandler(
86
86
  const seoTags =
87
87
  seoInstance && seoInstance.getMetaTags(config, "story-page-amp", { data: { story, timezone }, config }, { url });
88
88
 
89
- const infiniteScrollAmp = new InfiniteScrollAmp({
90
- ampConfig,
91
- publisherConfig: config,
92
- client,
93
- });
94
- const infiniteScrollInlineConfig = await infiniteScrollAmp.getInitialInlineConfig({
95
- itemsToTake: 5,
96
- storyId: story["story-content-id"],
97
- });
89
+ const infiniteScrollConfig = get(opts, ["featureConfig", "infiniteScroll"], "");
90
+ const infiniteScrollSource = get(infiniteScrollConfig, ["source"], "collection");
91
+ const inlineConfig = get(infiniteScrollConfig, ["inlineConfig"], "");
92
+ const remoteConfigEndpoint = get(infiniteScrollConfig, ["remoteConfigEndpoint"], "");
93
+
94
+ let infiniteScrollInlineConfig = [];
95
+
96
+ if (infiniteScrollSource === "custom") {
97
+ if (!inlineConfig || !remoteConfigEndpoint)
98
+ throw new Error("Required params of 'custom' source (inlineConfig /remoteConfigEndpoint) is missing!!");
99
+ infiniteScrollInlineConfig = await inlineConfig();
100
+ } else {
101
+ const infiniteScrollAmp = new InfiniteScrollAmp({
102
+ ampConfig,
103
+ publisherConfig: config,
104
+ client,
105
+ infiniteScrollSource,
106
+ });
107
+ infiniteScrollInlineConfig = await infiniteScrollAmp.getInitialInlineConfig({
108
+ storyId: story["story-content-id"],
109
+ });
110
+ }
98
111
  if (infiniteScrollInlineConfig instanceof Error) return next(infiniteScrollInlineConfig);
99
112
  if (infiniteScrollInlineConfig) {
100
113
  set(
@@ -1,9 +1,9 @@
1
1
  class InfiniteScrollAmp {
2
- constructor({ ampConfig, client, publisherConfig, queryParams }) {
2
+ constructor({ ampConfig, client, publisherConfig, queryParams, infiniteScrollSource }) {
3
3
  this.client = client;
4
4
  this.publisherConfig = publisherConfig;
5
5
  this.queryParams = queryParams;
6
- this.collSlug = "amp-infinite-scroll"; // this is hardcoded to "amp-infinite-scroll" temporarily. Ideally it should come from ampConfig from platform
6
+ this.infiniteScrollSource = infiniteScrollSource;
7
7
  }
8
8
 
9
9
  // eslint-disable-next-line class-methods-use-this
@@ -17,12 +17,20 @@ class InfiniteScrollAmp {
17
17
  );
18
18
  }
19
19
 
20
+ getFilteredApiItems(relatedStories) {
21
+ return relatedStories.filter(
22
+ (story) =>
23
+ story.access !== "subscription" &&
24
+ story["story-template"] !== "visual-story"
25
+ );
26
+ }
27
+
20
28
  formatData({ itemsArr, type }) {
21
29
  // formats configuration as per need of amp infinite scroll
22
30
  const arr = itemsArr.map((item) => ({
23
31
  image: this.getImagePath(item),
24
- title: item.story.headline,
25
- url: `/amp/story/${item.story.slug}`,
32
+ title: item.headline,
33
+ url: `/amp/story/${item.slug}`,
26
34
  }));
27
35
  switch (type) {
28
36
  case "inline":
@@ -36,39 +44,54 @@ class InfiniteScrollAmp {
36
44
 
37
45
  getImagePath(item) {
38
46
  const cdnImage = this.publisherConfig["cdn-image"];
39
- const s3Key = item.story["hero-image-s3-key"];
47
+ const s3Key = item["hero-image-s3-key"];
40
48
  const hostWithProtocol = /^https:\/\//.test(cdnImage) ? cdnImage : `https://${cdnImage}`;
41
49
  return `${hostWithProtocol}/${s3Key}?format=webp&w=250`;
42
50
  }
43
51
 
44
- async getResponse({ itemsTaken }) {
52
+ async getInfiniteScrollList({ storyId, type, offset = 0, limit = null }) {
53
+ let filteredItems = [];
54
+ const params = {
55
+ ...(offset && { offset }),
56
+ ...(limit && { limit }),
57
+ };
58
+ if (this.infiniteScrollSource === "relatedStoriesApi") {
59
+ const relatedStoriesList = await this.client.getRelatedStories(storyId, null, params);
60
+ if (!relatedStoriesList)
61
+ return new Error();
62
+ return filteredItems = this.getFilteredApiItems(relatedStoriesList["related-stories"]);
63
+ } else {
64
+ const collection = await this.client.getCollectionBySlug("amp-infinite-scroll");
65
+ if (!collection || (collection.items && !collection.items.length) || collection.error || collection === null)
66
+ return new Error();
67
+ const collectionItems = this.getFilteredCollItems(collection, storyId).map(items => items.story);
68
+ return filteredItems = type === "inlineConfig"
69
+ ? collectionItems.slice(0, 5)
70
+ : collectionItems.slice(5);
71
+ }
72
+ }
73
+
74
+ async getResponse() {
45
75
  const { "story-id": storyId } = this.queryParams;
46
76
  if (!storyId) return new Error(`Query param "story-id" missing`);
47
-
48
- const collection = await this.client.getCollectionBySlug(this.collSlug);
49
- if (!collection || collection.error)
50
- return new Error(`Infinite scroll collection ${this.collSlug} returned falsy value`);
51
- const filteredItems = this.getFilteredCollItems(collection, storyId);
52
- const slicedItems = filteredItems.slice(itemsTaken);
53
- const formattedData = this.formatData({ itemsArr: slicedItems });
54
-
77
+ const filteredItems =
78
+ await this.getInfiniteScrollList({ storyId, type: "remoteConfig", offset: 5 });
79
+ if (filteredItems instanceof Error) return new Error(`Infinite scroll collection amp-infinite-scroll returned falsy value`);
80
+ const formattedData = this.formatData({ itemsArr: filteredItems });
55
81
  return JSON.stringify(formattedData);
56
82
  }
57
83
 
58
- async getInitialInlineConfig({ itemsToTake, storyId }) {
59
- if (!itemsToTake || !storyId) return new Error("Required params for getInitialInlineConfig missing");
84
+ async getInitialInlineConfig({ storyId }) {
85
+ if (!storyId) return new Error("Required params for getInitialInlineConfig missing");
86
+ const filteredItems =
87
+ await this.getInfiniteScrollList({ storyId, type: "inlineConfig", offset: 0, limit: 5 });
60
88
 
61
- const collection = await this.client.getCollectionBySlug(this.collSlug);
62
- if (!collection || (collection.items && !collection.items.length) || collection.error) return null;
63
- const filteredItems = this.getFilteredCollItems(collection, storyId);
64
- const slicedItems = filteredItems.slice(0, itemsToTake);
65
- const formattedData = this.formatData({
66
- itemsArr: slicedItems,
89
+ if (filteredItems instanceof Error) return null;
90
+ const formattedData = filteredItems.length > 0 && this.formatData({
91
+ itemsArr: filteredItems,
67
92
  type: "inline",
68
93
  });
69
-
70
94
  return JSON.stringify(formattedData);
71
95
  }
72
96
  }
73
-
74
97
  module.exports = InfiniteScrollAmp;
@@ -3,8 +3,17 @@
3
3
 
4
4
  const assert = require("assert");
5
5
  const InfiniteScrollAmp = require("../../../server/amp/helpers/infinite-scroll");
6
+ const { getTextStory } = require("../../data/amp-test-data");
6
7
 
7
8
  function getClientStub({
9
+ getStoryById = (id) =>
10
+ new Promise((resolve) => {
11
+ if (id === "4444")
12
+ resolve({
13
+ story: getTextStory({ "story-content-id": "7f3d5bdb-ec52-4047-ac0d-df4036ec974b" }),
14
+ });
15
+ resolve(null);
16
+ }),
8
17
  getCollectionBySlug = (slug) =>
9
18
  new Promise((resolve) => {
10
19
  if (slug === "amp-infinite-scroll")
@@ -19,6 +28,7 @@ function getClientStub({
19
28
  "story-content-id": 1111,
20
29
  slug: "sports/aa",
21
30
  "hero-image-s3-key": "aa/a.jpg",
31
+ access: "public",
22
32
  },
23
33
  },
24
34
  {
@@ -30,6 +40,7 @@ function getClientStub({
30
40
  "story-content-id": 2222,
31
41
  slug: "sports/bb",
32
42
  "hero-image-s3-key": "bb/b.jpg",
43
+ access: "public",
33
44
  },
34
45
  },
35
46
  {
@@ -41,6 +52,7 @@ function getClientStub({
41
52
  "story-content-id": 3333,
42
53
  slug: "sports/cc",
43
54
  "hero-image-s3-key": "cc/c.jpg",
55
+ access: "public",
44
56
  },
45
57
  },
46
58
  {
@@ -52,6 +64,7 @@ function getClientStub({
52
64
  "story-content-id": 4444,
53
65
  slug: "sports/dd",
54
66
  "hero-image-s3-key": "dd/d.jpg",
67
+ access: "public",
55
68
  },
56
69
  },
57
70
  {
@@ -63,6 +76,7 @@ function getClientStub({
63
76
  "story-content-id": 5555,
64
77
  slug: "sports/ee",
65
78
  "hero-image-s3-key": "ee/e.jpg",
79
+ access: "public",
66
80
  },
67
81
  },
68
82
  {
@@ -74,6 +88,31 @@ function getClientStub({
74
88
  "story-content-id": 6666,
75
89
  slug: "sports/ff",
76
90
  "hero-image-s3-key": "ff/f.jpg",
91
+ access: "public",
92
+ },
93
+ },
94
+ {
95
+ type: "story",
96
+ id: 7777,
97
+ story: {
98
+ "story-template": "text",
99
+ headline: "ggg",
100
+ "story-content-id": 7777,
101
+ slug: "sports/gg",
102
+ "hero-image-s3-key": "gg/g.jpg",
103
+ access: "public",
104
+ },
105
+ },
106
+ {
107
+ type: "story",
108
+ id: 8888,
109
+ story: {
110
+ "story-template": "text",
111
+ headline: "hhh",
112
+ "story-content-id": 8888,
113
+ slug: "sports/hh",
114
+ "hero-image-s3-key": "hh/h.jpg",
115
+ access: "public",
77
116
  },
78
117
  },
79
118
  ],
@@ -83,6 +122,7 @@ function getClientStub({
83
122
  } = {}) {
84
123
  return {
85
124
  getCollectionBySlug,
125
+ getStoryById
86
126
  };
87
127
  }
88
128
  const dummyPublisherConfig = {
@@ -96,9 +136,7 @@ describe("getInitialInlineConfig method of InfiniteScrollAmp helper function", f
96
136
  client: getClientStub(),
97
137
  publisherConfig: dummyPublisherConfig,
98
138
  });
99
- const inlineConfig = await infiniteScrollAmp.getInitialInlineConfig({
100
- itemsToTake: 5,
101
- });
139
+ const inlineConfig = await infiniteScrollAmp.getInitialInlineConfig({ storyId: "" });
102
140
  assert.strictEqual(inlineConfig instanceof Error, true);
103
141
  assert.throws(() => {
104
142
  throw new Error("Required params for getInitialInlineConfig missing");
@@ -117,8 +155,7 @@ describe("getInitialInlineConfig method of InfiniteScrollAmp helper function", f
117
155
  publisherConfig: dummyPublisherConfig,
118
156
  });
119
157
  const inlineConfig = await infiniteScrollAmp.getInitialInlineConfig({
120
- itemsToTake: 5,
121
- storyId: 2222,
158
+ storyId: 1111,
122
159
  });
123
160
  assert.strictEqual(inlineConfig, null);
124
161
  });
@@ -137,8 +174,7 @@ describe("getInitialInlineConfig method of InfiniteScrollAmp helper function", f
137
174
  publisherConfig: dummyPublisherConfig,
138
175
  });
139
176
  const inlineConfig = await infiniteScrollAmp.getInitialInlineConfig({
140
- itemsToTake: 5,
141
- storyId: 2222,
177
+ storyId: 1111,
142
178
  });
143
179
  assert.strictEqual(inlineConfig, null);
144
180
  });
@@ -150,8 +186,7 @@ describe("getInitialInlineConfig method of InfiniteScrollAmp helper function", f
150
186
  publisherConfig: dummyPublisherConfig,
151
187
  });
152
188
  const inlineConfig = await infiniteScrollAmp.getInitialInlineConfig({
153
- itemsToTake: 5,
154
- storyId: 2222,
189
+ storyId: 1111,
155
190
  });
156
191
  assert.strictEqual(false, /sports\/bb/.test(inlineConfig));
157
192
  assert.strictEqual(false, /bb\/b.jpg/.test(inlineConfig));
@@ -164,8 +199,7 @@ describe("getInitialInlineConfig method of InfiniteScrollAmp helper function", f
164
199
  publisherConfig: dummyPublisherConfig,
165
200
  });
166
201
  const inlineConfig = await infiniteScrollAmp.getInitialInlineConfig({
167
- itemsToTake: 5,
168
- storyId: 3333,
202
+ storyId: 1111,
169
203
  });
170
204
  assert.strictEqual(false, /sports\/bb/.test(inlineConfig));
171
205
  assert.strictEqual(false, /bb\/b.jpg/.test(inlineConfig));
@@ -179,8 +213,7 @@ describe("getInitialInlineConfig method of InfiniteScrollAmp helper function", f
179
213
  publisherConfig: dummyPublisherConfig,
180
214
  });
181
215
  const inlineConfig = await infiniteScrollAmp.getInitialInlineConfig({
182
- itemsToTake: 5,
183
- storyId: 2222,
216
+ storyId: 1111,
184
217
  });
185
218
  function isInlineConfigStructureValid(jsonStr) {
186
219
  const stories = JSON.parse(jsonStr);
@@ -207,7 +240,7 @@ describe("getResponse method of InfiniteScrollAmp helper function", function ()
207
240
  publisherConfig: dummyPublisherConfig,
208
241
  queryParams: { foo: "bar" },
209
242
  });
210
- const jsonResponse = await infiniteScrollAmp.getResponse({ itemsTaken: 2 });
243
+ const jsonResponse = await infiniteScrollAmp.getResponse();
211
244
  assert.strictEqual(jsonResponse instanceof Error, true);
212
245
  assert.throws(() => {
213
246
  throw new Error(`Query param "story-id" missing`);
@@ -226,7 +259,7 @@ describe("getResponse method of InfiniteScrollAmp helper function", function ()
226
259
  publisherConfig: dummyPublisherConfig,
227
260
  queryParams: { "story-id": 2222 },
228
261
  });
229
- const jsonResponse = await infiniteScrollAmp.getResponse({ itemsTaken: 2 });
262
+ const jsonResponse = await infiniteScrollAmp.getResponse();
230
263
  assert.strictEqual(jsonResponse instanceof Error, true);
231
264
  });
232
265
  it("should remove current story from response", async function () {
@@ -237,7 +270,7 @@ describe("getResponse method of InfiniteScrollAmp helper function", function ()
237
270
  publisherConfig: dummyPublisherConfig,
238
271
  queryParams: { "story-id": 4444 },
239
272
  });
240
- const jsonResponse = await infiniteScrollAmp.getResponse({ itemsTaken: 2 });
273
+ const jsonResponse = await infiniteScrollAmp.getResponse();
241
274
  assert.strictEqual(false, /sports\/dd/.test(jsonResponse));
242
275
  assert.strictEqual(false, /dd\/d.jpg/.test(jsonResponse));
243
276
  });
@@ -249,7 +282,7 @@ describe("getResponse method of InfiniteScrollAmp helper function", function ()
249
282
  publisherConfig: dummyPublisherConfig,
250
283
  queryParams: { "story-id": 4444 },
251
284
  });
252
- const jsonResponse = await infiniteScrollAmp.getResponse({ itemsTaken: 2 });
285
+ const jsonResponse = await infiniteScrollAmp.getResponse();
253
286
  assert.strictEqual(false, /sports\/bb/.test(jsonResponse));
254
287
  assert.strictEqual(false, /bb\/b.jpg/.test(jsonResponse));
255
288
  });
@@ -262,7 +295,8 @@ describe("getResponse method of InfiniteScrollAmp helper function", function ()
262
295
  publisherConfig: dummyPublisherConfig,
263
296
  queryParams: { "story-id": 4444 },
264
297
  });
265
- const jsonResponse = await infiniteScrollAmp.getResponse({ itemsTaken: 2 });
298
+ const jsonResponse = await infiniteScrollAmp.getResponse();
299
+
266
300
  function isJsonConfigStructureValid(jsonStr) {
267
301
  const parsed = JSON.parse(jsonStr);
268
302
  const stories = parsed.pages;