Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSTEAMA 1315 - Move logic that creates SMP settings object in Simorgh #11866

Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
8b898d5
Merge branch 'latest' of https://github.com/bbc/simorgh into latest
holchris Jul 25, 2024
cf08d2e
Merge branch 'latest' of https://github.com/bbc/simorgh into latest
holchris Aug 19, 2024
2cc824a
update hindi tv programme fixture data
holchris Aug 19, 2024
9fc111d
create TvMediaBlock type
holchris Aug 19, 2024
2093bc2
wip on demand tv block test
holchris Aug 19, 2024
569e22c
update types for TvMediaBlock
holchris Aug 19, 2024
adb3fc4
code clean up
holchris Aug 20, 2024
83311c8
refactor blockTypeMapping
holchris Aug 20, 2024
e34dcde
create tvMedia config
holchris Aug 20, 2024
72ebbcc
create tvMediaConfig
holchris Aug 20, 2024
360aa68
refactored and updated unit test
Nabeel1276 Aug 20, 2024
283d8a8
Merge branch 'WSTEAMA-1315-move-logic-that-creates-SMP-settings-objec…
holchris Aug 20, 2024
62abe06
hard coded object to pass tests
Nabeel1276 Aug 21, 2024
9760b0d
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
Nabeel1276 Aug 22, 2024
4386927
addressed PR comments are removed redundant data
Nabeel1276 Aug 22, 2024
c5f35d8
refactored and passed all tests
Nabeel1276 Aug 23, 2024
e117b72
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
Nabeel1276 Aug 23, 2024
6b64261
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
Nabeel1276 Aug 23, 2024
222ca3e
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
Nabeel1276 Aug 23, 2024
bbaa49a
updated unit tests and playerConfig object
Nabeel1276 Aug 27, 2024
ec4c72d
added value for type in placeholderConfig
Nabeel1276 Aug 27, 2024
fdda3ce
removed unnecessary variable
Nabeel1276 Aug 27, 2024
304e216
Merge branch 'WSTEAMA-1315-move-logic-that-creates-SMP-settings-objec…
holchris Aug 27, 2024
5c9d4ad
Merge branch 'refactor-media-loader-config' of https://github.com/bbc…
holchris Aug 27, 2024
69983e7
refactor place holder config
holchris Aug 27, 2024
88a5aa0
rewrite tests
holchris Aug 27, 2024
f2ca631
refactor types
holchris Aug 27, 2024
0e9e6de
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
karinathomasbbc Aug 27, 2024
2881839
change import order
holchris Aug 27, 2024
4bfeb9f
Merge branch 'WSTEAMA-1315-move-logic-that-creates-SMP-settings-objec…
holchris Aug 27, 2024
a68d1a8
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
karinathomasbbc Aug 27, 2024
f5fecba
Delete ; which was accidentally added due to merge conflict
karinathomasbbc Aug 27, 2024
9a8ba81
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
Nabeel1276 Aug 28, 2024
00800e1
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
holchris Aug 28, 2024
91c9931
remove guidanceMessage
holchris Aug 28, 2024
e54663b
Revert "remove guidanceMessage"
holchris Aug 28, 2024
70af831
removed vpid and allowed embedRights
Nabeel1276 Aug 28, 2024
7379346
made placeholderImageOriginCode mandatory
Nabeel1276 Aug 28, 2024
b856b62
updated test
Nabeel1276 Aug 28, 2024
4463627
Merge branch 'WSTEAMA-1315-move-logic-that-creates-SMP-settings-objec…
holchris Aug 28, 2024
4fa7bea
fix typescript errors
holchris Aug 28, 2024
5963b08
merge from latest
holchris Aug 28, 2024
7de68c8
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
Nabeel1276 Aug 28, 2024
4528cc3
Merge branch 'WSTEAMA-1315-move-logic-that-creates-SMP-settings-objec…
holchris Aug 28, 2024
1099ebd
remove blank space
holchris Aug 28, 2024
70eaa58
update tests
holchris Aug 28, 2024
d5e926f
adds ignore linting
holchris Aug 28, 2024
d1a223e
adds ignore linting
holchris Aug 28, 2024
cbc887a
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
Nabeel1276 Aug 29, 2024
e482e92
added optional chaining for some buildPlaceholderConfig values
Nabeel1276 Aug 29, 2024
75e9fe9
Merge branch 'WSTEAMA-1315-move-logic-that-creates-SMP-settings-objec…
holchris Aug 29, 2024
18832ea
adds optional chainin
holchris Aug 29, 2024
e2c1ba8
added optional chaining for values with arrays
Nabeel1276 Aug 29, 2024
a3ba261
fixed linting/typescript issues
Nabeel1276 Aug 29, 2024
fe44026
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
Nabeel1276 Aug 29, 2024
1001159
Merge branch 'WSTEAMA-1315-move-logic-that-creates-SMP-settings-objec…
holchris Aug 29, 2024
d3d0849
removed linting overrides
Nabeel1276 Aug 29, 2024
05a2182
used MediaType as a type
Nabeel1276 Aug 29, 2024
00ce3a7
code refactor
Nabeel1276 Aug 29, 2024
3c656c8
Merge branch 'WSTEAMA-1315-move-logic-that-creates-SMP-settings-objec…
holchris Aug 29, 2024
ded6b04
extract holdingImageURL into variable
holchris Aug 29, 2024
4ee69a7
added condition for returning null
Nabeel1276 Aug 29, 2024
b7ff08a
code refactor - used holdinholdingImageURL variable for placeholderIm…
Nabeel1276 Aug 29, 2024
5c5e636
Merge branch 'latest' into WSTEAMA-1315-move-logic-that-creates-SMP-s…
karinathomasbbc Aug 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions src/app/components/MediaLoader/configs/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
import filterForBlockType from '#app/lib/utilities/blockHandlers';
import clipMedia from './clipMedia';
import aresMedia from './aresMedia';
import { AresMediaBlock, ClipMediaBlock, MediaBlock } from '../types';
import tvMedia from './tvMedia';
import {
ConfigBuilderReturnProps,
MediaBlock,
ConfigBuilderProps,
} from '../types';

