Repository: meilisearch/meilisearch
File: meilisearch/tests/search/errors.rs (Rust)

Code before:
      "message": "Invalid value type at `.facets`: expected an array, but found a string: `\"doggo\"`",
      "code": "invalid_search_facets",
      "type": "invalid_request",
      "link": "https://docs.meilisearch.com/errors#invalid-search-facets"
    }
    "###);
    // Can't make the `attributes_to_highlight` fail with a get search since it'll accept anything as an array of strings.
}

#[actix_rt::test]
async fn search_non_filterable_facets() {
    let server = Server::new().await;
    let index = server.index("test");
    index.update_settings(json!({"filterableAttributes": ["title"]})).await;

    let (response, code) = index.search_post(json!({"facets": ["doggo"]})).await;
    snapshot!(code, @"400 Bad Request");
    snapshot!(json_string!(response), @r###"
    {
      "message": "Invalid facet distribution, the fields `doggo` are not set as filterable.",
      "code": "invalid_search_facets",
      "type": "invalid_request",
      "link": "https://docs.meilisearch.com/errors#invalid-search-facets"
    }
    "###);
    // Can't make the `attributes_to_highlight` fail with a get search since it'll accept anything as an array of strings.
}

#[actix_rt::test]
async fn search_bad_highlight_pre_tag() {
    let server = Server::new().await;
    let index = server.index("test");

    let (response, code) = index.search_post(json!({"highlightPreTag": ["doggo"]})).await;
    snapshot!(code, @"400 Bad Request");
    snapshot!(json_string!(response), @r###"
    {
      "message": "Invalid value type at `.highlightPreTag`: expected a string, but found an array: `[\"doggo\"]`",
      "code": "invalid_search_highlight_pre_tag",
      "type": "invalid_request",
      "link": "https://docs.meilisearch.com/errors#invalid-search-highlight-pre-tag"
    }
    "###);
    // Can't make the `highlight_pre_tag` fail with a get search since it'll accept anything as a strings.
}

#[actix_rt::test]
async fn search_bad_highlight_post_tag() {
    let server = Server::new().await;
    let index = server.index("test");


Review comment (suggestion):
Could you write a test with a `search_get` since you actually can in this case

Code after:
      "message": "Invalid value type at `.facets`: expected an array, but found a string: `\"doggo\"`",
      "code": "invalid_search_facets",
      "type": "invalid_request",
      "link": "https://docs.meilisearch.com/errors#invalid-search-facets"
    }
    "###);
    // Can't make the `attributes_to_highlight` fail with a get search since it'll accept anything as an array of strings.
}

#[actix_rt::test]
async fn search_non_filterable_facets() {
    let server = Server::new().await;
    let index = server.index("test");
    index.update_settings(json!({"filterableAttributes": ["title"]})).await;
    // Wait for the settings update to complete
    index.wait_task(0).await;

    let (response, code) = index.search_post(json!({"facets": ["doggo"]})).await;
    snapshot!(code, @"400 Bad Request");
    snapshot!(json_string!(response), @r###"
    {
      "message": "Invalid facet distribution, the fields `doggo` are not set as filterable.",
      "code": "invalid_search_facets",
      "type": "invalid_request",
      "link": "https://docs.meilisearch.com/errors#invalid-search-facets"
    }
    "###);

    let (response, code) = index.search_get("facets=doggo").await;
    snapshot!(code, @"400 Bad Request");
    snapshot!(json_string!(response), @r###"
    {
      "message": "Invalid facet distribution, the fields `doggo` are not set as filterable.",
      "code": "invalid_search_facets",
      "type": "invalid_request",
      "link": "https://docs.meilisearch.com/errors#invalid-search-facets"
    }
    "###);
}

#[actix_rt::test]
async fn search_bad_highlight_pre_tag() {
    let server = Server::new().await;
    let index = server.index("test");

    let (response, code) = index.search_post(json!({"highlightPreTag": ["doggo"]})).await;
    snapshot!(code, @"400 Bad Request");
    snapshot!(json_string!(response), @r###"
    {
      "message": "Invalid value type at `.highlightPreTag`: expected a string, but found an array: `[\"doggo\"]`",
      "code": "invalid_search_highlight_pre_tag",