Skip to content

Add Playwright-based integration tests for Blazor Server UI and Docker build support#457

Merged
StuartFerguson merged 23 commits intomainfrom
copilot/update-integration-tests-playwright
Jan 6, 2026
Merged

Add Playwright-based integration tests for Blazor Server UI and Docker build support#457
StuartFerguson merged 23 commits intomainfrom
copilot/update-integration-tests-playwright

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 5, 2026

  • Analyze existing integration test structure and Docker setup
  • Create new test project EstateManagementUI.BlazorIntegrationTests targeting Blazor UI
  • Add Playwright packages and dependencies
  • Copy and adapt Docker infrastructure from existing integration tests
  • Create Playwright-based web driver helpers (replacing Selenium Extensions)
  • Port test hooks and setup code to use Playwright
  • Port all feature files for Blazor UI
  • Add comprehensive UI helper methods (login, navigation, verification)
  • Add extensive step definitions for feature tests
  • Add project README documentation
  • Create comprehensive migration guide from Selenium to Playwright
  • Update main repository README with test project information
  • Add dropdown selection helper methods
  • Update .gitignore for Playwright artifacts
  • Create implementation summary document
  • Add Dockerfile for Blazor Server application
  • Add NuGet.Config and Certificates to Blazor Server
  • Add .dockerignore for Blazor Server
  • Add Docker properties to csproj for Visual Studio recognition
  • Add Visual Studio Azure Container Tools package
  • Add .dockerignore reference with DependentUpon Dockerfile
  • Configure Kestrel with HTTPS certificate loading
  • Copy certificates to Docker runtime image
  • Add comprehensive diagnostics for certificate loading
  • Fix Node.js installation in Docker (--insecure for corporate proxies)
  • Add ID attributes to all interactive UI elements for Playwright test selectors
  • Add SecurityServiceLocalPort and SecurityServicePort configuration support
  • Add HttpClientIgnoreCertificateErrors configuration for CI/CD testing
  • Add ID attributes to Estate Name and Reference elements
  • Convert Estate Name and Reference to readonly input elements
  • Build verification (requires private NuGet feed access)
  • Test execution validation (requires Docker and full build)

Summary

Successfully created integration tests for Blazor UI using Playwright and added complete Docker build infrastructure. Changed Estate Name and Reference from <p> paragraph elements to readonly <input> elements to support Playwright's GetValueById() method which requires form input elements. The readonly inputs maintain the display-only nature while allowing tests to retrieve values using InputValueAsync().

Original prompt

This section details on the original issue you should resolve

<issue_title>Integration Tests for UI</issue_title>
<issue_description>I currently have a set of integration tests for the existing UI (EstateManagementUI.IntegrationTests.csproj)

I would like to build a new set of tests keeping the whole docker infrastructure etc in that test project but with 2 changes:

  1. Change the tests to target the new Blazor UI
  2. Move from selenium to Playwright for the test framework

If it makes more sense to clone the create a new set of code for the web driver then do this

Also might make more sense to do each set of tests as a new commit but will leave that up to you.</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.

Copilot AI changed the title [WIP] Update integration tests for new Blazor UI with Playwright Add Playwright-based integration tests for Blazor Server UI Jan 5, 2026
Copilot AI requested a review from StuartFerguson January 5, 2026 07:53
@StuartFerguson
Copy link
Copy Markdown
Member

@copilot can you add a docker file to build the blazor app please

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot can you add a docker file to build the blazor app please

Added Dockerfile for the Blazor Server application in commit db02a75.

The Dockerfile includes:

  • Multi-stage build using .NET 10.0 SDK
  • Node.js installation for Tailwind CSS compilation
  • npm install and CSS build steps
  • NuGet package restoration with private feed support
  • Publishing to the stuartferguson/txnprocbase base image

Also added:

  • .dockerignore to exclude build artifacts and node_modules
  • NuGet.Config for private package feed access
  • Certificates/ directory with the required certificate file

The image will be built as estatemanagementuiblazor which matches the integration test configuration.

Copilot AI changed the title Add Playwright-based integration tests for Blazor Server UI Add Playwright-based integration tests for Blazor Server UI and Docker build support Jan 5, 2026
@StuartFerguson
Copy link
Copy Markdown
Member

