mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-21 06:20:33 -04:00
* Moved Collapse Series with relationships into a user preference rather than library setting. * Fixed bookmarks not converting to webp after initial save * Fixed a bug where when merging we'd print out a duplicate series error when we shouldn't have * Fixed a bug where clicking on a genre or tag from server stats wouldn't load all-series page in a filtered state. * Implemented the ability to have Login role and thus disable accounts. * Ensure first time flow gets the Login role * Refactored user management screen so that pending users can be edited or deleted before the end user accepts the invite. A side effect is old legacy users that were here before email was required can now be deleted. * Show a progress bar under the main series image on larger viewports to show whole series progress. * Removed code no longer needed * Cleanup tags, people, collections without connections after editing series metadata. * Moved the Entity Builders to the main project
189 lines
6.7 KiB
C#
189 lines
6.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using API.Comparators;
|
|
using API.Entities;
|
|
using API.Entities.Enums;
|
|
using API.Extensions;
|
|
using API.Helpers.Builders;
|
|
using Xunit;
|
|
|
|
namespace API.Tests.Extensions;
|
|
|
|
public class SeriesExtensionsTests
|
|
{
|
|
[Fact]
|
|
public void GetCoverImage_MultipleSpecials_Comics()
|
|
{
|
|
var series = new SeriesBuilder("Test 1")
|
|
.WithFormat(MangaFormat.Archive)
|
|
.WithVolume(new VolumeBuilder("0")
|
|
.WithName(API.Services.Tasks.Scanner.Parser.Parser.DefaultVolume)
|
|
.WithChapter(new ChapterBuilder(API.Services.Tasks.Scanner.Parser.Parser.DefaultChapter)
|
|
.WithCoverImage("Special 1")
|
|
.WithIsSpecial(true)
|
|
.Build())
|
|
.WithChapter(new ChapterBuilder(API.Services.Tasks.Scanner.Parser.Parser.DefaultChapter)
|
|
.WithCoverImage("Special 2")
|
|
.WithIsSpecial(true)
|
|
.Build())
|
|
.Build())
|
|
.Build();
|
|
|
|
Assert.Equal("Special 1", series.GetCoverImage());
|
|
|
|
}
|
|
|
|
[Fact]
|
|
public void GetCoverImage_MultipleSpecials_Books()
|
|
{
|
|
var series = new SeriesBuilder("Test 1")
|
|
.WithFormat(MangaFormat.Archive)
|
|
.WithVolume(new VolumeBuilder("0")
|
|
.WithName(API.Services.Tasks.Scanner.Parser.Parser.DefaultVolume)
|
|
.WithChapter(new ChapterBuilder(API.Services.Tasks.Scanner.Parser.Parser.DefaultChapter)
|
|
.WithCoverImage("Special 1")
|
|
.WithIsSpecial(true)
|
|
.Build())
|
|
.WithChapter(new ChapterBuilder(API.Services.Tasks.Scanner.Parser.Parser.DefaultChapter)
|
|
.WithCoverImage("Special 2")
|
|
.WithIsSpecial(true)
|
|
.Build())
|
|
.Build())
|
|
.Build();
|
|
|
|
Assert.Equal("Special 1", series.GetCoverImage());
|
|
}
|
|
|
|
[Fact]
|
|
public void GetCoverImage_JustChapters_Comics()
|
|
{
|
|
var series = new SeriesBuilder("Test 1")
|
|
.WithFormat(MangaFormat.Archive)
|
|
.WithVolume(new VolumeBuilder("0")
|
|
.WithName(API.Services.Tasks.Scanner.Parser.Parser.DefaultVolume)
|
|
.WithChapter(new ChapterBuilder("2.5")
|
|
.WithIsSpecial(false)
|
|
.WithCoverImage("Special 1")
|
|
.Build())
|
|
.WithChapter(new ChapterBuilder("2")
|
|
.WithIsSpecial(false)
|
|
.WithCoverImage("Special 2")
|
|
.Build())
|
|
.Build())
|
|
.Build();
|
|
|
|
foreach (var vol in series.Volumes)
|
|
{
|
|
vol.CoverImage = vol.Chapters.MinBy(x => double.Parse(x.Number), ChapterSortComparerZeroFirst.Default)?.CoverImage;
|
|
}
|
|
|
|
Assert.Equal("Special 2", series.GetCoverImage());
|
|
}
|
|
|
|
[Fact]
|
|
public void GetCoverImage_JustChaptersAndSpecials_Comics()
|
|
{
|
|
var series = new SeriesBuilder("Test 1")
|
|
.WithFormat(MangaFormat.Archive)
|
|
.WithVolume(new VolumeBuilder("0")
|
|
.WithName(API.Services.Tasks.Scanner.Parser.Parser.DefaultVolume)
|
|
.WithChapter(new ChapterBuilder("2.5")
|
|
.WithIsSpecial(false)
|
|
.WithCoverImage("Special 1")
|
|
.Build())
|
|
.WithChapter(new ChapterBuilder("2")
|
|
.WithIsSpecial(false)
|
|
.WithCoverImage("Special 2")
|
|
.Build())
|
|
.WithChapter(new ChapterBuilder("0")
|
|
.WithIsSpecial(true)
|
|
.WithCoverImage("Special 3")
|
|
.Build())
|
|
.Build())
|
|
.Build();
|
|
|
|
foreach (var vol in series.Volumes)
|
|
{
|
|
vol.CoverImage = vol.Chapters.MinBy(x => double.Parse(x.Number), ChapterSortComparerZeroFirst.Default)?.CoverImage;
|
|
}
|
|
|
|
Assert.Equal("Special 2", series.GetCoverImage());
|
|
}
|
|
|
|
[Fact]
|
|
public void GetCoverImage_VolumesChapters_Comics()
|
|
{
|
|
var series = new SeriesBuilder("Test 1")
|
|
.WithFormat(MangaFormat.Archive)
|
|
.WithVolume(new VolumeBuilder("0")
|
|
.WithName(API.Services.Tasks.Scanner.Parser.Parser.DefaultVolume)
|
|
.WithChapter(new ChapterBuilder("2.5")
|
|
.WithIsSpecial(false)
|
|
.WithCoverImage("Special 1")
|
|
.Build())
|
|
.WithChapter(new ChapterBuilder("2")
|
|
.WithIsSpecial(false)
|
|
.WithCoverImage("Special 2")
|
|
.Build())
|
|
.WithChapter(new ChapterBuilder("0")
|
|
.WithIsSpecial(true)
|
|
.WithCoverImage("Special 3")
|
|
.Build())
|
|
.Build())
|
|
.WithVolume(new VolumeBuilder("1")
|
|
.WithNumber(1)
|
|
.WithChapter(new ChapterBuilder("0")
|
|
.WithIsSpecial(false)
|
|
.WithCoverImage("Volume 1")
|
|
.Build())
|
|
.Build())
|
|
.Build();
|
|
|
|
foreach (var vol in series.Volumes)
|
|
{
|
|
vol.CoverImage = vol.Chapters.MinBy(x => double.Parse(x.Number), ChapterSortComparerZeroFirst.Default)?.CoverImage;
|
|
}
|
|
|
|
Assert.Equal("Volume 1", series.GetCoverImage());
|
|
}
|
|
|
|
[Fact]
|
|
public void GetCoverImage_VolumesChaptersAndSpecials_Comics()
|
|
{
|
|
var series = new SeriesBuilder("Test 1")
|
|
.WithFormat(MangaFormat.Archive)
|
|
.WithVolume(new VolumeBuilder("0")
|
|
.WithName(API.Services.Tasks.Scanner.Parser.Parser.DefaultVolume)
|
|
.WithChapter(new ChapterBuilder("2.5")
|
|
.WithIsSpecial(false)
|
|
.WithCoverImage("Special 1")
|
|
.Build())
|
|
.WithChapter(new ChapterBuilder("2")
|
|
.WithIsSpecial(false)
|
|
.WithCoverImage("Special 2")
|
|
.Build())
|
|
.WithChapter(new ChapterBuilder("0")
|
|
.WithIsSpecial(true)
|
|
.WithCoverImage("Special 3")
|
|
.Build())
|
|
.Build())
|
|
.WithVolume(new VolumeBuilder("1")
|
|
.WithNumber(1)
|
|
.WithChapter(new ChapterBuilder("0")
|
|
.WithIsSpecial(false)
|
|
.WithCoverImage("Volume 1")
|
|
.Build())
|
|
.Build())
|
|
.Build();
|
|
|
|
foreach (var vol in series.Volumes)
|
|
{
|
|
vol.CoverImage = vol.Chapters.MinBy(x => double.Parse(x.Number), ChapterSortComparerZeroFirst.Default)?.CoverImage;
|
|
}
|
|
|
|
Assert.Equal("Volume 1", series.GetCoverImage());
|
|
}
|
|
|
|
|
|
}
|