Static files: Fix tree to only provide items from expected folders (closes #20962) (#21001)

* Applies checks for root folders to static file tree service.

* Add integration tests.

* Fix ancestor test.

* Amends from code review.

* Integration test compatibility suppressions.

* Reverted breaking change in test base class.
This commit is contained in:
Andy Butland
2025-12-02 02:20:08 +01:00
committed by GitHub
parent 742de79f46
commit 84c15ff4d7
9 changed files with 220 additions and 38 deletions

View File

@@ -14,7 +14,7 @@ public class StyleSheetTreeServiceTests : FileSystemTreeServiceTestsBase
protected override IFileSystem? GetStylesheetsFileSystem() => TestFileSystem;
[Test]
public void Can_Get_Siblings_From_StyleSheet_Tree_Service()
public void Can_Get_Siblings()
{
var service = new StyleSheetTreeService(FileSystems);
@@ -30,20 +30,20 @@ public class StyleSheetTreeServiceTests : FileSystemTreeServiceTestsBase
}
[Test]
public void Can_Get_Ancestors_From_StyleSheet_Tree_Service()
public void Can_Get_Ancestors()
{
var service = new StyleSheetTreeService(FileSystems);
var path = Path.Join("tests", $"file5{FileExtension}");
FileSystemTreeItemPresentationModel[] treeModel = service.GetAncestorModels(path, true);
FileSystemTreeItemPresentationModel[] treeModels = service.GetAncestorModels(path, true);
Assert.IsNotEmpty(treeModel);
Assert.AreEqual(treeModel.Length, 2);
Assert.AreEqual(treeModel[0].Name, "tests");
Assert.IsNotEmpty(treeModels);
Assert.AreEqual(treeModels.Length, 2);
Assert.AreEqual(treeModels[0].Name, "tests");
}
[Test]
public void Can_Get_PathViewModels_From_StyleSheet_Tree_Service()
public void Can_Get_PathViewModels()
{
var service = new StyleSheetTreeService(FileSystems);
@@ -59,7 +59,7 @@ public class StyleSheetTreeServiceTests : FileSystemTreeServiceTestsBase
var service = new StyleSheetTreeService(FileSystems);
for (int i = 0; i < 2; i++)
{
using var stream = CreateStream(Path.Join("tests"));
using var stream = CreateStream();
TestFileSystem.AddFile($"file{i}.invalid", stream);
}