@copilot that dockerfile is not recognised in visual studio as a docker file any ideas ?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot that dockerfile is not recognised in visual studio as a docker file any ideas ?

Fixed in commit e2d762d. Added Docker-related properties to the .csproj file:

  • ContainerDevelopmentMode: Regular
  • DockerDefaultTargetOS: Linux
  • UserSecretsId: Generated GUID

Visual Studio uses these properties to recognize the Dockerfile and enable Docker tooling support. The Dockerfile should now appear in the project and be available for right-click context menu operations like "Build Docker Image" and "Run Container".

@StuartFerguson
Copy link
Copy Markdown
Member

@copilot still cant right click and build the docker image

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot still cant right click and build the docker image

Fixed in commit cefec86. Added the missing Microsoft.VisualStudio.Azure.Containers.Tools.Targets package (v1.22.1) which provides Visual Studio's Docker tooling support.

Also added explicit reference to .dockerignore with DependentUpon relationship to the Dockerfile.

After reloading the project in Visual Studio, you should now be able to:

  • Right-click the project → Add → Docker Support
  • Right-click Dockerfile → Build Docker Image
  • Right-click project → Container Tools → Build/Start/Debug in Container

If the context menu still doesn't appear, try closing and reopening Visual Studio to ensure the new package is fully loaded.

@StuartFerguson
Copy link
Copy Markdown
Member

@copilot get this error on the startup of the UI container

fail: Microsoft.Extensions.Hosting.Internal.Host[11]

  Hosting failed to start

  System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.

  To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.

  For more information on configuring HTTPS see [https://go.microsoft.com/fwlink/?linkid=848054.⁠](https://go.microsoft.com/fwlink/?linkid=848054.)

     at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)

     at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken)

     at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)

     at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)

     at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)

     at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__14_1(IHostedService service, CancellationToken token)

     at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
     
     
     I am sure this wass covered in the kestrel setup of the old UI

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot ok test running nowbut get this error on teh ClickOnTheSignInButton() helper method

  • waiting for Locator("#loginButton") to be visible
    ...

Fixed in commit bed3647. Added id attributes to all interactive elements throughout the Blazor UI components:

Login buttons:

  • id="loginButton" on all Sign In links (EntryScreen, EstateInfo, MerchantInfo, FileInfo pages)

Navigation links (NavMenu):

  • id="dashboardLink" - Dashboard
  • id="estateDetailsLink" - Estate Management
  • id="merchantsLink" - Merchant Management
  • id="contractsLink" - Contract Management
  • id="operatorsLink" - Operator Management
  • id="fileProcessingLink" - File Processing

Action buttons (Index pages):

  • id="newMerchantButton" - Add New Merchant
  • id="newOperatorButton" - Add New Operator
  • id="newContractButton" - Add New Contract

Submit buttons (New/Create pages):

  • id="createContractButton" - Contract creation
  • id="createMerchantButton" - Merchant creation
  • id="createOperatorButton" - Operator creation

All test selectors like Locator("#loginButton"), Locator("#merchantsLink"), etc. should now work correctly. The tests can locate and interact with all UI elements.

@StuartFerguson
Copy link
Copy Markdown
Member

@copilot in my old UI i used these 2 config settings for use with integration tests

String securityServiceLocalPort =
ConfigurationReader.GetValueOrDefault("AppSettings", "SecurityServiceLocalPort", null);
String securityServicePort =
ConfigurationReader.GetValueOrDefault("AppSettings", "SecurityServicePort", null);

can you factor these into the authentication setup in the Blazor UI

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot in my old UI i used these 2 config settings for use with integration tests

String securityServiceLocalPort =
...

Added in commit e09577f. The Blazor UI now supports SecurityServiceLocalPort and SecurityServicePort configuration settings for integration testing.

Changes made:

  1. appsettings.json - Added AppSettings section:
