Applies optimizations to formatted integration tests (#5043)

This commit is contained in:
PedroTurik 2024-11-07 11:58:55 -03:00 committed by GitHub
parent b427b9e88f
commit 03886d0012
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,14 +6,14 @@ use crate::json;
#[actix_rt::test] #[actix_rt::test]
async fn formatted_contain_wildcard() { async fn formatted_contain_wildcard() {
let server = Server::new().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.unique_index();
index.update_settings(json!({ "displayedAttributes": ["id", "cattos"] })).await; index.update_settings(json!({ "displayedAttributes": ["id", "cattos"] })).await;
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await;
index.search(json!({ "q": "pésti", "attributesToRetrieve": ["father", "mother"], "attributesToHighlight": ["father", "mother", "*"], "attributesToCrop": ["doggos"], "showMatchesPosition": true }), index.search(json!({ "q": "pésti", "attributesToRetrieve": ["father", "mother"], "attributesToHighlight": ["father", "mother", "*"], "attributesToCrop": ["doggos"], "showMatchesPosition": true }),
|response, code| |response, code|
@ -135,12 +135,7 @@ async fn formatted_contain_wildcard() {
#[actix_rt::test] #[actix_rt::test]
async fn format_nested() { async fn format_nested() {
let server = Server::new().await; let index = shared_index_with_nested_documents().await;
let index = server.index("test");
let documents = NESTED_DOCUMENTS.clone();
index.add_documents(documents, None).await;
index.wait_task(0).await;
index index
.search(json!({ "q": "pésti", "attributesToRetrieve": ["doggos"] }), |response, code| { .search(json!({ "q": "pésti", "attributesToRetrieve": ["doggos"] }), |response, code| {
@ -340,15 +335,15 @@ async fn format_nested() {
#[actix_rt::test] #[actix_rt::test]
async fn displayedattr_2_smol() { async fn displayedattr_2_smol() {
let server = Server::new().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.unique_index();
// not enough displayed for the other settings // not enough displayed for the other settings
index.update_settings(json!({ "displayedAttributes": ["id"] })).await; index.update_settings(json!({ "displayedAttributes": ["id"] })).await;
let documents = NESTED_DOCUMENTS.clone(); let documents = NESTED_DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await;
index index
.search(json!({ "attributesToRetrieve": ["father", "id"], "attributesToHighlight": ["mother"], "attributesToCrop": ["cattos"] }), .search(json!({ "attributesToRetrieve": ["father", "id"], "attributesToHighlight": ["mother"], "attributesToCrop": ["cattos"] }),
@ -538,15 +533,15 @@ async fn displayedattr_2_smol() {
#[cfg(feature = "default")] #[cfg(feature = "default")]
#[actix_rt::test] #[actix_rt::test]
async fn test_cjk_highlight() { async fn test_cjk_highlight() {
let server = Server::new().await; let server = Server::new_shared();
let index = server.index("test"); let index = server.unique_index();
let documents = json!([ let documents = json!([
{ "id": 0, "title": "この度、クーポンで無料で頂きました。" }, { "id": 0, "title": "この度、クーポンで無料で頂きました。" },
{ "id": 1, "title": "大卫到了扫罗那里" }, { "id": 1, "title": "大卫到了扫罗那里" },
]); ]);
index.add_documents(documents, None).await; let (response, _) = index.add_documents(documents, None).await;
index.wait_task(0).await; index.wait_task(response.uid()).await;
index index
.search(json!({"q": "", "attributesToHighlight": ["title"]}), |response, code| { .search(json!({"q": "", "attributesToHighlight": ["title"]}), |response, code| {