-
Notifications
You must be signed in to change notification settings - Fork 78
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
Feat course optimizer page #1533
base: master
Are you sure you want to change the base?
Conversation
@@ -47,6 +48,7 @@ export default function initializeStore(preloadedState = undefined) { | |||
processingNotification: processingNotificationReducer, | |||
helpUrls: helpUrlsReducer, | |||
courseExport: courseExportReducer, | |||
courseOptimizer: courseOptimizerReducer, |
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.
Is there a reason for putting this in the Redux state and for implementing all this new code as JavaScript instead of TypeScript? I would really prefer that all net-new modules be using TypeScript, React Context, and React Query instead of JS and Redux, as recommended in OEP-67.
Is there something more I can do to raise awareness of this?
}; | ||
|
||
CourseOptimizerPage.defaultProps = {}; | ||
export default injectIntl(CourseOptimizerPage); |
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.
courseId: PropTypes.string.isRequired, | ||
}; | ||
|
||
CourseOptimizerPage.defaultProps = {}; |
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.
Don't use defaultProps
- it's deprecated.
CourseOptimizerPage.propTypes = { | ||
intl: intlShape.isRequired, | ||
courseId: PropTypes.string.isRequired, | ||
}; |
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.
I strongly prefer TypeScript types over propTypes
, because TypeScript types get checked by CI whereas propTypes warnings are routinely ignored. Open up the JS console on any authoring MFE page in your browser, and you'll see the problem.
beforeEach(() => { | ||
initializeMockApp({ | ||
authenticatedUser: { | ||
userId: 3, | ||
username: 'abc123', | ||
administrator: true, | ||
roles: [], | ||
}, | ||
}); | ||
axiosMock = new MockAdapter(getAuthenticatedHttpClient()); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); |
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.
Instead of all this boilerplate, you can just use
const { axiosMock } = initializeMocks();
as the first line of each test case. You can then remove the beforeEach
and afterEach
you have here, because initializeMocks
takes care of that all for you, including jest.clearAllMocks();
.
See
frontend-app-authoring/src/testUtils.tsx
Lines 152 to 162 in f86c609
/** | |
* Initialize common mocks that many of our React components will require. | |
* | |
* This should be called within each test case, or in `beforeEach()`. | |
* | |
* Returns the new `axiosMock` in case you need to mock out axios requests. | |
*/ | |
export function initializeMocks({ user = defaultUser, initialState = undefined }: { | |
user?: { userId: number, username: string }, | |
initialState?: Record<string, any>, // TODO: proper typing for our redux state | |
} = {}) { |
Description
Course Optimizer Page.
Depends on openedx/edx-platform#35887 - test together.
This is a draft. What's missing: