Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions src/course-home/live-tab/LiveTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const LiveTab = () => {
return (
<div
id="live_tab"
role="region"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: liveModel[courseId]?.iframe }}
/>
Expand Down
77 changes: 77 additions & 0 deletions src/course-home/live-tab/LiveTab.test.jsx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this tests?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was deleted

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React from 'react';
import { render } from '@testing-library/react';
import { useSelector } from 'react-redux';
import LiveTab from './LiveTab';

jest.mock('react-redux', () => ({
useSelector: jest.fn(),
}));

describe('LiveTab', () => {
afterEach(() => {
jest.clearAllMocks();
document.body.innerHTML = '';
});

it('renders iframe from liveModel using dangerouslySetInnerHTML', () => {
useSelector.mockImplementation((selector) => selector({
courseHome: { courseId: 'course-v1:test+id+2024' },
models: {
live: {
'course-v1:test+id+2024': {
iframe: '<iframe id="lti-tab-embed" src="about:blank"></iframe>',
},
},
},
}));

render(<LiveTab />);

const iframe = document.getElementById('lti-tab-embed');
expect(iframe).toBeInTheDocument();
expect(iframe.src).toBe('about:blank');
});

it('adds classes to iframe after mount', () => {
document.body.innerHTML = `
<div id="live_tab">
<iframe id="lti-tab-embed" class=""></iframe>
</div>
`;

useSelector.mockImplementation((selector) => selector({
courseHome: { courseId: 'course-v1:test+id+2024' },
models: {
live: {
'course-v1:test+id+2024': {
iframe: '<iframe id="lti-tab-embed"></iframe>',
},
},
},
}));

render(<LiveTab />);

const iframe = document.getElementById('lti-tab-embed');
expect(iframe.className).toContain('vh-100');
expect(iframe.className).toContain('w-100');
expect(iframe.className).toContain('border-0');
});

it('does not throw if iframe is not found in DOM', () => {
useSelector.mockImplementation((selector) => selector({
courseHome: { courseId: 'course-v1:test+id+2024' },
models: {
live: {
'course-v1:test+id+2024': {
iframe: '<div>No iframe here</div>',
},
},
},
}));

expect(() => render(<LiveTab />)).not.toThrow();
const iframe = document.getElementById('lti-tab-embed');
expect(iframe).toBeNull();
});
});
18 changes: 18 additions & 0 deletions src/course-home/outline-tab/OutlineTab.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@ describe('Outline Tab', () => {
expect(expandedSectionNode).toHaveAttribute('aria-expanded', 'true');
});

it('displays correct heading for expanded section', async () => {
const { courseBlocks } = await buildMinimalCourseBlocks(courseId, 'Title', { resumeBlock: true });
setTabData({ course_blocks: { blocks: courseBlocks.blocks } });
await fetchAndRender();
const headingContent = screen.getByText('Title of Section');
const { parentElement } = headingContent;
expect(parentElement.tagName).toBe('H2');
});

it('checks that the expanded section is within the correct list', async () => {
const { courseBlocks } = await buildMinimalCourseBlocks(courseId, 'Title', { resumeBlock: true });
setTabData({ course_blocks: { blocks: courseBlocks.blocks } });
await fetchAndRender();
const listElement = screen.getByRole('presentation', { id: 'courseHome-outline' });
expect(listElement).toBeInTheDocument();
expect(listElement.tagName).toBe('OL');
});

it('includes outline_tab_notifications_slot', async () => {
const { courseBlocks } = await buildMinimalCourseBlocks(courseId, 'Title', { resumeBlock: true });
setTabData({
Expand Down
4 changes: 3 additions & 1 deletion src/course-home/outline-tab/section-outline/SectionTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ const SectionTitle: React.FC<Props> = ({ complete, hideFromTOC, title }) => {
)}
</div>
<div className="col-7 ml-3 p-0 font-weight-bold text-dark-500">
<span className="align-middle col-6">{title}</span>
<h2 className="h4 text-dark-500 mb-0">
<span className="align-middle col-6">{title}</span>
</h2>
<span className="sr-only">
, {intl.formatMessage(complete ? messages.completedSection : messages.incompleteSection)}
</span>
Expand Down
5 changes: 3 additions & 2 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,12 @@
.course-outline-tab .pgn__card {
.pgn__card-header {
display: block;

.pgn__card-header-content {
margin-top: 0;
}
}

.pgn__card-header-actions {
margin-left: 0;
}
Expand All @@ -456,6 +456,7 @@
@import "courseware/course/content-tools/calculator/calculator.scss";
@import "courseware/course/content-tools/contentTools.scss";
@import "course-home/dates-tab/timeline/Day.scss";
@import "generic/upsell-bullets/UpsellBullets.scss";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[important]: We need to verify what do we need to do with UpsellBullets.scss

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was removed, no errors occurred

@import "course-home/outline-tab/widgets/ProctoringInfoPanel.scss";
@import "course-home/outline-tab/widgets/FlagButton.scss";
@import "course-home/progress-tab/course-completion/CompletionDonutChart.scss";
Expand Down
2 changes: 1 addition & 1 deletion src/plugin-slots/CourseHomeSectionOutlineSlot/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const CourseHomeSectionOutlineSlot: React.FC<Props> = ({
idAliases={['course_home_section_outline_slot']}
pluginProps={{ expandAll, sectionIds, sections }}
>
<ol id="courseHome-outline" className="list-unstyled">
<ol id="courseHome-outline" className="list-unstyled" role="presentation">
{sectionIds.map((sectionId) => (
<Section
key={sectionId}
Expand Down