Skip to content

Commit

Permalink
vebt-767 FE - CT - Replace GI ratings environment variable with featu…
Browse files Browse the repository at this point in the history
…re toggle (#32800)

* vebt-767 FE - CT - Replace GI ratings environment variable with feature toggle

* VEBT-767 resolve failed test.
  • Loading branch information
GcioNapoleon authored Nov 4, 2024
1 parent 8728258 commit 0b2de99
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
15 changes: 7 additions & 8 deletions src/applications/gi/components/profile/InstitutionProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import { getScrollOptions } from 'platform/utilities/ui';
import scrollTo from 'platform/utilities/ui/scrollTo';
import environment from 'platform/utilities/environment';
import { VaLink } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
import { useFeatureToggle } from 'platform/utilities/feature-toggles';
import ProfilePageHeader from '../../containers/ProfilePageHeader';
Expand Down Expand Up @@ -60,7 +59,10 @@ export default function InstitutionProfile({
scrollTo('school-locations', getScrollOptions());
};
// environment variable to keep ratings out of production until ready
const isProduction = !environment.isProduction();
const isShowRatingsToggle = useToggleValue(
TOGGLE_NAMES.giComparisonToolShowRatings,
);

let stars = false;
let ratingCount = 0;
let institutionRatingIsNotNull = false;
Expand Down Expand Up @@ -93,10 +95,7 @@ export default function InstitutionProfile({
}
/** ************************************************************************ */
const displayStars =
isProduction &&
stars &&
isProduction &&
ratingCount >= MINIMUM_RATING_COUNT;
isShowRatingsToggle && stars && ratingCount >= MINIMUM_RATING_COUNT;

const institutionProfileId = 'institution-profile';
const profilePageHeaderId = 'profile-page-header';
Expand Down Expand Up @@ -141,7 +140,7 @@ export default function InstitutionProfile({
jumpToId="getting-started-with-benefits"
/>
{displayStars &&
isProduction && (
isShowRatingsToggle && (
<JumpLink label="Veteran ratings" jumpToId="veteran-ratings" />
)}
<JumpLink
Expand Down Expand Up @@ -264,7 +263,7 @@ export default function InstitutionProfile({
<GettingStartedWithBenefits />
</ProfileSection>
{displayStars &&
isProduction && (
isShowRatingsToggle && (
<ProfileSection label="Veteran ratings" id="veteran-ratings">
<div>
<SchoolRatings
Expand Down
21 changes: 13 additions & 8 deletions src/applications/gi/containers/search/ResultCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import classNames from 'classnames';
import appendQuery from 'append-query';
import { Link } from 'react-router-dom';
import recordEvent from 'platform/monitoring/record-event';
import environment from 'platform/utilities/environment';
import { useFeatureToggle } from 'platform/utilities/feature-toggles';

import {
addCompareInstitution,
removeCompareInstitution,
Expand All @@ -24,9 +25,6 @@ import { CautionFlagAdditionalInfo } from '../../components/CautionFlagAdditiona
import RatingsStars from '../../components/profile/schoolRatings/RatingsStars';
import SchoolClassification from '../../components/SchoolClassification';

// environment variable to keep ratings out of production until ready
const isProduction = !environment.isProduction();

export function ResultCard({
compare,
estimated,
Expand Down Expand Up @@ -57,6 +55,11 @@ export function ResultCard({
programLengthInHours,
type,
} = institution;
const { useToggleValue, TOGGLE_NAMES } = useFeatureToggle();
// environment variable to keep ratings out of production until ready
const isShowRatingsToggle = useToggleValue(
TOGGLE_NAMES.giComparisonToolShowRatings,
);

let ratingCount = 0;
let ratingAverage = false;
Expand Down Expand Up @@ -184,7 +187,7 @@ export function ResultCard({

// toggle for production/staging------------------------------------------------
let ratingsInformation = false;
if (isProduction) {
if (isShowRatingsToggle) {
const stars = convertRatingToStars(ratingAverage);
const displayStars = stars && ratingCount >= MINIMUM_RATING_COUNT;

Expand Down Expand Up @@ -223,12 +226,14 @@ export function ResultCard({
};

const estimateTuition = ({ qualifier, value }) => {
if (qualifier === '% of instate tuition') {
return <span>{value}% in-state</span>;
}
if (qualifier === null) {
return value;
}

if (qualifier === '% of instate tuition') {
return <span>{value}% in-state</span>;
}

const lesserVal = tuitionOutOfState
? Math.min(value, tuitionOutOfState)
: value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { expect } from 'chai';
import { waitFor } from '@testing-library/react';
import sinon from 'sinon';
import userEvent from '@testing-library/user-event';
import { Toggler } from '~/platform/utilities/feature-toggles';
import { mockConstants, renderWithStoreAndRouter } from '../../helpers';
import ResultCard from '../../../containers/search/ResultCard';

Expand Down Expand Up @@ -96,6 +97,9 @@ describe('<ResultCard>', () => {
{
initialState: {
constants: mockConstants(),
featureToggles: {
[Toggler.TOGGLE_NAMES.giComparisonToolShowRatings]: true,
},
},
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,5 +293,6 @@
"yellowRibbonAutomatedDateOnSchoolSearch": "yellow_ribbon_automated_date_on_school_search",
"showYellowRibbonTable": "show_yellow_ribbon_table",
"showLcInComparisonTool": "show_lc_in_comparison_tool",
"giComparisonToolShowRatings": "gi_comparison_tool_show_ratings",
"fsrWizard": "fsr_wizard"
}

0 comments on commit 0b2de99

Please sign in to comment.