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:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user