mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-23 15:30:34 -04:00
* Fixed a bug where cache TTL was using a field which always was 0. * Updated Scan Series task (from UI) to always re-calculate what's on file and not rely on last update. This leads to more reliable results, despite extra overhead. * Added image range processing on images for the reader, for slower networks or large files * On manga (single) try to use prefetched image, rather than re-requesting an image on pagination * Reduced some more latency when rendering first page of next chapter via continuous reading mode * Fixed a bug where metadata filter, after updating a typeahead, collapsing filter area then re-opening, the filter would still be applied, but the typeahead wouldn't show the modification. * Coded an idea around download reporting, commiting for history, might not go with it. * Refactored the download indicator into it's own component. Cleaning up some code for download within card component * Another throw away commit. Put in some temp code, not working but not sure if I'm ditching entirely. * Updated download service to enable range processing (so downloads can resume) and to reduce re-zipping if we've just downloaded something. * Refactored events widget download indicator to the correct design. I will be moving forward with this new functionality. * Added Required fields to ProgressDTO * Cleaned up the event widget and updated existing download progress to indicate preparing the download, rather than the download itself. * Updated dependencies for security alerts * Refactored all download code to be streamlined and globally handled * Updated ScanSeries to find the highest folder path before library, not just within the files. This could lead to scan series missing files due to nested folders on same parent level. * Updated the caching code to use a builtin annotation. Images are now caching correctly. * Fixed a bad redirect on an auth guard * Tweaked how long we allow cache for, as the cover update now doesn't work well. * Fixed a bug on downloading bookmarks from multiple series, where it would just choose the first series id for the temp file. * Added an extra check for downloading bookmarks * UI Security updates, Fixed a bug on bookmark reader, the reader on last page would throw some errors and not show No Next Chapter toast. * After scan, clear temp * Code smells
182 lines
6.2 KiB
C#
182 lines
6.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using API.Data;
|
|
using API.Entities;
|
|
using API.Entities.Enums;
|
|
using API.Helpers;
|
|
using API.Services.Tasks.Scanner;
|
|
using Xunit;
|
|
|
|
namespace API.Tests.Helpers;
|
|
|
|
public class SeriesHelperTests
|
|
{
|
|
#region FindSeries
|
|
[Fact]
|
|
public void FindSeries_ShouldFind_SameFormat()
|
|
{
|
|
var series = DbFactory.Series("Darker than Black");
|
|
series.OriginalName = "Something Random";
|
|
series.Format = MangaFormat.Archive;
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Archive,
|
|
Name = "Darker than Black",
|
|
NormalizedName = API.Parser.Parser.Normalize("Darker than Black")
|
|
}));
|
|
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Archive,
|
|
Name = "Darker than Black".ToLower(),
|
|
NormalizedName = API.Parser.Parser.Normalize("Darker than Black")
|
|
}));
|
|
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Archive,
|
|
Name = "Darker than Black".ToUpper(),
|
|
NormalizedName = API.Parser.Parser.Normalize("Darker than Black")
|
|
}));
|
|
}
|
|
|
|
[Fact]
|
|
public void FindSeries_ShouldNotFind_WrongFormat()
|
|
{
|
|
var series = DbFactory.Series("Darker than Black");
|
|
series.OriginalName = "Something Random";
|
|
series.Format = MangaFormat.Archive;
|
|
Assert.False(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Image,
|
|
Name = "Darker than Black",
|
|
NormalizedName = API.Parser.Parser.Normalize("Darker than Black")
|
|
}));
|
|
|
|
Assert.False(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Image,
|
|
Name = "Darker than Black".ToLower(),
|
|
NormalizedName = API.Parser.Parser.Normalize("Darker than Black")
|
|
}));
|
|
|
|
Assert.False(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Image,
|
|
Name = "Darker than Black".ToUpper(),
|
|
NormalizedName = API.Parser.Parser.Normalize("Darker than Black")
|
|
}));
|
|
}
|
|
|
|
[Fact]
|
|
public void FindSeries_ShouldFind_UsingOriginalName()
|
|
{
|
|
var series = DbFactory.Series("Darker than Black");
|
|
series.OriginalName = "Something Random";
|
|
series.Format = MangaFormat.Image;
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Image,
|
|
Name = "Something Random",
|
|
NormalizedName = API.Parser.Parser.Normalize("Something Random")
|
|
}));
|
|
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Image,
|
|
Name = "Something Random".ToLower(),
|
|
NormalizedName = API.Parser.Parser.Normalize("Something Random")
|
|
}));
|
|
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Image,
|
|
Name = "Something Random".ToUpper(),
|
|
NormalizedName = API.Parser.Parser.Normalize("Something Random")
|
|
}));
|
|
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Image,
|
|
Name = "SomethingRandom".ToUpper(),
|
|
NormalizedName = API.Parser.Parser.Normalize("SomethingRandom")
|
|
}));
|
|
}
|
|
|
|
[Fact]
|
|
public void FindSeries_ShouldFind_UsingLocalizedName()
|
|
{
|
|
var series = DbFactory.Series("Darker than Black");
|
|
series.LocalizedName = "Something Random";
|
|
series.Format = MangaFormat.Image;
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Image,
|
|
Name = "Something Random",
|
|
NormalizedName = API.Parser.Parser.Normalize("Something Random")
|
|
}));
|
|
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Image,
|
|
Name = "Something Random".ToLower(),
|
|
NormalizedName = API.Parser.Parser.Normalize("Something Random")
|
|
}));
|
|
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Image,
|
|
Name = "Something Random".ToUpper(),
|
|
NormalizedName = API.Parser.Parser.Normalize("Something Random")
|
|
}));
|
|
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Image,
|
|
Name = "SomethingRandom".ToUpper(),
|
|
NormalizedName = API.Parser.Parser.Normalize("SomethingRandom")
|
|
}));
|
|
}
|
|
|
|
[Fact]
|
|
public void FindSeries_ShouldFind_UsingLocalizedName_2()
|
|
{
|
|
var series = DbFactory.Series("My Dress-Up Darling");
|
|
series.LocalizedName = "Sono Bisque Doll wa Koi wo Suru";
|
|
series.Format = MangaFormat.Archive;
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Archive,
|
|
Name = "My Dress-Up Darling",
|
|
NormalizedName = API.Parser.Parser.Normalize("My Dress-Up Darling")
|
|
}));
|
|
|
|
Assert.True(SeriesHelper.FindSeries(series, new ParsedSeries()
|
|
{
|
|
Format = MangaFormat.Archive,
|
|
Name = "Sono Bisque Doll wa Koi wo Suru".ToLower(),
|
|
NormalizedName = API.Parser.Parser.Normalize("Sono Bisque Doll wa Koi wo Suru")
|
|
}));
|
|
}
|
|
#endregion
|
|
|
|
[Fact]
|
|
public void RemoveMissingSeries_Should_RemoveSeries()
|
|
{
|
|
var existingSeries = new List<Series>()
|
|
{
|
|
EntityFactory.CreateSeries("Darker than Black Vol 1"),
|
|
EntityFactory.CreateSeries("Darker than Black"),
|
|
EntityFactory.CreateSeries("Beastars"),
|
|
};
|
|
var missingSeries = new List<Series>()
|
|
{
|
|
EntityFactory.CreateSeries("Darker than Black Vol 1"),
|
|
};
|
|
existingSeries = SeriesHelper.RemoveMissingSeries(existingSeries, missingSeries, out var removeCount).ToList();
|
|
|
|
Assert.DoesNotContain(missingSeries[0].Name, existingSeries.Select(s => s.Name));
|
|
Assert.Equal(missingSeries.Count, removeCount);
|
|
}
|
|
}
|