From 21ab1174db5f32384f27bc744967ed10bb0874d3 Mon Sep 17 00:00:00 2001 From: Ciaran Liedeman Date: Sat, 27 Jun 2026 00:11:47 +0200 Subject: [PATCH] test(fork): add bUnit smoke test and fork CI workflow Confirm bUnit works against the fork's stack (xUnit v3 + Microsoft.Testing.Platform on net10/net11) by rendering UseFragment and asserting ChildContent / LoadingContent, and add a pull_request CI workflow scoped to the forked packages. - add bunit 2.7.2 to central package management - StrawberryShake.Razor.Tests references bunit; UseFragmentBunitTests renders the component via bUnit (4/4 pass on net10 and net11) - ci-fork.yml builds + tests Razor.Tests (runtime + bUnit) and Core.Tests on pull_request and fork/release-branch pushes (the Razor codegen snapshot tests bake the generator assembly version and aren't CI-portable, so they are excluded) Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/ci-fork.yml | 39 +++++++++++++++++++ src/Directory.Packages.props | 1 + .../StrawberryShake.Razor.Tests.csproj | 4 ++ .../test/Razor.Tests/UseFragmentBunitTests.cs | 32 +++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 .github/workflows/ci-fork.yml create mode 100644 src/StrawberryShake/Client/test/Razor.Tests/UseFragmentBunitTests.cs diff --git a/.github/workflows/ci-fork.yml b/.github/workflows/ci-fork.yml new file mode 100644 index 00000000000..213cad09567 --- /dev/null +++ b/.github/workflows/ci-fork.yml @@ -0,0 +1,39 @@ +name: 🍓 Fork CI + +# Builds and tests the forked StrawberryShake runtime packages (Razor + Core), including a +# bUnit smoke test. Scoped to what the fork touches - not the full upstream monorepo matrix. +# The Razor codegen snapshot tests bake the generator assembly version (0.0.0.0 locally vs the +# stamped version in CI) so they are not CI-portable and are not run here. + +on: + pull_request: + push: + branches: + - fork + - "release/fork-*" + +permissions: + contents: read + +jobs: + test: + name: Build & test forked packages + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + + - name: Install .NET + uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0 + with: + dotnet-version: | + 8.x + 9.x + 10.x + 11.0.100-preview.5.26302.115 + + - name: Test StrawberryShake.Razor (runtime + bUnit) + run: dotnet test src/StrawberryShake/Client/test/Razor.Tests/StrawberryShake.Razor.Tests.csproj -c Release + + - name: Test StrawberryShake.Core + run: dotnet test src/StrawberryShake/Client/test/Core.Tests/StrawberryShake.Core.Tests.csproj -c Release diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 7acff5dbc26..595a5f6dc13 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -74,6 +74,7 @@ + diff --git a/src/StrawberryShake/Client/test/Razor.Tests/StrawberryShake.Razor.Tests.csproj b/src/StrawberryShake/Client/test/Razor.Tests/StrawberryShake.Razor.Tests.csproj index cb439f6db37..81ce15bfa89 100644 --- a/src/StrawberryShake/Client/test/Razor.Tests/StrawberryShake.Razor.Tests.csproj +++ b/src/StrawberryShake/Client/test/Razor.Tests/StrawberryShake.Razor.Tests.csproj @@ -9,6 +9,10 @@ net11.0;net10.0 + + + + diff --git a/src/StrawberryShake/Client/test/Razor.Tests/UseFragmentBunitTests.cs b/src/StrawberryShake/Client/test/Razor.Tests/UseFragmentBunitTests.cs new file mode 100644 index 00000000000..0b47d4cbe97 --- /dev/null +++ b/src/StrawberryShake/Client/test/Razor.Tests/UseFragmentBunitTests.cs @@ -0,0 +1,32 @@ +using Bunit; + +namespace StrawberryShake.Razor; + +/// +/// Smoke tests confirming bUnit can render the StrawberryShake.Razor components. +/// +public class UseFragmentBunitTests : BunitContext +{ + [Fact] + public void Renders_ChildContent_When_Data_Is_Present() + { + // arrange & act + var cut = Render>(parameters => parameters + .Add(p => p.Data, "Strawberry") + .Add(p => p.ChildContent, data => $"{data}")); + + // assert + cut.MarkupMatches("Strawberry"); + } + + [Fact] + public void Renders_LoadingContent_When_Data_Is_Null() + { + // arrange & act + var cut = Render>(parameters => parameters + .Add(p => p.LoadingContent, "loading")); + + // assert + cut.MarkupMatches("loading"); + } +}