Skip to content

Commit

Permalink
feat(alerts): guard series suggestions behind feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
anandaroop committed Dec 14, 2023
1 parent 4826e38 commit d81558a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
SavedSearchStoreProvider,
savedSearchModel,
} from "app/Scenes/SavedSearchAlert/SavedSearchStore"
import { __globalStoreTestUtils__ } from "app/store/GlobalStore"
import { flushPromiseQueue } from "app/utils/tests/flushPromiseQueue"
import { setupTestWrapper } from "app/utils/tests/setupTestWrapper"
import { Suspense } from "react"
Expand All @@ -25,6 +26,10 @@ jest.mock("@react-navigation/native", () => {
})

describe("SavedSearchSuggestedFilters", () => {
beforeEach(() => {
__globalStoreTestUtils__?.injectFeatureFlags({ AREnableArtistSeriesSuggestions: true })
})

const { renderWithRelay } = setupTestWrapper({
Component: () => (
<Suspense fallback={null}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ import { SavedSearchFilterPill } from "app/Scenes/SavedSearchAlert/Components/Sa
import { CreateSavedSearchAlertNavigationStack } from "app/Scenes/SavedSearchAlert/SavedSearchAlertModel"
import { SavedSearchStore } from "app/Scenes/SavedSearchAlert/SavedSearchStore"
import { isValueSelected, useSavedSearchFilter } from "app/Scenes/SavedSearchAlert/helpers"
import { useFeatureFlag } from "app/utils/hooks/useFeatureFlag"
import { Suspense } from "react"
import { graphql, useLazyLoadQuery } from "react-relay"
import { useTracking } from "react-tracking"

const SUPPORTED_SEARCH_CRITERIA = [
SearchCriteria.additionalGeneIDs,
SearchCriteria.artistSeriesIDs,
SearchCriteria.attributionClass,
SearchCriteria.priceRange,
]

export const SavedSearchSuggestedFilters: React.FC<{}> = () => {
const tracking = useTracking()
const isArtistSeriesSuggestionEnabled = useFeatureFlag("AREnableArtistSeriesSuggestions")

if (isArtistSeriesSuggestionEnabled) {
SUPPORTED_SEARCH_CRITERIA.push(SearchCriteria.artistSeriesIDs)
}

const navigation =
useNavigation<NavigationProp<CreateSavedSearchAlertNavigationStack, "CreateSavedSearchAlert">>()
Expand All @@ -41,12 +46,13 @@ export const SavedSearchSuggestedFilters: React.FC<{}> = () => {
savedSearchSuggestedFiltersFetchQuery,
{
attributes: { artistIDs: attributes.artistIDs },
source: currentArtworkID
? {
type: "ARTWORK",
id: currentArtworkID,
}
: undefined,
source:
isArtistSeriesSuggestionEnabled && currentArtworkID
? {
type: "ARTWORK",
id: currentArtworkID,
}
: undefined,
}
)

Expand Down Expand Up @@ -90,7 +96,7 @@ export const SavedSearchSuggestedFilters: React.FC<{}> = () => {
handleAdditionalGeneIDsPress(value)
break
case SearchCriteria.artistSeriesIDs:
handleArtistSeriesPress(value)
isArtistSeriesSuggestionEnabled && handleArtistSeriesPress(value)
break

// These are all string values
Expand Down
6 changes: 6 additions & 0 deletions src/app/store/config/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ export const features: { [key: string]: FeatureDescriptor } = {
showInDevMenu: true,
echoFlagKey: "AREnablePartnerOffer",
},
AREnableArtistSeriesSuggestions: {
description: "Enable artist series suggestions",
readyForRelease: true,
showInDevMenu: true,
echoFlagKey: "AREnableArtistSeriesSuggestions",
},
}

export interface DevToggleDescriptor {
Expand Down

0 comments on commit d81558a

Please sign in to comment.