Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageVersion Include="AngleSharp" Version="1.8.6" />
<PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
<PackageVersion Include="AspNetCore.HealthChecks.Uris" Version="9.0.0" />
<PackageVersion Include="bunit.web" Version="1.40.0" />
<PackageVersion Include="bunit" Version="2.13.3" />
<PackageVersion Include="ClientProxyBase" Version="2026.11.2" />
<PackageVersion Include="coverlet.collector" Version="10.1.0" />
<PackageVersion Include="coverlet.MTP" Version="10.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public DockerHelper(LocalAppHost appHost)
public HttpClient TestHostHttpClient { get; }
public LocalTransactionProcessorClient TransactionProcessorClient { get; }

public int GetHostPort(ContainerType containerType) => 5004;
public int GetHostPort(ContainerType containerType) => 8004;

public sealed class LocalTransactionProcessorClient
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public LocalAppHost(string projectPath)
_httpClient = new HttpClient();
}

public Uri BaseUri { get; } = new("http://127.0.0.1:5004");
public Uri BaseUri { get; } = new("http://127.0.0.1:8004");

public async Task StartAsync()
{
Expand All @@ -38,10 +38,11 @@ public async Task StartAsync()

startInfo.ArgumentList.Add("run");
startInfo.ArgumentList.Add("--no-build");
startInfo.ArgumentList.Add("--no-launch-profile");
startInfo.ArgumentList.Add("--project");
startInfo.ArgumentList.Add(_projectPath);

startInfo.Environment["ASPNETCORE_ENVIRONMENT"] = "Test";
startInfo.Environment["ASPNETCORE_ENVIRONMENT"] = "Development";
startInfo.Environment["AppSettings__TestMode"] = "BackedByTestDataStore";
startInfo.Environment["ASPNETCORE_URLS"] = BaseUri.ToString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ private async Task AssertHeadingVisibleAsync(string heading)

private string ResolveBaseUrl()
{
return "http://127.0.0.1:5004";
return "http://127.0.0.1:8004";
}

private static bool IsMoneyLabel(string label)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"TestSettings": {
"BaseUrl": "http://127.0.0.1:5004",
"BaseUrl": "http://127.0.0.1:8004",
"Browser": "Chrome",
"Headless": false,
"DefaultTimeout": 30000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<ItemGroup>
<PackageReference Include="AngleSharp" />
<PackageReference Include="bunit.web" />
<PackageReference Include="bunit" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="coverlet.MTP" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />
Expand Down
4 changes: 2 additions & 2 deletions EstateManagementUI.BlazorServer.Tests/Pages/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Microsoft.Extensions.DependencyInjection;
using Imposter.Abstractions;
using SimpleResults;
using TestContext = Bunit.TestContext;
using TestContext = Bunit.BunitContext;

namespace EstateManagementUI.BlazorServer.Tests.Pages;

Expand Down Expand Up @@ -87,7 +87,7 @@ protected BaseTest() {
parameters => parameters.Get(p => p.ChildContent));

var claims = new[] { new Claim(ClaimTypes.Role, "Estate"), new Claim("estateId", Guid.NewGuid().ToString()), new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", "EstateUser") };
this.AddTestAuthorization().SetClaims(claims);
this.AddAuthorization().SetClaims(claims);
}

protected readonly IMediatorImposter _mockMediator;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void ContractsIndex_RendersCorrectly()
.ReturnsAsync(Result.Success(contracts));

// Act
IRenderedComponent<ContractsIndex> cut = RenderComponent<ContractsIndex>();
IRenderedComponent<ContractsIndex> cut = Render<ContractsIndex>();

// Assert
cut.Markup.ShouldContain("Contract Management");
Expand All @@ -55,7 +55,7 @@ public void ContractsIndex_WithNoContracts_ShowsEmptyState()
.ReturnsAsync(Result.Success(emptyList));

// Act
IRenderedComponent<ContractsIndex> cut = RenderComponent<ContractsIndex>();
IRenderedComponent<ContractsIndex> cut = Render<ContractsIndex>();

// Assert
cut.WaitForAssertion(() => cut.Markup.ShouldContain("No contracts found"), timeout: TimeSpan.FromSeconds(5));
Expand Down Expand Up @@ -89,7 +89,7 @@ public void ContractsIndex_WithContracts_DisplaysContractList()
.ReturnsAsync(Result.Success(contracts));

// Act
IRenderedComponent<ContractsIndex> cut = RenderComponent<ContractsIndex>();
IRenderedComponent<ContractsIndex> cut = Render<ContractsIndex>();

// Assert
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Contract 1"), timeout: TimeSpan.FromSeconds(5));
Expand Down Expand Up @@ -121,7 +121,7 @@ public void ContractsIndex_DisplaysProductCount()
.ReturnsAsync(Result.Success(contracts));

// Act
IRenderedComponent<ContractsIndex> cut = RenderComponent<ContractsIndex>();
IRenderedComponent<ContractsIndex> cut = Render<ContractsIndex>();

// Assert
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Product(s)"), timeout: TimeSpan.FromSeconds(5));
Expand All @@ -135,7 +135,7 @@ public void ContractsIndex_HasCorrectPageTitle()
.ReturnsAsync(Result.Success(new List<ContractModels.ContractModel>()));

// Act
IRenderedComponent<ContractsIndex> cut = RenderComponent<ContractsIndex>();
IRenderedComponent<ContractsIndex> cut = Render<ContractsIndex>();

// Assert
IRenderedComponent<Microsoft.AspNetCore.Components.Web.PageTitle> pageTitle = cut.FindComponent<Microsoft.AspNetCore.Components.Web.PageTitle>();
Expand All @@ -150,7 +150,7 @@ public void ContractsIndex_LoadContractFails_NavigatesToError()
.ReturnsAsync(Result.Failure());

// Act
IRenderedComponent<ContractsIndex> cut = RenderComponent<ContractsIndex>();
IRenderedComponent<ContractsIndex> cut = Render<ContractsIndex>();

// Assert
_fakeNavigationManager.Uri.ShouldContain("error");
Expand All @@ -163,7 +163,7 @@ public void ContractsIndex_AddNewContractButton_NavigatesToNewContractPage()
this.ContractUIService.GetContracts(Arg<CorrelationId>.Any(), Arg<Guid>.Any())
.ReturnsAsync(Result.Success(new List<ContractModels.ContractModel>()));

IRenderedComponent<ContractsIndex> cut = RenderComponent<ContractsIndex>();
IRenderedComponent<ContractsIndex> cut = Render<ContractsIndex>();
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Contract Management"), timeout: TimeSpan.FromSeconds(5));

// Act - Find and click the "Add New Contract" button
Expand Down Expand Up @@ -194,11 +194,11 @@ public void ContractsIndex_ViewButton_NavigatesToContractDetails()
this.ContractUIService.GetContracts(Arg<CorrelationId>.Any(), Arg<Guid>.Any())
.ReturnsAsync(Result.Success(contracts));

IRenderedComponent<ContractsIndex> cut = RenderComponent<ContractsIndex>();
IRenderedComponent<ContractsIndex> cut = Render<ContractsIndex>();
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Test Contract"), timeout: TimeSpan.FromSeconds(5));

// Act - Find and click the "View" button
IRefreshableElementCollection<IElement> buttons = cut.FindAll("button");
IReadOnlyList<IElement> buttons = cut.FindAll("button");
IElement? viewButton = buttons.FirstOrDefault(b => b.TextContent.Contains("View"));
viewButton.ShouldNotBeNull();
viewButton.Click();
Expand Down Expand Up @@ -227,11 +227,11 @@ public void ContractsIndex_EditButton_NavigatesToEditContractPage()
this.ContractUIService.GetContracts(Arg<CorrelationId>.Any(), Arg<Guid>.Any())
.ReturnsAsync(Result.Success(contracts));

IRenderedComponent<ContractsIndex> cut = RenderComponent<ContractsIndex>();
IRenderedComponent<ContractsIndex> cut = Render<ContractsIndex>();
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Test Contract"), timeout: TimeSpan.FromSeconds(5));

// Act - Find and click the "Edit" button
IRefreshableElementCollection<IElement> buttons = cut.FindAll("button");
IReadOnlyList<IElement> buttons = cut.FindAll("button");
IElement? editButton = buttons.FirstOrDefault(b => b.TextContent.Contains("Edit"));
editButton.ShouldNotBeNull();
editButton.Click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void ContractsNew_RendersCorrectly()
this.OperatorUIService.GetOperatorsForDropDown(Arg<CorrelationId>.Any(), Arg<Guid>.Any()).ReturnsAsync(Result.Success(new List<OperatorModels.OperatorDropDownModel>()));

// Act
IRenderedComponent<ContractsNew> cut = RenderComponent<ContractsNew>();
IRenderedComponent<ContractsNew> cut = Render<ContractsNew>();

// Assert
cut.Markup.ShouldContain("Create New Contract");
Expand All @@ -31,7 +31,7 @@ public void ContractsNew_HasCorrectPageTitle()
this.OperatorUIService.GetOperatorsForDropDown(Arg<CorrelationId>.Any(), Arg<Guid>.Any()).ReturnsAsync(Result.Success(new List<OperatorModels.OperatorDropDownModel>()));

// Act
IRenderedComponent<ContractsNew> cut = RenderComponent<ContractsNew>();
IRenderedComponent<ContractsNew> cut = Render<ContractsNew>();

// Assert
IRenderedComponent<Microsoft.AspNetCore.Components.Web.PageTitle> pageTitle = cut.FindComponent<Microsoft.AspNetCore.Components.Web.PageTitle>();
Expand All @@ -44,11 +44,11 @@ public void ContractsNew_CancelButton_NavigatesToContractsIndex()
// Arrange
this.OperatorUIService.GetOperatorsForDropDown(Arg<CorrelationId>.Any(), Arg<Guid>.Any()).ReturnsAsync(Result.Success(new List<OperatorModels.OperatorDropDownModel>()));

IRenderedComponent<ContractsNew> cut = RenderComponent<ContractsNew>();
IRenderedComponent<ContractsNew> cut = Render<ContractsNew>();
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Create New Contract"), timeout: TimeSpan.FromSeconds(5));

// Act - Find and click the Cancel button
IRefreshableElementCollection<IElement> buttons = cut.FindAll("button");
IReadOnlyList<IElement> buttons = cut.FindAll("button");
IElement? cancelButton = buttons.FirstOrDefault(b => b.TextContent.Contains("Cancel"));
cancelButton.ShouldNotBeNull();
cancelButton.Click();
Expand All @@ -63,7 +63,7 @@ public void ContractsNew_CreateContractButton_IsPresent()
// Arrange
this.OperatorUIService.GetOperatorsForDropDown(Arg<CorrelationId>.Any(), Arg<Guid>.Any()).ReturnsAsync(Result.Success(new List<OperatorModels.OperatorDropDownModel>()));

IRenderedComponent<ContractsNew> cut = RenderComponent<ContractsNew>();
IRenderedComponent<ContractsNew> cut = Render<ContractsNew>();
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Create New Contract"), timeout: TimeSpan.FromSeconds(5));

// Act & Assert
Expand Down Expand Up @@ -91,7 +91,7 @@ public void ContractsNew_LoadsOperatorsSuccessfully()
this.OperatorUIService.GetOperatorsForDropDown(Arg<CorrelationId>.Any(), Arg<Guid>.Any()).ReturnsAsync(Result.Success(operators));

// Act
IRenderedComponent<ContractsNew> cut = RenderComponent<ContractsNew>();
IRenderedComponent<ContractsNew> cut = Render<ContractsNew>();

// Assert - Verify both operators are loaded and displayed in the dropdown
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Test Operator 1"), timeout: TimeSpan.FromSeconds(5));
Expand All @@ -105,7 +105,7 @@ public void ContractsNew_LoadsOperatorsFailed_NavigateToError()
this.OperatorUIService.GetOperatorsForDropDown(Arg<CorrelationId>.Any(), Arg<Guid>.Any()).ReturnsAsync(Result.Failure());

// Act
IRenderedComponent<ContractsNew> cut = RenderComponent<ContractsNew>();
IRenderedComponent<ContractsNew> cut = Render<ContractsNew>();

_fakeNavigationManager.Uri.ShouldContain("error");
}
Expand All @@ -117,7 +117,7 @@ public void ContractsNew_WithNoOperators_ShowsNoOperatorsMessage()
this.OperatorUIService.GetOperatorsForDropDown(Arg<CorrelationId>.Any(), Arg<Guid>.Any()).ReturnsAsync(Result.Success(new List<OperatorModels.OperatorDropDownModel>()));

// Act
IRenderedComponent<ContractsNew> cut = RenderComponent<ContractsNew>();
IRenderedComponent<ContractsNew> cut = Render<ContractsNew>();

// Assert
cut.WaitForAssertion(() => cut.Markup.ShouldContain("No operators available"), timeout: TimeSpan.FromSeconds(5));
Expand All @@ -141,7 +141,7 @@ public void ContractsNew_SuccessfulCreation_NavigatesToContractsIndex()
this.ContractUIService.CreateContract(Arg<CorrelationId>.Any(), Arg<Guid>.Any(), Arg<ContractModels.CreateContractFormModel>.Any())
.ReturnsAsync(Result.Success());

IRenderedComponent<ContractsNew> cut = RenderComponent<ContractsNew>();
IRenderedComponent<ContractsNew> cut = Render<ContractsNew>();
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Test Operator"), timeout: TimeSpan.FromSeconds(5));

// Act - Fill in the form
Expand Down Expand Up @@ -179,7 +179,7 @@ public void ContractsNew_FailedCreation_ShowsErrorMessage()
this.ContractUIService.CreateContract(Arg<CorrelationId>.Any(), Arg<Guid>.Any(), Arg<ContractModels.CreateContractFormModel>.Any())
.ReturnsAsync(Result.Failure());

IRenderedComponent<ContractsNew> cut = RenderComponent<ContractsNew>();
IRenderedComponent<ContractsNew> cut = Render<ContractsNew>();
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Test Operator"), timeout: TimeSpan.FromSeconds(5));

// Act - Fill in the form
Expand Down Expand Up @@ -215,7 +215,7 @@ public void ContractsNew_FormValidation_RequiresDescription()

this.OperatorUIService.GetOperatorsForDropDown(Arg<CorrelationId>.Any(), Arg<Guid>.Any()).ReturnsAsync(Result.Success(operators));

IRenderedComponent<ContractsNew> cut = RenderComponent<ContractsNew>();
IRenderedComponent<ContractsNew> cut = Render<ContractsNew>();
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Test Operator"), timeout: TimeSpan.FromSeconds(5));

// Act - Submit form without description
Expand Down Expand Up @@ -247,7 +247,7 @@ public void ContractsNew_FormValidation_RequiresOperator()

this.OperatorUIService.GetOperatorsForDropDown(Arg<CorrelationId>.Any(), Arg<Guid>.Any()).ReturnsAsync(Result.Success(operators));

IRenderedComponent<ContractsNew> cut = RenderComponent<ContractsNew>();
IRenderedComponent<ContractsNew> cut = Render<ContractsNew>();
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Test Operator"), timeout: TimeSpan.FromSeconds(5));

// Act - Submit form without selecting operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void ContractsView_RendersCorrectly()
.ReturnsAsync(Result.Success(contract));

// Act
var cut = RenderComponent<View>(parameters => parameters
var cut = Render<View>(parameters => parameters
.Add(p => p.ContractId, contractId));

// Assert
Expand All @@ -51,7 +51,7 @@ public void ContractsView_DisplaysContractDetails()
.ReturnsAsync(Result.Success(contract));

// Act
var cut = RenderComponent<View>(parameters => parameters
var cut = Render<View>(parameters => parameters
.Add(p => p.ContractId, contractId));
cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

Expand All @@ -74,7 +74,7 @@ public void ContractsView_HasCorrectPageTitle()
.ReturnsAsync(Result.Success(contract));

// Act
var cut = RenderComponent<View>(parameters => parameters
var cut = Render<View>(parameters => parameters
.Add(p => p.ContractId, contractId));

// Assert
Expand All @@ -98,7 +98,7 @@ public void ContractsView_HasBackButton()
.ReturnsAsync(Result.Success(contract));

// Act
var cut = RenderComponent<View>(parameters => parameters
var cut = Render<View>(parameters => parameters
.Add(p => p.ContractId, contractId));
cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

Expand All @@ -122,12 +122,12 @@ public void ContractsView_BackButton_NavigatesToContractsList()
.ReturnsAsync(Result.Success(contract));

// Act
var cut = RenderComponent<View>(parameters => parameters
var cut = Render<View>(parameters => parameters
.Add(p => p.ContractId, contractId));
cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

// Find and click the Back to List button
IRefreshableElementCollection<IElement> buttons = cut.FindAll("button");
IReadOnlyList<IElement> buttons = cut.FindAll("button");
IElement? backButton = buttons.FirstOrDefault(b => b.TextContent.Contains("Back to List"));
backButton.ShouldNotBeNull();
backButton.Click();
Expand Down Expand Up @@ -164,7 +164,7 @@ public void ContractsView_DisplaysProducts_WhenPresent()
.ReturnsAsync(Result.Success(contract));

// Act
var cut = RenderComponent<View>(parameters => parameters
var cut = Render<View>(parameters => parameters
.Add(p => p.ContractId, contractId));
cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

Expand All @@ -191,7 +191,7 @@ public void ContractsView_DisplaysNoProducts_WhenEmpty()
.ReturnsAsync(Result.Success(contract));

// Act
var cut = RenderComponent<View>(parameters => parameters
var cut = Render<View>(parameters => parameters
.Add(p => p.ContractId, contractId));
cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

Expand Down Expand Up @@ -238,7 +238,7 @@ public void ContractsView_DisplaysTransactionFees_WhenPresent()
.ReturnsAsync(Result.Success(contract));

// Act
var cut = RenderComponent<View>(parameters => parameters
var cut = Render<View>(parameters => parameters
.Add(p => p.ContractId, contractId));
cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

Expand All @@ -257,7 +257,7 @@ public void ContractsView_LoadContract_QueryFails_ShowsNotFoundMessage()
.ReturnsAsync(Result.Failure());

// Act
var cut = RenderComponent<View>(parameters => parameters
var cut = Render<View>(parameters => parameters
.Add(p => p.ContractId, contractId));
//cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

Expand Down
Loading
Loading