Update tests

This commit is contained in:
Louis Dureuil 2024-09-17 17:22:14 +02:00
parent 98b77aec66
commit c42746c4cd
No known key found for this signature in database

View File

@ -5804,356 +5804,15 @@ async fn federation_inconsistent_merge_order() {
} }
"###); "###);
// works again with merging and forcing an order
let (response, code) = server
.multi_search(json!({"federation": {
"facetsByIndex": {
"movies": ["title", "color"],
"batman": ["title"],
"movies-2": ["title", "color"],
},
"mergeFacets": {
"sortFacetValuesBy": "count"
}
}, "queries": [
{"indexUid" : "movies", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] },
{"indexUid" : "batman", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] },
{"indexUid" : "movies-2", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] },
]}))
.await;
snapshot!(code, @"200 OK");
insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###"
{
"hits": [
{
"title": "Badman",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman Returns",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman the dark knight returns: Part 1",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman the dark knight returns: Part 2",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Captain Marvel",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Captain Marvel",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "Escape Room",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Escape Room",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "Gläss",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Gläss",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "How to Train Your Dragon: The Hidden World",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "How to Train Your Dragon: The Hidden World",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "Shazam!",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Shazam!",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
}
],
"processingTimeMs": "[time]",
"limit": 20,
"offset": 0,
"estimatedTotalHits": 15,
"facetDistribution": {
"color": {
"red": 6,
"blue": 6,
"yellow": 4,
"green": 4
},
"title": {
"Shazam!": 2,
"How to Train Your Dragon: The Hidden World": 2,
"Gläss": 2,
"Escape Room": 2,
"Captain Marvel": 2,
"Batman the dark knight returns: Part 2": 1,
"Batman the dark knight returns: Part 1": 1,
"Batman Returns": 1,
"Batman": 1,
"Badman": 1
}
},
"facetStats": {}
}
"###);
// works also with the other order
let (response, code) = server
.multi_search(json!({"federation": {
"facetsByIndex": {
"movies": ["title", "color"],
"batman": ["title"],
"movies-2": ["title", "color"],
},
"mergeFacets": {
"sortFacetValuesBy": "alpha"
}
}, "queries": [
{"indexUid" : "movies", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] },
{"indexUid" : "batman", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] },
{"indexUid" : "movies-2", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] },
]}))
.await;
snapshot!(code, @"200 OK");
insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###"
{
"hits": [
{
"title": "Badman",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman Returns",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman the dark knight returns: Part 1",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman the dark knight returns: Part 2",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Captain Marvel",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Captain Marvel",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "Escape Room",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Escape Room",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "Gläss",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Gläss",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "How to Train Your Dragon: The Hidden World",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "How to Train Your Dragon: The Hidden World",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "Shazam!",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Shazam!",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
}
],
"processingTimeMs": "[time]",
"limit": 20,
"offset": 0,
"estimatedTotalHits": 15,
"facetDistribution": {
"color": {
"blue": 6,
"green": 4,
"red": 6,
"yellow": 4
},
"title": {
"Badman": 1,
"Batman": 1,
"Batman Returns": 1,
"Batman the dark knight returns: Part 1": 1,
"Batman the dark knight returns: Part 2": 1,
"Captain Marvel": 2,
"Escape Room": 2,
"Gläss": 2,
"How to Train Your Dragon: The Hidden World": 2,
"Shazam!": 2
}
},
"facetStats": {}
}
"###);
// can limit the number of values // can limit the number of values
let (response, code) = server let (response, code) = server
.multi_search(json!({"federation": { .multi_search(json!({"federation": {
"facetsByIndex": { "facetsByIndex": {
"movies": ["title", "color"], "movies": ["title", "color"],
"batman": ["title"], "batman": ["title"],
"movies-2": ["title", "color"], "movies-2": ["title"],
}, },
"mergeFacets": { "mergeFacets": {
"sortFacetValuesBy": "count",
"maxValuesPerFacet": 3, "maxValuesPerFacet": 3,
} }
}, "queries": [ }, "queries": [
@ -6293,172 +5952,9 @@ async fn federation_inconsistent_merge_order() {
"estimatedTotalHits": 15, "estimatedTotalHits": 15,
"facetDistribution": { "facetDistribution": {
"color": { "color": {
"red": 6, "blue": 3,
"blue": 6, "green": 2,
"yellow": 4 "red": 3
},
"title": {
"Shazam!": 2,
"How to Train Your Dragon: The Hidden World": 2,
"Gläss": 2
}
},
"facetStats": {}
}
"###);
// can limit the number of values by alpha
let (response, code) = server
.multi_search(json!({"federation": {
"facetsByIndex": {
"movies": ["title", "color"],
"batman": ["title"],
"movies-2": ["title", "color"],
},
"mergeFacets": {
"sortFacetValuesBy": "alpha",
"maxValuesPerFacet": 3,
}
}, "queries": [
{"indexUid" : "movies", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] },
{"indexUid" : "batman", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] },
{"indexUid" : "movies-2", "q": "", "sort": ["title:asc"], "attributesToRetrieve": ["title"] },
]}))
.await;
snapshot!(code, @"200 OK");
insta::assert_json_snapshot!(response, { ".processingTimeMs" => "[time]" }, @r###"
{
"hits": [
{
"title": "Badman",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman Returns",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman the dark knight returns: Part 1",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Batman the dark knight returns: Part 2",
"_federation": {
"indexUid": "batman",
"queriesPosition": 1,
"weightedRankingScore": 1.0
}
},
{
"title": "Captain Marvel",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Captain Marvel",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "Escape Room",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Escape Room",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "Gläss",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Gläss",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "How to Train Your Dragon: The Hidden World",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "How to Train Your Dragon: The Hidden World",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
},
{
"title": "Shazam!",
"_federation": {
"indexUid": "movies",
"queriesPosition": 0,
"weightedRankingScore": 1.0
}
},
{
"title": "Shazam!",
"_federation": {
"indexUid": "movies-2",
"queriesPosition": 2,
"weightedRankingScore": 1.0
}
}
],
"processingTimeMs": "[time]",
"limit": 20,
"offset": 0,
"estimatedTotalHits": 15,
"facetDistribution": {
"color": {
"blue": 6,
"green": 4,
"red": 6
}, },
"title": { "title": {
"Badman": 1, "Badman": 1,