export default (blocks: MediaBlock[]) => {
const aresMediaBlock: AresMediaBlock = filterForBlockType(
blocks,
'aresMedia',
);

const clipMediaBlock: ClipMediaBlock = filterForBlockType(
blocks,
'clipMedia',
);
const blockTypeMapping: Record<
string,
(arg0: ConfigBuilderProps) => ConfigBuilderReturnProps
> = {
aresMedia,
clipMedia,
tvMedia,
};

switch (true) {
case !!aresMediaBlock:
return aresMedia;
case !!clipMediaBlock:
return clipMedia;
default:
return null;
}
/* eslint-disable no-console */
/* eslint-disable no-restricted-syntax */
Nabeel1276 marked this conversation as resolved.
Show resolved Hide resolved
export default (blocks: MediaBlock[]) => {
const availableMediaType =
['aresMedia', 'clipMedia', 'tvMedia'].find(mediaType =>
filterForBlockType(blocks, mediaType),
) || '';
return blockTypeMapping[availableMediaType];
Nabeel1276 marked this conversation as resolved.
Show resolved Hide resolved
};
49 changes: 49 additions & 0 deletions src/app/components/MediaLoader/configs/tvMedia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import filterForBlockType from '#lib/utilities/blockHandlers';
import { ConfigBuilderProps, ConfigBuilderReturnProps } from '../types';
import buildPlaceholderConfig from '../utils/buildPlaceholderConfig';

export default ({
blocks,
basePlayerConfig,
translations,
}: ConfigBuilderProps): ConfigBuilderReturnProps => {
const { model: tvMediaBlock } = filterForBlockType(blocks, 'tvMedia');

const placeholderConfig = buildPlaceholderConfig({
title: tvMediaBlock.episodeTitle,
duration: tvMediaBlock?.versions?.[0]?.duration,
Nabeel1276 marked this conversation as resolved.
Show resolved Hide resolved
durationISO8601: tvMediaBlock?.versions?.[0]?.durationISO8601,
type: 'video',
holdingImageURL: `https://${tvMediaBlock.imageUrl}`,
karinathomasbbc marked this conversation as resolved.
Show resolved Hide resolved
holchris marked this conversation as resolved.
Show resolved Hide resolved
placeholderImageLocator: `https://${tvMediaBlock.imageUrl}`,
holchris marked this conversation as resolved.
Show resolved Hide resolved
placeholderImageOriginCode: 'pips',
translations,
});

return {
playerConfig: {
...basePlayerConfig,
autoplay: false,
statsObject: {
...basePlayerConfig.statsObject,
episodePID: tvMediaBlock.id,
},
playlistObject: {
title: tvMediaBlock.episodeTitle,
holdingImageURL: `https://${tvMediaBlock.imageUrl}`,
items: [
{
versionID: tvMediaBlock?.versions?.[0]?.versionId,
kind: tvMediaBlock.smpKind,
duration: tvMediaBlock?.versions?.[0]?.duration,
},
],
summary: tvMediaBlock.synopses.short,
...(tvMediaBlock.embedding && { embedRights: 'allowed' }),
},
},
mediaType: 'video',
placeholderConfig,
showAds: false,
};
};
43 changes: 42 additions & 1 deletion src/app/components/MediaLoader/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type PlayerConfig = {
clipPID?: string;
destination: string;
producer: string | '';
episodePID?: string;
};
mediator?: { host: string };
ui: PlayerUiConfig;
Expand Down Expand Up @@ -46,6 +47,8 @@ export type PlaylistItem = {
kind: string;
duration: number;
live?: boolean;
embedRights?: 'allowed';
vpid?: string;
holchris marked this conversation as resolved.
Show resolved Hide resolved
};

export type ConfigBuilderProps = {
Expand Down Expand Up @@ -233,11 +236,49 @@ export type SyndicationAresMediaBlock = {
};
};

export type TvMediaBlock = {
type: 'tvMedia';
model: {
id: string;
subType: 'episode';
format: 'Video';
title: string;
synopses: {
short: string;
medium: string;
};
imageUrl: string;
embedding: boolean;
advertising: boolean;
versions: [
{
versionId: string;
types: string[];
duration: number;
durationISO8601: string;
warnings: Record<string, string>;
availableTerritories: {
uk: boolean;
nonUk: boolean;
world: boolean;
};
availableFrom: number;
availabilityStatus: string;
},
];
availability: string;
smpKind: string;
episodeTitle: string;
type: 'audio' | 'video';
Nabeel1276 marked this conversation as resolved.
Show resolved Hide resolved
};
};

export type MediaBlock =
| AresMediaBlock
| ClipMediaBlock
| CaptionBlock
| SyndicationAresMediaBlock;
| SyndicationAresMediaBlock
| TvMediaBlock;

export type BuildConfigProps = {
blocks: MediaBlock[];
Expand Down
93 changes: 93 additions & 0 deletions src/app/components/MediaLoader/utils/buildSetting.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { PageTypes, Services } from '#app/models/types/global';
import { MEDIA_PAGE } from '#app/routes/utils/pageTypes';
import hindiTvProgramme from '#data/hindi/bbc_hindi_tv/tv_programmes/w13xttlw.json';
import { service as hindiServiceConfig } from '#app/lib/config/services/hindi';
import buildSettings from './buildSettings';
import { aresMediaBlocks, clipMediaBlocks } from '../fixture';
import {
Expand Down Expand Up @@ -397,4 +400,94 @@ describe('buildSettings', () => {
);
});
});

