From e290d7a515465bf0bab5380a2a4f0c0c4454860f Mon Sep 17 00:00:00 2001 From: Anto Subash Date: Thu, 26 Mar 2026 22:25:59 +0100 Subject: [PATCH 1/2] feat(ci): add testing step to CI workflow and update application factory to include FileStorageDbContext --- .github/workflows/ci.yml | 3 +++ .../Fixtures/SimpleModuleWebApplicationFactory.cs | 1 + 2 files changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b458dcb6..be469bab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,3 +59,6 @@ jobs: - name: Build frontend run: npm run build + + - name: Test + run: dotnet test --no-build diff --git a/tests/SimpleModule.Tests.Shared/Fixtures/SimpleModuleWebApplicationFactory.cs b/tests/SimpleModule.Tests.Shared/Fixtures/SimpleModuleWebApplicationFactory.cs index 551235b1..49255490 100644 --- a/tests/SimpleModule.Tests.Shared/Fixtures/SimpleModuleWebApplicationFactory.cs +++ b/tests/SimpleModule.Tests.Shared/Fixtures/SimpleModuleWebApplicationFactory.cs @@ -57,6 +57,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) ReplaceDbContext(services); ReplaceDbContext(services); ReplaceDbContext(services); + ReplaceDbContext(services); ReplaceDbContext(services, useOpenIddict: true); // Remove hosted seed services — they need real DB tables that From 2a0f17b551bc7cb5f1a9fe57f3f8917ad81dc86e Mon Sep 17 00:00:00 2001 From: Anto Subash Date: Thu, 26 Mar 2026 22:34:33 +0100 Subject: [PATCH 2/2] fix(tests): use platform-agnostic paths in ViteDevWatchService tests Replace hardcoded Windows paths (C:\...) with Path.Combine() so tests pass on both Windows and Linux CI runners. --- .../ViteDevWatchServiceTests.cs | 128 +++++++++++++----- 1 file changed, 93 insertions(+), 35 deletions(-) diff --git a/tests/SimpleModule.DevTools.Tests/ViteDevWatchServiceTests.cs b/tests/SimpleModule.DevTools.Tests/ViteDevWatchServiceTests.cs index 5a3898db..84655422 100644 --- a/tests/SimpleModule.DevTools.Tests/ViteDevWatchServiceTests.cs +++ b/tests/SimpleModule.DevTools.Tests/ViteDevWatchServiceTests.cs @@ -164,58 +164,116 @@ public void Discovers_Multiple_Modules_Within_Same_Group() public sealed class ContainsSegmentTests { - [Theory] - [InlineData("C:\\project\\wwwroot\\file.js", "wwwroot", true)] - [InlineData("C:\\project\\src\\file.js", "wwwroot", false)] - [InlineData("/project/node_modules/pkg/index.js", "node_modules", true)] - [InlineData("/project/my_node_modules_backup/file.js", "node_modules", false)] - [InlineData("C:\\a\\_scan\\file.css", "_scan", true)] - [InlineData("C:\\a\\scanner\\file.css", "_scan", false)] - public void ContainsSegment_Detects_Path_Segments( - string fullPath, - string segment, - bool expected - ) - { - ViteDevWatchService.ContainsSegment(fullPath, segment).Should().Be(expected); + private static string P(params string[] parts) => Path.Combine(parts); + + [Fact] + public void ContainsSegment_Detects_Matching_Segment() + { + var path = P("project", "wwwroot", "file.js"); + ViteDevWatchService.ContainsSegment(path, "wwwroot").Should().BeTrue(); + } + + [Fact] + public void ContainsSegment_Returns_False_For_Missing_Segment() + { + var path = P("project", "src", "file.js"); + ViteDevWatchService.ContainsSegment(path, "wwwroot").Should().BeFalse(); + } + + [Fact] + public void ContainsSegment_Detects_NodeModules() + { + var path = P("project", "node_modules", "pkg", "index.js"); + ViteDevWatchService.ContainsSegment(path, "node_modules").Should().BeTrue(); + } + + [Fact] + public void ContainsSegment_Does_Not_Match_Partial_Segment_Name() + { + var path = P("project", "my_node_modules_backup", "file.js"); + ViteDevWatchService.ContainsSegment(path, "node_modules").Should().BeFalse(); + } + + [Fact] + public void ContainsSegment_Detects_Scan_Segment() + { + var path = P("a", "_scan", "file.css"); + ViteDevWatchService.ContainsSegment(path, "_scan").Should().BeTrue(); + } + + [Fact] + public void ContainsSegment_Does_Not_Match_Scanner_For_Scan() + { + var path = P("a", "scanner", "file.css"); + ViteDevWatchService.ContainsSegment(path, "_scan").Should().BeFalse(); } [Fact] public void ContainsSegment_Is_Case_Insensitive() { - ViteDevWatchService - .ContainsSegment("C:\\project\\WWWROOT\\file.js", "wwwroot") - .Should() - .BeTrue(); + var path = P("project", "WWWROOT", "file.js"); + ViteDevWatchService.ContainsSegment(path, "wwwroot").Should().BeTrue(); } } public sealed class ShouldIgnorePathTests { - [Theory] - [InlineData("C:\\modules\\Products\\wwwroot\\Products.pages.js", true)] - [InlineData("C:\\modules\\Products\\node_modules\\react\\index.js", true)] - [InlineData("C:\\modules\\Products\\Pages\\index.ts", false)] - [InlineData("C:\\modules\\Products\\Views\\Browse.tsx", false)] - public void ShouldIgnoreModulePath_Filters_Correctly(string path, bool expected) + private static string P(params string[] parts) => Path.Combine(parts); + + [Fact] + public void ShouldIgnoreModulePath_Ignores_Wwwroot() + { + var path = P("modules", "Products", "wwwroot", "Products.pages.js"); + ViteDevWatchService.ShouldIgnoreModulePath(path).Should().BeTrue(); + } + + [Fact] + public void ShouldIgnoreModulePath_Ignores_NodeModules() + { + var path = P("modules", "Products", "node_modules", "react", "index.js"); + ViteDevWatchService.ShouldIgnoreModulePath(path).Should().BeTrue(); + } + + [Fact] + public void ShouldIgnoreModulePath_Allows_Pages() { - ViteDevWatchService.ShouldIgnoreModulePath(path).Should().Be(expected); + var path = P("modules", "Products", "Pages", "index.ts"); + ViteDevWatchService.ShouldIgnoreModulePath(path).Should().BeFalse(); } - [Theory] - [InlineData("C:\\ClientApp\\node_modules\\react\\index.js", true)] - [InlineData("C:\\ClientApp\\app.tsx", false)] - public void ShouldIgnoreClientAppPath_Filters_Correctly(string path, bool expected) + [Fact] + public void ShouldIgnoreModulePath_Allows_Views() { - ViteDevWatchService.ShouldIgnoreClientAppPath(path).Should().Be(expected); + var path = P("modules", "Products", "Views", "Browse.tsx"); + ViteDevWatchService.ShouldIgnoreModulePath(path).Should().BeFalse(); } - [Theory] - [InlineData("C:\\Styles\\_scan\\output.css", true)] - [InlineData("C:\\Styles\\app.css", false)] - public void ShouldIgnoreTailwindPath_Filters_Correctly(string path, bool expected) + [Fact] + public void ShouldIgnoreClientAppPath_Ignores_NodeModules() + { + var path = P("ClientApp", "node_modules", "react", "index.js"); + ViteDevWatchService.ShouldIgnoreClientAppPath(path).Should().BeTrue(); + } + + [Fact] + public void ShouldIgnoreClientAppPath_Allows_Source_Files() + { + var path = P("ClientApp", "app.tsx"); + ViteDevWatchService.ShouldIgnoreClientAppPath(path).Should().BeFalse(); + } + + [Fact] + public void ShouldIgnoreTailwindPath_Ignores_Scan_Directory() + { + var path = P("Styles", "_scan", "output.css"); + ViteDevWatchService.ShouldIgnoreTailwindPath(path).Should().BeTrue(); + } + + [Fact] + public void ShouldIgnoreTailwindPath_Allows_Source_Css() { - ViteDevWatchService.ShouldIgnoreTailwindPath(path).Should().Be(expected); + var path = P("Styles", "app.css"); + ViteDevWatchService.ShouldIgnoreTailwindPath(path).Should().BeFalse(); } }