-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1274 from openedx/ammar/integrate-skills-charts
feat: integrate skills charts
- Loading branch information
Showing
13 changed files
with
434 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { | ||
Spinner, | ||
} from '@openedx/paragon'; | ||
import PropTypes from 'prop-types'; | ||
import EmptyChart from './charts/EmptyChart'; | ||
|
||
const ProgressOverlay = ({ isError, message }) => ( | ||
<div className="position-relative" style={{ minHeight: '50vh' }}> | ||
<div className="position-absolute w-100 h-100 d-flex align-items-center justify-content-center bg-transparent"> | ||
{isError ? <EmptyChart /> : <Spinner animation="border" variant="primary" screenReaderText={message} />} | ||
</div> | ||
</div> | ||
); | ||
|
||
ProgressOverlay.propTypes = { | ||
isError: PropTypes.bool.isRequired, | ||
message: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default ProgressOverlay; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { advanceAnalyticsQueryKeys } from './constants'; | ||
import EnterpriseDataApiService from '../../../data/services/EnterpriseDataApiService'; | ||
|
||
export const useEnterpriseSkillsAnalytics = (enterpriseCustomerUUID, startDate, endDate, queryOptions = {}) => { | ||
Check failure on line 6 in src/components/AdvanceAnalyticsV2/data/hooks.js GitHub Actions / tests (18)
|
||
const requestOptions = { startDate, endDate }; | ||
return useQuery({ | ||
queryKey: advanceAnalyticsQueryKeys.skills(enterpriseCustomerUUID, requestOptions), | ||
queryFn: () => EnterpriseDataApiService.fetchAdminAnalyticsSkills(enterpriseCustomerUUID, requestOptions), | ||
staleTime: 1 * (1000 * 60 * 60), // 1 hour. Length of time before your data becomes stale | ||
cacheTime: 2 * (1000 * 60 * 60), // 2 hours. Length of time before inactive data gets removed from the cache | ||
...queryOptions, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import axios from 'axios'; | ||
import MockAdapter from 'axios-mock-adapter'; | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { QueryClientProvider } from '@tanstack/react-query'; | ||
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; | ||
import { camelCaseObject } from '@edx/frontend-platform/utils'; | ||
import { useEnterpriseSkillsAnalytics } from './hooks'; | ||
import EnterpriseDataApiService from '../../../data/services/EnterpriseDataApiService'; | ||
import { queryClient } from '../../test/testUtils'; | ||
|
||
jest.mock('@edx/frontend-platform/logging', () => ({ | ||
logError: jest.fn(), | ||
})); | ||
|
||
jest.spyOn(EnterpriseDataApiService, 'fetchAdminAnalyticsSkills'); | ||
|
||
const axiosMock = new MockAdapter(axios); | ||
getAuthenticatedHttpClient.mockReturnValue(axios); | ||
|
||
const mockAnalyticsSkillsData = { | ||
top_skills: [], | ||
top_skills_by_enrollments: [], | ||
top_skills_by_completions: [], | ||
}; | ||
|
||
axiosMock.onAny().reply(200); | ||
axios.get = jest.fn(() => Promise.resolve({ data: mockAnalyticsSkillsData })); | ||
|
||
const TEST_ENTERPRISE_ID = '33ce6562-95e0-4ecf-a2a7-7d407eb96f69'; | ||
|
||
describe('useEnterpriseSkillsAnalytics', () => { | ||
const wrapper = ({ children }) => ( | ||
<QueryClientProvider client={queryClient()}> | ||
{children} | ||
</QueryClientProvider> | ||
); | ||
|
||
it('fetch skills analytics data', async () => { | ||
const startDate = '2021-01-01'; | ||
const endDate = '2021-12-31'; | ||
const requestOptions = { startDate, endDate }; | ||
const { result, waitForNextUpdate } = renderHook( | ||
() => useEnterpriseSkillsAnalytics(TEST_ENTERPRISE_ID, startDate, endDate), | ||
{ wrapper }, | ||
); | ||
|
||
expect(result.current).toEqual( | ||
expect.objectContaining({ | ||
isLoading: true, | ||
error: null, | ||
data: undefined, | ||
}), | ||
); | ||
|
||
await waitForNextUpdate(); | ||
|
||
expect(EnterpriseDataApiService.fetchAdminAnalyticsSkills).toHaveBeenCalled(); | ||
expect(EnterpriseDataApiService.fetchAdminAnalyticsSkills).toHaveBeenCalledWith(TEST_ENTERPRISE_ID, requestOptions); | ||
expect(result.current).toEqual(expect.objectContaining({ | ||
isLoading: false, | ||
error: null, | ||
data: camelCaseObject(mockAnalyticsSkillsData), | ||
})); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.