-
Notifications
You must be signed in to change notification settings - Fork 44
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: decodeURIComponent for locationId #189
fix: decodeURIComponent for locationId #189
Conversation
Thanks for the pull request, @vunguyen-dmt! 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. |
Signed CLA for github username: vunguyen-dmt. |
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #189 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 110 110
Lines 1079 1079
Branches 159 159
=========================================
Hits 1079 1079
☔ View full report in Codecov by Sentry. |
Hi @openedx/content-aurora! Would some be able to review/merge this for us? Thanks! |
Hi @openedx/content-aurora, just checking in on this :) |
I am confuse for what this pr suppose to do?
|
Hi @leangseu-edx. My courses were created back in Maple or Lilac through course_run API so some of them may have characters not from [A-z-az0-9-_.]. I believe in the current version (Palm) if courses were created in the web UI, they should not have any problems with decoding URLs. If this app was created with an assumption that course id only contains [A-z-az0-9_-.] characters then this PR is not needed. |
Can you update import * as platform from '@edx/frontend-platform';
import * as constants from './app';
jest.unmock('./app');
jest.mock('@edx/frontend-platform', () => {
const PUBLIC_PATH = '/test-public-path/';
return {
getConfig: () => ({ PUBLIC_PATH }),
PUBLIC_PATH,
};
});
describe('app constants', () => {
test('route path draws from public path and adds courseId', () => {
expect(constants.routePath()).toEqual(`${platform.PUBLIC_PATH}:courseId`);
});
describe('locationId', () => {
const domain = 'https://example.com';
test('returns trimmed pathname', () => {
const old = window.location;
Object.defineProperty(window, "location", {
value: new URL(`${domain}${platform.PUBLIC_PATH}somePath.jpg`),
writable: true,
});
expect(constants.locationId()).toEqual(window.location.pathname.replace(platform.PUBLIC_PATH, ''));
window.location = old;
});
test('handle none-standard characters pathName', () => {
const old = window.location;
const noneStandardPath = `${platform.PUBLIC_PATH}ORG+%C4%90+2023`;
const expectedPath = `${platform.PUBLIC_PATH}ORG+Đ+2023`;
Object.defineProperty(window, "location", {
value: new URL(`${domain}${noneStandardPath}`),
writable: true,
});
expect(noneStandardPath).not.toEqual(expectedPath);
expect(constants.locationId()).toEqual(expectedPath.replace(platform.PUBLIC_PATH, ''));
window.location = old;
});
});
}); |
Thanks! I updated it. |
Please update the entire file. I added another test specifically for this one and the previous test wasn't working properly. |
Hi @leangseu-edx! Would you mind enabling tests again for this PR? |
Hi @vunguyen-dmt! It looks like there is a failing test - would you mind having a look? Thanks! |
Hi @vunguyen-dmt! Just following up on this :) |
I can do some JavaScript, but I don't know much about writing Reactjs unit tests. |
I've copied these code to apps.test.js. Is there anything else? |
Hi @leangseu-edx! Would you be able to help with the author's question, and re-enable checks to run? |
af4d469
to
9bcdd34
Compare
Squashed commit of the following: commit af4d469 Author: Vu Nguyen <[email protected]> Date: Wed Oct 4 11:27:58 2023 +0700 update test cases commit d0c28fb Merge: 1f4d50b 5492520 Author: vunguyen-dmt <[email protected]> Date: Wed Oct 4 11:22:24 2023 +0700 Merge branch 'openedx:master' into fix_location_id_error commit 1f4d50b Merge: a280a35 eb73457 Author: Vu Nguyen <[email protected]> Date: Fri Jul 21 03:45:05 2023 +0700 Merge branch 'fix_location_id_error' of https://github.com/vunguyen-dmt/frontend-app-ora-grading into fix_location_id_error commit a280a35 Author: Vu Nguyen <[email protected]> Date: Fri Jul 21 03:44:28 2023 +0700 fix: decodeURIComponent for locationId commit eb73457 Author: Vu Nguyen <[email protected]> Date: Fri Jul 21 03:41:28 2023 +0700 update src/data/constants/app.test.js commit 513dd32 Merge: e899846 78ada8c Author: vunguyen-dmt <[email protected]> Date: Wed Jul 19 16:12:14 2023 +0700 Merge branch 'master' into fix_location_id_error commit e899846 Author: Vu Nguyen <[email protected]> Date: Thu Jun 8 10:29:45 2023 +0700 fix: decodeURIComponent for locationId
9bcdd34
to
86cce77
Compare
@vunguyen-dmt 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
The current code is wrong for this case (localtion id contains characters like: Đ) :
https://apps.demo.openedx.overhang.io/ora-grading/block-v1:ORG+Đ001+2023+type@openassessment+block@14709d5612014c57befb3c278b3b9b4f
Current code:
This PR code
The localtionId is used in initialize request
{LMS_BASE_URL}/api/ora_staff_grader/initialize?oraLocation={locationId}