feat: added support to check if active enterprise is same as EnterpriseCourseEnrollment object (#967)

This commit is contained in:
Hammad Ahmad Waqas
2022-09-07 11:39:03 +05:00
committed by GitHub
parent a7b584c566
commit f9806d0759
12 changed files with 266 additions and 0 deletions

View File

@@ -483,6 +483,13 @@ describe('CoursewareContainer', () => {
expect(global.location.href).toEqual('http://localhost/redirect/consent?consentPath=data_sharing_consent_url');
});
it('should go to access denied page for a incorrect_active_enterprise error code', async () => {
const { courseMetadata } = setUpWithDeniedStatus('incorrect_active_enterprise');
await loadContainer();
expect(global.location.href).toEqual(`http://localhost/course/${courseMetadata.id}/access-denied`);
});
it('should go to course home for an authentication_required error code', async () => {
const { courseMetadata } = setUpWithDeniedStatus('authentication_required');
await loadContainer();

View File

@@ -40,6 +40,12 @@ export default () => {
global.location.assign(`${getConfig().LMS_BASE_URL}${consentPath}`);
}}
/>
<PageRoute
path={`${path}/home/:courseId`}
render={({ match }) => {
global.location.assign(`/course/${match.params.courseId}/home`);
}}
/>
</Switch>
</div>
);

View File

@@ -34,4 +34,18 @@ describe('CoursewareRedirectLandingPage', () => {
expect(redirectUrl).toHaveBeenCalledWith('http://localhost:18000/grant_data_sharing_consent');
});
it('Redirects to correct consent URL', () => {
const history = createMemoryHistory({
initialEntries: ['/redirect/home/course-v1:edX+DemoX+Demo_Course'],
});
render(
<Router history={history}>
<CoursewareRedirectLandingPage />
</Router>,
);
expect(redirectUrl).toHaveBeenCalledWith('/course/course-v1:edX+DemoX+Demo_Course/home');
});
});