From 0e2a5951b411c1d8e2e677cefa39587aab87156e Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Mon, 24 Jul 2023 18:04:58 +0200 Subject: [PATCH] Add more advanced tests --- meilisearch/tests/search/facet_search.rs | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/meilisearch/tests/search/facet_search.rs b/meilisearch/tests/search/facet_search.rs index 7628f2fed..b38668ad3 100644 --- a/meilisearch/tests/search/facet_search.rs +++ b/meilisearch/tests/search/facet_search.rs @@ -56,6 +56,54 @@ async fn simple_facet_search() { assert_eq!(response["facetHits"].as_array().unwrap().len(), 1); } +#[actix_rt::test] +async fn advanced_facet_search() { + let server = Server::new().await; + let index = server.index("test"); + + let documents = DOCUMENTS.clone(); + index.update_settings_filterable_attributes(json!(["genres"])).await; + index.update_settings_typo_tolerance(json!({ "enabled": false })).await; + index.add_documents(documents, None).await; + index.wait_task(2).await; + + let (response, code) = + index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await; + + assert_eq!(code, 200, "{}", response); + assert_eq!(dbg!(response)["facetHits"].as_array().unwrap().len(), 0); + + let (response, code) = + index.facet_search(json!({"facetName": "genres", "facetQuery": "àdventure"})).await; + + assert_eq!(code, 200, "{}", response); + assert_eq!(response["facetHits"].as_array().unwrap().len(), 1); +} + +#[actix_rt::test] +async fn more_advanced_facet_search() { + let server = Server::new().await; + let index = server.index("test"); + + let documents = DOCUMENTS.clone(); + index.update_settings_filterable_attributes(json!(["genres"])).await; + index.update_settings_typo_tolerance(json!({ "disableOnWords": ["adventre"] })).await; + index.add_documents(documents, None).await; + index.wait_task(2).await; + + let (response, code) = + index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await; + + assert_eq!(code, 200, "{}", response); + assert_eq!(dbg!(response)["facetHits"].as_array().unwrap().len(), 0); + + let (response, code) = + index.facet_search(json!({"facetName": "genres", "facetQuery": "adventure"})).await; + + assert_eq!(code, 200, "{}", response); + assert_eq!(response["facetHits"].as_array().unwrap().len(), 1); +} + #[actix_rt::test] async fn non_filterable_facet_search_error() { let server = Server::new().await;