#4840 - Partial fix - Remove hard coded task ids to prevent flaky tests.

# Conflicts:
#	crates/meilisearch/tests/documents/add_documents.rs
#	crates/meilisearch/tests/search/facet_search.rs
#	crates/meilisearch/tests/settings/get_settings.rs
#	crates/meilisearch/tests/snapshot/mod.rs
This commit is contained in:
Mahmoud Rawas 2024-12-21 21:46:51 +11:00
parent fc23a0ee52
commit 91c7ef8723
24 changed files with 555 additions and 547 deletions

View file

@ -378,15 +378,15 @@ async fn error_update_settings_unknown_field() {
async fn test_partial_update() {
let server = Server::new().await;
let index = server.index("test");
let (_response, _code) = index.update_settings(json!({"displayedAttributes": ["foo"]})).await;
index.wait_task(0).await;
let (task, _code) = index.update_settings(json!({"displayedAttributes": ["foo"]})).await;
index.wait_task(task.uid()).await;
let (response, code) = index.settings().await;
assert_eq!(code, 200);
assert_eq!(response["displayedAttributes"], json!(["foo"]));
assert_eq!(response["searchableAttributes"], json!(["*"]));
let (_response, _) = index.update_settings(json!({"searchableAttributes": ["bar"]})).await;
index.wait_task(1).await;
let (task, _) = index.update_settings(json!({"searchableAttributes": ["bar"]})).await;
index.wait_task(task.uid()).await;
let (response, code) = index.settings().await;
assert_eq!(code, 200);
@ -398,10 +398,10 @@ async fn test_partial_update() {
async fn error_delete_settings_unexisting_index() {
let server = Server::new().await;
let index = server.index("test");
let (_response, code) = index.delete_settings().await;
let (task, code) = index.delete_settings().await;
assert_eq!(code, 202);
let response = index.wait_task(0).await;
let response = index.wait_task(task.uid()).await;
assert_eq!(response["status"], "failed");
}
@ -422,12 +422,12 @@ async fn reset_all_settings() {
let (response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 202);
assert_eq!(response["taskUid"], 0);
index.wait_task(0).await;
index.wait_task(response.uid()).await;
index
let (update_task,_status_code) = index
.update_settings(json!({"displayedAttributes": ["name", "age"], "searchableAttributes": ["name"], "stopWords": ["the"], "filterableAttributes": ["age"], "synonyms": {"puppy": ["dog", "doggo", "potat"] }}))
.await;
index.wait_task(1).await;
index.wait_task(update_task.uid()).await;
let (response, code) = index.settings().await;
assert_eq!(code, 200);
assert_eq!(response["displayedAttributes"], json!(["name", "age"]));
@ -436,8 +436,8 @@ async fn reset_all_settings() {
assert_eq!(response["synonyms"], json!({"puppy": ["dog", "doggo", "potat"] }));
assert_eq!(response["filterableAttributes"], json!(["age"]));
index.delete_settings().await;
index.wait_task(2).await;
let (delete_task,_status_code) = index.delete_settings().await;
index.wait_task(delete_task.uid()).await;
let (response, code) = index.settings().await;
assert_eq!(code, 200);
@ -456,14 +456,14 @@ async fn reset_all_settings() {
async fn update_setting_unexisting_index() {
let server = Server::new().await;
let index = server.index("test");
let (_response, code) = index.update_settings(json!({})).await;
let (task, code) = index.update_settings(json!({})).await;
assert_eq!(code, 202);
let response = index.wait_task(0).await;
let response = index.wait_task(task.uid()).await;
assert_eq!(response["status"], "succeeded");
let (_response, code) = index.get().await;
assert_eq!(code, 200);
index.delete_settings().await;
let response = index.wait_task(1).await;
let (task,_status_code) = index.delete_settings().await;
let response = index.wait_task(task.uid()).await;
assert_eq!(response["status"], "succeeded");
}
@ -506,16 +506,16 @@ async fn set_and_reset_distinct_attribute_with_dedicated_route() {
let server = Server::new().await;
let index = server.index("test");
let (_response, _code) = index.update_distinct_attribute(json!("test")).await;
index.wait_task(0).await;
let (task, _code) = index.update_distinct_attribute(json!("test")).await;
index.wait_task(task.uid()).await;
let (response, _) = index.get_distinct_attribute().await;
assert_eq!(response, "test");
index.update_distinct_attribute(json!(null)).await;
let (task,_status_code) = index.update_distinct_attribute(json!(null)).await;
index.wait_task(1).await;
index.wait_task(task.uid()).await;
let (response, _) = index.get_distinct_attribute().await;