-
Notifications
You must be signed in to change notification settings - Fork 19
feat: [FC-86] Created Intro section for Course About page #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
brian-smith-tcril
merged 7 commits into
openedx:master
from
raccoongang:Peter_Kulko/course-about-intro
Oct 15, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f28392a
feat: created Intro section for Course About page
peterkulko 6cb1fdc
docs: updated plugin-slots README.md
peterkulko 73ebff5
refactor: after review
peterkulko 5f47afe
refactor: added type imports and some refactoring
peterkulko f0e1da2
refactor: corrected card min-height
peterkulko c7b105f
feat: added new slots for course media section
peterkulko ae6caaf
refactor: after review
peterkulko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| export const mockCourseAboutResponse = { | ||
| accessExpiration: null, | ||
| contentTypeGatingEnabled: false, | ||
| courseGoals: { | ||
| selectedGoal: null, | ||
| weeklyLearningGoalEnabled: false, | ||
| }, | ||
| effort: null, | ||
| end: null, | ||
| enrollment: { | ||
| mode: null, | ||
| isActive: false, | ||
| }, | ||
| enrollmentStart: null, | ||
| enrollmentEnd: null, | ||
| entranceExamData: { | ||
| entranceExamCurrentScore: 0, | ||
| entranceExamEnabled: false, | ||
| entranceExamId: '', | ||
| entranceExamMinimumScorePct: 0.65, | ||
| entranceExamPassed: true, | ||
| }, | ||
| id: 'course-v1:openedx+123+2024', | ||
| license: null, | ||
| language: 'en', | ||
| media: { | ||
| courseImage: { | ||
| uri: '/asset-v1:openedx+123+2024+type@asset+block@494a0bae6c7f4aef47b5c0f7d85414b49371151e82646cbbbc22289b4c100c5f.jpg', | ||
| }, | ||
| courseVideo: { | ||
| uri: 'https://youtube.com/watch?v=test123', | ||
| }, | ||
| image: { | ||
| raw: 'http://local.openedx.io:8000/asset-v1:openedx+123+2024+type@asset+block@494a0bae6c7f4aef47b5c0f7d85414b49371151e82646cbbbc22289b4c100c5f.jpg', | ||
| small: 'http://local.openedx.io:8000/asset-v1:openedx+123+2024+type@asset+block@494a0bae6c7f4aef47b5c0f7d85414b49371151e82646cbbbc22289b4c100c5f.jpg', | ||
| large: 'http://local.openedx.io:8000/asset-v1:openedx+123+2024+type@asset+block@494a0bae6c7f4aef47b5c0f7d85414b49371151e82646cbbbc22289b4c100c5f.jpg', | ||
| }, | ||
| }, | ||
| name: 'Test 2', | ||
| offer: null, | ||
| org: 'openedx', | ||
| relatedPrograms: null, | ||
| shortDescription: 'The first MOOC to teach positive psychology. Learn science-based principles and practices for a happy, meaningful life.', | ||
| start: '2030-01-01T00:00:00Z', | ||
| startDisplay: null, | ||
| startType: 'empty', | ||
| pacing: 'instructor', | ||
| userTimezone: null, | ||
| showCalculator: false, | ||
| canAccessProctoredExams: false, | ||
| notes: { | ||
| enabled: false, | ||
| visible: true, | ||
| }, | ||
| marketingUrl: null, | ||
| celebrations: { | ||
| firstSection: false, | ||
| streakLengthToCelebrate: null, | ||
| streakDiscountEnabled: false, | ||
| weeklyGoal: false, | ||
| }, | ||
| userHasPassingGrade: false, | ||
| courseExitPageIsActive: false, | ||
| certificateData: null, | ||
| verifyIdentityUrl: null, | ||
| verificationStatus: 'none', | ||
| linkedinAddToProfileUrl: null, | ||
| isIntegritySignatureEnabled: false, | ||
| userNeedsIntegritySignature: false, | ||
| learningAssistantEnabled: false, | ||
| showCoursewareLink: false, | ||
| isCourseFull: false, | ||
| canEnroll: true, | ||
| invitationOnly: false, | ||
| isShibCourse: false, | ||
| allowAnonymous: false, | ||
| ecommerceCheckout: false, | ||
| singlePaidMode: {}, | ||
| ecommerceCheckoutLink: 'http://example.com/checkout', | ||
| courseImageUrls: [ | ||
| 'raw', | ||
| 'small', | ||
| 'large', | ||
| ], | ||
| startDateIsStillDefault: true, | ||
| advertisedStart: null, | ||
| coursePrice: 'Free', | ||
| preRequisiteCourses: [], | ||
| sidebarHtmlEnabled: false, | ||
| courseAboutSectionHtml: null, | ||
| aboutSidebarHtml: null, | ||
| displayNumberWithDefault: '123', | ||
| displayOrgWithDefault: 'openedx', | ||
| overview: '<div>Course overview content</div>', | ||
| ocwLinks: [], | ||
| prerequisites: [], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export { mockCourseResponse } from './course'; | ||
| export { mockCourseListSearchResponse } from './courseListSearch'; | ||
| export { mockCourseAboutResponse } from './courseAbout'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @import "./course-intro/course-media/CourseMedia"; | ||
|
|
||
| .course-about-intro .pgn__card { | ||
| min-height: var(--catalog-course-about-page-intro-card-min-height, var(--catalog-course-about-page-course-media-image-height, 15.75rem)); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| import { useLocation } from 'react-router-dom'; | ||
|
|
||
| import genericMessages from '../generic/video-modal/messages'; | ||
| import { | ||
| render, waitFor, screen, userEvent, | ||
| } from '../setupTest'; | ||
| import { mockCourseAboutResponse } from '../__mocks__'; | ||
| import CourseAboutPage from './CourseAboutPage'; | ||
| import { fetchCourseAboutData } from './data/api'; | ||
| import messages from './course-intro/messages'; | ||
| import courseMediaMessages from './course-intro/course-media/messages'; | ||
|
|
||
| const mockGetAuthenticatedUser = jest.fn(); | ||
|
|
||
| jest.mock('@edx/frontend-platform/auth', () => ({ | ||
| getAuthenticatedUser: () => mockGetAuthenticatedUser(), | ||
| })); | ||
|
|
||
| jest.mock('./data/api', () => ({ | ||
| fetchCourseAboutData: jest.fn(), | ||
| })); | ||
|
|
||
| jest.mock('react-router-dom', () => ({ | ||
| useLocation: jest.fn(), | ||
| })); | ||
|
|
||
| const mockFetchCourseAboutData = fetchCourseAboutData as jest.Mock; | ||
| const mockUseLocation = useLocation as jest.Mock; | ||
|
|
||
| describe('CourseAboutPage Integration Tests', () => { | ||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| mockUseLocation.mockReturnValue({ | ||
| pathname: '/catalog/course-v1:TestX+Test101+2023/about', | ||
| }); | ||
| mockGetAuthenticatedUser.mockReturnValue(null); | ||
| }); | ||
|
|
||
| it('should show loading state when data is being fetched', async () => { | ||
| mockFetchCourseAboutData.mockReturnValue(new Promise(() => {})); | ||
| render(<CourseAboutPage />); | ||
| expect(screen.getByRole('status')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should render course page with all components', async () => { | ||
| mockFetchCourseAboutData.mockReturnValue(mockCourseAboutResponse); | ||
| render(<CourseAboutPage />); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByText(mockCourseAboutResponse.name)).toBeInTheDocument(); | ||
| expect(screen.getByText(mockCourseAboutResponse.displayOrgWithDefault)).toBeInTheDocument(); | ||
| expect(screen.getByText(mockCourseAboutResponse.shortDescription)).toBeInTheDocument(); | ||
|
|
||
| expect(screen.getByRole('heading', { level: 1 })).toBeInTheDocument(); | ||
| expect(screen.getByAltText(mockCourseAboutResponse.name)).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| it('should handle course with video correctly', async () => { | ||
| const courseWithVideo = { | ||
| ...mockCourseAboutResponse, | ||
| media: { | ||
| ...mockCourseAboutResponse.media, | ||
| courseVideo: { | ||
| uri: 'https://www.youtube.com/watch?v=test123', | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| mockFetchCourseAboutData.mockReturnValue(courseWithVideo); | ||
|
|
||
| render(<CourseAboutPage />); | ||
|
|
||
| await waitFor(() => { | ||
| const videoButton = screen.getByLabelText(courseMediaMessages.playCourseIntroductionVideo.defaultMessage); | ||
| expect(videoButton).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| const videoButton = screen.getByLabelText(courseMediaMessages.playCourseIntroductionVideo.defaultMessage); | ||
|
|
||
| await userEvent.click(videoButton); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByRole('dialog')).toBeInTheDocument(); | ||
| expect(screen.getByTitle(genericMessages.videoIframeTitle.defaultMessage)).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| it('should handle course without video correctly', async () => { | ||
| const courseWithoutVideo = { | ||
| ...mockCourseAboutResponse, | ||
| media: { | ||
| ...mockCourseAboutResponse.media, | ||
| courseVideo: { | ||
| uri: null, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| mockFetchCourseAboutData.mockReturnValue(courseWithoutVideo); | ||
|
|
||
| render(<CourseAboutPage />); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.queryByLabelText( | ||
| courseMediaMessages.playCourseIntroductionVideo.defaultMessage, | ||
| )).not.toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| it('should display enrollment button for non-enrolled user', async () => { | ||
| const courseData = { | ||
| ...mockCourseAboutResponse, | ||
| enrollment: { isActive: false }, | ||
| canEnroll: true, | ||
| }; | ||
|
|
||
| mockFetchCourseAboutData.mockReturnValue(courseData); | ||
|
|
||
| render(<CourseAboutPage />); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByRole('button', { | ||
| name: messages.enrollNowBtn.defaultMessage, | ||
| })).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| it('should display enrolled status for enrolled user', async () => { | ||
| mockGetAuthenticatedUser.mockReturnValue({ username: 'testuser' }); | ||
|
|
||
| const courseData = { | ||
| ...mockCourseAboutResponse, | ||
| enrollment: { isActive: true }, | ||
| showCoursewareLink: true, | ||
| }; | ||
|
|
||
| mockFetchCourseAboutData.mockReturnValue(courseData); | ||
|
|
||
| render(<CourseAboutPage />); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByText(messages.statusMessageEnrolled.defaultMessage)).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| it('should handle course full scenario', async () => { | ||
| const courseData = { | ||
| ...mockCourseAboutResponse, | ||
| isCourseFull: true, | ||
| canEnroll: false, | ||
| }; | ||
|
|
||
| mockFetchCourseAboutData.mockReturnValue(courseData); | ||
|
|
||
| render(<CourseAboutPage />); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByText(messages.statusMessageFull.defaultMessage)).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] Should we add empty or pre-defined
LEARNING_BASE_URLsettings to.envand.env.developmentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, thanks