Skip to content

Conversation

@HammadAhmadWaqas
Copy link
Member

https://2u-internal.atlassian.net/browse/ENT-6111

If the active enterprise customer is not equal to the enrollment’s enterprise customer, return the incorrect_active_enterprise error from course-home:course-metadata API

image

@codecov
Copy link

codecov bot commented Aug 30, 2022

Codecov Report

Base: 83.97% // Head: 84.09% // Increases project coverage by +0.11% 🎉

Coverage data is based on head (28a232c) compared to base (a7b584c).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 28a232c differs from pull request most recent head d08b4f4. Consider uploading reports for the commit d08b4f4 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #967      +/-   ##
==========================================
+ Coverage   83.97%   84.09%   +0.11%     
==========================================
  Files         260      264       +4     
  Lines        4475     4508      +33     
  Branches     1150     1155       +5     
==========================================
+ Hits         3758     3791      +33     
  Misses        697      697              
  Partials       20       20              
Impacted Files Coverage Δ
src/index.jsx 0.00% <ø> (ø)
...s/active-enteprise-alert/ActiveEnterpriseAlert.jsx 100.00% <100.00%> (ø)
src/alerts/active-enteprise-alert/hooks.js 100.00% <100.00%> (ø)
src/alerts/active-enteprise-alert/messages.js 100.00% <100.00%> (ø)
src/courseware/CoursewareRedirectLandingPage.jsx 66.66% <100.00%> (+6.66%) ⬆️
src/generic/CourseAccessErrorPage.jsx 100.00% <100.00%> (ø)
src/shared/access.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

{text}
<FormattedMessage
id="learning.activeEnterprise.alert"
description="Prompts the user to change active enterprise customer to access the course content."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prompts the user to log-in with the correct enterprise to access the course content

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

<PageRoute
path={`${path}/home/:courseId`}
render={({ match }) => {
global.location.assign(`/course/${match.params.courseId}/home`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use Redirect or history.push

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this whole file we are using the assign method, To make my code consistent with existing code I am using asign

Copy link

@muneebGH muneebGH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good hammad bhai 🎨
just a few comments.

useDispatch: () => mockDispatch,
useSelector: () => ({ courseStatus: mockCourseStatus }),
}));
jest.mock('./PageLoading', () => () => <div data-testid="PageLoading" />);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we change data-testid to the format like page-loading?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

history.push(accessDeniedUrl);
});

it('Displays loading in start on page rendering', async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async might not be needed here and in the 2 tests below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/index.jsx Outdated
<Switch>
<PageRoute exact path="/goal-unsubscribe/:token" component={GoalUnsubscribe} />
<PageRoute path="/redirect" component={CoursewareRedirectLandingPage} />
<PageRoute path="/course/:courseId/access_denied" component={CourseAccessErrorPage} />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen the convention of using dashed instead of underscores in URLs many times, like should it be access-denied?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

let mockData;
beforeAll(async () => {
await initializeTestStore({ excludeFetchCourse: true, excludeFetchSequence: true });
mockData = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this assignment be moved out of beforeAll method to where declaration of variable is, as it will stay the same on every iteration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

expect(screen.getByRole('alert')).toBeInTheDocument();
expect(screen.getByText('test message')).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'change enterprise now' })).toHaveAttribute(
'href', 'http://localhost:18000/enterprise/select/active/?success_url=http%3A%2F%2Flocalhost%2F',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this base url needs to be dynamic like ${getConfig().LMS_BASE_URL}/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Idea, fixing.

<Hyperlink
style={{ textDecoration: 'underline' }}
destination={
`${getConfig().LMS_BASE_URL}/enterprise/select/active/?success_url=${encodeURIComponent(global.location.href)}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we please add /enterprise/select/active/ in constants, so that It can be written in one place and imported everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our project, We are not saving URL paths anywhere, I tried to follow code patterns here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I think we should follow this practice to call it everywhere from one place.

@@ -0,0 +1,29 @@
/* eslint-disable import/prefer-default-export */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please remove this comment about disabling eslint. I think we don't need it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must add this because we are not returning any default component from here.

@HammadAhmadWaqas HammadAhmadWaqas merged commit f9806d0 into master Sep 7, 2022
@HammadAhmadWaqas HammadAhmadWaqas deleted the hammad/ENT-6111 branch September 7, 2022 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants