@@ -1259,12 +1259,12 @@ mod tests {
12591259 json ! ( [ burnout_pocket( ) , multimatch_pocket( ) , ] ) ,
12601260 )
12611261 . with_record ( "yelp-suggestions" , "data-4" , json ! ( [ ramen_yelp( ) , ] ) )
1262- . with_record ( "yeld-suggestions" , "data-4" , json ! ( [ ramen_yelp( ) , ] ) )
12631262 . with_record ( "mdn-suggestions" , "data-5" , json ! ( [ array_mdn( ) , ] ) )
12641263 . with_icon ( good_place_eats_icon ( ) )
12651264 . with_icon ( california_icon ( ) )
12661265 . with_icon ( caltech_icon ( ) )
1267- . with_icon ( yelp_favicon ( ) )
1266+ . with_icon ( yelp_light_theme_icon ( ) )
1267+ . with_icon ( yelp_dark_theme_icon ( ) )
12681268 . with_icon ( multimatch_wiki_icon ( ) ) ,
12691269 ) ;
12701270
@@ -2758,68 +2758,165 @@ mod tests {
27582758 fn query_no_yelp_icon_data ( ) -> anyhow:: Result < ( ) > {
27592759 before_each ( ) ;
27602760
2761- let snapshot = Snapshot :: with_records ( json ! ( [ {
2762- "id" : "data-1" ,
2763- "type" : "yelp-suggestions" ,
2764- "last_modified" : 15 ,
2765- "attachment" : {
2766- "filename" : "data-1.json" ,
2767- "mimetype" : "application/json" ,
2768- "location" : "data-1.json" ,
2769- "hash" : "" ,
2770- "size" : 0 ,
2771- } ,
2772- } ] ) ) ?
2773- . with_data (
2774- "data-1.json" ,
2775- json ! ( [
2776- {
2761+ let store = TestStore :: new (
2762+ MockRemoteSettingsClient :: default ( )
2763+ . with_record ( "yelp-suggestions" , "data-1" , json ! ( [ {
2764+ "subjects" : [ "ramen" ] ,
2765+ "preModifiers" : [ ] ,
2766+ "postModifiers" : [ ] ,
2767+ "locationSigns" : [ ] ,
2768+ "yelpModifiers" : [ ] ,
2769+ "iconLightTheme" : "yelp-light-theme-icon" ,
2770+ "iconDarkTheme" : "yelp-dark-theme-icon" ,
2771+ "score" : 0.5
2772+ } ] ) )
2773+ ) ;
2774+
2775+ store. ingest ( SuggestIngestionConstraints :: default ( ) ) ;
2776+
2777+ assert_eq ! (
2778+ store. fetch_suggestions( SuggestionQuery :: yelp( "ramen" ) ) ,
2779+ vec![
2780+ Suggestion :: Yelp {
2781+ title: "ramen" . into( ) ,
2782+ url: "https://www.yelp.com/search?find_desc=ramen" . into( ) ,
2783+ icon_light_theme: None ,
2784+ icon_light_theme_mimetype: None ,
2785+ icon_dark_theme: None ,
2786+ icon_dark_theme_mimetype: None ,
2787+ score: 0.5 ,
2788+ has_location_sign: false ,
2789+ subject_exact_match: true ,
2790+ location_param: "find_loc" . into( ) ,
2791+ }
2792+ ] ,
2793+ ) ;
2794+ Ok ( ( ) )
2795+ }
2796+
2797+ #[ test]
2798+ fn query_full_yelp_icon_data ( ) -> anyhow:: Result < ( ) > {
2799+ before_each ( ) ;
2800+
2801+ let store = TestStore :: new (
2802+ MockRemoteSettingsClient :: default ( )
2803+ . with_record ( "yelp-suggestions" , "data-1" , json ! ( [ {
27772804 "subjects" : [ "ramen" ] ,
27782805 "preModifiers" : [ ] ,
27792806 "postModifiers" : [ ] ,
27802807 "locationSigns" : [ ] ,
27812808 "yelpModifiers" : [ ] ,
27822809 "icon" : "yelp-favicon" ,
2810+ "iconLightTheme" : "yelp-light-theme-icon" ,
2811+ "iconDarkTheme" : "yelp-dark-theme-icon" ,
27832812 "score" : 0.5
2784- } ,
2785- ] ) ,
2786- ) ?;
2813+ } ] ) )
2814+ . with_icon ( yelp_favicon ( ) )
2815+ . with_icon ( yelp_light_theme_icon ( ) )
2816+ . with_icon ( yelp_dark_theme_icon ( ) )
2817+ ) ;
27872818
2788- let store = unique_test_store ( SnapshotSettingsClient :: with_snapshot ( snapshot ) ) ;
2819+ store. ingest ( SuggestIngestionConstraints :: default ( ) ) ;
27892820
2790- store. ingest ( SuggestIngestionConstraints :: default ( ) ) ?;
2821+ assert_eq ! (
2822+ store. fetch_suggestions( SuggestionQuery :: yelp( "ramen" ) ) ,
2823+ vec![
2824+ Suggestion :: Yelp {
2825+ title: "ramen" . into( ) ,
2826+ url: "https://www.yelp.com/search?find_desc=ramen" . into( ) ,
2827+ icon_light_theme: Some ( "yelp-light-theme-icon-data" . into( ) ) ,
2828+ icon_light_theme_mimetype: Some ( "image/svg+xml" . into( ) ) ,
2829+ icon_dark_theme: Some ( "yelp-dark-theme-icon-data" . into( ) ) ,
2830+ icon_dark_theme_mimetype: Some ( "image/svg+xml" . into( ) ) ,
2831+ score: 0.5 ,
2832+ has_location_sign: false ,
2833+ subject_exact_match: true ,
2834+ location_param: "find_loc" . into( ) ,
2835+ }
2836+ ] ,
2837+ ) ;
2838+ Ok ( ( ) )
2839+ }
27912840
2792- let table = [ (
2793- "keyword = ramen; Yelp only" ,
2794- SuggestionQuery {
2795- keyword : "ramen" . into ( ) ,
2796- providers : vec ! [ SuggestionProvider :: Yelp ] ,
2797- limit : None ,
2798- } ,
2799- expect ! [ [ r#"
2800- [
2801- Yelp {
2802- url: "https://www.yelp.com/search?find_desc=ramen",
2803- title: "ramen",
2804- icon: None,
2805- icon_mimetype: None,
2806- score: 0.5,
2807- has_location_sign: false,
2808- subject_exact_match: true,
2809- location_param: "find_loc",
2810- },
2811- ]
2812- "# ] ] ,
2813- ) ] ;
2841+ #[ test]
2842+ fn query_only_light_theme_yelp_icon_data ( ) -> anyhow:: Result < ( ) > {
2843+ before_each ( ) ;
28142844
2815- for ( what, query, expect) in table {
2816- expect. assert_debug_eq (
2817- & store
2818- . query ( query)
2819- . with_context ( || format ! ( "Couldn't query store for {}" , what) ) ?,
2820- ) ;
2821- }
2845+ let store = TestStore :: new (
2846+ MockRemoteSettingsClient :: default ( )
2847+ . with_record ( "yelp-suggestions" , "data-1" , json ! ( [ {
2848+ "subjects" : [ "ramen" ] ,
2849+ "preModifiers" : [ ] ,
2850+ "postModifiers" : [ ] ,
2851+ "locationSigns" : [ ] ,
2852+ "yelpModifiers" : [ ] ,
2853+ "iconLightTheme" : "yelp-light-theme-icon" ,
2854+ "iconDarkTheme" : "yelp-dark-theme-icon" ,
2855+ "score" : 0.5
2856+ } ] ) )
2857+ . with_icon ( yelp_light_theme_icon ( ) )
2858+ ) ;
2859+
2860+ store. ingest ( SuggestIngestionConstraints :: default ( ) ) ;
2861+
2862+ assert_eq ! (
2863+ store. fetch_suggestions( SuggestionQuery :: yelp( "ramen" ) ) ,
2864+ vec![
2865+ Suggestion :: Yelp {
2866+ title: "ramen" . into( ) ,
2867+ url: "https://www.yelp.com/search?find_desc=ramen" . into( ) ,
2868+ icon_light_theme: Some ( "yelp-light-theme-icon-data" . into( ) ) ,
2869+ icon_light_theme_mimetype: Some ( "image/svg+xml" . into( ) ) ,
2870+ icon_dark_theme: None ,
2871+ icon_dark_theme_mimetype: None ,
2872+ score: 0.5 ,
2873+ has_location_sign: false ,
2874+ subject_exact_match: true ,
2875+ location_param: "find_loc" . into( ) ,
2876+ }
2877+ ] ,
2878+ ) ;
2879+ Ok ( ( ) )
2880+ }
28222881
2882+ #[ test]
2883+ fn query_only_dark_theme_yelp_icon_data ( ) -> anyhow:: Result < ( ) > {
2884+ before_each ( ) ;
2885+
2886+ let store = TestStore :: new (
2887+ MockRemoteSettingsClient :: default ( )
2888+ . with_record ( "yelp-suggestions" , "data-1" , json ! ( [ {
2889+ "subjects" : [ "ramen" ] ,
2890+ "preModifiers" : [ ] ,
2891+ "postModifiers" : [ ] ,
2892+ "locationSigns" : [ ] ,
2893+ "yelpModifiers" : [ ] ,
2894+ "iconLightTheme" : "yelp-light-theme-icon" ,
2895+ "iconDarkTheme" : "yelp-dark-theme-icon" ,
2896+ "score" : 0.5
2897+ } ] ) )
2898+ . with_icon ( yelp_dark_theme_icon ( ) )
2899+ ) ;
2900+
2901+ store. ingest ( SuggestIngestionConstraints :: default ( ) ) ;
2902+
2903+ assert_eq ! (
2904+ store. fetch_suggestions( SuggestionQuery :: yelp( "ramen" ) ) ,
2905+ vec![
2906+ Suggestion :: Yelp {
2907+ title: "ramen" . into( ) ,
2908+ url: "https://www.yelp.com/search?find_desc=ramen" . into( ) ,
2909+ icon_light_theme: None ,
2910+ icon_light_theme_mimetype: None ,
2911+ icon_dark_theme: Some ( "yelp-dark-theme-icon-data" . into( ) ) ,
2912+ icon_dark_theme_mimetype: Some ( "image/svg+xml" . into( ) ) ,
2913+ score: 0.5 ,
2914+ has_location_sign: false ,
2915+ subject_exact_match: true ,
2916+ location_param: "find_loc" . into( ) ,
2917+ }
2918+ ] ,
2919+ ) ;
28232920 Ok ( ( ) )
28242921 }
28252922
0 commit comments