Skip to content

Commit

Permalink
Add ParameterGroupName to ParameterEditor; fixes #720
Browse files Browse the repository at this point in the history
* Add ParameterGroupName to ParameterEditor
* Show complete group hierarchy path instead of only main group
* Ugrade Bunit becuse of transitive vulnerability and bump CDP4-COMET-SDK to 27.4.1
* Refactor due to SQ issue
* Rename method according to review
  • Loading branch information
lxatstariongroup authored Dec 6, 2024
1 parent 369d136 commit a200985
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 28 deletions.
2 changes: 1 addition & 1 deletion COMET.Web.Common.Test/COMET.Web.Common.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="bunit.web" Version="1.26.64" />
<PackageReference Include="bunit.web" Version="1.36.0" />
<PackageReference Include="DevExpress.Blazor" Version="23.2.9" />
<PackageReference Include="Moq" Version="4.20.72" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion COMET.Web.Common.Tests/COMET.Web.Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="bunit" Version="1.26.64" />
<PackageReference Include="bunit" Version="1.36.0" />
<PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
Expand Down
4 changes: 2 additions & 2 deletions COMET.Web.Common/COMET.Web.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<ItemGroup>
<PackageReference Include="AsyncEnumerator" Version="4.0.2" />
<PackageReference Include="Blazored.FluentValidation" Version="2.2.0" />
<PackageReference Include="CDP4ServicesDal-CE" Version="27.4.0" />
<PackageReference Include="CDP4Web-CE" Version="27.4.0" />
<PackageReference Include="CDP4ServicesDal-CE" Version="27.4.1" />
<PackageReference Include="CDP4Web-CE" Version="27.4.1" />
<PackageReference Include="DevExpress.Blazor" Version="23.2.9" />
<PackageReference Include="FluentResults" Version="3.16.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="8.0.10" />
Expand Down
2 changes: 1 addition & 1 deletion COMETwebapp.Tests/COMETwebapp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="bunit" Version="1.26.64" />
<PackageReference Include="bunit" Version="1.36.0" />
<PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
Expand Down
25 changes: 13 additions & 12 deletions COMETwebapp.Tests/Pages/ModelDashboard/ModelDashboardTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,27 +172,28 @@ public async Task VerifyIterationSelection()
public void VerifyIterationPreselection()
{
this.openedIterations.AddRange(new List<Iteration> { this.firstIteration });

this.context.RenderComponent<ModelDashboard>(parameters =>
{
parameters.Add(p => p.IterationId, this.firstIteration.Iid.ToShortGuid());
});

var navigation = this.context.Services.GetService<NavigationManager>();
var navigationManager = this.context.Services.GetRequiredService<NavigationManager>();
var testUri = $"/ModelDashboard?IterationId={this.firstIteration.Iid.ToShortGuid()}";

// Act: Navigate to the URI and render the component
navigationManager.NavigateTo(testUri);
this.context.RenderComponent<ModelDashboard>();

Assert.Multiple(() =>
{
Assert.That(this.viewModel.SelectedThing, Is.EqualTo(this.firstIteration));
Assert.That(navigation.Uri.Contains("server"), Is.True);
Assert.That(navigation.Uri.Contains(this.firstIteration.Iid.ToShortGuid()), Is.True);
Assert.That(navigationManager.Uri.Contains("server"), Is.True);
Assert.That(navigationManager.Uri.Contains(this.firstIteration.Iid.ToShortGuid()), Is.True);
});

this.viewModel.SelectedThing = null;

this.context.RenderComponent<ModelDashboard>(parameters =>
{
parameters.Add(p => p.IterationId, this.secondIteration.Iid.ToShortGuid());
});
testUri = $"/ModelDashboard?IterationId={this.secondIteration.Iid.ToShortGuid()}";

// Act: Navigate to the URI and render the component
navigationManager.NavigateTo(testUri);
this.context.RenderComponent<ModelDashboard>();

Assert.That(this.viewModel.SelectedThing, Is.EqualTo(this.firstIteration));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,27 @@ public void VerifyIterationPreselection()
{
this.openedIterations.AddRange(new List<Iteration> { this.firstIteration });

this.context.RenderComponent<ParameterEditor>(parameters => { parameters.Add(p => p.IterationId, this.firstIteration.Iid.ToShortGuid()); });
var navigationManager = this.context.Services.GetRequiredService<NavigationManager>();
var testUri = $"/ParameterEditor?IterationId={this.firstIteration.Iid.ToShortGuid()}";

var navigation = this.context.Services.GetService<NavigationManager>();
// Act: Navigate to the URI and render the component
navigationManager.NavigateTo(testUri);
this.context.RenderComponent<ParameterEditor>();

Assert.Multiple(() =>
{
Assert.That(this.viewModel.SelectedThing, Is.EqualTo(this.firstIteration));
Assert.That(navigation.Uri.Contains("server"), Is.True);
Assert.That(navigation.Uri.Contains(this.firstIteration.Iid.ToShortGuid()), Is.True);
Assert.That(navigationManager.Uri.Contains("server"), Is.True);
Assert.That(navigationManager.Uri.Contains(this.firstIteration.Iid.ToShortGuid()), Is.True);
});

this.viewModel.SelectedThing = null;

this.context.RenderComponent<ParameterEditor>(parameters => { parameters.Add(p => p.IterationId, this.secondIteration.Iid.ToShortGuid()); });
testUri = $"/ParameterEditor?IterationId={this.secondIteration.Iid.ToShortGuid()}";

// Act: Navigate to the URI and render the component
navigationManager.NavigateTo(testUri);
this.context.RenderComponent<ParameterEditor>();

Assert.That(this.viewModel.SelectedThing, Is.EqualTo(this.firstIteration));
}
Expand Down
17 changes: 12 additions & 5 deletions COMETwebapp.Tests/Pages/Viewer/ViewerTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,27 @@ public void VerifyIterationPreselection()
{
this.openedIterations.AddRange(new List<Iteration> { this.firstIteration });

this.context.RenderComponent<Viewer>(parameters => { parameters.Add(p => p.IterationId, this.firstIteration.Iid.ToShortGuid()); });
var navigationManager = this.context.Services.GetRequiredService<NavigationManager>();
var testUri = $"/Viewer?IterationId={this.firstIteration.Iid.ToShortGuid()}";

var navigation = this.context.Services.GetService<NavigationManager>();
// Act: Navigate to the URI and render the component
navigationManager.NavigateTo(testUri);
this.context.RenderComponent<Viewer>();

Assert.Multiple(() =>
{
Assert.That(this.viewModel.SelectedThing, Is.EqualTo(this.firstIteration));
Assert.That(navigation.Uri.Contains("server"), Is.True);
Assert.That(navigation.Uri.Contains(this.firstIteration.Iid.ToShortGuid()), Is.True);
Assert.That(navigationManager.Uri.Contains("server"), Is.True);
Assert.That(navigationManager.Uri.Contains(this.firstIteration.Iid.ToShortGuid()), Is.True);
});

this.viewModel.SelectedThing = null;

this.context.RenderComponent<Viewer>(parameters => { parameters.Add(p => p.IterationId, this.secondIteration.Iid.ToShortGuid()); });
testUri = $"/Viewer?IterationId={this.secondIteration.Iid.ToShortGuid()}";

// Act: Navigate to the URI and render the component
navigationManager.NavigateTo(testUri);
this.context.RenderComponent<Viewer>();

Assert.That(this.viewModel.SelectedThing, Is.EqualTo(this.firstIteration));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class ParameterTableViewModelTestFixture
private Iteration iteration;
private Option option;
private CDPMessageBus messageBus;
private ParameterGroup parameterGroup;
private ParameterGroup parameterGroup2;

[SetUp]
public void Setup()
Expand Down Expand Up @@ -86,12 +88,26 @@ public void Setup()
ShortName = "kg"
};

this.parameterGroup = new ParameterGroup()
{
Iid = Guid.NewGuid(),
Name = "ParameterGroup 1"
};

this.parameterGroup2 = new ParameterGroup()
{
Iid = Guid.NewGuid(),
Name = "ParameterGroup 2",
ContainingGroup = this.parameterGroup
};

var parameter1 = new Parameter()
{
Iid = Guid.NewGuid(),
Owner = this.domain,
ParameterType = parameterType,
Scale = scale,
Group = this.parameterGroup,
ValueSet =
{
new ParameterValueSet()
Expand All @@ -111,6 +127,7 @@ public void Setup()
Owner = this.domain,
ParameterType = parameterType,
Scale = scale,
Group = this.parameterGroup,
ValueSet =
{
new ParameterValueSet()
Expand All @@ -130,6 +147,7 @@ public void Setup()
ParameterType = parameterType,
Scale = scale,
Owner = this.domain,
Group = this.parameterGroup2,
ValueSet =
{
new ParameterValueSet()
Expand Down Expand Up @@ -166,7 +184,8 @@ public void Setup()
{
Iid = Guid.NewGuid(),
Name = "Container",
Parameter = { parameter3 }
Parameter = { parameter3 },
ParameterGroup = { this.parameterGroup, this.parameterGroup2 }
};

var elementDefinition = new ElementDefinition()
Expand Down Expand Up @@ -228,6 +247,7 @@ public void VerifyParameterRowProperties()
Assert.That(parameterRow.ParameterName, Is.EqualTo("mass"));
Assert.That(parameterRow.Option, Is.Empty);
Assert.That(parameterRow.State, Is.Empty);
Assert.That(parameterRow.ParameterGroupPath, Is.EqualTo($"{this.parameterGroup.Name} => {this.parameterGroup2.Name}"));
});
}

Expand Down
4 changes: 4 additions & 0 deletions COMETwebapp/COMETwebapp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@
</Content>
</ItemGroup>

<ItemGroup>
<Folder Include="logs\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
</DxGridDataColumn>
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.ModelCode)" Caption="@("Model Code")" AllowGroup="false" AllowSort="true" />
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.OwnerName)" Caption="@("Owner")" AllowGroup="false" AllowSort="true" />
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.ParameterGroupPath)" Caption="@("Parameter Group Path")" AllowGroup="false" AllowSort="true" />
</Columns>
</DxGrid>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,33 @@ private void InitializesProperties(bool isReadOnly)
this.Option = this.ValueSet.ActualOption is not null ? this.ValueSet.ActualOption?.Name : string.Empty;
this.State = this.ValueSet.ActualState is not null ? this.ValueSet.ActualState.Name : string.Empty;
this.Switch = this.ValueSet.ValueSwitch;
this.CalculateParameterGroupPath();
}

/// <summary>
/// Calculate and set the values of <see cref="ParameterGroup"/> parameters
/// </summary>
private void CalculateParameterGroupPath()
{
var parameterGroupPath = string.Empty;

if (this.Parameter.Group != null)
{
var group = this.Parameter.Group;
parameterGroupPath = this.Parameter.Group.Name;

while (group != null)
{
if (group.ContainingGroup != null)
{
parameterGroupPath = $"{group.ContainingGroup.Name} => {parameterGroupPath}";
}

group = group.ContainingGroup;
}
}

this.ParameterGroupPath = parameterGroupPath;
}

/// <summary>
Expand Down Expand Up @@ -168,6 +195,11 @@ public bool IsPublishable
/// </summary>
public string OwnerName { get; private set; }

/// <summary>
/// Gets the <see cref="ParameterGroup" /> name
/// </summary>
public string ParameterGroupPath { get; private set; }

/// <summary>
/// Gets the switch for the published value
/// </summary>
Expand Down

0 comments on commit a200985

Please sign in to comment.