diff --git a/packages/shared/src/components/feeds/MobileFeedActions.spec.tsx b/packages/shared/src/components/feeds/MobileFeedActions.spec.tsx index f9311b8e9ff..b55702e34fb 100644 --- a/packages/shared/src/components/feeds/MobileFeedActions.spec.tsx +++ b/packages/shared/src/components/feeds/MobileFeedActions.spec.tsx @@ -1,16 +1,15 @@ import type { ReactElement } from 'react'; import React from 'react'; import { QueryClient } from '@tanstack/react-query'; -import { GrowthBook } from '@growthbook/growthbook'; import { render, screen } from '@testing-library/react'; import loggedUser from '../../../__tests__/fixture/loggedUser'; import { TestBootProvider } from '../../../__tests__/helpers/boot'; import { useReadingStreak } from '../../hooks/streaks'; import { MobileFeedActions } from './MobileFeedActions'; -const mockQuestButton = jest.fn( - (): ReactElement =>
Quest button
, -); +const mockQuestButton = jest.fn(() => ( +
Quest button
+)); jest.mock('next/dynamic', () => () => { return function MockDynamicComponent() { @@ -58,31 +57,16 @@ jest.mock('../quest/QuestButton', () => ({ const mockUseReadingStreak = useReadingStreak as jest.Mock; -const getGrowthBook = (isQuestsFeatureEnabled = true): GrowthBook => { - const gb = new GrowthBook(); - - gb.setFeatures({ - quests: { - defaultValue: isQuestsFeatureEnabled, - }, - }); - - return gb; -}; - const renderComponent = ({ optOutQuestSystem = false, - isQuestsFeatureEnabled = true, }: { optOutQuestSystem?: boolean; - isQuestsFeatureEnabled?: boolean; } = {}) => render( , @@ -99,7 +83,7 @@ describe('MobileFeedActions', () => { }); it('should render the quest entry next to the streak button', () => { - renderComponent({ optOutQuestSystem: false, isQuestsFeatureEnabled: true }); + renderComponent({ optOutQuestSystem: false }); const actionButtons = screen.getAllByTestId(/^(streak|quest)-button$/); @@ -112,7 +96,7 @@ describe('MobileFeedActions', () => { }); it('should hide the quest entry when opted out from quests', () => { - renderComponent({ optOutQuestSystem: true, isQuestsFeatureEnabled: true }); + renderComponent({ optOutQuestSystem: true }); expect(screen.queryByTestId('quest-button')).not.toBeInTheDocument(); }); diff --git a/packages/shared/src/components/header/QuestHeaderButton.tsx b/packages/shared/src/components/header/QuestHeaderButton.tsx index 1a6f743b6dc..70afaa9e69b 100644 --- a/packages/shared/src/components/header/QuestHeaderButton.tsx +++ b/packages/shared/src/components/header/QuestHeaderButton.tsx @@ -2,8 +2,6 @@ import type { ReactElement } from 'react'; import React from 'react'; import { useAuthContext } from '../../contexts/AuthContext'; import { useSettingsContext } from '../../contexts/SettingsContext'; -import { useConditionalFeature } from '../../hooks/useConditionalFeature'; -import { questsFeature } from '../../lib/featureManagement'; import { QuestButton } from '../quest/QuestButton'; interface QuestHeaderButtonProps { @@ -15,18 +13,8 @@ export function QuestHeaderButton({ }: QuestHeaderButtonProps): ReactElement | null { const { isLoggedIn, isAuthReady } = useAuthContext(); const { loadedSettings, optOutQuestSystem } = useSettingsContext(); - const { value: isQuestsFeatureEnabled } = useConditionalFeature({ - feature: questsFeature, - shouldEvaluate: isLoggedIn, - }); - if ( - !isAuthReady || - !loadedSettings || - !isLoggedIn || - isQuestsFeatureEnabled !== true || - optOutQuestSystem - ) { + if (!isAuthReady || !loadedSettings || !isLoggedIn || optOutQuestSystem) { return null; } diff --git a/packages/shared/src/components/layout/HeaderButtons.spec.tsx b/packages/shared/src/components/layout/HeaderButtons.spec.tsx index 185224f3f36..b9260073961 100644 --- a/packages/shared/src/components/layout/HeaderButtons.spec.tsx +++ b/packages/shared/src/components/layout/HeaderButtons.spec.tsx @@ -2,7 +2,6 @@ import type { ReactElement } from 'react'; import React from 'react'; import { QueryClient } from '@tanstack/react-query'; import { render, screen } from '@testing-library/react'; -import { GrowthBook } from '@growthbook/growthbook-react'; import { TestBootProvider } from '../../../__tests__/helpers/boot'; import { HeaderButtons } from './HeaderButtons'; @@ -34,53 +33,29 @@ jest.mock('../quest/QuestButton', () => ({ QuestButton: (): ReactElement =>
Quest button
, })); -const getGrowthBook = (isQuestsFeatureEnabled = true): GrowthBook => { - const gb = new GrowthBook(); - - gb.setFeatures({ - quests: { - defaultValue: isQuestsFeatureEnabled, - }, - }); - - return gb; -}; - const renderComponent = ({ optOutQuestSystem = false, - isQuestsFeatureEnabled = true, }: { optOutQuestSystem?: boolean; - isQuestsFeatureEnabled?: boolean; } = {}) => render( , ); describe('HeaderButtons', () => { - it('should render the quest entry when quest experiment is enabled', () => { - renderComponent({ optOutQuestSystem: false, isQuestsFeatureEnabled: true }); + it('should render the quest entry for logged-in users', () => { + renderComponent({ optOutQuestSystem: false }); expect(screen.getByText('Quest button')).toBeInTheDocument(); }); it('should hide the quest entry when opted out from quests', () => { - renderComponent({ optOutQuestSystem: true, isQuestsFeatureEnabled: true }); - - expect(screen.queryByText('Quest button')).not.toBeInTheDocument(); - }); - - it('should hide the quest entry when quest experiment is disabled', () => { - renderComponent({ - optOutQuestSystem: false, - isQuestsFeatureEnabled: false, - }); + renderComponent({ optOutQuestSystem: true }); expect(screen.queryByText('Quest button')).not.toBeInTheDocument(); }); diff --git a/packages/shared/src/components/profile/ProfileSettingsMenu.tsx b/packages/shared/src/components/profile/ProfileSettingsMenu.tsx index 9e6bf13b62f..a1b2dd22d3b 100644 --- a/packages/shared/src/components/profile/ProfileSettingsMenu.tsx +++ b/packages/shared/src/components/profile/ProfileSettingsMenu.tsx @@ -69,8 +69,6 @@ import { VolunteeringIcon } from '../icons/Volunteering'; import { GraduationIcon } from '../icons/Graduation'; import { MedalBadgeIcon } from '../icons/MedalBadge'; import { MedalIcon } from '../icons/Medal'; -import { questsFeature } from '../../lib/featureManagement'; -import { useConditionalFeature } from '../../hooks/useConditionalFeature'; type MenuItems = Record< string, @@ -87,11 +85,6 @@ const useAccountPageItems = ({ onClose }: { onClose?: () => void } = {}) => { const { logEvent } = useLogContext(); const { user } = useAuthContext(); - const { value: isQuestsFeatureEnabled } = useConditionalFeature({ - feature: questsFeature, - shouldEvaluate: !!user, - }); - const items = useMemo( () => defineMenuItems({ @@ -347,7 +340,7 @@ const useAccountPageItems = ({ onClose }: { onClose?: () => void } = {}) => { [logEvent, onClose, openModal, user?.username], ); - return { items, isQuestsFeatureEnabled }; + return { items }; }; interface ProfileSettingsMenuProps { @@ -363,8 +356,7 @@ export const InnerProfileSettingsMenu = ({ const { asPath } = useRouter(); const isMobile = useViewSize(ViewSize.MobileL); const hasAccessToCores = useHasAccessToCores(); - const { items: accountPageItems, isQuestsFeatureEnabled } = - useAccountPageItems({ onClose }); + const { items: accountPageItems } = useAccountPageItems({ onClose }); return (