Skip to content

Fix incomplete test setup causing 4 test failures and add PR build workflow#576

Merged
StuartFerguson merged 6 commits intomainfrom
copilot/fix-unit-test-failures
Jan 9, 2026
Merged

Fix incomplete test setup causing 4 test failures and add PR build workflow#576
StuartFerguson merged 6 commits intomainfrom
copilot/fix-unit-test-failures

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 9, 2026

Four Blazor component tests were failing due to incomplete mock setup - missing service registrations and mediator query mocks.

Changes

PermissionsDebugPageTests.cs

  • Added mocks for IPermissionService, AuthenticationStateProvider, and IPermissionStore
  • Component requires all three services during render; tests only provided TestContext

EstateIndexPageTests.cs

  • Added missing mediator mocks for GetMerchantsQuery, GetOperatorsQuery, GetContractsQuery
  • Component's OnInitializedAsync calls 4 queries; tests only mocked GetEstateQuery

Both fixes follow existing test patterns - registering mocks via Services.AddSingleton() and setting up default return values to allow component initialization.

pr-build-and-test.yml

  • Added GitHub Actions workflow for automated PR validation
  • Triggers on pull requests to main branch for relevant paths
  • Restores NuGet packages using both PUBLICFEEDURL and PRIVATEFEED_URL secrets
  • Builds solution in Release configuration (includes Blazor Server app)
  • Runs Blazor Server unit tests with detailed reporting
  • Publishes test results with artifacts retention for 30 days
Original prompt

This section details on the original issue you should resolve

<issue_title>Unit Test failures</issue_title>
<issue_description>Image</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…geTests

Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unit test failures Fix incomplete test setup causing 4 test failures Jan 9, 2026
Copilot AI requested a review from StuartFerguson January 9, 2026 11:26
@StuartFerguson
Copy link
Copy Markdown
Member

@copilot can you build me a pull request workflow that will build my blazor server app and run the unit tests you have just built

can you use these 2 sources when restoring nuget packages

--source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}

Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 9, 2026

@copilot can you build me a pull request workflow that will build my blazor server app and run the unit tests you have just built

can you use these 2 sources when restoring nuget packages
...

I've created a new GitHub Actions workflow in .github/workflows/pr-build-and-test.yml that:

  • Triggers on pull requests to the main branch
  • Restores NuGet packages using both feed URLs from secrets
  • Builds the Blazor Server app and full solution
  • Runs unit tests for both BlazorServer.Tests and BusinessLogic.Tests
  • Publishes test results with detailed reporting

The workflow uses .NET 10 and includes artifact upload for test results with 30-day retention. Commit: 9cae659

Comment thread .github/workflows/pr-build-and-test.yml Fixed
Copilot AI changed the title Fix incomplete test setup causing 4 test failures Fix incomplete test setup causing 4 test failures and add PR build workflow Jan 9, 2026
@StuartFerguson
Copy link
Copy Markdown
Member

@copilot can you remove the Run Business Logic unit tests step and also if I build the solution do i need to build the Blazor UI as well ?

Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 9, 2026

@copilot can you remove the Run Business Logic unit tests step and also if I build the solution do i need to build the Blazor UI as well ?

I've updated the workflow:

  1. Removed the "Run Business Logic unit tests" step
  2. Removed the redundant "Build Blazor Server project" step - you're correct, building the solution includes all projects so the separate Blazor Server build is unnecessary

The workflow now:

  • Restores packages
  • Builds the full solution once
  • Runs only the Blazor Server unit tests

Commit: cc7fdcc

@StuartFerguson StuartFerguson marked this pull request as ready for review January 9, 2026 12:00
@StuartFerguson StuartFerguson merged commit fdd0a73 into main Jan 9, 2026
10 checks passed
@github-actions github-actions Bot deleted the copilot/fix-unit-test-failures branch March 11, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit Test failures

3 participants