@financial-times/cp-content-pipeline-schema 3.9.0 → 3.11.0
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/.toolkitrc.yml +1 -7
- package/CHANGELOG.md +15 -0
- package/lib/generated/index.d.ts +6 -0
- package/lib/model/Content.d.ts +2 -0
- package/lib/model/Content.js +18 -0
- package/lib/model/Content.js.map +1 -1
- package/lib/model/Content.test.js +66 -0
- package/lib/model/Content.test.js.map +1 -1
- package/lib/model/schemas/capi/index.d.ts +1 -11
- package/lib/model/schemas/capi/live-blog-package.d.ts +1 -11
- package/lib/model/schemas/capi/live-blog-package.js +0 -1
- package/lib/model/schemas/capi/live-blog-package.js.map +1 -1
- package/lib/resolvers/content.d.ts +4 -0
- package/lib/resolvers/content.js +4 -0
- package/lib/resolvers/content.js.map +1 -1
- package/lib/resolvers/index.d.ts +4 -0
- package/package.json +2 -2
- package/queries/article.graphql +2 -0
- package/src/generated/index.ts +6 -0
- package/src/model/Content.test.ts +82 -0
- package/src/model/Content.ts +26 -0
- package/src/model/schemas/capi/live-blog-package.ts +0 -1
- package/src/resolvers/content.ts +4 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/typedefs/content.graphql +6 -0
|
@@ -325,4 +325,86 @@ describe('Content', () => {
|
|
|
325
325
|
expect(capiResponse.isFTEdit()).toBe(false)
|
|
326
326
|
})
|
|
327
327
|
})
|
|
328
|
+
|
|
329
|
+
describe('isLiveQandA', () => {
|
|
330
|
+
test('identifies articles that are Live Q&As', () => {
|
|
331
|
+
const article = cloneDeep({
|
|
332
|
+
...baseCapiObject,
|
|
333
|
+
internalAnalyticsTags: 'someStringHereisLiveQandAsomethingElse',
|
|
334
|
+
})
|
|
335
|
+
const capiResponse = new Content(article, context)
|
|
336
|
+
|
|
337
|
+
expect(capiResponse.isLiveQandA()).toBe(true)
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
test('ignores articles that are not Live Q&As', () => {
|
|
341
|
+
const article = cloneDeep({
|
|
342
|
+
...baseCapiObject,
|
|
343
|
+
internalAnalyticsTags: 'testSomethingThatisNotALiveQ&A',
|
|
344
|
+
})
|
|
345
|
+
const capiResponse = new Content(article, context)
|
|
346
|
+
|
|
347
|
+
expect(capiResponse.isLiveQandA()).toBe(false)
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
test('handles missing `internalAnalyticsTags` property', () => {
|
|
351
|
+
const article = cloneDeep({
|
|
352
|
+
...baseCapiObject,
|
|
353
|
+
})
|
|
354
|
+
const capiResponse = new Content(article, context)
|
|
355
|
+
|
|
356
|
+
expect(capiResponse.isLiveQandA()).toBe(false)
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
test('is case-insensitive', () => {
|
|
360
|
+
const article = cloneDeep({
|
|
361
|
+
...baseCapiObject,
|
|
362
|
+
internalAnalyticsTags: 'LIVeQaNdA',
|
|
363
|
+
})
|
|
364
|
+
const capiResponse = new Content(article, context)
|
|
365
|
+
|
|
366
|
+
expect(capiResponse.isLiveQandA()).toBe(true)
|
|
367
|
+
})
|
|
368
|
+
})
|
|
369
|
+
|
|
370
|
+
describe('isArchived', () => {
|
|
371
|
+
test('identifies articles that are archived', () => {
|
|
372
|
+
const article = cloneDeep({
|
|
373
|
+
...baseCapiObject,
|
|
374
|
+
internalAnalyticsTags: 'something archived somethng else',
|
|
375
|
+
})
|
|
376
|
+
const capiResponse = new Content(article, context)
|
|
377
|
+
|
|
378
|
+
expect(capiResponse.isArchived()).toBe(true)
|
|
379
|
+
})
|
|
380
|
+
|
|
381
|
+
test('ignores articles that are not archived', () => {
|
|
382
|
+
const article = cloneDeep({
|
|
383
|
+
...baseCapiObject,
|
|
384
|
+
internalAnalyticsTags: 'archive will not match, it misses the d',
|
|
385
|
+
})
|
|
386
|
+
const capiResponse = new Content(article, context)
|
|
387
|
+
|
|
388
|
+
expect(capiResponse.isArchived()).toBe(false)
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
test('handles missing `internalAnalyticsTags` property', () => {
|
|
392
|
+
const article = cloneDeep({
|
|
393
|
+
...baseCapiObject,
|
|
394
|
+
})
|
|
395
|
+
const capiResponse = new Content(article, context)
|
|
396
|
+
|
|
397
|
+
expect(capiResponse.isArchived()).toBe(false)
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
test('is case-insensitive', () => {
|
|
401
|
+
const article = cloneDeep({
|
|
402
|
+
...baseCapiObject,
|
|
403
|
+
internalAnalyticsTags: 'ArChIvEd',
|
|
404
|
+
})
|
|
405
|
+
const capiResponse = new Content(article, context)
|
|
406
|
+
|
|
407
|
+
expect(capiResponse.isArchived()).toBe(true)
|
|
408
|
+
})
|
|
409
|
+
})
|
|
328
410
|
})
|
package/src/model/Content.ts
CHANGED
|
@@ -941,6 +941,32 @@ export class Content {
|
|
|
941
941
|
return false
|
|
942
942
|
}
|
|
943
943
|
|
|
944
|
+
isLiveQandA(): boolean {
|
|
945
|
+
if (
|
|
946
|
+
'internalAnalyticsTags' in this.capiData &&
|
|
947
|
+
this.capiData.internalAnalyticsTags
|
|
948
|
+
) {
|
|
949
|
+
return this.capiData.internalAnalyticsTags
|
|
950
|
+
.toLowerCase()
|
|
951
|
+
.includes('liveqanda')
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
return false
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
isArchived(): boolean {
|
|
958
|
+
if (
|
|
959
|
+
'internalAnalyticsTags' in this.capiData &&
|
|
960
|
+
this.capiData.internalAnalyticsTags
|
|
961
|
+
) {
|
|
962
|
+
return this.capiData.internalAnalyticsTags
|
|
963
|
+
.toLowerCase()
|
|
964
|
+
.includes('archived')
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
return false
|
|
968
|
+
}
|
|
969
|
+
|
|
944
970
|
design(): Design {
|
|
945
971
|
if ('design' in this.capiData && this.capiData.design.theme) {
|
|
946
972
|
return { theme: this.capiData.design.theme }
|
package/src/resolvers/content.ts
CHANGED
|
@@ -99,6 +99,8 @@ const resolvers = {
|
|
|
99
99
|
return {
|
|
100
100
|
isPartnerContent: parent.isPartnerContent(),
|
|
101
101
|
isFTEdit: parent.isFTEdit(),
|
|
102
|
+
isLiveQandA: parent.isLiveQandA(),
|
|
103
|
+
isArchived: parent.isArchived(),
|
|
102
104
|
}
|
|
103
105
|
},
|
|
104
106
|
},
|
|
@@ -197,6 +199,8 @@ const resolvers = {
|
|
|
197
199
|
isFTEdit: (parent) => parent.isFTEdit ?? null,
|
|
198
200
|
isOpinion: (parent) => parent.isOpinion ?? null,
|
|
199
201
|
isPartnerContent: (parent) => parent.isPartnerContent ?? null,
|
|
202
|
+
isLiveQandA: (parent) => parent.isLiveQandA ?? null,
|
|
203
|
+
isArchived: (parent) => parent.isArchived ?? null,
|
|
200
204
|
},
|
|
201
205
|
|
|
202
206
|
Media: {
|