@@ -91,9 +91,6 @@ const getMutator = (instance) => ({
9191 quickMarcRecordStatus : {
9292 GET : jest . fn ( ( ) => Promise . resolve ( { } ) ) ,
9393 } ,
94- quickMarcEditInstance : {
95- GET : jest . fn ( ( ) => Promise . resolve ( instance ) ) ,
96- } ,
9794 locations : {
9895 GET : ( ) => Promise . resolve ( { } ) ,
9996 } ,
@@ -622,7 +619,6 @@ const getInitialValues = (action, marcType) => {
622619 [ QUICK_MARC_ACTIONS . EDIT ] : ( ) => ( {
623620 leader : leadersMap [ marcType ] ,
624621 records : recordsMap [ action ] ( ) [ marcType ] ,
625- relatedRecordVersion : 1 ,
626622 } ) ,
627623 [ QUICK_MARC_ACTIONS . DERIVE ] : ( ) => ( {
628624 leader : bibLeader ,
@@ -661,7 +657,6 @@ const getFormValues = (action, marcType) => {
661657 marcFormat : marcType . toUpperCase ( ) ,
662658 parsedRecordDtoId : '00000000-0000-0000-0000-000000000000' ,
663659 records : recordsMap [ action ] ( ) [ marcType ] ,
664- relatedRecordVersion : 1 ,
665660 suppressDiscovery : false ,
666661 updateInfo : { recordState : 'NEW' } ,
667662 } ) ,
@@ -924,7 +919,6 @@ describe('useSaveRecord', () => {
924919 } ,
925920 ] ,
926921 'parsedRecordDtoId' : '00000000-0000-0000-0000-000000000000' ,
927- 'relatedRecordVersion' : 1 ,
928922 'marcFormat' : 'BIBLIOGRAPHIC' ,
929923 'suppressDiscovery' : false ,
930924 'updateInfo' : {
@@ -967,7 +961,6 @@ describe('useSaveRecord', () => {
967961 } ,
968962 ] ,
969963 'parsedRecordDtoId' : '00000000-0000-0000-0000-000000000000' ,
970- 'relatedRecordVersion' : 1 ,
971964 'marcFormat' : 'BIBLIOGRAPHIC' ,
972965 'suppressDiscovery' : false ,
973966 'updateInfo' : {
@@ -989,7 +982,6 @@ describe('useSaveRecord', () => {
989982 marcFormat : MARC_TYPES . AUTHORITY . toUpperCase ( ) ,
990983 parsedRecordDtoId : '00000000-0000-0000-0000-000000000000' ,
991984 records : undefined ,
992- relatedRecordVersion : 1 ,
993985 suppressDiscovery : false ,
994986 updateInfo : { recordState : 'NEW' } ,
995987 _actionType : 'create' ,
@@ -1507,42 +1499,6 @@ describe('useSaveRecord', () => {
15071499 } ) ;
15081500 } ) ;
15091501
1510- describe ( 'when there is a record returned with different version' , ( ) => {
1511- it ( 'should return the optimistic locking error' , async ( ) => {
1512- const marcType = MARC_TYPES . BIB ;
1513- const action = QUICK_MARC_ACTIONS . EDIT ;
1514-
1515- const { result } = renderHook ( useSaveRecord , {
1516- initialProps : {
1517- ...getInitialProps ( marcType ) ,
1518- mutator : getMutator ( {
1519- ...getInstance ( ) ,
1520- _version : '2' ,
1521- } ) ,
1522- } ,
1523- wrapper : getWrapper ( {
1524- quickMarcContext : {
1525- action,
1526- marcType,
1527- initialValues : getInitialValues ( action , marcType ) ,
1528- instance : {
1529- ...getInstance ( ) ,
1530- _version : '1' ,
1531- } ,
1532- } ,
1533- } ) ,
1534- } ) ;
1535-
1536- await act ( async ( ) => result . current . onSubmit ( getFormValues ( QUICK_MARC_ACTIONS . EDIT , marcType ) ) ) ;
1537-
1538- expect ( result . current . httpError ) . toEqual ( {
1539- errorType : ERROR_TYPES . OPTIMISTIC_LOCKING ,
1540- message : 'ui-quick-marc.record.save.error.derive' ,
1541- } ) ;
1542- expect ( mockUpdateMarcRecord ) . not . toHaveBeenCalled ( ) ;
1543- } ) ;
1544- } ) ;
1545-
15461502 describe ( 'when there is an error during PUT request due to optimistic locking' , ( ) => {
15471503 it ( 'should return the error' , async ( ) => {
15481504 const marcType = MARC_TYPES . BIB ;
@@ -1578,38 +1534,6 @@ describe('useSaveRecord', () => {
15781534 } ) ;
15791535 } ) ;
15801536
1581- describe ( 'when record not found (already deleted)' , ( ) => {
1582- it ( 'should return the error' , async ( ) => {
1583- const marcType = MARC_TYPES . BIB ;
1584- const action = QUICK_MARC_ACTIONS . EDIT ;
1585-
1586- const { result } = renderHook ( useSaveRecord , {
1587- initialProps : {
1588- ...getInitialProps ( marcType ) ,
1589- mutator : {
1590- ...getMutator ( getInstance ( ) ) ,
1591- quickMarcEditInstance : { GET : jest . fn ( ) . mockRejectedValue ( { httpStatus : 404 } ) } ,
1592- } ,
1593- } ,
1594- wrapper : getWrapper ( {
1595- quickMarcContext : {
1596- action,
1597- marcType,
1598- initialValues : getInitialValues ( action , marcType ) ,
1599- instance : getInstance ( ) ,
1600- } ,
1601- } ) ,
1602- } ) ;
1603-
1604- await act ( async ( ) => result . current . onSubmit ( getFormValues ( QUICK_MARC_ACTIONS . EDIT , marcType ) ) ) ;
1605-
1606- expect ( result . current . httpError ) . toEqual ( {
1607- errorType : 'other' ,
1608- httpStatus : 404 ,
1609- } ) ;
1610- } ) ;
1611- } ) ;
1612-
16131537 describe ( 'when a member tenant edits a shared record' , ( ) => {
16141538 it ( 'should apply the central tenant id for all authority linking ' , async ( ) => {
16151539 checkIfUserInMemberTenant . mockClear ( ) . mockReturnValue ( true ) ;
@@ -1952,7 +1876,6 @@ describe('useSaveRecord', () => {
19521876 'parsedRecordDtoId' : '2b56625f-1ca0-4ada-a32d-2667be1bd509' ,
19531877 'externalId' : 'e72f49c9-9bbf-4d2b-89eb-3d2ee5878530' ,
19541878 'externalHrid' : 'in00000000035' ,
1955- 'relatedRecordVersion' : 1 ,
19561879 } ;
19571880
19581881 await result . current . onSubmit ( formValues ) ;
0 commit comments