3 blocker phases
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Baya.Application.Models.Search;
|
||||
using Baya.Domain.Entities.Catalog;
|
||||
using Baya.Domain.Entities.Verification;
|
||||
|
||||
namespace Baya.Test.Foundation.Search;
|
||||
@@ -118,6 +119,43 @@ public sealed class SearchIndexTests
|
||||
Assert.Equal(new[] { high.NurseId, low.NurseId }, page.Items.Select(i => i.NurseId).ToArray());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SameNurseMultipleMatchingVariants_CollapsesToOneCardWithCheapestPriceAndMatchCount()
|
||||
{
|
||||
using var host = new SearchIndexTestHost();
|
||||
var nurse = host.SeedNurse(Female, true, true, VerificationStatus.Approved, 2000, host.District3Id);
|
||||
Project(host, nurse);
|
||||
|
||||
// A second, cheaper variant in the same category — the maintainer fans it out across the nurse's
|
||||
// existing areas, so it also becomes a match for the same search.
|
||||
var cheaper = new NurseServiceVariant
|
||||
{
|
||||
NurseId = nurse.NurseId,
|
||||
ServiceCategoryId = host.CategoryId,
|
||||
Price = 1000,
|
||||
PriceUnit = "per_day",
|
||||
SessionCount = null,
|
||||
DisplayName = "cheaper",
|
||||
OptionSetHash = $"hash-{nurse.NurseId}-2",
|
||||
IsActive = true
|
||||
};
|
||||
host.Db.Set<NurseServiceVariant>().Add(cheaper);
|
||||
host.Db.SaveChanges();
|
||||
host.Maintainer.ReindexVariantAsync(cheaper, default).GetAwaiter().GetResult();
|
||||
host.Db.SaveChanges();
|
||||
|
||||
// Two searchable rows for the one nurse, but the search must collapse them to one card.
|
||||
Assert.Equal(2, host.SearchableRowCount());
|
||||
|
||||
var page = host.Search.SearchAsync(Criteria(host.CategoryId, host.CityId), default).Result;
|
||||
|
||||
Assert.Single(page.Items);
|
||||
Assert.Equal(1, page.Total);
|
||||
Assert.Equal(nurse.NurseId, page.Items[0].NurseId);
|
||||
Assert.Equal("1000", page.Items[0].Price); // the cheaper matching variant is the representative
|
||||
Assert.Equal(2, page.Items[0].MatchingServiceCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SuspendingANurseRemovesThemFromSearch()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user