refactor: handle relative proctoring link (#974)
This commit is contained in:
@@ -62,6 +62,11 @@ const CardHeader = ({
|
||||
const cardHeaderRef = useRef(null);
|
||||
const [isManageTagsDrawerOpen, openManageTagsDrawer, closeManageTagsDrawer] = useToggle(false);
|
||||
|
||||
// Use studio url as base if proctoringExamConfigurationLink is a relative link
|
||||
const fullProctoringExamConfigurationLink = () => (
|
||||
proctoringExamConfigurationLink && new URL(proctoringExamConfigurationLink, getConfig().STUDIO_BASE_URL).href
|
||||
);
|
||||
|
||||
const isDisabledPublish = (status === ITEM_BADGE_STATUS.live
|
||||
|| status === ITEM_BADGE_STATUS.publishedNotLive) && !hasChanges;
|
||||
|
||||
@@ -156,8 +161,8 @@ const CardHeader = ({
|
||||
<Dropdown.Item
|
||||
as={Hyperlink}
|
||||
target="_blank"
|
||||
destination={proctoringExamConfigurationLink}
|
||||
href={proctoringExamConfigurationLink}
|
||||
destination={fullProctoringExamConfigurationLink()}
|
||||
href={fullProctoringExamConfigurationLink()}
|
||||
externalLinkTitle={intl.formatMessage(messages.proctoringLinkTooltip)}
|
||||
>
|
||||
{intl.formatMessage(messages.menuProctoringLinkText)}
|
||||
|
||||
@@ -265,14 +265,31 @@ describe('<CardHeader />', () => {
|
||||
it('check if proctoringExamConfigurationLink is visible', async () => {
|
||||
const { findByText, findByTestId } = renderComponent({
|
||||
...cardHeaderProps,
|
||||
proctoringExamConfigurationLink: 'https://localhost:8000/',
|
||||
proctoringExamConfigurationLink: 'proctoringlink',
|
||||
isSequential: true,
|
||||
});
|
||||
|
||||
const menuButton = await findByTestId('subsection-card-header__menu-button');
|
||||
await act(async () => fireEvent.click(menuButton));
|
||||
|
||||
expect(await findByText(messages.menuProctoringLinkText.defaultMessage)).toBeInTheDocument();
|
||||
const element = await findByText(messages.menuProctoringLinkText.defaultMessage);
|
||||
expect(element).toBeInTheDocument();
|
||||
expect(element.getAttribute('href')).toBe(`${getConfig().STUDIO_BASE_URL}/proctoringlink`);
|
||||
});
|
||||
|
||||
it('check if proctoringExamConfigurationLink is absolute', async () => {
|
||||
const { findByText, findByTestId } = renderComponent({
|
||||
...cardHeaderProps,
|
||||
proctoringExamConfigurationLink: 'http://localhost:9000/proctoringlink',
|
||||
isSequential: true,
|
||||
});
|
||||
|
||||
const menuButton = await findByTestId('subsection-card-header__menu-button');
|
||||
await act(async () => fireEvent.click(menuButton));
|
||||
|
||||
const element = await findByText(messages.menuProctoringLinkText.defaultMessage);
|
||||
expect(element).toBeInTheDocument();
|
||||
expect(element.getAttribute('href')).toBe('http://localhost:9000/proctoringlink');
|
||||
});
|
||||
|
||||
it('check if discussion enabled badge is visible', async () => {
|
||||
|
||||
Reference in New Issue
Block a user