@@ -598,8 +598,17 @@ describe('<TagListTable />', () => {
598598 expect ( screen . getByText ( / i n v a l i d c h a r a c t e r / i) ) . toBeInTheDocument ( ) ;
599599 } ) ;
600600
601- it ( 'should show an inline duplicate-name error when the entered root tag already exists' , async ( ) => {
602- axiosMock . onPost ( createTagUrl ) . reply ( 400 , [ 'Tag with this name already exists' ] ) ;
601+ it ( 'should show failure feedback when creating a duplicate root tag name' , async ( ) => {
602+ axiosMock . onPost ( createTagUrl ) . reply ( ( ) => {
603+ const error = new Error ( 'Request failed with status code 400' ) ;
604+ error . name = 'AxiosError' ;
605+ error . response = {
606+ data : {
607+ tag : [ 'Tag with this name already exists' ] ,
608+ } ,
609+ } ;
610+ return Promise . reject ( error ) ;
611+ } ) ;
603612
604613 fireEvent . click ( await screen . findByLabelText ( 'Create Tag' ) ) ;
605614 const draftRow = await screen . findAllByRole ( 'row' ) ;
@@ -609,12 +618,19 @@ describe('<TagListTable />', () => {
609618 fireEvent . change ( input , { target : { value : 'root tag 1' } } ) ;
610619 fireEvent . click ( saveButton ) ;
611620
612- expect ( await screen . findByText ( 'Tag with this name already exists' ) ) . toBeInTheDocument ( ) ;
621+ expect ( await screen . findByText ( 'Error creating tag: Tag with this name already exists' ) ) . toBeInTheDocument ( ) ;
613622 } ) ;
614623
615624 it ( 'should keep the inline row and show a failure toast when save request fails' , async ( ) => {
616- axiosMock . onPost ( createTagUrl ) . reply ( 500 , {
617- error : 'Internal server error' ,
625+ axiosMock . onPost ( createTagUrl ) . reply ( ( ) => {
626+ const error = new Error ( 'Request failed with status code 500' ) ;
627+ error . name = 'AxiosError' ;
628+ error . response = {
629+ data : {
630+ tag : [ 'Internal server error' ] ,
631+ } ,
632+ } ;
633+ return Promise . reject ( error ) ;
618634 } ) ;
619635
620636 fireEvent . click ( await screen . findByLabelText ( 'Create Tag' ) ) ;
0 commit comments