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
9 changes: 7 additions & 2 deletions src/course-outline/card-header/CardHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)}
Expand Down
21 changes: 19 additions & 2 deletions src/course-outline/card-header/CardHeader.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down