@@ -587,8 +587,17 @@ describe('<TagListTable />', () => {
587587 expect ( screen . getByText ( / i n v a l i d c h a r a c t e r / i) ) . toBeInTheDocument ( ) ;
588588 } ) ;
589589
590- it ( 'should show an inline duplicate-name error when the entered root tag already exists' , async ( ) => {
591- axiosMock . onPost ( createTagUrl ) . reply ( 400 , [ 'Tag with this name already exists' ] ) ;
590+ it ( 'should show failure feedback when creating a duplicate root tag name' , async ( ) => {
591+ axiosMock . onPost ( createTagUrl ) . reply ( ( ) => {
592+ const error = new Error ( 'Request failed with status code 400' ) ;
593+ error . name = 'AxiosError' ;
594+ error . response = {
595+ data : {
596+ tag : [ 'Tag with this name already exists' ] ,
597+ } ,
598+ } ;
599+ return Promise . reject ( error ) ;
600+ } ) ;
592601
593602 fireEvent . click ( await screen . findByLabelText ( 'Create Tag' ) ) ;
594603 const draftRow = await screen . findAllByRole ( 'row' ) ;
@@ -598,12 +607,19 @@ describe('<TagListTable />', () => {
598607 fireEvent . change ( input , { target : { value : 'root tag 1' } } ) ;
599608 fireEvent . click ( saveButton ) ;
600609
601- expect ( await screen . findByText ( 'Tag with this name already exists' ) ) . toBeInTheDocument ( ) ;
610+ expect ( await screen . findByText ( 'Error creating tag: Tag with this name already exists' ) ) . toBeInTheDocument ( ) ;
602611 } ) ;
603612
604613 it ( 'should keep the inline row and show a failure toast when save request fails' , async ( ) => {
605- axiosMock . onPost ( createTagUrl ) . reply ( 500 , {
606- error : 'Internal server error' ,
614+ axiosMock . onPost ( createTagUrl ) . reply ( ( ) => {
615+ const error = new Error ( 'Request failed with status code 500' ) ;
616+ error . name = 'AxiosError' ;
617+ error . response = {
618+ data : {
619+ tag : [ 'Internal server error' ] ,
620+ } ,
621+ } ;
622+ return Promise . reject ( error ) ;
607623 } ) ;
608624
609625 fireEvent . click ( await screen . findByLabelText ( 'Create Tag' ) ) ;
0 commit comments