mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-01 04:34:49 -04:00
* Moved the Server Settings out into a button on nav header * Refactored Mange Users page to the new design (skeleton). Implemented skeleton code for Invite User. * Hashed out more of the code, but need to move all the email code to a Kavita controlled API server due to password credentials. * Cleaned up some warnings * When no user exists for an api key in Plugin controller, throw 401. * Hooked in the ability to check if the Kavita instance can be accessed externally so we can determine if the user can invite or not. * Hooked up some logic if the user's server isn't accessible, then default to old flow * Basic flow is working for confirm email. Needs validation, error handling, etc. * Refactored Password validation to account service * Cleaned up the code in confirm-email to work much better. * Refactored the login page to have a container functionality, so we can reuse the styles on multiple pages (registration pages). Hooked up the code for confirm email. * Messy code, but making progress. Refactored Register to be used only for first time user registration. Added a new register component to handle first time flow only. * Invite works much better, still needs a bit of work for non-accessible server setup. Started work on underlying manage users page to meet new design. * Changed (you) to a star to indicate who you're logged in as. * Inviting a user is now working and tested fully. * Removed the register member component as we now have invite and confirm components. * Editing a user is now working. Username change and Role/Library access from within one screen. Email changing is on hold. * Cleaned up code for edit user and disabled email field for now. * Cleaned up the code to indicate changing a user's email is not possible. * Implemented a migration for existing accounts so they can validate their emails and still login. * Change url for email server * Implemented the ability to resend an email confirmation code (or regenerate for non accessible servers). Fixed an overflow on the confirm dialog. * Took care of some code cleanup * Removed 3 db calls from cover refresh and some misc cleanup * Fixed a broken test
130 lines
5.2 KiB
C#
130 lines
5.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using API.Entities;
|
|
using API.Entities.Enums;
|
|
using API.Entities.Metadata;
|
|
using API.Parser;
|
|
using API.Services.Tasks;
|
|
using API.Services.Tasks.Scanner;
|
|
using API.Tests.Helpers;
|
|
using Xunit;
|
|
|
|
namespace API.Tests.Services
|
|
{
|
|
public class ScannerServiceTests
|
|
{
|
|
[Fact]
|
|
public void FindSeriesNotOnDisk_Should_Remove1()
|
|
{
|
|
var infos = new Dictionary<ParsedSeries, List<ParserInfo>>();
|
|
|
|
ParserInfoFactory.AddToParsedInfo(infos, new ParserInfo() {Series = "Darker than Black", Volumes = "1", Format = MangaFormat.Archive});
|
|
//AddToParsedInfo(infos, new ParserInfo() {Series = "Darker than Black", Volumes = "1", Format = MangaFormat.Epub});
|
|
|
|
var existingSeries = new List<Series>
|
|
{
|
|
new Series()
|
|
{
|
|
Name = "Darker Than Black",
|
|
LocalizedName = "Darker Than Black",
|
|
OriginalName = "Darker Than Black",
|
|
Volumes = new List<Volume>()
|
|
{
|
|
new Volume()
|
|
{
|
|
Number = 1,
|
|
Name = "1"
|
|
}
|
|
},
|
|
NormalizedName = API.Parser.Parser.Normalize("Darker Than Black"),
|
|
Metadata = new SeriesMetadata(),
|
|
Format = MangaFormat.Epub
|
|
}
|
|
};
|
|
|
|
Assert.Equal(1, ScannerService.FindSeriesNotOnDisk(existingSeries, infos).Count());
|
|
}
|
|
|
|
[Fact]
|
|
public void FindSeriesNotOnDisk_Should_RemoveNothing_Test()
|
|
{
|
|
var infos = new Dictionary<ParsedSeries, List<ParserInfo>>();
|
|
|
|
ParserInfoFactory.AddToParsedInfo(infos, new ParserInfo() {Series = "Darker than Black", Format = MangaFormat.Archive});
|
|
ParserInfoFactory.AddToParsedInfo(infos, new ParserInfo() {Series = "Cage of Eden", Volumes = "1", Format = MangaFormat.Archive});
|
|
ParserInfoFactory.AddToParsedInfo(infos, new ParserInfo() {Series = "Cage of Eden", Volumes = "10", Format = MangaFormat.Archive});
|
|
|
|
var existingSeries = new List<Series>
|
|
{
|
|
new Series()
|
|
{
|
|
Name = "Cage of Eden",
|
|
LocalizedName = "Cage of Eden",
|
|
OriginalName = "Cage of Eden",
|
|
NormalizedName = API.Parser.Parser.Normalize("Cage of Eden"),
|
|
Metadata = new SeriesMetadata(),
|
|
Format = MangaFormat.Archive
|
|
},
|
|
new Series()
|
|
{
|
|
Name = "Darker Than Black",
|
|
LocalizedName = "Darker Than Black",
|
|
OriginalName = "Darker Than Black",
|
|
NormalizedName = API.Parser.Parser.Normalize("Darker Than Black"),
|
|
Metadata = new SeriesMetadata(),
|
|
Format = MangaFormat.Archive
|
|
}
|
|
};
|
|
|
|
|
|
|
|
Assert.Empty(ScannerService.FindSeriesNotOnDisk(existingSeries, infos));
|
|
}
|
|
|
|
|
|
// TODO: Figure out how to do this with ParseScannedFiles
|
|
// [Theory]
|
|
// [InlineData(new [] {"Darker than Black"}, "Darker than Black", "Darker than Black")]
|
|
// [InlineData(new [] {"Darker than Black"}, "Darker Than Black", "Darker than Black")]
|
|
// [InlineData(new [] {"Darker than Black"}, "Darker Than Black!", "Darker than Black")]
|
|
// [InlineData(new [] {""}, "Runaway Jack", "Runaway Jack")]
|
|
// public void MergeNameTest(string[] existingSeriesNames, string parsedInfoName, string expected)
|
|
// {
|
|
// var collectedSeries = new ConcurrentDictionary<ParsedSeries, List<ParserInfo>>();
|
|
// foreach (var seriesName in existingSeriesNames)
|
|
// {
|
|
// AddToParsedInfo(collectedSeries, new ParserInfo() {Series = seriesName, Format = MangaFormat.Archive});
|
|
// }
|
|
//
|
|
// var actualName = new ParseScannedFiles(_bookService, _logger).MergeName(collectedSeries, new ParserInfo()
|
|
// {
|
|
// Series = parsedInfoName,
|
|
// Format = MangaFormat.Archive
|
|
// });
|
|
//
|
|
// Assert.Equal(expected, actualName);
|
|
// }
|
|
|
|
// [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 = ScannerService.RemoveMissingSeries(existingSeries, missingSeries, out var removeCount).ToList();
|
|
//
|
|
// Assert.DoesNotContain(missingSeries[0].Name, existingSeries.Select(s => s.Name));
|
|
// Assert.Equal(missingSeries.Count, removeCount);
|
|
// }
|
|
|
|
|
|
}
|
|
}
|