Skip to content

Commit

Permalink
fix: removing references to outdated variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kiram15 committed Oct 16, 2024
1 parent 57c70ff commit 8b8bf32
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/components/ContentHighlights/ContentHighlights.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ContentHighlights = ({ location, enterpriseGroupsV1 }) => {
const { state: locationState } = location;
const [toasts, setToasts] = useState([]);
const isEdxStaff = getAuthenticatedUser().administrator;
const [isSubGroup, setIsSubGroup] = useState(false);
const [hasBudgetGroup, setHasBudgetGroup] = useState(false);
const { enterpriseCuration: { enterpriseCuration } } = useContext(EnterpriseAppContext);
const intl = useIntl();

Expand All @@ -31,8 +31,8 @@ const ContentHighlights = ({ location, enterpriseGroupsV1 }) => {
try {
const response = await LmsApiService.fetchEnterpriseGroups();
response.data.results.forEach((group) => {
if (group.applies_to_all_contexts === false) {
setIsSubGroup(true);
if (group.group_type === 'budget') {
setHasBudgetGroup(true);
}
});
} catch (error) {
Expand Down Expand Up @@ -102,7 +102,7 @@ const ContentHighlights = ({ location, enterpriseGroupsV1 }) => {
description: 'Hero title for the highlights page.',
})}
/>
{isSubGroup && (
{hasBudgetGroup && (
<Alert variant="warning" className="mt-4 mb-0" icon={WarningFilled}>
<Alert.Heading>
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('<ContentHighlights>', () => {
});
it('Displays the alert if custom groups is enabled and user is staff', () => {
LmsApiService.fetchEnterpriseGroups.mockImplementation(() => Promise.resolve({
data: { results: [{ applies_to_all_contexts: true }] },
data: { results: [{ group_type: 'budget' }] },
}));
renderWithRouter(<ContentHighlightsWrapper location={{ state: {} }} />);
});
Expand Down
8 changes: 4 additions & 4 deletions src/components/Sidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const Sidebar = ({
const { canManageLearnerCredit } = useContext(EnterpriseSubsidiesContext);
const { FEATURE_CONTENT_HIGHLIGHTS } = getConfig();
const isEdxStaff = getAuthenticatedUser().administrator;
const [isSubGroup, setIsSubGroup] = useState(false);
const hideHighlightsForGroups = enterpriseGroupsV1 && isSubGroup && !isEdxStaff;
const [hasBudgetGroup, setHasBudgetGroup] = useState(false);
const hideHighlightsForGroups = enterpriseGroupsV1 && hasBudgetGroup && !isEdxStaff;
const intl = useIntl();

const getSidebarWidth = useCallback(() => {
Expand Down Expand Up @@ -89,8 +89,8 @@ const Sidebar = ({
// we only want to hide the feature if a customer has a group this does not
// apply to all contexts/include all users
response.data.results.forEach((group) => {
if (group.applies_to_all_contexts === false) {
setIsSubGroup(true);
if (group.group_type === 'budget') {
setHasBudgetGroup(true);
}
});
} catch (error) {
Expand Down
10 changes: 5 additions & 5 deletions src/containers/Sidebar/Sidebar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ describe('<Sidebar />', () => {
});

it.each([
{ appliesToAllContexts: true },
{ appliesToAllContexts: false },
])('hides highlights when we have groups with a subset of all learners (%s)', async ({ appliesToAllContexts }) => {
{ groupType: 'budget' },
{ groupType: 'flex' },
])('hides highlights when we have budget groups (%s)', async ({ groupType }) => {
getAuthenticatedUser.mockReturnValue({
administrator: false,
});
Expand All @@ -460,12 +460,12 @@ describe('<Sidebar />', () => {
},
});
LmsApiService.fetchEnterpriseGroups.mockImplementation(() => Promise.resolve({
data: { results: [{ applies_to_all_contexts: appliesToAllContexts }] },
data: { results: [{ group_type: groupType }] },
}));
render(<SidebarWrapper store={store} />);
const highlightsLink = screen.queryByRole('link', { name: 'Highlights' });
await waitFor(() => {
if (appliesToAllContexts) {
if (groupType === 'flex') {
expect(highlightsLink).toBeInTheDocument();
} else {
expect(highlightsLink).not.toBeInTheDocument();
Expand Down

0 comments on commit 8b8bf32

Please sign in to comment.