Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/components/UI/Predict/constants/feedConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export interface PredictFeedTabConfig {
export interface PredictFeedConfig {
id: PredictFeedId;
titleKey: string;
/** Whether the feed exposes user-selectable filter chips. Defaults to true. */
showFilterBar?: boolean;
header: {
showBackButton: boolean;
showSearchButton: boolean;
Expand Down Expand Up @@ -189,6 +191,7 @@ export const PREDICT_FEED_REGISTRY: Record<PredictFeedId, PredictFeedConfig> = {
live: {
id: 'live',
titleKey: 'predict.feed.live',
showFilterBar: false,
header: {
showBackButton: true,
showSearchButton: true,
Expand Down
12 changes: 12 additions & 0 deletions app/components/UI/Predict/hooks/usePredictFeedConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,23 @@ describe('usePredictFeedConfig', () => {
});

describe('static-only feeds', () => {
it('hides the filter bar for the Live feed', () => {
const { result } = renderHook(() => usePredictFeedConfig('live'));

expect(result.current.showFilterBar).toBe(false);
});

it('exposes static filters and disables dynamic fetching', () => {
const { result } = renderHook(() => usePredictFeedConfig('live'));

expect(ids(result.current.filters)).toEqual(['live']);
expect(result.current.filters[0].isDynamic).toBe(false);
expect(result.current.activeFilter?.params).toEqual({
status: 'open',
order: 'volume24hr',
limit: 10,
live: true,
});
expect(result.current.dynamicFilters.status).toBe('idle');
expect(mockUsePredictFilterOptions).toHaveBeenCalledWith(
{ source: 'related-tags' },
Expand Down
3 changes: 3 additions & 0 deletions app/components/UI/Predict/hooks/usePredictFeedConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export interface PredictFeedConfigResult {
tabs: PredictFeedTabSummary[];
/** Hidden for single-tab feeds; filters still render for that one tab. */
showTabBar: boolean;
/** Hidden when the active feed has no user-selectable filters. */
showFilterBar: boolean;
activeTabId?: string;
setActiveTabId: (id: string) => void;
/** Static + deduped dynamic filters for the active tab. */
Expand Down Expand Up @@ -356,6 +358,7 @@ export const usePredictFeedConfig = (
header: config?.header,
tabs,
showTabBar: tabs.length > 1,
showFilterBar: config?.showFilterBar ?? true,
activeTabId: resolvedActiveTabId,
setActiveTabId,
filters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const feedConfigResult = (
{ id: 'tennis', titleKey: 'predict.feed.tabs.tennis' },
],
showTabBar: true,
showFilterBar: true,
activeTabId: 'basketball',
setActiveTabId: mockSetActiveTabId,
filters: [
Expand Down Expand Up @@ -295,13 +296,14 @@ describe('PredictFeedView', () => {
expect(screen.getAllByText('Tennis').length).toBeGreaterThan(0);
});

it('hides the tab bar for a single-tab feed but still renders filters', () => {
it('hides the tab and filter bars for the Live feed', () => {
mockUsePredictFeedConfig.mockReturnValue(
feedConfigResult({
feedId: 'live',
titleKey: 'predict.feed.live',
tabs: [{ id: 'live', titleKey: 'predict.feed.live' }],
showTabBar: false,
showFilterBar: false,
activeTabId: 'live',
filters: [
{
Expand All @@ -321,8 +323,8 @@ describe('PredictFeedView', () => {
screen.queryByTestId(PredictFeedViewSelectorsIDs.TABS),
).not.toBeOnTheScreen();
expect(
screen.getByTestId(PredictFeedViewSelectorsIDs.FILTERS),
).toBeOnTheScreen();
screen.queryByTestId(PredictFeedViewSelectorsIDs.FILTERS),
).not.toBeOnTheScreen();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const PredictFeedView: React.FC = () => {
header,
tabs,
showTabBar,
showFilterBar,
activeTabId,
setActiveTabId,
filters,
Expand Down Expand Up @@ -391,12 +392,14 @@ const PredictFeedView: React.FC = () => {
/>
)}

<PredictChipList
chips={chips}
activeChipKey={activeFilterId ?? ''}
onChipSelect={handleFilterSelect}
testID={PredictFeedViewSelectorsIDs.FILTERS}
/>
{showFilterBar && (
<PredictChipList
chips={chips}
activeChipKey={activeFilterId ?? ''}
onChipSelect={handleFilterSelect}
testID={PredictFeedViewSelectorsIDs.FILTERS}
/>
)}

{renderContent()}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,23 @@ describe('PredictFeedView (component view)', () => {
),
).toBeOnTheScreen();
});

it('hides Live filter chips while requesting only live markets', async () => {
const { findByTestId, queryByTestId } = renderPredictFeedView({
initialParams: { feedId: 'live' },
});

await findByTestId(
PredictFeedViewSelectorsIDs.EMPTY_STATE,
{},
{ timeout: 10000 },
);

expect(
queryByTestId(PredictFeedViewSelectorsIDs.FILTERS),
).not.toBeOnTheScreen();
expect(Engine.context.PredictController.listMarkets).toHaveBeenCalledWith(
expect.objectContaining({ live: true }),
);
});
});
Loading