@@ -395,6 +395,21 @@ describe('fromEndpointPayload', () => {
395395 expect ( fromEndpointPayload ( { project_name : 'p' , contributors : [ ] } ) ) . toEqual ( [ ] ) ;
396396 } ) ;
397397
398+ it ( 'preserves author_level from endpoint payload' , ( ) => {
399+ const data = {
400+ project_name : 'proj' ,
401+ contributors : [
402+ { author : { name : 'Alice Smith' } , author_level : 'first' , credit_levels : [ ] } ,
403+ { author : { name : 'Bob Jones' } , author_level : null , credit_levels : [ ] } ,
404+ { author : { name : 'Carol Lee' } , author_level : 'senior' , credit_levels : [ ] } ,
405+ ] ,
406+ } ;
407+ const rows = fromEndpointPayload ( data ) ;
408+ expect ( rows [ 0 ] . author_level ) . toBe ( 'first' ) ;
409+ expect ( rows [ 1 ] . author_level ) . toBeNull ( ) ;
410+ expect ( rows [ 2 ] . author_level ) . toBe ( 'senior' ) ;
411+ } ) ;
412+
398413 it ( 'round-trips through toEndpointPayload → fromEndpointPayload' , ( ) => {
399414 const original = initMatrix ( [ 'Alice Smith' , 'Bob Jones' ] ) ;
400415 original [ 0 ] [ 'Conceptualization' ] = 'Lead' ;
@@ -405,6 +420,21 @@ describe('fromEndpointPayload', () => {
405420 expect ( restored [ 1 ] [ 'Software' ] ) . toBe ( 'Equal' ) ;
406421 expect ( restored [ 0 ] [ 'Software' ] ) . toBe ( 'None' ) ;
407422 } ) ;
423+
424+ it ( 'round-trips author_level through toEndpointPayload → fromEndpointPayload' , ( ) => {
425+ const data = {
426+ project_name : 'proj' ,
427+ contributors : [
428+ { author : { name : 'Alice Smith' } , author_level : 'first' , credit_levels : [ ] } ,
429+ { author : { name : 'Bob Jones' } , author_level : 'senior' , credit_levels : [ ] } ,
430+ ] ,
431+ } ;
432+ const rows = fromEndpointPayload ( data ) ;
433+ const payload = toEndpointPayload ( rows , 'proj' ) ;
434+ const restored = fromEndpointPayload ( payload ) ;
435+ expect ( restored [ 0 ] . author_level ) . toBe ( 'first' ) ;
436+ expect ( restored [ 1 ] . author_level ) . toBe ( 'senior' ) ;
437+ } ) ;
408438} ) ;
409439
410440// ---------------------------------------------------------------------------
@@ -426,6 +456,15 @@ describe('rowsToWidgetAuthors', () => {
426456 const authors = rowsToWidgetAuthors ( rows ) ;
427457 expect ( authors [ 0 ] . credit_levels ) . toHaveLength ( 0 ) ;
428458 } ) ;
459+
460+ it ( 'preserves author_level in widget author objects' , ( ) => {
461+ const rows = initMatrix ( [ 'Alice Smith' , 'Bob Jones' ] ) ;
462+ rows [ 0 ] . author_level = 'first' ;
463+ rows [ 1 ] . author_level = 'senior' ;
464+ const authors = rowsToWidgetAuthors ( rows ) ;
465+ expect ( authors [ 0 ] . author_level ) . toBe ( 'first' ) ;
466+ expect ( authors [ 1 ] . author_level ) . toBe ( 'senior' ) ;
467+ } ) ;
429468} ) ;
430469
431470// ---------------------------------------------------------------------------
0 commit comments