Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/export-page/CourseExportPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('<CourseExportPage />', () => {
const { getByText } = render(<RootWrapper />);
expect(getByText(stepperMessages.stepperPreparingDescription.defaultMessage)).toBeInTheDocument();
});
it('should show download path', async () => {
it('should show download path for relative path', async () => {
axiosMock
.onGet(getExportStatusApiUrl(courseId))
.reply(200, { exportStatus: EXPORT_STAGES.SUCCESS, exportOutput: '/test-download-path.test' });
Expand All @@ -124,4 +124,17 @@ describe('<CourseExportPage />', () => {
expect(downloadButton).toBeInTheDocument();
expect(downloadButton.getAttribute('href')).toEqual(`${getConfig().STUDIO_BASE_URL}/test-download-path.test`);
});
it('should show download path for absolute path', async () => {
axiosMock
.onGet(getExportStatusApiUrl(courseId))
.reply(200, { exportStatus: EXPORT_STAGES.SUCCESS, exportOutput: 'http://test-download-path.test' });
const { getByText, container } = render(<RootWrapper />);
const startExportButton = container.querySelector('.btn-primary');
fireEvent.click(startExportButton);
// eslint-disable-next-line no-promise-executor-return
await new Promise((r) => setTimeout(r, 3500));
const downloadButton = getByText(stepperMessages.downloadCourseButtonTitle.defaultMessage);
expect(downloadButton).toBeInTheDocument();
expect(downloadButton.getAttribute('href')).toEqual('http://test-download-path.test');
});
});
7 changes: 6 additions & 1 deletion src/export-page/data/thunks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Cookies from 'universal-cookie';
import moment from 'moment';
import { getConfig } from '@edx/frontend-platform';

import { RequestStatus } from '../../data/constants';
import { setExportCookie } from '../utils';
Expand Down Expand Up @@ -48,7 +49,11 @@ export function fetchExportStatus(courseId) {
dispatch(updateCurrentStage(Math.abs(exportStatus)));

if (exportOutput) {
dispatch(updateDownloadPath(exportOutput));
if (exportOutput.startsWith('/')) {
dispatch(updateDownloadPath(`${getConfig().STUDIO_BASE_URL}${exportOutput}`));
} else {
dispatch(updateDownloadPath(exportOutput));
}
dispatch(updateSuccessDate(moment().valueOf()));
}

Expand Down
3 changes: 1 addition & 2 deletions src/export-page/export-stepper/ExportStepper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from '@edx/frontend-platform/i18n';
import PropTypes from 'prop-types';
import { useDispatch, useSelector } from 'react-redux';
import { getConfig } from '@edx/frontend-platform';
import { Button } from '@edx/paragon';

import CourseStepper from '../../generic/course-stepper';
Expand Down Expand Up @@ -91,7 +90,7 @@ const ExportStepper = ({ intl, courseId }) => {
errorMessage={errorMessage}
hasError={!!errorMessage}
/>
{downloadPath && currentStage === EXPORT_STAGES.SUCCESS && <Button className="ml-5.5 mt-n2.5" href={`${getConfig().STUDIO_BASE_URL}${downloadPath}`}>{intl.formatMessage(messages.downloadCourseButtonTitle)}</Button>}
{downloadPath && currentStage === EXPORT_STAGES.SUCCESS && <Button className="ml-5.5 mt-n2.5" href={downloadPath} download>{intl.formatMessage(messages.downloadCourseButtonTitle)}</Button>}
</div>
);
};
Expand Down