Update scheduling parameters and refactor channel endpoints: extend HorizonDays to 7 and RetentionDays to 90 in appsettings.json. Consolidate channel-related endpoint logic by removing obsolete files and enhancing the ShowEndpoints with audience and genre management capabilities. Improve error handling and streamline command handlers for channel operations.
build / backend (push) Successful in 7m40s
build / frontend (push) Failing after 39s
tests / backend-tests (push) Successful in 6m9s

This commit is contained in:
Leonid Pershin
2026-07-26 13:32:13 +03:00
parent c4ef954dea
commit 66040a8841
272 changed files with 27944 additions and 8699 deletions
@@ -0,0 +1,104 @@
using TeleWave.Domain.Programming;
using Xunit;
namespace TeleWave.Domain.Tests.Programming;
public class GroupTests
{
private static IReadOnlyList<Guid> Order(Group group) =>
group.Items.OrderBy(i => i.Position).Select(i => i.Id).ToList();
[Fact]
public void AddElement_AppendsAndRejectsDuplicates()
{
var group = Group.Create("Боевики 90-х");
var showId = Guid.NewGuid();
Assert.NotNull(group.AddElement(GroupElementKind.Show, showId));
Assert.Null(group.AddElement(GroupElementKind.Show, showId));
Assert.Single(group.Items);
}
[Fact]
public void AddElement_SameIdDifferentKind_AreDistinct()
{
var group = Group.Create("Смешанная");
var id = Guid.NewGuid();
group.AddElement(GroupElementKind.Show, id);
group.AddElement(GroupElementKind.Collection, id);
Assert.Equal(2, group.Items.Count);
}
[Fact]
public void RemoveElement_DropsAllMatchingPositions()
{
var group = Group.Create("Боевики");
var showId = Guid.NewGuid();
group.AddElement(GroupElementKind.Show, showId);
group.AddElement(GroupElementKind.Show, Guid.NewGuid());
var removed = group.RemoveElement(GroupElementKind.Show, showId);
Assert.Equal(1, removed);
Assert.Single(group.Items);
}
[Fact]
public void SetWeight_ClampsNegativeToZero()
{
var group = Group.Create("Боевики");
var item = group.AddElement(GroupElementKind.Show, Guid.NewGuid())!;
group.SetWeight(item.Id, -5);
// Ноль — законный вес («исключить, не удаляя»), отрицательный сломал бы взвешенный выбор.
Assert.Equal(0, item.Weight);
}
[Fact]
public void SetWeight_UnknownItem_ReturnsFalse()
{
var group = Group.Create("Боевики");
Assert.False(group.SetWeight(Guid.NewGuid(), 3));
}
[Fact]
public void Reorder_KeepsUnmentionedAfterRequested()
{
var group = Group.Create("Боевики");
var a = group.AddElement(GroupElementKind.Show, Guid.NewGuid())!;
var b = group.AddElement(GroupElementKind.Show, Guid.NewGuid())!;
var c = group.AddElement(GroupElementKind.Show, Guid.NewGuid())!;
group.Reorder([c.Id]);
Assert.Equal([c.Id, a.Id, b.Id], Order(group));
}
[Fact]
public void SetFilter_TreatsBlankAsAbsent()
{
var group = Group.Create("Боевики");
group.SetFilter(" ");
Assert.Null(group.FilterJson);
}
[Fact]
public void UpdateStats_StoresSnapshot()
{
var group = Group.Create("Боевики");
var at = new DateTimeOffset(2026, 1, 1, 0, 0, 0, TimeSpan.Zero);
group.UpdateStats(3, 42, TimeSpan.FromHours(18), at);
Assert.Equal(3, group.ItemCount);
Assert.Equal(42, group.UnitCount);
Assert.Equal(TimeSpan.FromHours(18), group.TotalDuration);
Assert.Equal(at, group.StatsComputedAt);
}
}