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
fix: getting course-id when public path is set, closes #126 #127
Conversation
Thanks for the pull request, @ghassanmas! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #127 +/- ##
==========================================
+ Coverage 82.91% 82.96% +0.05%
==========================================
Files 46 46
Lines 679 681 +2
Branches 132 132
==========================================
+ Hits 563 565 +2
Misses 116 116
☔ View full report in Codecov by Sentry. |
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.
@ghassanmas, thanks for this! It looks like this fixes it, but do you mind adding a couple of unit tests, one with the subpath set and one without? This will make sure future changes don't break this for either use case.
@arbrandes Make sense.
|
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.
@ghassanmas While I was looking at a similar issue and I also noticed another place that would show a similar issue.
There is a card at the bottom of the bulk email that provides a Course Info
link and that also misses the course ID. Attaching the screenshot below.
While you're working on this, I thought I'd mention it here.
I guess this is the place that might need a change as well.
That's just it: I don't think there are. We've been neglecting these tests in the rush to fix MFEs prior to release, but it is a mistake that will eventually bite us. If you want I can whip up an example here and submit a PR to your branch. |
We could do this, but I don't think it's a great idea: there might (and probably are) legitimate uses of |
@arbrandes, I will play with it a bit, and commit something for you to see, if it looks good, then I would use for the second issue @arslanashraf7 raised. Regarding the eslint role, we can have a way stop it have stop it, assuming we document it somewhere for frotnend devs, when/how disable...etc. |
@arbrandes check the latest commit and let me know, if it looks good use for the other componenet. |
expect(linkEl.href).toEqual('http://localhost:18000/courses/test-course-id/instructor#view-course-info'); | ||
}); | ||
}); | ||
test('Page container with BackToInstructor compo with PUBLIC_PATH', async () => { |
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 repeating tests that are similar except for a few variables (in this case, PUBLIC_PATH
), I suggest you use test.each()
. Like this instance in frontend-app-discussions, for example.
Otherwise, this looks like a good place to include it!
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 think we need to re-architect what we're testing for, and where. Apologies, it turns out that that is not a very good place to test, actually.
The good news it that I found a test that does something similar to what I was thinking. See this one in frontend-app-ora-grading.
Here, since what's affected by this currently is BackToInstructor
, I think the test should be specific to this component, in a new BackToInstructor.test.jsx
. You can then try to mock window.location.pathname
to be something that contains a PUBLIC_PATH and something that doesn't, and check that both work.
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.
Made another pass, @ghassanmas. Thanks for bearing with me!
Oh, and can you please squash your commits so that the linter passes? |
8ebd65f
to
730efbb
Compare
@arbrandes I think I have addressed them and just test the both urls after building the mfe, and it behave as expected. |
src/components/bulk-email-tool/bulk-email-task-manager/BulkEmailPendingTasksAlert.jsx
Outdated
Show resolved
Hide resolved
This change change the way course-id is retrieved, in 1. BackToInstructor 2. BulkEmailPendingTasksAlert componenets, before it was resolved by guessing course-id index in the url, which would not be true if the public path is set something other than '/'. Since public path would shift the index of course-id in the url. Instead the course-id is resolved through react-router just like the container componenet, using the `useParams` hook.
The commit add two tests for the following componenets: 1. BackToInstructor 2. BulkEmailPendingTasksAlert Which tests course url when public path is set to something other than '/' and also when it is '/'.
@ghassanmas 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
@ghassanmas, looks good, thanks! Mind creating a backport to Palm? |
@arbrandes just did #130 not there is also the (#129) node v18 backport which we might need to merge first, given my changes here applied on top of Node 18 update thus tjhe backport if failiing node 16 tests, once #129 is merged I can rebease it. |
This fixes #126
This change, change the way course-id is used, is navigation
componenet, before it resolved by guessing course-id index
in the url, which would not be true if the public path is
set. Since public path would shift the index of course-id
in the url when set.
Instead the course-id is resolved through react-router just
like the container componenet, using the
useParams
hook.Testing:
If public path is not set, it shouldn't affect the behaviour, however if pubic path is set to anything, the back button would not work unless checking to this change