From 027f3fca6ccbea82b804643ac2b41ffb0d534610 Mon Sep 17 00:00:00 2001 From: Matthias Van Parijs Date: Fri, 20 Dec 2024 14:05:18 +0100 Subject: [PATCH] fix: Tests for stitcher --- .../__snapshots__/interstitials.test.ts.snap | 309 +----------------- .../test/__snapshots__/playlist.test.ts.snap | 52 ++- packages/stitcher/test/interstitials.test.ts | 18 +- packages/stitcher/test/test-data.ts | 51 ++- 4 files changed, 74 insertions(+), 356 deletions(-) diff --git a/packages/stitcher/test/__snapshots__/interstitials.test.ts.snap b/packages/stitcher/test/__snapshots__/interstitials.test.ts.snap index 650a73d2..c4dfc017 100644 --- a/packages/stitcher/test/__snapshots__/interstitials.test.ts.snap +++ b/packages/stitcher/test/__snapshots__/interstitials.test.ts.snap @@ -111,7 +111,7 @@ exports[`getStaticDateRanges should create dateRanges for vod 1`] = ` "RESTRICT": "SKIP,JUMP", "RESUME-OFFSET": 0, "TIMELINE-OCCUPIES": "POINT", - "TIMELINE-STYLE": "PRIMARY", + "TIMELINE-STYLE": "HIGHLIGHT", }, "id": "1619950355250", "startDate": DateTime { @@ -152,156 +152,6 @@ exports[`getStaticDateRanges should create dateRanges for vod 1`] = ` "weekData": null, }, }, - { - "classId": "com.apple.hls.interstitial", - "clientAttributes": { - "ASSET-LIST": "stitcher-endpoint/out/asset-list.json?dt=2021-05-02T10%3A12%3A45.250%2B00%3A00&sid=36bab417-0952-4c23-bdf0-9a424e4651ad", - "CONTENT-MAY-VARY": "YES", - "CUE": "ONCE", - "RESTRICT": "SKIP,JUMP", - "RESUME-OFFSET": 0, - "TIMELINE-OCCUPIES": "POINT", - "TIMELINE-STYLE": "HIGHLIGHT", - }, - "id": "1619950365250", - "startDate": DateTime { - "_zone": SystemZone {}, - "c": { - "day": 2, - "hour": 10, - "millisecond": 250, - "minute": 12, - "month": 5, - "second": 45, - "year": 2021, - }, - "invalid": null, - "isLuxonDateTime": true, - "loc": Locale { - "eraCache": {}, - "fastNumbersCached": null, - "intl": "en-US", - "locale": "en-US", - "meridiemCache": null, - "monthsCache": { - "format": {}, - "standalone": {}, - }, - "numberingSystem": null, - "outputCalendar": null, - "specifiedLocale": null, - "weekSettings": null, - "weekdaysCache": { - "format": {}, - "standalone": {}, - }, - }, - "localWeekData": null, - "o": -0, - "ts": 1619950365250, - "weekData": null, - }, - }, - { - "classId": "com.apple.hls.interstitial", - "clientAttributes": { - "ASSET-LIST": "stitcher-endpoint/out/asset-list.json?dt=2021-05-02T10%3A13%3A45.250%2B00%3A00&sid=36bab417-0952-4c23-bdf0-9a424e4651ad", - "CONTENT-MAY-VARY": "YES", - "CUE": "ONCE", - "RESTRICT": "SKIP,JUMP", - "RESUME-OFFSET": 0, - "TIMELINE-OCCUPIES": "POINT", - "TIMELINE-STYLE": "PRIMARY", - }, - "id": "1619950425250", - "startDate": DateTime { - "_zone": SystemZone {}, - "c": { - "day": 2, - "hour": 10, - "millisecond": 250, - "minute": 13, - "month": 5, - "second": 45, - "year": 2021, - }, - "invalid": null, - "isLuxonDateTime": true, - "loc": Locale { - "eraCache": {}, - "fastNumbersCached": null, - "intl": "en-US", - "locale": "en-US", - "meridiemCache": null, - "monthsCache": { - "format": {}, - "standalone": {}, - }, - "numberingSystem": null, - "outputCalendar": null, - "specifiedLocale": null, - "weekSettings": null, - "weekdaysCache": { - "format": {}, - "standalone": {}, - }, - }, - "localWeekData": null, - "o": -0, - "ts": 1619950425250, - "weekData": null, - }, - }, - { - "classId": "com.apple.hls.interstitial", - "clientAttributes": { - "ASSET-LIST": "stitcher-endpoint/out/asset-list.json?dt=2021-05-02T10%3A13%3A45.250%2B00%3A00&sid=36bab417-0952-4c23-bdf0-9a424e4651ad", - "CONTENT-MAY-VARY": "YES", - "CUE": "ONCE", - "RESTRICT": "SKIP,JUMP", - "RESUME-OFFSET": 0, - "TIMELINE-OCCUPIES": "POINT", - "TIMELINE-STYLE": "PRIMARY", - }, - "id": "1619950425250", - "startDate": DateTime { - "_zone": SystemZone {}, - "c": { - "day": 2, - "hour": 10, - "millisecond": 250, - "minute": 13, - "month": 5, - "second": 45, - "year": 2021, - }, - "invalid": null, - "isLuxonDateTime": true, - "loc": Locale { - "eraCache": {}, - "fastNumbersCached": null, - "intl": "en-US", - "locale": "en-US", - "meridiemCache": null, - "monthsCache": { - "format": {}, - "standalone": {}, - }, - "numberingSystem": null, - "outputCalendar": null, - "specifiedLocale": null, - "weekSettings": null, - "weekdaysCache": { - "format": {}, - "standalone": {}, - }, - }, - "localWeekData": null, - "o": -0, - "ts": 1619950425250, - "weekData": null, - }, - }, ] `; @@ -413,7 +263,7 @@ exports[`getStaticDateRanges should create dateRanges for live 1`] = ` "CUE": "ONCE", "RESTRICT": "SKIP,JUMP", "TIMELINE-OCCUPIES": "POINT", - "TIMELINE-STYLE": "PRIMARY", + "TIMELINE-STYLE": "HIGHLIGHT", }, "id": "1619950355250", "startDate": DateTime { @@ -454,165 +304,18 @@ exports[`getStaticDateRanges should create dateRanges for live 1`] = ` "weekData": null, }, }, - { - "classId": "com.apple.hls.interstitial", - "clientAttributes": { - "ASSET-LIST": "stitcher-endpoint/out/asset-list.json?dt=2021-05-02T10%3A12%3A45.250%2B00%3A00&sid=36bab417-0952-4c23-bdf0-9a424e4651ad", - "CONTENT-MAY-VARY": "YES", - "CUE": "ONCE", - "RESTRICT": "SKIP,JUMP", - "TIMELINE-OCCUPIES": "POINT", - "TIMELINE-STYLE": "HIGHLIGHT", - }, - "id": "1619950365250", - "startDate": DateTime { - "_zone": SystemZone {}, - "c": { - "day": 2, - "hour": 10, - "millisecond": 250, - "minute": 12, - "month": 5, - "second": 45, - "year": 2021, - }, - "invalid": null, - "isLuxonDateTime": true, - "loc": Locale { - "eraCache": {}, - "fastNumbersCached": null, - "intl": "en-US", - "locale": "en-US", - "meridiemCache": null, - "monthsCache": { - "format": {}, - "standalone": {}, - }, - "numberingSystem": null, - "outputCalendar": null, - "specifiedLocale": null, - "weekSettings": null, - "weekdaysCache": { - "format": {}, - "standalone": {}, - }, - }, - "localWeekData": null, - "o": -0, - "ts": 1619950365250, - "weekData": null, - }, - }, - { - "classId": "com.apple.hls.interstitial", - "clientAttributes": { - "ASSET-LIST": "stitcher-endpoint/out/asset-list.json?dt=2021-05-02T10%3A13%3A45.250%2B00%3A00&sid=36bab417-0952-4c23-bdf0-9a424e4651ad", - "CONTENT-MAY-VARY": "YES", - "CUE": "ONCE", - "RESTRICT": "SKIP,JUMP", - "TIMELINE-OCCUPIES": "POINT", - "TIMELINE-STYLE": "PRIMARY", - }, - "id": "1619950425250", - "startDate": DateTime { - "_zone": SystemZone {}, - "c": { - "day": 2, - "hour": 10, - "millisecond": 250, - "minute": 13, - "month": 5, - "second": 45, - "year": 2021, - }, - "invalid": null, - "isLuxonDateTime": true, - "loc": Locale { - "eraCache": {}, - "fastNumbersCached": null, - "intl": "en-US", - "locale": "en-US", - "meridiemCache": null, - "monthsCache": { - "format": {}, - "standalone": {}, - }, - "numberingSystem": null, - "outputCalendar": null, - "specifiedLocale": null, - "weekSettings": null, - "weekdaysCache": { - "format": {}, - "standalone": {}, - }, - }, - "localWeekData": null, - "o": -0, - "ts": 1619950425250, - "weekData": null, - }, - }, - { - "classId": "com.apple.hls.interstitial", - "clientAttributes": { - "ASSET-LIST": "stitcher-endpoint/out/asset-list.json?dt=2021-05-02T10%3A13%3A45.250%2B00%3A00&sid=36bab417-0952-4c23-bdf0-9a424e4651ad", - "CONTENT-MAY-VARY": "YES", - "CUE": "ONCE", - "RESTRICT": "SKIP,JUMP", - "TIMELINE-OCCUPIES": "POINT", - "TIMELINE-STYLE": "PRIMARY", - }, - "id": "1619950425250", - "startDate": DateTime { - "_zone": SystemZone {}, - "c": { - "day": 2, - "hour": 10, - "millisecond": 250, - "minute": 13, - "month": 5, - "second": 45, - "year": 2021, - }, - "invalid": null, - "isLuxonDateTime": true, - "loc": Locale { - "eraCache": {}, - "fastNumbersCached": null, - "intl": "en-US", - "locale": "en-US", - "meridiemCache": null, - "monthsCache": { - "format": {}, - "standalone": {}, - }, - "numberingSystem": null, - "outputCalendar": null, - "specifiedLocale": null, - "weekSettings": null, - "weekdaysCache": { - "format": {}, - "standalone": {}, - }, - }, - "localWeekData": null, - "o": -0, - "ts": 1619950425250, - "weekData": null, - }, - }, ] `; exports[`getAssets should get assets by interstitials 1`] = ` [ - { - "duration": 25, - "url": "https://mock.com/ad_1/master.m3u8", - }, { "kind": "ad", "url": "https://mock.com/interstitial1/master.m3u8", }, + { + "duration": 25, + "url": "https://mock.com/ad_1/master.m3u8", + }, ] `; diff --git a/packages/stitcher/test/__snapshots__/playlist.test.ts.snap b/packages/stitcher/test/__snapshots__/playlist.test.ts.snap index 44626b3a..03644326 100644 --- a/packages/stitcher/test/__snapshots__/playlist.test.ts.snap +++ b/packages/stitcher/test/__snapshots__/playlist.test.ts.snap @@ -95,6 +95,15 @@ exports[`rewriteMediaPlaylistUrls should rewrite absolute segments 1`] = ` exports[`mapAdBreaksToSessionInterstitials should handle time based with vastUrl 1`] = ` [ { + "chunks": [ + { + "data": { + "data": undefined, + "url": "http://mock.com/vast_1.xml", + }, + "type": "vast", + }, + ], "dateTime": DateTime { "_zone": SystemZone {}, "c": { @@ -132,12 +141,17 @@ exports[`mapAdBreaksToSessionInterstitials should handle time based with vastUrl "ts": 1619950325250, "weekData": null, }, - "vast": { - "data": undefined, - "url": "http://mock.com/vast_1.xml", - }, }, { + "chunks": [ + { + "data": { + "data": undefined, + "url": "http://mock.com/vast_2.xml", + }, + "type": "vast", + }, + ], "dateTime": DateTime { "_zone": SystemZone {}, "c": { @@ -175,12 +189,17 @@ exports[`mapAdBreaksToSessionInterstitials should handle time based with vastUrl "ts": 1619950340250, "weekData": null, }, - "vast": { - "data": undefined, - "url": "http://mock.com/vast_2.xml", - }, }, { + "chunks": [ + { + "data": { + "data": undefined, + "url": "http://mock.com/vast_3.xml", + }, + "type": "vast", + }, + ], "dateTime": DateTime { "_zone": SystemZone {}, "c": { @@ -218,10 +237,6 @@ exports[`mapAdBreaksToSessionInterstitials should handle time based with vastUrl "ts": 1619950350250, "weekData": null, }, - "vast": { - "data": undefined, - "url": "http://mock.com/vast_3.xml", - }, }, ] `; @@ -229,6 +244,15 @@ exports[`mapAdBreaksToSessionInterstitials should handle time based with vastUrl exports[`mapAdBreaksToSessionInterstitials should handle vastData 1`] = ` [ { + "chunks": [ + { + "data": { + "data": "mocked VAST data", + "url": undefined, + }, + "type": "vast", + }, + ], "dateTime": DateTime { "_zone": SystemZone {}, "c": { @@ -266,10 +290,6 @@ exports[`mapAdBreaksToSessionInterstitials should handle vastData 1`] = ` "ts": 1619950335250, "weekData": null, }, - "vast": { - "data": "mocked VAST data", - "url": undefined, - }, }, ] `; diff --git a/packages/stitcher/test/interstitials.test.ts b/packages/stitcher/test/interstitials.test.ts index 3fbd8b79..49e18e97 100644 --- a/packages/stitcher/test/interstitials.test.ts +++ b/packages/stitcher/test/interstitials.test.ts @@ -43,15 +43,21 @@ describe("getAssets", () => { session.interstitials = [ { dateTime, - assets: [ + chunks: [ { - url: "https://mock.com/interstitial1/master.m3u8", - kind: "ad", + type: "asset", + data: { + url: "https://mock.com/interstitial1/master.m3u8", + kind: "ad", + }, + }, + { + type: "vast", + data: { + url: "https://mock.com/vast.xml", + }, }, ], - vast: { - url: "https://mock.com/vast.xml", - }, }, ]; diff --git a/packages/stitcher/test/test-data.ts b/packages/stitcher/test/test-data.ts index ebfbe075..66ff458e 100644 --- a/packages/stitcher/test/test-data.ts +++ b/packages/stitcher/test/test-data.ts @@ -81,50 +81,39 @@ export function addFakeInterstitials(session: Session) { session.interstitials = [ { dateTime: session.startTime, - vast: { - url: "https://mock.com/vast.xml", - }, - }, - { - dateTime: session.startTime.plus({ seconds: 10 }), - vast: { - data: "mocked VAST data", - }, - }, - // Manual bumper interstitial - { - dateTime: session.startTime.plus({ seconds: 30 }), - assets: [ + chunks: [ { - url: "https://mock.com/interstitial/bumper.m3u8", - kind: "bumper", + type: "vast", + data: { url: "https://mock.com/vast.xml" }, }, ], }, - // Manual ad interstitial { - dateTime: session.startTime.plus({ seconds: 40 }), - assets: [ + dateTime: session.startTime.plus({ seconds: 10 }), + chunks: [ { - url: "https://mock.com/interstitial/ad.m3u8", - kind: "ad", + type: "vast", + data: { data: "mocked VAST data" }, }, ], }, - // Multiple manual interstitials + // Manual bumper & ad interstitial { - dateTime: session.startTime.plus({ seconds: 100 }), - assets: [ + dateTime: session.startTime.plus({ seconds: 30 }), + chunks: [ { - url: "https://mock.com/interstitial/master1.m3u8", + type: "asset", + data: { + url: "https://mock.com/interstitial/bumper.m3u8", + kind: "bumper", + }, }, - ], - }, - { - dateTime: session.startTime.plus({ seconds: 100 }), - assets: [ { - url: "https://mock.com/interstitial/master2.m3u8", + type: "asset", + data: { + url: "https://mock.com/interstitial/ad.m3u8", + kind: "ad", + }, }, ], },