You've already forked AstralRinth
Allow searching by project dependencies (#6350)
* Allow searching by project dependencies * change field name * use query macro
This commit is contained in:
@@ -4,7 +4,7 @@ use common::database::*;
|
||||
|
||||
use common::dummy_data::DUMMY_CATEGORIES;
|
||||
|
||||
use ariadne::ids::base62_impl::parse_base62;
|
||||
use ariadne::ids::base62_impl::{parse_base62, to_base62};
|
||||
use common::environment::TestEnvironment;
|
||||
use common::environment::with_test_environment;
|
||||
use common::search::setup_search_projects;
|
||||
@@ -29,6 +29,12 @@ async fn search_projects() {
|
||||
|
||||
let api = &test_env.api;
|
||||
let test_name = test_env.db.database_name.clone();
|
||||
let dependency_project_id = id_conversion
|
||||
.iter()
|
||||
.find_map(|(project_id, test_id)| {
|
||||
(*test_id == 1).then_some(to_base62(*project_id))
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
// Pairs of:
|
||||
// 1. vec of search facets
|
||||
@@ -83,6 +89,12 @@ async fn search_projects() {
|
||||
json!([["categories:fabric"], ["project_types:modpack"]]),
|
||||
vec![4],
|
||||
),
|
||||
(
|
||||
json!([[format!(
|
||||
"dependency_project_ids:{dependency_project_id}"
|
||||
)]]),
|
||||
vec![7],
|
||||
),
|
||||
];
|
||||
// TODO: versions, game versions
|
||||
// Untested:
|
||||
@@ -123,6 +135,34 @@ async fn search_projects() {
|
||||
}
|
||||
})
|
||||
.await;
|
||||
|
||||
let projects = api
|
||||
.search_deserialized(
|
||||
Some(&format!("&{test_name}")),
|
||||
Some(json!([[format!(
|
||||
"dependency_project_ids:{dependency_project_id}"
|
||||
)]])),
|
||||
USER_USER_PAT,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(projects.total_hits, 1);
|
||||
assert_eq!(projects.hits[0].dependency_project_ids.len(), 1);
|
||||
assert_eq!(
|
||||
projects.hits[0].dependency_project_ids[0],
|
||||
dependency_project_id
|
||||
);
|
||||
assert_eq!(projects.hits[0].dependencies.len(), 1);
|
||||
assert_eq!(
|
||||
projects.hits[0].dependencies[0].project_id,
|
||||
dependency_project_id
|
||||
);
|
||||
assert!(
|
||||
projects.hits[0].dependencies[0]
|
||||
.slug
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.contains("searchable-project-1")
|
||||
);
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
Reference in New Issue
Block a user