Skip to content

Commit

Permalink
fix: removed usage of subs catalog consolidation feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Maham Akif authored and Maham Akif committed Feb 12, 2024
1 parent 975df0b commit 6098d3b
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/components/catalogInfoModal/CatalogInfoModal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('Course info modal works as expected', () => {
</IntlProvider>,
);
expect(
screen.queryByText('Included in business catalog'),
screen.queryByText('Included in subscription catalog'),
).toBeInTheDocument();
});
test('Renders Course info modal with no catalogs', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
checkAvailability,
checkSubscriptions,
} from '../../utils/catalogUtils';
import features from '../../config';

const nowDate = new Date(Date.now());

Expand Down Expand Up @@ -68,11 +67,9 @@ const CatalogCourseModalBanner = ({
messages['CatalogCourseModalBanner.bannerCatalogText'],
)}
</div>
{!features.CONSOLIDATE_SUBS_CATALOG && (
<div className="banner-subtitle small">
{checkSubscriptions(courseAssociatedCatalogs)}
</div>
)}
</div>
<div className="banner-section slash">/</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { Assignment, BookOpen, MoneyOutline } from '@edx/paragon/icons';
import messages from './CatalogCourseModalBanner.messages';
import { checkSubscriptions } from '../../utils/catalogUtils';
import features from '../../config';

const CatalogProgramModalBanner = ({
intl,
Expand Down Expand Up @@ -55,11 +54,9 @@ const CatalogProgramModalBanner = ({
messages['CatalogCourseModalBanner.bannerCatalogText'],
)}
</div>
{!features.CONSOLIDATE_SUBS_CATALOG && (
<div className="banner-subtitle small">
{checkSubscriptions(courseAssociatedCatalogs)}
</div>
)}
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ describe('Main Catalogs view works as expected', () => {
const listViewToggleButton = screen.getByLabelText('Card');
userEvent.click(listViewToggleButton);

await act(() => screen.findByText('Business'));
expect(screen.queryByText('Business')).toBeInTheDocument();
await act(() => screen.findByText('Subscription'));
expect(screen.queryByText('Subscription')).toBeInTheDocument();
});
test('all courses rendered in card view when search results available', () => {
render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import PropTypes from 'prop-types';

import React from 'react';
import messages from '../../CatalogSearchResults.messages';
import features from '../../../../config';

const CatalogBadges = ({ row }) => {
const intl = useIntl();
Expand All @@ -24,14 +23,6 @@ const CatalogBadges = ({ row }) => {
{intl.formatMessage(messages['catalogSearchResults.subscriptionBadge'])}
</Badge>
)}
{!features.CONSOLIDATE_SUBS_CATALOG
&& row.original.enterprise_catalog_query_titles.includes(
process.env.EDX_FOR_ONLINE_EDU_TITLE,
) && (
<Badge variant="light" className="padded-catalog">
{intl.formatMessage(messages['catalogSearchResults.educationBadge'])}
</Badge>
)}
</div>
);
};
Expand Down
12 changes: 1 addition & 11 deletions src/components/courseCard/CourseCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import messages from './CourseCard.messages';
import { CONTENT_TYPE_COURSE } from '../../constants';
import defaultCardHeader from '../../static/default-card-header-light.png';
import features from '../../config';

const CourseCard = ({
intl, onClick, original, learningType,
Expand Down Expand Up @@ -40,7 +39,6 @@ const CourseCard = ({

const imageSrc = card_image_url || defaultCardHeader;
const altText = `${title} course image`;
const businessBadgeMessageKey = features.CONSOLIDATE_SUBS_CATALOG ? 'courseCard.subscriptionBadge' : 'courseCard.businessBadge';

return (
<Card
Expand Down Expand Up @@ -76,15 +74,7 @@ const CourseCard = ({
variant="secondary"
className="business-catalog padded-catalog"
>
{intl.formatMessage(messages[businessBadgeMessageKey])}
</Badge>
)}
{!features.CONSOLIDATE_SUBS_CATALOG
&& enterprise_catalog_query_titles?.includes(
process.env.EDX_FOR_ONLINE_EDU_TITLE,
) && (
<Badge variant="light" className="padded-catalog">
{intl.formatMessage(messages['courseCard.educationBadge'])}
{intl.formatMessage(messages['courseCard.subscriptionBadge'])}
</Badge>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/courseCard/CourseCard.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('Course card works as expected', () => {
screen.queryByText(defaultProps.original.partners[0].name),
).toBeInTheDocument();
expect(screen.queryByText('$100 • Self paced')).toBeInTheDocument();
expect(screen.queryByText('Business')).toBeInTheDocument();
expect(screen.queryByText('Subscription')).toBeInTheDocument();
});
test('test card renders default image', async () => {
render(
Expand Down
10 changes: 0 additions & 10 deletions src/components/programCard/ProgramCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import defaultCardHeader from '@edx/brand/paragon/images/card-imagecap-fallback.png';
import messages from './ProgramCard.messages';
import { getCourses } from '../../utils/common';
import features from '../../config';

const ProgramCard = ({ intl, onClick, original }) => {
const {
Expand All @@ -29,9 +28,6 @@ const ProgramCard = ({ intl, onClick, original }) => {
const businessCatalogRequested = enterprise_catalog_query_titles?.includes(
process.env.EDX_FOR_BUSINESS_TITLE,
);
const eduCatalogRequested = enterprise_catalog_query_titles?.includes(
process.env.EDX_FOR_ONLINE_EDU_TITLE,
);
const imageSrc = card_image_url || defaultCardHeader;

return (
Expand Down Expand Up @@ -79,12 +75,6 @@ const ProgramCard = ({ intl, onClick, original }) => {
{intl.formatMessage(messages['ProgramCard.subscriptionBadge'])}
</Badge>
)}
{!features.CONSOLIDATE_SUBS_CATALOG
&& eduCatalogRequested && (
<Badge className="padded-catalog" variant="light">
{intl.formatMessage(messages['ProgramCard.educationBadge'])}
</Badge>
)}
</div>
</Card.Section>
</Card>
Expand Down
15 changes: 3 additions & 12 deletions src/utils/catalogUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@ import { EXEC_ED_TITLE } from '../constants';
const nowDate = new Date(Date.now());

function checkSubscriptions(courseAssociatedCatalogs) {
const inBusiness = courseAssociatedCatalogs.includes(
const inSubscription = courseAssociatedCatalogs.includes(
process.env.EDX_FOR_BUSINESS_TITLE,
);
const inEducation = courseAssociatedCatalogs.includes(
process.env.EDX_FOR_ONLINE_EDU_TITLE,
);
if (inBusiness && inEducation) {
return 'Included in education and business catalog';
}
if (inBusiness) {
return 'Included in business catalog';
}
if (inEducation) {
return 'Included in education catalog';
if (inSubscription) {
return 'Included in subscription catalog';
}
return false;
}
Expand Down

0 comments on commit 6098d3b

Please sign in to comment.