-
Notifications
You must be signed in to change notification settings - Fork 163
feat: import course in library stepper [FC-0112] #2567
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
Open
ChrisChV
wants to merge
9
commits into
openedx:master
Choose a base branch
from
open-craft:chris/FAL-4266-import-from-course-stepper
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d7c6081
feat: Import course modal created
ChrisChV 315ee6e
feat: Step 2 of course migration created
ChrisChV 5297e3b
refactor: Course List to enable select mode
ChrisChV a72d417
feat: Get course title from course details
ChrisChV 68edfa1
feat: Add previously migration chip
ChrisChV ec157ca
test: ImpoertStepperModal.test added
ChrisChV 0c3cad3
refactor: Extract SymmaryCard
ChrisChV 0406210
Merge branch 'master' into chris/FAL-4266-import-from-course-stepper
ChrisChV 3b32d20
style: Nits on the code
ChrisChV 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ ENABLE_UNIT_PAGE=true | |
| ENABLE_ASSETS_PAGE=false | ||
| ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN=true | ||
| ENABLE_CERTIFICATE_PAGE=true | ||
| ENABLE_COURSE_IMPORT_IN_LIBRARY=true | ||
| ENABLE_TAGGING_TAXONOMY_PAGES=true | ||
| BBB_LEARN_MORE_URL='' | ||
| INVITE_STUDENTS_EMAIL_TO="[email protected]" | ||
|
|
||
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
144 changes: 144 additions & 0 deletions
144
src/library-authoring/course-import/ImportStepperModal.test.tsx
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,144 @@ | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { | ||
| initializeMocks, | ||
| render, | ||
| screen, | ||
| fireEvent, | ||
| waitFor, | ||
| } from '@src/testUtils'; | ||
| import { initialState } from '@src/studio-home/factories/mockApiResponses'; | ||
| import { RequestStatus } from '@src/data/constants'; | ||
| import { type DeprecatedReduxState } from '@src/store'; | ||
| import studioHomeMock from '@src/studio-home/__mocks__/studioHomeMock'; | ||
| import { mockGetMigrationInfo } from '@src/studio-home/data/api.mocks'; | ||
| import { getCourseDetailsApiUrl } from '@src/course-outline/data/api'; | ||
| import { ImportStepperModal } from './ImportStepperModal'; | ||
|
|
||
| let axiosMock; | ||
| mockGetMigrationInfo.applyMock(); | ||
| type StudioHomeState = DeprecatedReduxState['studioHome']; | ||
|
|
||
| const libraryKey = 'lib:org:lib1'; | ||
| const mockOnClose = jest.fn(); | ||
| const numPages = 1; | ||
| const coursesCount = studioHomeMock.courses.length; | ||
|
|
||
| const renderComponent = (studioHomeState: Partial<StudioHomeState> = {}) => { | ||
| // Generate a custom initial state based on studioHomeCoursesRequestParams | ||
| const customInitialState: Partial<DeprecatedReduxState> = { | ||
| ...initialState, | ||
| studioHome: { | ||
| ...initialState.studioHome, | ||
| studioHomeData: { | ||
| courses: studioHomeMock.courses, | ||
| numPages, | ||
| coursesCount, | ||
| }, | ||
| loadingStatuses: { | ||
| ...initialState.studioHome.loadingStatuses, | ||
| courseLoadingStatus: RequestStatus.SUCCESSFUL, | ||
| }, | ||
| ...studioHomeState, | ||
| }, | ||
| }; | ||
|
|
||
| // Initialize the store with the custom initial state | ||
| const newMocks = initializeMocks({ initialState: customInitialState }); | ||
| const store = newMocks.reduxStore; | ||
| axiosMock = newMocks.axiosMock; | ||
|
|
||
| return { | ||
| ...render( | ||
| <ImportStepperModal | ||
| libraryKey={libraryKey} | ||
| onClose={mockOnClose} | ||
| isOpen | ||
| />, | ||
| ), | ||
| store, | ||
| }; | ||
| }; | ||
|
|
||
| describe('<ImportStepperModal />', () => { | ||
| it('should render correctly', async () => { | ||
| renderComponent(); | ||
| // Renders the stepper header | ||
| expect(await screen.findByText('Select Course')).toBeInTheDocument(); | ||
| expect(await screen.findByText('Review Import Details')).toBeInTheDocument(); | ||
|
|
||
| // Renders the course list and previously imported chip | ||
| expect(screen.getByText(/managing risk in the information age/i)).toBeInTheDocument(); | ||
| expect(screen.getByText(/run 0/i)).toBeInTheDocument(); | ||
| expect(await screen.findByText('Previously Imported')).toBeInTheDocument(); | ||
|
|
||
| // Renders cancel and next step buttons | ||
| expect(screen.getByRole('button', { name: /cancel/i })).toBeInTheDocument(); | ||
| expect(screen.getByRole('button', { name: /next step/i })).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should cancel the import', async () => { | ||
| const user = userEvent.setup(); | ||
| renderComponent(); | ||
|
|
||
| const cancelButon = await screen.findByRole('button', { name: /cancel/i }); | ||
| await user.click(cancelButon); | ||
|
|
||
| expect(mockOnClose).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should go to review import details step', async () => { | ||
| const user = userEvent.setup(); | ||
| renderComponent(); | ||
| axiosMock.onGet(getCourseDetailsApiUrl('course-v1:HarvardX+123+2023')).reply(200, { | ||
| courseId: 'course-v1:HarvardX+123+2023', | ||
| title: 'Managing Risk in the Information Age', | ||
| subtitle: '', | ||
| org: 'HarvardX', | ||
| description: 'This is a test course', | ||
| }); | ||
|
|
||
| const nextButton = await screen.findByRole('button', { name: /next step/i }); | ||
| expect(nextButton).toBeDisabled(); | ||
|
|
||
| // Select a course | ||
| const courseCard = screen.getAllByRole('radio')[0]; | ||
| await fireEvent.click(courseCard); | ||
| expect(courseCard).toBeChecked(); | ||
|
|
||
| // Click next | ||
| expect(nextButton).toBeEnabled(); | ||
| await user.click(nextButton); | ||
|
|
||
| await waitFor(async () => expect(await screen.findByText( | ||
| /managing risk in the information age is being analyzed for review prior to import/i, | ||
| )).toBeInTheDocument()); | ||
|
|
||
| expect(screen.getByText('Analysis Summary')).toBeInTheDocument(); | ||
| expect(screen.getByText('Import Details')).toBeInTheDocument(); | ||
| // The import details is loading | ||
| expect(screen.getByText('The selected course is being analyzed for import and review')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('the course should remain selected on back', async () => { | ||
| const user = userEvent.setup(); | ||
| renderComponent(); | ||
|
|
||
| const nextButton = await screen.findByRole('button', { name: /next step/i }); | ||
| expect(nextButton).toBeDisabled(); | ||
|
|
||
| // Select a course | ||
| const courseCard = screen.getAllByRole('radio')[0]; | ||
| await fireEvent.click(courseCard); | ||
| expect(courseCard).toBeChecked(); | ||
|
|
||
| // Click next | ||
| expect(nextButton).toBeEnabled(); | ||
| await user.click(nextButton); | ||
|
|
||
| const backButton = await screen.getByRole('button', { name: /back/i }); | ||
| await user.click(backButton); | ||
|
|
||
| expect(screen.getByText(/managing risk in the information age/i)).toBeInTheDocument(); | ||
| expect(courseCard).toBeChecked(); | ||
| }); | ||
| }); |
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.
If we go for the route, I think we don't need this flag, as we can test it directly using the url.
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.
The env flag is a requirement in the ticket #2524