Tests: xUnit project with HAR fixtures (50 tests); fix relative delivery/HLS URLs resolving to file:// on Linux
All checks were successful
release / build-release (push) Successful in 1m19s
All checks were successful
release / build-release (push) Successful in 1m19s
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
84
Jellyfin.Plugin.Floatplane.Tests/ChannelMappingTests.cs
Normal file
84
Jellyfin.Plugin.Floatplane.Tests/ChannelMappingTests.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Jellyfin.Plugin.Floatplane.Api.Models;
|
||||
using Jellyfin.Plugin.Floatplane.Channel;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Model.Channels;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Plugin.Floatplane.Tests;
|
||||
|
||||
public class ChannelMappingTests
|
||||
{
|
||||
private static PostModel FirstPost() => Fixture.Json<List<PostModel>>("content-creator.json")[0];
|
||||
|
||||
[Fact]
|
||||
public void ToItem_maps_post_fields()
|
||||
{
|
||||
var post = FirstPost();
|
||||
var creator = new CreatorModel { Id = "59f94c0bdd241b70349eb72b", Title = "LinusTechTips", Urlname = "linustechtips" };
|
||||
|
||||
var item = FloatplaneChannel.ToItem(post, creator);
|
||||
|
||||
Assert.Equal("post:SSvhppI28t", item.Id);
|
||||
Assert.Equal(post.Title, item.Name);
|
||||
Assert.Equal(ChannelItemType.Media, item.Type);
|
||||
Assert.Equal(ChannelMediaType.Video, item.MediaType);
|
||||
Assert.Equal(ChannelMediaContentType.Clip, item.ContentType);
|
||||
Assert.Equal(1104 * TimeSpan.TicksPerSecond, item.RunTimeTicks);
|
||||
Assert.NotNull(item.PremiereDate);
|
||||
Assert.Equal(new DateTime(2026, 10, 24, 18, 24, 0, 36, DateTimeKind.Utc), item.PremiereDate!.Value);
|
||||
Assert.Equal(2026, item.ProductionYear);
|
||||
Assert.EndsWith("_1200x675.jpeg", item.ImageUrl);
|
||||
Assert.Contains("ShortCircuit", item.Genres);
|
||||
Assert.Contains("LinusTechTips", item.Studios);
|
||||
Assert.Equal("https://www.floatplane.com/post/SSvhppI28t", item.HomePageUrl);
|
||||
Assert.Equal("SSvhppI28t", item.ProviderIds["Floatplane"]);
|
||||
Assert.Equal("Sample description.", item.Overview);
|
||||
Assert.NotNull(item.CommunityRating);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToItem_prefixes_locked_posts()
|
||||
{
|
||||
var post = FirstPost();
|
||||
post.IsAccessible = false;
|
||||
|
||||
var item = FloatplaneChannel.ToItem(post, null);
|
||||
|
||||
Assert.StartsWith("🔒 ", item.Name);
|
||||
Assert.Empty(item.Studios);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToItem_uses_stripped_html_when_markdown_missing()
|
||||
{
|
||||
var post = FirstPost();
|
||||
post.TextMarkdown = null;
|
||||
post.Text = "<p>First <b>bold</b> line.</p><p>Second & third</p>";
|
||||
|
||||
var item = FloatplaneChannel.ToItem(post, null);
|
||||
|
||||
Assert.Equal("First bold line.\nSecond & third", item.Overview);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StripHtml_converts_breaks_and_entities()
|
||||
{
|
||||
var text = FloatplaneChannel.StripHtml("<p>One<br/>Two</p><p>Three <x></p><ul><li>a</li><li>b</li></ul>");
|
||||
|
||||
Assert.Equal("One\nTwo\nThree <x>\na\nb", text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeterministicGuid_is_stable_and_distinct()
|
||||
{
|
||||
var a = FloatplaneChannel.DeterministicGuid("post:abc");
|
||||
var b = FloatplaneChannel.DeterministicGuid("post:abc");
|
||||
var c = FloatplaneChannel.DeterministicGuid("post:abd");
|
||||
|
||||
Assert.Equal(a, b);
|
||||
Assert.NotEqual(a, c);
|
||||
Assert.NotEqual(Guid.Empty, a);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user