From 6cf9bdcf946e1487c8ede392125e41cc93501fe7 Mon Sep 17 00:00:00 2001 From: dwithana Date: Wed, 13 Nov 2024 16:54:37 -0500 Subject: [PATCH] Fix annotation parsing for Aviary annotations --- src/components/Transcript/Transcript.test.js | 71 ++++++++++++++++ src/services/transcript-parser.js | 30 ++++--- src/services/transcript-parser.test.js | 63 +++++++++++++- src/services/utility-helpers.js | 18 ++-- src/test_data/multi-source-manifest.js | 87 ++++++++++++++++++++ 5 files changed, 249 insertions(+), 20 deletions(-) diff --git a/src/components/Transcript/Transcript.test.js b/src/components/Transcript/Transcript.test.js index 7e88ca73..cd34ec8d 100644 --- a/src/components/Transcript/Transcript.test.js +++ b/src/components/Transcript/Transcript.test.js @@ -4,6 +4,7 @@ import Transcript from './Transcript'; import * as transcriptParser from '@Services/transcript-parser'; import { withManifestAndPlayerProvider } from '@Services/testing-helpers'; import lunchroomManners from '@TestData/lunchroom-manners'; +import multiSourceManifest from '@TestData/multi-source-manifest'; describe('Transcript component', () => { let originalError, originalLogger; @@ -1067,5 +1068,75 @@ describe('Transcript component', () => { console.error = originalError; }); }); + + test('manifestUrl with TextualBody supplementing annotations (Aviary)', async () => { + const props = { + playerID: 'player-id', + manifestUrl: 'http://example.com/manifest.json' + }; + + const transcriptsList = [ + { + canvasId: 0, + items: [] + }, + { + canvasId: 1, + items: [ + { + title: 'Aviary Annotation Style Canvas', + id: 'Aviary Annotation Style Canvas-1', + url: 'http://example.com/manifest.json', + isMachineGen: false, + } + ] + } + ]; + const readSupplementingAnnotationsMock = jest + .spyOn(transcriptParser, 'readSupplementingAnnotations') + .mockReturnValue(transcriptsList); + + const parseTranscriptMock = jest + .spyOn(transcriptParser, 'parseTranscriptData') + .mockReturnValue({ + tData: [ + { begin: 22.2, end: 26.6, text: 'Transcript text line 1', tag: 'TIMED_CUE' }, + { begin: 26.7, end: 31.5, text: 'Transcript text line 2', tag: 'TIMED_CUE' } + ], + tUrl: 'http://example.com/manifest.json', + tType: transcriptParser.TRANSCRIPT_TYPES.timedText, + tFileExt: 'json', + }); + + const TranscriptWithState = withManifestAndPlayerProvider(Transcript, { + initialManifestState: { manifest: multiSourceManifest, canvasIndex: 1 }, + initialPlayerState: {}, + ...props + }); + + render( + <> +