Add opinions storage, morning drift, and Connections card tab.

This commit is contained in:
Leonid Pershin
2026-08-20 07:34:57 +03:00
parent b9d91d387e
commit b1b4f18b40
24 changed files with 1020 additions and 27 deletions
+51 -2
View File
@@ -177,6 +177,36 @@ public class PeopleApiTests(AppHostFixture fixture)
Assert.Contains(motherCard.Family.Children, child => child.Id == card.Id);
}
[Fact]
public async Task Card_ConnectionsCarryOnlyThisPersonsOpinions()
{
using var client = fixture.App.CreateHttpClient("server");
await SchoolApiTests.ResetAsync(client);
var school = await SchoolApiTests.CreateAsync(client, "Связи карточка", Start, seed: 1);
var pupils = await GetPeopleAsync(client, school.Id, "role=student&pageSize=20");
var pupil = pupils.People.First(person => person.Roles.Contains("student"));
var card = await GetCardAsync(client, school.Id, pupil.Id);
Assert.NotNull(card.Connections);
Assert.NotEmpty(card.Connections!.Family.Parents);
Assert.All(card.Connections.Family.Parents, parent =>
{
Assert.NotNull(parent.Opinion);
Assert.True(parent.Opinion > 0);
Assert.False(string.IsNullOrWhiteSpace(parent.OpinionLabel));
});
var linkedIds = card.Connections.Others.Select(row => row.Id).ToHashSet(StringComparer.Ordinal);
foreach (var other in card.Connections.Friends.Concat(card.Connections.Enemies))
{
Assert.DoesNotContain(other.Id, linkedIds);
}
using var bulk = await client.GetAsync($"/api/schools/{school.Id}/people/opinions", TestContext.Current.CancellationToken);
Assert.Equal(HttpStatusCode.NotFound, bulk.StatusCode);
}
/// <summary>
/// Phases 7 and 9 together: the roster survives a restart, and what comes back is the
/// composition *after* the first-September intake. Generating from the seed again would
@@ -320,7 +350,8 @@ public class PeopleApiTests(AppHostFixture fixture)
IReadOnlyList<LabeledStatResponse> Skills,
IReadOnlyList<DefLabelResponse> Traits,
IReadOnlyList<NeedStatResponse> Needs,
PersonFamilyResponse Family);
PersonFamilyResponse Family,
PersonConnectionsResponse? Connections);
private sealed record LabeledStatResponse(string Id, string Label, string Value);
@@ -332,7 +363,25 @@ public class PeopleApiTests(AppHostFixture fixture)
IReadOnlyList<PersonRelResponse> Siblings,
IReadOnlyList<PersonRelResponse> Partners);
private sealed record PersonRelResponse(string Id, string FullName, bool Female);
private sealed record PersonRelResponse(
string Id,
string FullName,
bool Female,
int? Opinion = null,
string? OpinionLabel = null);
private sealed record PersonOpinionLinkResponse(
string Id,
string FullName,
bool Female,
int Opinion,
string OpinionLabel);
private sealed record PersonConnectionsResponse(
PersonFamilyResponse Family,
IReadOnlyList<PersonOpinionLinkResponse> Friends,
IReadOnlyList<PersonOpinionLinkResponse> Enemies,
IReadOnlyList<PersonOpinionLinkResponse> Others);
private sealed record DirectoryResponse(IReadOnlyList<DirectoryPersonResponse> People);