"AppSettings": {
  "SecurityServiceLocalPort": null,
  "SecurityServicePort": null
}
  1. AuthenticationHelpers.cs (NEW) - Created helper class with GetSecurityServiceAddresses method that:

    • Reads the port configuration values
    • Defaults to port 5001 if not specified
    • Adjusts authority and issuer URLs based on configured ports
    • Includes console logging for diagnostics
  2. Program.cs - Updated authentication setup to:

    • Read SecurityServiceLocalPort and SecurityServicePort from configuration
    • Call AuthenticationHelpers.GetSecurityServiceAddresses() to get adjusted URLs
    • Set options.Authority to the adjusted authority address
    • Set options.MetadataAddress using the adjusted authority address

The implementation matches the legacy UI behavior, allowing integration tests to override the security service port dynamically.

@StuartFerguson
Copy link
Copy Markdown
Member

@copilot ok new error

AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemoteCertificateChainErrors

In my old app tehre was a section to ignore cert errors that was used for CI/CD testing controlled by a config parameter HttpClientIgnoreCertificateErrors, can you look at the old app and migrate this code over to the blazor app as well please

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot ok new error

AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemoteCertificateChainErrors
...

Added in commit ffe8e2d. The Blazor UI now supports HttpClientIgnoreCertificateErrors configuration to bypass SSL certificate validation in CI/CD testing environments.

Changes made:

  1. appsettings.json - Added configuration setting:
"AppSettings": {
  "HttpClientIgnoreCertificateErrors": false
}
  1. Program.cs - Updated OpenID Connect configuration to:
    • Read HttpClientIgnoreCertificateErrors from configuration (defaults to false)
    • When set to true, creates an HttpClientHandler with ServerCertificateCustomValidationCallback set to DangerousAcceptAnyServerCertificateValidator
    • Assigns the handler to options.BackchannelHttpHandler for OIDC backchannel communication
    • Logs a warning when certificate validation is disabled

This resolves the RemoteCertificateNameMismatch and RemoteCertificateChainErrors by allowing the OIDC client to accept any server certificate when the setting is enabled, matching the legacy UI behavior for integration testing.

@StuartFerguson
Copy link
Copy Markdown
Member

@copilot in running the ViewEstateDetails test i get this error

System.TimeoutException : Timeout 30000ms exceeded.

Call log:

    • waiting for Locator("#Estate_Name") to be visible

I dont think the element for the estate name has a id to lookup

this mght also be true of the Estate Reference

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 6, 2026

@copilot in running the ViewEstateDetails test i get this error

System.TimeoutException : Timeout 30000ms exceeded.

...

Fixed in commit 31e5c6a. Added id attributes to the Estate Name and Reference elements in the Estate Management page:

  • id="Estate_Name" on the estate name paragraph element (line 25)
  • id="Estate_Reference" on the reference paragraph element (line 33)

The ViewEstateDetails test can now successfully locate these elements using Locator("#Estate_Name") and Locator("#Estate_Reference").

@StuartFerguson
Copy link
Copy Markdown
Member

@copilot new error

Microsoft.Playwright.PlaywrightException : Error: Node is not an , <textarea> or element Call log: waiting for Locator("#Estate_Name") I guess again this will apply to the reference

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 6, 2026

@copilot new error

Microsoft.Playwright.PlaywrightException : Error: Node is not an , <textarea> or element ... Fixed in commit 5021871. Changed Estate Name and Reference from <p> paragraph elements to readonly <input> elements. The issue occurred because GetValueById() uses Playwright's InputValueAsync() method, which only works on form input elements (<input>, <textarea>, <select>), not on paragraph elements. Changes made: Line 25: <input id="Estate_Name" type="text" value="@estate.EstateName" readonly class="input-field text-lg font-semibold text-gray-900 bg-gray-50" /> Line 33: <input id="Estate_Reference" type="text" value="@estate.Reference" readonly class="input-field text-sm text-gray-600 bg-gray-50" /> The readonly attribute ensures these remain display-only fields while allowing Playwright's GetValueById() to retrieve their values successfully.

@StuartFerguson StuartFerguson marked this pull request as ready for review January 6, 2026 09:41
@StuartFerguson
Copy link
Copy Markdown
Member

Estate Tests now passing

@StuartFerguson StuartFerguson merged commit fe07a3b into main Jan 6, 2026
4 of 5 checks passed
@github-actions github-actions Bot deleted the copilot/update-integration-tests-playwright branch March 8, 2026 01:02
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.

Integration Tests for UI

2 participants