Skip to content

Commit

Permalink
Bug 1933217 - Implement suggestion and trending URL handling on the s…
Browse files Browse the repository at this point in the history
…earch engine selector.
  • Loading branch information
Standard8 committed Dec 3, 2024
1 parent 4d55324 commit 9019fbe
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 8 deletions.
48 changes: 42 additions & 6 deletions components/search/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ impl From<JSONEngineUrls> for SearchEngineUrls {
fn from(urls: JSONEngineUrls) -> Self {
Self {
search: urls.search.into(),
suggestions: None,
trending: None,
suggestions: urls.suggestions.map(|suggestions| suggestions.into()),
trending: urls.trending.map(|trending| trending.into()),
}
}
}
Expand Down Expand Up @@ -183,8 +183,26 @@ mod tests {
}]),
search_term_param_name: Some("baz".to_string()),
},
suggestions: None,
trending: None,
suggestions: Some(JSONEngineUrl {
base: "https://example.com/suggestions".to_string(),
method: Some(crate::JSONEngineMethod::Get),
params: Some(vec![SearchUrlParam {
name: "suggest-name".to_string(),
value: None,
experiment_config: Some("suggest-experiment-value".to_string()),
}]),
search_term_param_name: Some("suggest".to_string()),
}),
trending: Some(JSONEngineUrl {
base: "https://example.com/trending".to_string(),
method: Some(crate::JSONEngineMethod::Get),
params: Some(vec![SearchUrlParam {
name: "trend-name".to_string(),
value: Some("trend-value".to_string()),
experiment_config: None,
}]),
search_term_param_name: None,
}),
},
},
);
Expand All @@ -211,8 +229,26 @@ mod tests {
}],
search_term_param_name: Some("baz".to_string()),
},
suggestions: None,
trending: None
suggestions: Some(SearchEngineUrl {
base: "https://example.com/suggestions".to_string(),
method: "GET".to_string(),
params: vec![SearchUrlParam {
name: "suggest-name".to_string(),
value: None,
experiment_config: Some("suggest-experiment-value".to_string()),
}],
search_term_param_name: Some("suggest".to_string()),
}),
trending: Some(SearchEngineUrl {
base: "https://example.com/trending".to_string(),
method: "GET".to_string(),
params: vec![SearchUrlParam {
name: "trend-name".to_string(),
value: Some("trend-value".to_string()),
experiment_config: None,
}],
search_term_param_name: None,
})
}
}
)
Expand Down
41 changes: 39 additions & 2 deletions components/search/src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,23 @@ mod tests {
"base": "https://example.com/1",
"method": "GET",
"searchTermParamName": "q"
},
"suggestions": {
"base": "https://example.com/suggestions",
"method": "POST",
"params": [{
"name": "suggestion-name",
"value": "suggestion-value",
}],
"searchTermParamName": "suggest"
},
"trending": {
"base": "https://example.com/trending",
"method": "GET",
"params": [{
"name": "trending-name",
"experimentConfig": "trending-experiment-value",
}]
}
}
},
Expand Down Expand Up @@ -326,8 +343,28 @@ mod tests {
params: Vec::new(),
search_term_param_name: Some("q".to_string())
},
suggestions: None,
trending: None
suggestions: Some(SearchEngineUrl {
base: "https://example.com/suggestions".to_string(),
method: "POST".to_string(),
params: vec![SearchUrlParam {
name: "suggestion-name".to_string(),
value: Some("suggestion-value".to_string()),
experiment_config: None
}],
search_term_param_name: Some("suggest".to_string())
}),
trending: Some(SearchEngineUrl {
base: "https://example.com/trending".to_string(),
method: "GET".to_string(),
params: vec![SearchUrlParam {
name: "trending-name".to_string(),
value: None,
experiment_config: Some(
"trending-experiment-value".to_string()
)
}],
search_term_param_name: None
})
}
},
SearchEngineDefinition {
Expand Down

0 comments on commit 9019fbe

Please sign in to comment.