Expand integration coverage and fix settings UI
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using System.IO.Compression;
|
||||
using Jellyfin.Plugin.Multilang.Configuration;
|
||||
using Jellyfin.Plugin.Multilang.Data;
|
||||
using Jellyfin.Plugin.Multilang.Services.Backup;
|
||||
|
||||
namespace Jellyfin.Plugin.Multilang.Tests;
|
||||
|
||||
public sealed class MultilangBackupServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void FullExportIncludesTheSelectedSections()
|
||||
{
|
||||
var root = TestPaths.CreateRoot();
|
||||
try
|
||||
{
|
||||
var store = new TranslationStore(new TestApplicationPaths(root));
|
||||
store.SaveUserRules(UserId, new UserRulesDocument { Enabled = true, SortLocale = "fi-FI" });
|
||||
var service = new MultilangBackupService(store, null!, null!);
|
||||
|
||||
var bytes = service.Export(
|
||||
new BackupExportOptions(PluginSettings: true, UserSettings: true, TranslationsDatabase: true, DownloadedAssets: false),
|
||||
new PluginConfiguration { Languages = ["en", "fi"] });
|
||||
|
||||
using var zip = new ZipArchive(new MemoryStream(bytes), ZipArchiveMode.Read);
|
||||
Assert.NotNull(zip.GetEntry("manifest.json"));
|
||||
Assert.NotNull(zip.GetEntry("plugin-config.json"));
|
||||
Assert.NotNull(zip.GetEntry("translations.sqlite"));
|
||||
Assert.NotNull(zip.GetEntry("user-rules/" + UserId + ".json"));
|
||||
Assert.Null(zip.GetEntry("assets/"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
TestPaths.DeleteRoot(root);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UserExportCanBeInspectedAndImportedForAnotherUser()
|
||||
{
|
||||
var root = TestPaths.CreateRoot();
|
||||
try
|
||||
{
|
||||
var store = new TranslationStore(new TestApplicationPaths(root));
|
||||
var service = new MultilangBackupService(store, null!, null!);
|
||||
var sourceRules = new UserRulesDocument
|
||||
{
|
||||
Enabled = true,
|
||||
SortLocale = "sv-SE",
|
||||
TrustTmdbCollections = false
|
||||
};
|
||||
|
||||
var bytes = service.ExportUserRules(UserId, sourceRules);
|
||||
var inspection = service.InspectUserImport(new MemoryStream(bytes), OtherUserId);
|
||||
var result = service.ImportUser(new MemoryStream(bytes), OtherUserId, UserId);
|
||||
|
||||
Assert.Equal(1, inspection.UserSettingsCount);
|
||||
Assert.False(inspection.ContainsCurrentUser);
|
||||
Assert.Equal([UserId], inspection.UserIds);
|
||||
Assert.Equal(1, result.UserSettingsImported);
|
||||
var imported = store.GetUserRules(OtherUserId);
|
||||
Assert.NotNull(imported);
|
||||
Assert.True(imported.Enabled);
|
||||
Assert.Equal("sv-SE", imported.SortLocale);
|
||||
Assert.False(imported.TrustTmdbCollections);
|
||||
}
|
||||
finally
|
||||
{
|
||||
TestPaths.DeleteRoot(root);
|
||||
}
|
||||
}
|
||||
|
||||
private const string UserId = "11111111111111111111111111111111";
|
||||
private const string OtherUserId = "22222222222222222222222222222222";
|
||||
}
|
||||
Reference in New Issue
Block a user