From 41ec4d379a58f27833a56fe2555f8489340d13b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rua?= <140734849+joao4all@users.noreply.github.com> Date: Wed, 31 Jul 2024 08:29:12 +0100 Subject: [PATCH] Fix #689 2 tabs of same view: Filtering is identical (#712) --- .../Applications/DynamicApplicationBase.razor | 2 +- .../DynamicApplicationBase.razor.cs | 6 ++ .../ParameterEditorTestFixture.cs | 28 ++++++--- ...ParameterEditorBodyViewModelTestFixture.cs | 26 +------- .../ModelDashboard/ModelDashboardBody.razor | 2 +- .../ModelDashboardBody.razor.cs | 1 + .../ParameterEditor/ParameterEditorBody.razor | 4 +- .../ParameterEditorBody.razor.cs | 4 +- .../ParameterEditor/ParameterTable.razor | 2 +- .../ParameterEditor/ParameterTable.razor.cs | 30 ++++----- .../SubscriptionDashboardBody.razor.cs | 1 + .../SystemRepresentationBody.razor.cs | 1 + .../Components/Tabs/TabsPanelComponent.razor | 3 +- .../Components/Viewer/ViewerBody.razor.cs | 1 + .../Model/TabbedApplicationInformation.cs | 6 ++ .../IModelDashboardBodyViewModel.cs | 5 ++ .../ModelDashboardBodyViewModel.cs | 55 +++++++--------- .../IParameterEditorBodyViewModel.cs | 17 +++-- .../ParameterEditorBodyViewModel.cs | 63 +++++++------------ .../ISubscriptionDashboardBodyViewModel.cs | 6 ++ .../SubscriptionDashboardBodyViewModel.cs | 46 +++++++------- 21 files changed, 156 insertions(+), 153 deletions(-) diff --git a/COMET.Web.Common/Components/Applications/DynamicApplicationBase.razor b/COMET.Web.Common/Components/Applications/DynamicApplicationBase.razor index aac0d088..e72d4595 100644 --- a/COMET.Web.Common/Components/Applications/DynamicApplicationBase.razor +++ b/COMET.Web.Common/Components/Applications/DynamicApplicationBase.razor @@ -20,5 +20,5 @@ // limitations under the License. -------------------------------------------------------------------------------> - + diff --git a/COMET.Web.Common/Components/Applications/DynamicApplicationBase.razor.cs b/COMET.Web.Common/Components/Applications/DynamicApplicationBase.razor.cs index 6a4a5aa6..66b8d4c5 100644 --- a/COMET.Web.Common/Components/Applications/DynamicApplicationBase.razor.cs +++ b/COMET.Web.Common/Components/Applications/DynamicApplicationBase.razor.cs @@ -59,6 +59,12 @@ public partial class DynamicApplicationBase [Parameter] public Thing CurrentThing { get; set; } + /// + /// Gets or sets the component's id + /// + [Parameter] + public object Id { get; set; } + /// /// Gets the of parameters that have to be passed to the /// diff --git a/COMETwebapp.Tests/Pages/ParameterEditor/ParameterEditorTestFixture.cs b/COMETwebapp.Tests/Pages/ParameterEditor/ParameterEditorTestFixture.cs index 8c649f7a..e01a4656 100644 --- a/COMETwebapp.Tests/Pages/ParameterEditor/ParameterEditorTestFixture.cs +++ b/COMETwebapp.Tests/Pages/ParameterEditor/ParameterEditorTestFixture.cs @@ -73,7 +73,7 @@ public class ParameterEditorTestFixture private Mock session; private Iteration firstIteration; private Iteration secondIteration; - private ICDPMessageBus messageBus; + private CDPMessageBus messageBus; [SetUp] public void Setup() @@ -123,21 +123,31 @@ public void Setup() mockConfigurationService.Setup(x => x.ServerConfiguration).Returns(new ServerConfiguration()); this.messageBus = new CDPMessageBus(); + var parameterTableViewModel = new Mock(); + parameterTableViewModel.Setup(x => x.Rows).Returns(new SourceList()); + + var parameterEditorBodyViewModel = new Mock(); + parameterEditorBodyViewModel.Setup(x => x.OptionSelector).Returns(new Mock().Object); + parameterEditorBodyViewModel.Setup(x => x.BatchParameterEditorViewModel).Returns(new Mock().Object); + parameterEditorBodyViewModel.Setup(x => x.ParameterTypeSelector).Returns(new Mock().Object); + parameterEditorBodyViewModel.Setup(x => x.ElementSelector).Returns(new Mock().Object); + parameterEditorBodyViewModel.Setup(x => x.ParameterTableViewModel).Returns(parameterTableViewModel.Object); + + var configurationService = new Mock(); + configurationService.Setup(x => x.GetText(It.IsAny())).Returns("something"); + this.context.ConfigureDevExpressBlazor(); this.context.Services.AddSingleton(this.viewModel); this.context.Services.AddSingleton(this.sessionService.Object); + this.context.Services.AddSingleton(mockConfigurationService.Object); + this.context.Services.AddSingleton(parameterEditorBodyViewModel.Object); + this.context.Services.AddSingleton(parameterTableViewModel.Object); + this.context.Services.AddSingleton(configurationService.Object); + this.context.Services.AddSingleton(this.messageBus); this.context.Services.AddSingleton(); - this.context.Services.AddSingleton(); this.context.Services.AddSingleton(); this.context.Services.AddSingleton(); - this.context.Services.AddSingleton(); this.context.Services.AddSingleton(); - this.context.Services.AddSingleton(mockConfigurationService.Object); - this.context.Services.AddSingleton(this.messageBus); - - var configurationService = new Mock(); - configurationService.Setup(x => x.GetText(It.IsAny())).Returns("something"); - this.context.Services.AddSingleton(configurationService.Object); } [TearDown] diff --git a/COMETwebapp.Tests/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModelTestFixture.cs b/COMETwebapp.Tests/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModelTestFixture.cs index 6d0e1aba..6cca26c6 100644 --- a/COMETwebapp.Tests/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModelTestFixture.cs +++ b/COMETwebapp.Tests/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModelTestFixture.cs @@ -242,33 +242,13 @@ public async Task VerifyApplyFilters() await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading); this.viewModel.ElementSelector.SelectedElementBase = this.viewModel.ElementSelector.AvailableElements.First(); - await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading); - - this.tableViewModel.Verify(x => x.ApplyFilters(this.iteration.DefaultOption, this.viewModel.ElementSelector.SelectedElementBase, null, true), Times.Once); - - this.viewModel.ElementSelector.SelectedElementBase = null; - await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading); - this.viewModel.ParameterTypeSelector.SelectedParameterType = this.viewModel.ParameterTypeSelector.AvailableParameterTypes.First(); - await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading); - - this.tableViewModel.Verify(x => x.ApplyFilters(this.iteration.DefaultOption, - null, this.viewModel.ParameterTypeSelector.SelectedParameterType, true), Times.Once); - - this.viewModel.ParameterTypeSelector.SelectedParameterType = null; - await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading); - this.viewModel.OptionSelector.SelectedOption = this.viewModel.CurrentThing.Option.Last(); - await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading); - - this.tableViewModel.Verify(x => x.ApplyFilters(this.iteration.Option.Last(), - null, null, true), Times.Once); - this.viewModel.IsOwnedParameters = false; - await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading); - this.tableViewModel.Verify(x => x.ApplyFilters(this.iteration.Option.Last(), - null, null, false), Times.Once); + this.viewModel.ApplyFilters(); + + this.tableViewModel.Verify(x => x.ApplyFilters(It.IsAny