@@ -33,6 +33,7 @@ import stanfordManifest from '../../fixtures/presentation-2/stanford-manifest.js
3333import goettingen from '../../fixtures/presentation-2/uni-goettingen.json' ;
3434import villanovaManifest from '../../fixtures/presentation-2/villanova-manifest.json' ;
3535import wikimediaProxy from '../../fixtures/presentation-2/wikimedia-proxy.json' ;
36+ import malformedImageAnnotation from '../../fixtures/presentation-2/malformed-image-annotation.json' ;
3637import { convertPresentation2 , presentation2to3 } from '../../src/presentation-2' ;
3738
3839describe ( 'Presentation 2 to 3' , ( ) => {
@@ -2615,4 +2616,24 @@ describe('Presentation 2 to 3', () => {
26152616 }
26162617 ` ) ;
26172618 } ) ;
2619+
2620+ test ( 'Malformed annotation with dctypes:Image instead of oa:Annotation' , ( ) => {
2621+ // Some manifests (e.g., St. Andrews) have @type: "dctypes:Image" on annotations
2622+ // instead of the correct @type : "oa:Annotation". The converter should fix this.
2623+ const result = presentation2to3 . traverseManifest ( malformedImageAnnotation as any ) ;
2624+ const isValid = validator . validateManifest ( result ) ;
2625+
2626+ expect ( validator . validators . manifest ! . errors ) . toEqual ( null ) ;
2627+ expect ( isValid ) . toEqual ( true ) ;
2628+
2629+ // Verify the annotation was correctly converted
2630+ const canvas = result . items ?. [ 0 ] ;
2631+ const annotationPage = canvas ?. items ?. [ 0 ] ;
2632+ const annotation = annotationPage ?. items ?. [ 0 ] ;
2633+
2634+ expect ( annotation ) . toBeDefined ( ) ;
2635+ expect ( annotation ?. type ) . toEqual ( 'Annotation' ) ;
2636+ expect ( annotation ?. motivation ) . toEqual ( 'painting' ) ;
2637+ expect ( annotation ?. body ) . toBeDefined ( ) ;
2638+ } ) ;
26182639} ) ;
0 commit comments