diff --git a/src/taxonomy/tag-list/TagListTable.jsx b/src/taxonomy/tag-list/TagListTable.jsx
index 526f28db8..09ec2b990 100644
--- a/src/taxonomy/tag-list/TagListTable.jsx
+++ b/src/taxonomy/tag-list/TagListTable.jsx
@@ -24,7 +24,7 @@ const SubTagsExpanded = ({ taxonomyId, parentTagValue }) => {
{subTagsData.data.results.map(tagData => (
-
- {tagData.value} {tagData.childCount > 0 ? `(${tagData.childCount})` : null}
+ {tagData.value} {tagData.descendantCount > 0 ? `(${tagData.descendantCount})` : null}
))}
@@ -48,7 +48,7 @@ OptionalExpandLink.propTypes = DataTable.ExpandRow.propTypes;
const TagValue = ({ row }) => (
<>
{row.original.value}
- {` (${row.original.childCount})`}
+ {` (${row.original.descendantCount})`}
>
);
TagValue.propTypes = {
@@ -56,6 +56,7 @@ TagValue.propTypes = {
original: Proptypes.shape({
value: Proptypes.string.isRequired,
childCount: Proptypes.number.isRequired,
+ descendantCount: Proptypes.number.isRequired,
}).isRequired,
}).isRequired,
};
diff --git a/src/taxonomy/tag-list/TagListTable.test.jsx b/src/taxonomy/tag-list/TagListTable.test.jsx
index f2d850205..2d3837e16 100644
--- a/src/taxonomy/tag-list/TagListTable.test.jsx
+++ b/src/taxonomy/tag-list/TagListTable.test.jsx
@@ -3,7 +3,7 @@ import { IntlProvider } from '@edx/frontend-platform/i18n';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { initializeMockApp } from '@edx/frontend-platform';
import { AppProvider } from '@edx/frontend-platform/react';
-import { render, waitFor } from '@testing-library/react';
+import { render, waitFor, within } from '@testing-library/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import MockAdapter from 'axios-mock-adapter';
@@ -35,22 +35,25 @@ const mockTagsResponse = {
results: [
{
...tagDefaults,
- value: 'two level tag 1',
+ value: 'root tag 1',
child_count: 1,
+ descendant_count: 14,
_id: 1001,
sub_tags_url: '/request/to/load/subtags/1',
},
{
...tagDefaults,
- value: 'two level tag 2',
+ value: 'root tag 2',
child_count: 1,
+ descendant_count: 10,
_id: 1002,
sub_tags_url: '/request/to/load/subtags/2',
},
{
...tagDefaults,
- value: 'two level tag 3',
+ value: 'root tag 3',
child_count: 1,
+ descendant_count: 5,
_id: 1003,
sub_tags_url: '/request/to/load/subtags/3',
},
@@ -75,7 +78,7 @@ const subTagsResponse = {
},
],
};
-const subTagsUrl = 'http://localhost:18010/api/content_tagging/v1/taxonomies/1/tags/?full_depth_threshold=10000&parent_tag=two+level+tag+1';
+const subTagsUrl = 'http://localhost:18010/api/content_tagging/v1/taxonomies/1/tags/?full_depth_threshold=10000&parent_tag=root+tag+1';
describe('', () => {
beforeAll(async () => {
@@ -112,10 +115,12 @@ describe('', () => {
axiosMock.onGet(rootTagsListUrl).reply(200, mockTagsResponse);
const result = render();
await waitFor(() => {
- expect(result.getByText('two level tag 1')).toBeInTheDocument();
+ expect(result.getByText('root tag 1')).toBeInTheDocument();
});
const rows = result.getAllByRole('row');
expect(rows.length).toBe(3 + 1); // 3 items plus header
+ expect(within(rows[0]).getAllByRole('columnheader')[0].textContent).toEqual('Tag name');
+ expect(within(rows[1]).getAllByRole('cell')[0].textContent).toEqual('root tag 1 (14)');
});
it('should render page correctly with subtags', async () => {
diff --git a/src/taxonomy/tag-list/data/types.mjs b/src/taxonomy/tag-list/data/types.mjs
index 694f65b34..fcb4a38fe 100644
--- a/src/taxonomy/tag-list/data/types.mjs
+++ b/src/taxonomy/tag-list/data/types.mjs
@@ -12,6 +12,7 @@
/**
* @typedef {Object} TagData
* @property {number} childCount
+ * @property {number} descendantCount
* @property {number} depth
* @property {string} externalId
* @property {number} id