@@ -22,9 +22,13 @@ import { useFeatureFlagEnabled, usePostHog } from "posthog-js/react"
2222import { PostHogEvents } from "@/common/constants"
2323
2424jest . mock ( "posthog-js/react" )
25+ jest . mock ( "ol-components/CarouselV2" , ( ) => ( {
26+ CarouselV2 : ( { children } : { children : React . ReactNode } ) => (
27+ < div > { children } </ div >
28+ ) ,
29+ } ) )
2530const mockedUseFeatureFlagEnabled = jest . mocked ( useFeatureFlagEnabled )
2631const mockedPostHogCapture = jest . fn ( )
27- jest . mock ( "posthog-js/react" )
2832jest . mocked ( usePostHog ) . mockReturnValue (
2933 // @ts -expect-error Not mocking all of posthog
3034 { capture : mockedPostHogCapture } ,
@@ -91,6 +95,13 @@ const setupAPIs = () => {
9195 attestations ,
9296 )
9397
98+ setMockResponse . get ( expect . stringContaining ( urls . search . resources ( ) ) , {
99+ count : 0 ,
100+ next : null ,
101+ previous : null ,
102+ results : [ ] ,
103+ } )
104+
94105 mockedUseFeatureFlagEnabled . mockReturnValue ( false )
95106 return { featured, media }
96107}
@@ -417,22 +428,27 @@ describe("Home Page Carousel", () => {
417428
418429 renderWithProviders ( < HomePage heroImageIndex = { 1 } /> )
419430
420- await screen . findAllByRole ( "tablist" ) . then ( ( [ featured , media ] ) => {
431+ await screen . findAllByRole ( "tablist" ) . then ( ( [ featured ] ) => {
421432 within ( featured ) . getByRole ( "tab" , { name : "All" } )
422433 within ( featured ) . getByRole ( "tab" , { name : "Free" } )
423434 within ( featured ) . getByRole ( "tab" , { name : "With Certificate" } )
424435 within ( featured ) . getByRole ( "tab" , {
425436 name : "Professional & Executive Learning" ,
426437 } )
427- within ( media ) . getByRole ( "tab" , { name : "All" } )
428- within ( media ) . getByRole ( "tab" , { name : "Videos" } )
429- within ( media ) . getByRole ( "tab" , { name : "Podcasts" } )
430438 } )
431439 } )
432440} )
433441
434442test ( "Headings" , async ( ) => {
435- const { featured, media } = setupAPIs ( )
443+ const { featured } = setupAPIs ( )
444+
445+ const videoShorts = [ learningResources . video ( ) , learningResources . video ( ) ]
446+ setMockResponse . get ( expect . stringContaining ( urls . search . resources ( ) ) , {
447+ count : videoShorts . length ,
448+ next : null ,
449+ previous : null ,
450+ results : videoShorts ,
451+ } )
436452
437453 renderWithProviders ( < HomePage heroImageIndex = { 1 } /> )
438454 await waitFor ( ( ) => {
@@ -442,8 +458,7 @@ test("Headings", async () => {
442458 // Featured course order is randomized on frontend, so just check for presence
443459 ...featured . results . map ( ( ) => ( { level : 3 , name : expect . any ( String ) } ) ) ,
444460 { level : 2 , name : "Continue Your Journey" } ,
445- { level : 2 , name : "Media" } ,
446- ...media . results . map ( ( result ) => ( { level : 3 , name : result . title } ) ) ,
461+ { level : 2 , name : "MIT Learning Moments" } ,
447462 { level : 2 , name : "Browse by Topic" } ,
448463 { level : 2 , name : "From Our Community" } ,
449464 { level : 2 , name : "MIT News & Events" } ,
0 commit comments