Keep the query params intact within the app. (#201)

Currently, if the user lands on one page with course_id and enroll action
params and navigates to another page with the MFE, the query params
are not passed to that other page and resulting in not enrolling into
the course.

Also add these query params into login and register payload.

VAN-415
This commit is contained in:
Waheed Ahmed
2021-03-11 20:01:16 +05:00
committed by GitHub
parent daae34dab6
commit c2d9a9384d
10 changed files with 105 additions and 39 deletions

View File

@@ -1,4 +1,5 @@
import processLink from './dataUtils';
import { LOGIN_PAGE } from '../constants';
import processLink, { updatePathWithQueryParams } from './dataUtils';
describe('processLink', () => {
it('should use the provided processLink function to', () => {
@@ -12,3 +13,20 @@ describe('processLink', () => {
expect(matches[2]).toEqual(expectedText);
});
});
describe('updatePathWithQueryParams', () => {
it('should append query params into the path', () => {
const params = '?course_id=testCourseId';
const expectedPath = `${LOGIN_PAGE}${params}`;
Object.defineProperty(window, 'location', {
value: {
href: 'http://localhost/',
search: params,
},
});
const updatedPath = updatePathWithQueryParams(LOGIN_PAGE);
expect(updatedPath).toEqual(expectedPath);
});
});