Skip to content

Commit 801def1

Browse files
feat: refactor after rebase
1 parent a6306bd commit 801def1

File tree

6 files changed

+82
-142
lines changed

6 files changed

+82
-142
lines changed

src/course-home/live-tab/LiveTab.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const LiveTab = () => {
1313
return (
1414
<div
1515
id="live_tab"
16+
role="region"
1617
// eslint-disable-next-line react/no-danger
1718
dangerouslySetInnerHTML={{ __html: liveModel[courseId]?.iframe }}
1819
/>
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import { useSelector } from 'react-redux';
4+
import LiveTab from './LiveTab';
5+
6+
jest.mock('react-redux', () => ({
7+
useSelector: jest.fn(),
8+
}));
9+
10+
describe('LiveTab', () => {
11+
afterEach(() => {
12+
jest.clearAllMocks();
13+
document.body.innerHTML = '';
14+
});
15+
16+
it('renders iframe from liveModel using dangerouslySetInnerHTML', () => {
17+
useSelector.mockImplementation((selector) => selector({
18+
courseHome: { courseId: 'course-v1:test+id+2024' },
19+
models: {
20+
live: {
21+
'course-v1:test+id+2024': {
22+
iframe: '<iframe id="lti-tab-embed" src="about:blank"></iframe>',
23+
},
24+
},
25+
},
26+
}));
27+
28+
render(<LiveTab />);
29+
30+
const iframe = document.getElementById('lti-tab-embed');
31+
expect(iframe).toBeInTheDocument();
32+
expect(iframe.src).toBe('about:blank');
33+
});
34+
35+
it('adds classes to iframe after mount', () => {
36+
document.body.innerHTML = `
37+
<div id="live_tab">
38+
<iframe id="lti-tab-embed" class=""></iframe>
39+
</div>
40+
`;
41+
42+
useSelector.mockImplementation((selector) => selector({
43+
courseHome: { courseId: 'course-v1:test+id+2024' },
44+
models: {
45+
live: {
46+
'course-v1:test+id+2024': {
47+
iframe: '<iframe id="lti-tab-embed"></iframe>',
48+
},
49+
},
50+
},
51+
}));
52+
53+
render(<LiveTab />);
54+
55+
const iframe = document.getElementById('lti-tab-embed');
56+
expect(iframe.className).toContain('vh-100');
57+
expect(iframe.className).toContain('w-100');
58+
expect(iframe.className).toContain('border-0');
59+
});
60+
61+
it('does not throw if iframe is not found in DOM', () => {
62+
useSelector.mockImplementation((selector) => selector({
63+
courseHome: { courseId: 'course-v1:test+id+2024' },
64+
models: {
65+
live: {
66+
'course-v1:test+id+2024': {
67+
iframe: '<div>No iframe here</div>',
68+
},
69+
},
70+
},
71+
}));
72+
73+
expect(() => render(<LiveTab />)).not.toThrow();
74+
const iframe = document.getElementById('lti-tab-embed');
75+
expect(iframe).toBeNull();
76+
});
77+
});

src/course-home/outline-tab/Section.jsx

-139
This file was deleted.

src/course-home/outline-tab/section-outline/SectionTitle.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ const SectionTitle: React.FC<Props> = ({ complete, hideFromTOC, title }) => {
3535
)}
3636
</div>
3737
<div className="col-7 ml-3 p-0 font-weight-bold text-dark-500">
38-
<span className="align-middle col-6">{title}</span>
38+
<h2 className="course-outline-tab-section-title text-dark-500 mb-0">
39+
<span className="align-middle col-6">{title}</span>
40+
</h2>
3941
<span className="sr-only">
4042
, {intl.formatMessage(complete ? messages.completedSection : messages.incompleteSection)}
4143
</span>

src/index.scss

-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@
467467
@import "courseware/course/content-tools/contentTools.scss";
468468
@import "course-home/dates-tab/timeline/Day.scss";
469469
@import "course-home/outline-tab/Section.scss";
470-
@import "generic/upgrade-notification/UpgradeNotification.scss";
471470
@import "generic/upsell-bullets/UpsellBullets.scss";
472471
@import "course-home/outline-tab/widgets/ProctoringInfoPanel.scss";
473472
@import "course-home/outline-tab/widgets/FlagButton.scss";

src/plugin-slots/CourseHomeSectionOutlineSlot/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const CourseHomeSectionOutlineSlot: React.FC<Props> = ({
1515
id="course_home_section_outline_slot"
1616
pluginProps={{ expandAll, sectionIds, sections }}
1717
>
18-
<ol id="courseHome-outline" className="list-unstyled">
18+
<ol id="courseHome-outline" className="list-unstyled" role="presentation">
1919
{sectionIds.map((sectionId) => (
2020
<Section
2121
key={sectionId}

0 commit comments

Comments
 (0)