Implement BumperEndpoints and remove deprecated bumper-related functionality
ci / build-backend (push) Successful in 1m39s
ci / build-frontend (push) Failing after 26s
ci / tests (push) Skipped
ci / sonar (push) Skipped

Added new BumperEndpoints to the API for managing bumper templates and variants, enhancing the channel management capabilities. Removed outdated bumper-related commands and handlers from the application, streamlining the codebase and improving maintainability. Updated ChannelEndpoints to reflect these changes and ensure proper routing for the new endpoints.
This commit is contained in:
Leonid Pershin
2026-07-27 22:01:56 +03:00
parent ee0b4d2d01
commit ba3721eb92
140 changed files with 7326 additions and 3609 deletions
@@ -61,8 +61,19 @@ public class QueryHandlersTests
var fixture = new TestDb();
var channel = Channel.Create("c", "c", T0);
var show = Show.Create("Show A", ShowKind.Series);
var variant = channel.BumperTemplates[0].Variants[0];
var bumperTemplate = BumperTemplate.Create("Блок", "Текст 1");
var variant = bumperTemplate.Variants[0];
var asset = MediaAsset.Register("Show.A.S01E01.mkv", ".mkv", MediaSource.Upload);
var bumperAsset = MediaAsset.RegisterGenerated("Блок: СЕЙЧАС / Show A");
// Метка в расписании берётся из кэша заставки — там лежит ровно тот текст, что играл.
var cache = BumperAsset.Create(
bumperTemplate.Id,
variant.Id,
"sig",
"""[{"style":"Label","color":"Accent","text":"СЕЙЧАС"},{"style":"Title","color":"Text","text":"Show A"}]""",
null,
bumperAsset.Id
);
var program = ScheduleEntry.Program(
channel.Id,
asset.Id,
@@ -73,7 +84,7 @@ public class QueryHandlersTests
);
var bumper = ScheduleEntry.Bumper(
channel.Id,
Guid.NewGuid(),
bumperAsset.Id,
T0.AddMinutes(20),
T0.AddMinutes(20).AddSeconds(8),
show.Id,
@@ -83,7 +94,10 @@ public class QueryHandlersTests
{
seed.Shows.Add(show);
seed.Channels.Add(channel);
seed.BumperTemplates.Add(bumperTemplate);
seed.MediaAssets.Add(asset);
seed.MediaAssets.Add(bumperAsset);
seed.BumperAssets.Add(cache);
seed.ScheduleEntries.Add(program);
seed.ScheduleEntries.Add(bumper);
await seed.SaveChangesAsync(CancellationToken.None);
@@ -98,7 +112,8 @@ public class QueryHandlersTests
Assert.True(result.IsSuccess);
Assert.Equal(2, result.Value.Count);
var bumperDto = result.Value.Single(e => e.Kind == ScheduleEntryKind.Bumper);
Assert.NotNull(bumperDto.BumperName);
Assert.Equal("Текст 1", bumperDto.BumperName);
Assert.Equal("СЕЙЧАС · Show A", bumperDto.BumperText);
}
[Fact]
@@ -150,52 +165,4 @@ public class QueryHandlersTests
);
Assert.True(ok.IsSuccess);
}
[Fact]
public async Task AddAndRemoveBumperTemplate_WorkThroughStorage()
{
var fixture = new TestDb();
var channel = Channel.Create("c", "c", T0);
await using (var seed = fixture.New())
{
seed.Channels.Add(channel);
await seed.SaveChangesAsync(CancellationToken.None);
}
Guid templateId;
await using (var db = fixture.New())
{
var added = await new AddBumperTemplateCommandHandler(db).Handle(
new AddBumperTemplateCommand(channel.Id, ""),
CancellationToken.None
);
Assert.True(added.IsSuccess);
templateId = added.Value;
await db.SaveChangesAsync(CancellationToken.None);
}
var storage = Substitute.For<IBumperTemplateStorage>();
await using (var db = fixture.New())
{
var removed = await new RemoveBumperTemplateCommandHandler(db, storage).Handle(
new RemoveBumperTemplateCommand(channel.Id, templateId),
CancellationToken.None
);
Assert.True(removed.IsSuccess);
}
await storage.Received(1).DeleteTemplateAsync(templateId, Arg.Any<CancellationToken>());
// дефолтный блок удалить нельзя
await using (var db = fixture.New())
{
var def = await db
.Channels.Include(c => c.BumperTemplates)
.FirstAsync(c => c.Id == channel.Id);
var result = await new RemoveBumperTemplateCommandHandler(db, storage).Handle(
new RemoveBumperTemplateCommand(channel.Id, def.BumperTemplates[0].Id),
CancellationToken.None
);
Assert.Equal(ChannelErrors.CannotRemoveDefaultBumperTemplate, result.Error);
}
}
}