mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 06:11:10 +00:00
Adds a per-library option to skip hidden files and directories during scans
This commit is contained in:
1 parent
0bb795dca5
commit
0e8d61b215
67 files changed
+4624
-19
No files matched your search
+43
@@ -11,6 +11,7 @@ using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
@@ -56,6 +57,36 @@ public class EditLibraryViewEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
Assert.Contains($"libraries/{libraryId}", _apiFactory.ApiClientStub.GetEndpointsCalled);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public async Task EditLibraryView_WhenLibraryHasHiddenFilesSetting_ShouldRenderTheCheckboxWithItsStoredState(bool shouldSkipHiddenFilesAndDirectoriesDuringScan)
|
||||
{
|
||||
// Arrange
|
||||
_apiFactory.ApiClientStub.Reset();
|
||||
Guid libraryId = Guid.NewGuid();
|
||||
LibraryDto expectedLibrary = _libraryDtoFixture.Create(
|
||||
id: libraryId,
|
||||
title: "Books",
|
||||
libraryType: "Book",
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan: shouldSkipHiddenFilesAndDirectoriesDuringScan);
|
||||
_apiFactory.ApiClientStub.RegisterGetResponse($"libraries/{libraryId}", expectedLibrary);
|
||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await webClient.Client.GetAsync($"/en-us/libraries/manage/item/{libraryId}");
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
string? checkboxTag = GetCheckboxTag(content, "ShouldSkipHiddenFilesAndDirectoriesDuringScan");
|
||||
Assert.NotNull(checkboxTag);
|
||||
if (shouldSkipHiddenFilesAndDirectoriesDuringScan)
|
||||
Assert.Contains("checked", checkboxTag, StringComparison.OrdinalIgnoreCase);
|
||||
else
|
||||
Assert.DoesNotContain("checked", checkboxTag, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EditLibraryView_WhenThemeProvidesFileSystemBrowserTemplates_ShouldRenderThemedComponent()
|
||||
{
|
||||
@@ -104,6 +135,18 @@ public class EditLibraryViewEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
Assert.Contains("initFileSystemBrowser(", content);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rendered checkbox input tag with the provided name, or <see langword="null"/> when it is not present.
|
||||
/// </summary>
|
||||
/// <param name="content">The rendered HTML content.</param>
|
||||
/// <param name="name">The name of the checkbox input.</param>
|
||||
/// <returns>The rendered checkbox input tag, or <see langword="null"/>.</returns>
|
||||
private static string? GetCheckboxTag(string content, string name)
|
||||
{
|
||||
Match match = Regex.Match(content, $@"<input[^>]*name=""{Regex.Escape(name)}""[^>]*>");
|
||||
return match.Success ? match.Value : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the theme template response returned for the specified page key of the given theme.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user