describe('OnDemandTv', () => {
const hindiTvBaseSettings = {
counterName: 'hindi.bbc_hindi_tv.tv.w172zm8920nck2z.page',
lang: 'hi',
service: 'hindi' as Services,
statsDestination: 'WS_NEWS_LANGUAGES',
producer: 'HINDI',
translations: hindiServiceConfig.default.translations,
} as BuildConfigProps;

const hindiTvMediaBlocks = hindiTvProgramme.content.blocks.map(
tvMediaBlock => {
return {
type: 'tvMedia',
model: {
...tvMediaBlock,
},
};
},
);
it('Should process a On Demand TV block into a valid playlist item.', () => {
const result = buildSettings({
...hindiTvBaseSettings,
blocks: hindiTvMediaBlocks as MediaBlock[],
pageType: MEDIA_PAGE,
});

expect(result).toStrictEqual({
playerConfig: {
product: 'news',
enableToucan: true,
appType: 'responsive',
autoplay: false,
externalEmbedUrl: '',
holchris marked this conversation as resolved.
Show resolved Hide resolved
mediator: { host: 'open.test.bbc.co.uk' },
appName: 'news-hindi',
counterName: 'hindi.bbc_hindi_tv.tv.w172zm8920nck2z.page',
statsObject: {
destination: 'WS_NEWS_LANGUAGES',
producer: 'HINDI',
episodePID: 'w172zm89sk8n4lc',
},
ui: {
controls: { enabled: true },
fullscreen: { enabled: true },
locale: {
lang: 'hi',
},
subtitles: {
defaultOn: true,
enabled: true,
},
},
holchris marked this conversation as resolved.
Show resolved Hide resolved
playlistObject: {
title: 'दुनिया',
holdingImageURL:
'https://ichef.bbci.co.uk/images/ic/$recipe/p0jlxsx8.jpg',
items: [
{
versionID: 'w1mskyp9nwh0dvl',
kind: 'programme',
duration: 1192,
},
],
summary:
'ताज़ा अंतरराष्ट्रीय, क्षेत्रीय ख़बरों और विश्लेषण के लिए देखिए बीबीसी दुनिया',
},
},
mediaType: 'video',
placeholderConfig: {
mediaInfo: {
title: 'दुनिया',
datetime: 'PT19M52S',
duration: '19:52',
durationSpoken: 'अवधि 19,52',
type: 'video',
guidanceMessage: undefined,
holchris marked this conversation as resolved.
Show resolved Hide resolved
},
placeholderSrc:
'https://ichef.bbci.co.uk/images/ic/$recipe/p0jlxsx8.jpg',
placeholderSrcset:
'https://ichef.bbci.co.uk/images/ic/240xn/p0jlxsx8.jpg.webp 240w, https://ichef.bbci.co.uk/images/ic/320xn/p0jlxsx8.jpg.webp 320w, https://ichef.bbci.co.uk/images/ic/480xn/p0jlxsx8.jpg.webp 480w, https://ichef.bbci.co.uk/images/ic/624xn/p0jlxsx8.jpg.webp 624w, https://ichef.bbci.co.uk/images/ic/800xn/p0jlxsx8.jpg.webp 800w',
translatedNoJSMessage:
'This video cannot play in your browser. Please enable JavaScript or try a different browser.',
},
showAds: false,
});
});
});
});
Loading