@@ -3596,6 +3596,7 @@ describe("DiscoveryStreamFeed", () => {
35963596 const expectedData = {
35973597 lastUpdated : 0 ,
35983598 personalized : false ,
3599+ sectionsEnabled : undefined ,
35993600 data : {
36003601 settings : { } ,
36013602 sections : [ ] ,
@@ -3623,6 +3624,123 @@ describe("DiscoveryStreamFeed", () => {
36233624 } ,
36243625 } ;
36253626
3627+ assert . deepEqual ( feedData , expectedData ) ;
3628+ } ) ;
3629+ it ( "should fetch proper data from getComponentFeed with sections enabled" , async ( ) => {
3630+ setPref ( "discoverystream.sections.enabled" , true ) ;
3631+ const fakeCache = { } ;
3632+ sandbox . stub ( feed . cache , "get" ) . returns ( Promise . resolve ( fakeCache ) ) ;
3633+ sandbox . stub ( feed , "rotate" ) . callsFake ( val => val ) ;
3634+ sandbox
3635+ . stub ( feed , "scoreItems" )
3636+ . callsFake ( val => ( { data : val , filtered : [ ] , personalized : false } ) ) ;
3637+ sandbox . stub ( feed , "fetchFromEndpoint" ) . resolves ( {
3638+ recommendedAt : 1755834072383 ,
3639+ surfaceId : "NEW_TAB_EN_US" ,
3640+ data : [
3641+ {
3642+ corpusItemId : "decaf-c0ff33" ,
3643+ scheduledCorpusItemId : "matcha-latte-ff33c1" ,
3644+ excerpt : "excerpt" ,
3645+ iconUrl : "iconUrl" ,
3646+ imageUrl : "imageUrl" ,
3647+ isTimeSensitive : true ,
3648+ publisher : "publisher" ,
3649+ receivedRank : 0 ,
3650+ tileId : 12345 ,
3651+ title : "title" ,
3652+ topic : "topic" ,
3653+ url : "url" ,
3654+ features : { } ,
3655+ } ,
3656+ ] ,
3657+ feeds : {
3658+ "section-1" : {
3659+ title : "Section 1" ,
3660+ subtitle : "Subtitle 1" ,
3661+ receivedFeedRank : 1 ,
3662+ layout : "cards" ,
3663+ iab : "iab-category" ,
3664+ isInitiallyVisible : true ,
3665+ recommendations : [
3666+ {
3667+ corpusItemId : "decaf-c0ff34" ,
3668+ scheduledCorpusItemId : "matcha-latte-ff33c2" ,
3669+ excerpt : "section excerpt" ,
3670+ iconUrl : "sectionIconUrl" ,
3671+ imageUrl : "sectionImageUrl" ,
3672+ isTimeSensitive : false ,
3673+ publisher : "section publisher" ,
3674+ receivedRank : 1 ,
3675+ title : "section title" ,
3676+ topic : "section topic" ,
3677+ url : "section url" ,
3678+ features : { } ,
3679+ } ,
3680+ ] ,
3681+ } ,
3682+ } ,
3683+ } ) ;
3684+
3685+ const feedData = await feed . getComponentFeed ( "url" ) ;
3686+ const expectedData = {
3687+ lastUpdated : 0 ,
3688+ personalized : false ,
3689+ sectionsEnabled : true ,
3690+ data : {
3691+ settings : { } ,
3692+ sections : [
3693+ {
3694+ sectionKey : "section-1" ,
3695+ title : "Section 1" ,
3696+ subtitle : "Subtitle 1" ,
3697+ receivedRank : 1 ,
3698+ layout : "cards" ,
3699+ iab : "iab-category" ,
3700+ visible : true ,
3701+ } ,
3702+ ] ,
3703+ interestPicker : { } ,
3704+ recommendations : [
3705+ {
3706+ id : "decaf-c0ff33" ,
3707+ corpus_item_id : "decaf-c0ff33" ,
3708+ scheduled_corpus_item_id : "matcha-latte-ff33c1" ,
3709+ excerpt : "excerpt" ,
3710+ icon_src : "iconUrl" ,
3711+ isTimeSensitive : true ,
3712+ publisher : "publisher" ,
3713+ raw_image_src : "imageUrl" ,
3714+ received_rank : 0 ,
3715+ recommended_at : 1755834072383 ,
3716+ title : "title" ,
3717+ topic : "topic" ,
3718+ url : "url" ,
3719+ features : { } ,
3720+ } ,
3721+ {
3722+ id : "decaf-c0ff34" ,
3723+ corpus_item_id : "decaf-c0ff34" ,
3724+ scheduled_corpus_item_id : "matcha-latte-ff33c2" ,
3725+ excerpt : "section excerpt" ,
3726+ icon_src : "sectionIconUrl" ,
3727+ isTimeSensitive : false ,
3728+ publisher : "section publisher" ,
3729+ raw_image_src : "sectionImageUrl" ,
3730+ received_rank : 1 ,
3731+ recommended_at : 1755834072383 ,
3732+ title : "section title" ,
3733+ topic : "section topic" ,
3734+ url : "section url" ,
3735+ features : { } ,
3736+ section : "section-1" ,
3737+ } ,
3738+ ] ,
3739+ surfaceId : "NEW_TAB_EN_US" ,
3740+ status : "success" ,
3741+ } ,
3742+ } ;
3743+
36263744 assert . deepEqual ( feedData , expectedData ) ;
36273745 } ) ;
36283746 } ) ;
0 commit comments