-
Notifications
You must be signed in to change notification settings - Fork 81
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
}; | ||
|
||
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.
src/optimizer-page/data/api.test.js
Outdated
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 | |
} = {}) { |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1533 +/- ##
==========================================
- Coverage 93.08% 93.07% -0.01%
==========================================
Files 1051 1092 +41
Lines 20586 21617 +1031
Branches 4459 4654 +195
==========================================
+ Hits 19162 20120 +958
- Misses 1355 1425 +70
- Partials 69 72 +3 ☔ View full report in Codecov by Sentry. |
Hi @bradenmacdonald , I think I addressed your main concerns. Is there anything I missed or that you would like me to change? |
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.
This looks really good! My feedback comments are summarized below:
- We should show block displayName in results
- Should we display locked link count?
- Fix tooltip text for locked files (and text suggestion)
}, | ||
lockedInfoTooltip: { | ||
id: 'course-authoring.course-optimizer.lockedInfoTooltip', | ||
defaultMessage: 'These course files are "locked", so we cannot test whether they work or not.', |
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.
nit: "so we cannot verify if the link can access the file"
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.
not nit: The "
should be \'
id: string; | ||
displayName: string; | ||
blocks: { | ||
id: string; |
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.
We want to show the displayName
for blocks.
onSort: () => {}, | ||
width: 'col-3', | ||
hideHeader: true, | ||
}, |
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.
We should have show the displayName of the block. I think we can either add another column or replace the 'Go to Block' text with the displayName of the block.
<SectionCollapsible | ||
key={section.id} | ||
title={section.displayName} | ||
redItalics={intl.formatMessage(messages.brokenLinksNumber, { count: brokenLinkCounts[index] })} |
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.
Should we show a count for locked links as well?
I think it looks fantastic! Great job, and thanks so much. |
Description
Course Optimizer is a feature approved by the Openedx community that adds a "Course Optimizer" page to studio where users can run a scan of a course for broken links - links that point to pages that have a 404.
Depends on backend: openedx/edx-platform#35887 - test together.
This also requires adding a nav menu item to edx-platform legacy studio. That should be implemented before enabling the waffle flag on prod.
Links
Testing instructions