@@ -3,7 +3,7 @@ import { IntlProvider } from '@edx/frontend-platform/i18n';
33import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth' ;
44import { initializeMockApp } from '@edx/frontend-platform' ;
55import { AppProvider } from '@edx/frontend-platform/react' ;
6- import { render , waitFor } from '@testing-library/react' ;
6+ import { render , waitFor , within } from '@testing-library/react' ;
77import { QueryClient , QueryClientProvider } from '@tanstack/react-query' ;
88import MockAdapter from 'axios-mock-adapter' ;
99
@@ -35,22 +35,25 @@ const mockTagsResponse = {
3535 results : [
3636 {
3737 ...tagDefaults ,
38- value : 'two level tag 1' ,
38+ value : 'root tag 1' ,
3939 child_count : 1 ,
40+ descendant_count : 14 ,
4041 _id : 1001 ,
4142 sub_tags_url : '/request/to/load/subtags/1' ,
4243 } ,
4344 {
4445 ...tagDefaults ,
45- value : 'two level tag 2' ,
46+ value : 'root tag 2' ,
4647 child_count : 1 ,
48+ descendant_count : 10 ,
4749 _id : 1002 ,
4850 sub_tags_url : '/request/to/load/subtags/2' ,
4951 } ,
5052 {
5153 ...tagDefaults ,
52- value : 'two level tag 3' ,
54+ value : 'root tag 3' ,
5355 child_count : 1 ,
56+ descendant_count : 5 ,
5457 _id : 1003 ,
5558 sub_tags_url : '/request/to/load/subtags/3' ,
5659 } ,
@@ -75,7 +78,7 @@ const subTagsResponse = {
7578 } ,
7679 ] ,
7780} ;
78- const subTagsUrl = 'http://localhost:18010/api/content_tagging/v1/taxonomies/1/tags/?full_depth_threshold=10000&parent_tag=two+level +tag+1' ;
81+ const subTagsUrl = 'http://localhost:18010/api/content_tagging/v1/taxonomies/1/tags/?full_depth_threshold=10000&parent_tag=root +tag+1' ;
7982
8083describe ( '<TagListTable />' , ( ) => {
8184 beforeAll ( async ( ) => {
@@ -112,10 +115,12 @@ describe('<TagListTable />', () => {
112115 axiosMock . onGet ( rootTagsListUrl ) . reply ( 200 , mockTagsResponse ) ;
113116 const result = render ( < RootWrapper /> ) ;
114117 await waitFor ( ( ) => {
115- expect ( result . getByText ( 'two level tag 1' ) ) . toBeInTheDocument ( ) ;
118+ expect ( result . getByText ( 'root tag 1' ) ) . toBeInTheDocument ( ) ;
116119 } ) ;
117120 const rows = result . getAllByRole ( 'row' ) ;
118121 expect ( rows . length ) . toBe ( 3 + 1 ) ; // 3 items plus header
122+ expect ( within ( rows [ 0 ] ) . getAllByRole ( 'columnheader' ) [ 0 ] . textContent ) . toEqual ( 'Tag name' ) ;
123+ expect ( within ( rows [ 1 ] ) . getAllByRole ( 'cell' ) [ 0 ] . textContent ) . toEqual ( 'root tag 1 (14)' ) ;
119124 } ) ;
120125
121126 it ( 'should render page correctly with subtags' , async ( ) => {
0 commit comments