@@ -36,14 +77,12 @@ const Enrollments = ({
defaultMessage: 'See audit and certificate track enrollments over time.',
description: 'Subtitle for the enrollments over time chart.',
})}
- startDate={startDate}
- endDate={endDate}
- granularity={granularity}
- calculation={calculation}
- activeTab={ANALYTICS_TABS.ENROLLMENTS}
- chartType={CHART_TYPES.ENROLLMENTS_OVER_TIME}
- enterpriseId={enterpriseId}
- isDownloadCSV
+ DownloadCSVComponent={(
+
+ )}
/>
+ )}
/>
+ )}
/>
{
axiosMock.onGet(/\/enrollments(\?.*)/).reply(200, mockAnalyticsTableData);
const { container } = render(
-
-
-
- ,
- ,
+
+
+
+
+ ,
+
+ ,
);
const sections = [
@@ -146,17 +149,19 @@ describe('Enrollments Component', () => {
}));
render(
-
-
-
- ,
- ,
+
+
+
+
+ ,
+
+ ,
);
expect(screen.getByText('Loading enrollments over time chart data')).toBeInTheDocument();
diff --git a/src/components/AdvanceAnalyticsV2/tabs/Leaderboard.test.jsx b/src/components/AdvanceAnalyticsV2/tabs/Leaderboard.test.jsx
index 0f6ce03d14..1c09351b0a 100644
--- a/src/components/AdvanceAnalyticsV2/tabs/Leaderboard.test.jsx
+++ b/src/components/AdvanceAnalyticsV2/tabs/Leaderboard.test.jsx
@@ -7,6 +7,7 @@ import { QueryClientProvider } from '@tanstack/react-query';
import MockAdapter from 'axios-mock-adapter';
import axios from 'axios';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
+import { BrowserRouter as Router } from 'react-router-dom';
import Leaderboard from './Leaderboard';
import { queryClient } from '../../test/testUtils';
import EnterpriseDataApiService from '../../../data/services/EnterpriseDataApiService';
@@ -55,15 +56,17 @@ const TEST_ENTERPRISE_ID = '33ce6562-95e0-4ecf-a2a7-7d407eb96f69';
describe('Leaderboard Component', () => {
test('renders all sections with correct classes and content', () => {
const { container } = render(
-
-
-
- ,
- ,
+
+
+
+
+ ,
+
+ ,
);
const sections = [
@@ -82,15 +85,17 @@ describe('Leaderboard Component', () => {
});
test('renders the table rows with correct values', async () => {
render(
-
-
-
- ,
- ,
+
+
+
+
+ ,
+
+ ,
);
// validate the header row
diff --git a/src/components/AdvanceAnalyticsV2/tabs/Skills.jsx b/src/components/AdvanceAnalyticsV2/tabs/Skills.jsx
index 1cd58463ff..caf9315337 100644
--- a/src/components/AdvanceAnalyticsV2/tabs/Skills.jsx
+++ b/src/components/AdvanceAnalyticsV2/tabs/Skills.jsx
@@ -7,6 +7,7 @@ import {
} from '../data/constants';
import { useEnterpriseAnalyticsData } from '../data/hooks';
import ChartWrapper from '../charts/ChartWrapper';
+import DownloadCSV from '../DownloadCSV';
const Skills = ({ startDate, endDate, enterpriseId }) => {
const intl = useIntl();
@@ -34,12 +35,15 @@ const Skills = ({ startDate, endDate, enterpriseId }) => {
defaultMessage: 'See the top skills that are the most in demand in your organization, based on enrollments and completions.',
description: 'Subtitle for the top skills chart.',
})}
- startDate={startDate}
- endDate={endDate}
- activeTab={ANALYTICS_TABS.SKILLS}
- chartType={CHART_TYPES.BUBBLE}
- enterpriseId={enterpriseId}
- isDownloadCSV
+ DownloadCSVComponent={(
+
+ )}
/>
render(
-
-
-
- {component}
-
-
- ,
+
+
+
+
+ {component}
+
+
+
+ ,
);
describe('AnalyticsV2Page', () => {
diff --git a/src/data/services/EnterpriseDataApiService.js b/src/data/services/EnterpriseDataApiService.js
index 79f3d04884..5fe872cbeb 100644
--- a/src/data/services/EnterpriseDataApiService.js
+++ b/src/data/services/EnterpriseDataApiService.js
@@ -204,6 +204,18 @@ class EnterpriseDataApiService {
const url = `${EnterpriseDataApiService.enterpriseAdminAnalyticsV2BaseUrl}${enterpriseId}/${chartUrl}?${new URLSearchParams(options).toString()}`;
return EnterpriseDataApiService.apiClient().get(url);
}
+
+ static getAnalyticsCSVDownloadURL(key, enterpriseId, options) {
+ const queryParams = new URLSearchParams({
+ ...options,
+ ...{ response_type: 'csv' },
+ });
+ const tableURL = EnterpriseDataApiService.constructAnalyticsDataURL(
+ key,
+ `${EnterpriseDataApiService.enterpriseAdminAnalyticsV2BaseUrl}${enterpriseId}`,
+ );
+ return `${tableURL}?${queryParams.toString()}`;
+ }
}
export default EnterpriseDataApiService;