This implements a side drawer widget for content taxonomy tags. It includes displaying the object's tags, along with their lineage (ancestor tags) data. It also implements the listing the available taxonomy tags (including nesting ones) to select from to apply to this unit. Note: The editing of tags (adding/removing) will be added in a future PR. * feat: Add initial UnitTaxonomyTagsDrawer widget * feat: Add fetching unit taxonomy tags from backend * feat: Add fetching/group tags with taxonomies * feat: Add fetch Unit data and display name * feat: Add Taxonomy Tags dropdown selector * feat: Add TagBubble for tag styling * chore: Add distinct keys to elements + remove logs * feat: Add close drawer with ESC- keypress * feat: Make dropdown selectors keyboard accessible * chore: Fix issues causing validation to fail * test: Add coverage tests for UnitTaxonomyDrawer * feat: Incorporate tags lineage data from API * refactor: Remove/replace deprecated injectIntl * test: Remove redux store related code + fix warnings * feat: Use <Loading /> instead of loading string * docs: Add docs string to TaxonomyTagsCollapsible * feat: Use <Spinner/> to allow mutiple loading to show * feat: Rename UnitTaxonomyTagDrawer -> ContentTagsDrawer * feat: Add ContentTagsTree component to render Tags * feat: Only fetch tags when dropdowns are opened * refactor: Simply dropdown close/open states * feat: Use built in class styles instead of custom * feat: Replace hardcoded values with scss variables * refactor: follow existing structure for reactQuery/APIs * feat: Change tag bubble outline color * feat: Add TagOutlineIcon for implicit tags * feat: Make aria label internationalized * feat: Replace custom styles with builtin classes * fix: Fix bug with closing drawer * refactor: Simplify content tags fetching code * refactor: Simplify getTaxonomyListApiUrl
71 lines
1.8 KiB
JavaScript
71 lines
1.8 KiB
JavaScript
import MockAdapter from 'axios-mock-adapter';
|
|
import { initializeMockApp } from '@edx/frontend-platform';
|
|
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
|
|
|
|
import { taxonomyListMock } from '../__mocks__';
|
|
|
|
import {
|
|
getTaxonomyListApiUrl,
|
|
getExportTaxonomyApiUrl,
|
|
getTaxonomyListData,
|
|
getTaxonomyExportFile,
|
|
} from './api';
|
|
|
|
let axiosMock;
|
|
|
|
describe('taxonomy api calls', () => {
|
|
const { location } = window;
|
|
beforeEach(() => {
|
|
initializeMockApp({
|
|
authenticatedUser: {
|
|
userId: 3,
|
|
username: 'abc123',
|
|
administrator: true,
|
|
roles: [],
|
|
},
|
|
});
|
|
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
|
|
});
|
|
|
|
afterEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
beforeAll(() => {
|
|
delete window.location;
|
|
window.location = {
|
|
href: '',
|
|
};
|
|
});
|
|
|
|
afterAll(() => {
|
|
window.location = location;
|
|
});
|
|
|
|
it('should get taxonomy list data', async () => {
|
|
axiosMock.onGet(getTaxonomyListApiUrl()).reply(200, taxonomyListMock);
|
|
const result = await getTaxonomyListData();
|
|
|
|
expect(axiosMock.history.get[0].url).toEqual(getTaxonomyListApiUrl());
|
|
expect(result).toEqual(taxonomyListMock);
|
|
});
|
|
|
|
it('should get taxonomy list data with org', async () => {
|
|
const org = 'testOrg';
|
|
axiosMock.onGet(getTaxonomyListApiUrl(org)).reply(200, taxonomyListMock);
|
|
const result = await getTaxonomyListData(org);
|
|
|
|
expect(axiosMock.history.get[0].url).toEqual(getTaxonomyListApiUrl(org));
|
|
expect(result).toEqual(taxonomyListMock);
|
|
});
|
|
|
|
it('should set window.location.href correctly', () => {
|
|
const pk = 1;
|
|
const format = 'json';
|
|
|
|
getTaxonomyExportFile(pk, format);
|
|
|
|
expect(window.location.href).toEqual(getExportTaxonomyApiUrl(pk, format));
|
|
});
|
|
});
|