@@ -14,6 +14,13 @@ import {
1414import { mockGraphQL } from '../../../__tests__/helpers/graphql' ;
1515import { BootApp } from '../../lib/boot' ;
1616import { GrowthBookProvider } from '../../components/GrowthBookProvider' ;
17+ import { useOnboardingActions } from '../auth/useOnboardingActions' ;
18+
19+ jest . mock ( '../auth/useOnboardingActions' , ( ) => ( {
20+ useOnboardingActions : jest . fn ( ) ,
21+ } ) ) ;
22+
23+ const mockUseOnboardingActions = useOnboardingActions as jest . Mock ;
1724
1825const client = new QueryClient ( ) ;
1926const noop = jest . fn ( ) ;
@@ -82,6 +89,7 @@ const feeds = [
8289describe ( 'useFeeds hook' , ( ) => {
8390 beforeEach ( ( ) => {
8491 client . clear ( ) ;
92+ mockUseOnboardingActions . mockReturnValue ( { isOnboardingComplete : true } ) ;
8593
8694 mockGraphQL ( {
8795 request : {
@@ -251,4 +259,34 @@ describe('useFeeds hook', () => {
251259 result . current . feeds ! . edges . find ( ( f ) => f . node . id === 'cf1' ) ,
252260 ) . toBeFalsy ( ) ;
253261 } ) ;
262+
263+ it ( 'should not request tag chip feeds until onboarding is complete' , async ( ) => {
264+ mockUseOnboardingActions . mockReturnValue ( { isOnboardingComplete : false } ) ;
265+
266+ let withoutChipsCalled = false ;
267+ mockGraphQL ( {
268+ request : {
269+ query : FEED_LIST_QUERY ,
270+ variables : {
271+ includeTagChipFeeds : false ,
272+ } ,
273+ } ,
274+ result : ( ) => {
275+ withoutChipsCalled = true ;
276+
277+ return {
278+ data : {
279+ feedList : {
280+ pageInfo : { endCursor : expect . any ( String ) , hasNextPage : false } ,
281+ edges : feeds ,
282+ } ,
283+ } ,
284+ } ;
285+ } ,
286+ } ) ;
287+
288+ renderHook ( ( ) => useFeeds ( ) , { wrapper : Wrapper } ) ;
289+
290+ await waitFor ( ( ) => expect ( withoutChipsCalled ) . toBe ( true ) ) ;
291+ } ) ;
254292} ) ;
0 commit comments