Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Loading Bug on program manager dashboard #485

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// <copyright file="ApplicationBaseViewModel.cs" company="RHEA System S.A.">
// Copyright (c) 2023 RHEA System S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, Miguel Serra
//
// This file is part of COMET WEB Community Edition
// The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25
Expand Down Expand Up @@ -53,7 +53,7 @@ public abstract class ApplicationBaseViewModel : HaveObjectChangedTracking, IApp
protected ApplicationBaseViewModel(ISessionService sessionService)
{
this.Disposables.Add(CDPMessageBus.Current.Listen<SessionEvent>()
.Where(x => x.Status == SessionStatus.EndUpdate)
.Where(x => x.Session == this.SessionService?.Session && x.Status == SessionStatus.EndUpdate)
.SubscribeAsync(_ => this.OnSessionRefreshed()));

this.SessionService = sessionService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// <copyright file="ParameterEditorBodyViewModelTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2023 RHEA System S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, Miguel Serra
//
// This file is part of COMET WEB Community Edition
// The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
Expand Down Expand Up @@ -56,6 +56,7 @@ public class ParameterEditorBodyViewModelTestFixture
private IParameterEditorBodyViewModel viewModel;
private Mock<IParameterTableViewModel> tableViewModel;
private Iteration iteration;
private Mock<ISession> session;

[SetUp]
public void SetUp()
Expand Down Expand Up @@ -209,11 +210,11 @@ public void SetUp()
this.iteration.DefaultOption = this.iteration.Option.First();

var sessionService = new Mock<ISessionService>();
var session = new Mock<ISession>();
this.session = new Mock<ISession>();
var permissionService = new Mock<IPermissionService>();
permissionService.Setup(x => x.CanWrite(It.IsAny<Thing>())).Returns(true);
session.Setup(x => x.PermissionService).Returns(permissionService.Object);
sessionService.Setup(x => x.Session).Returns(session.Object);
this.session.Setup(x => x.PermissionService).Returns(permissionService.Object);
sessionService.Setup(x => x.Session).Returns(this.session.Object);
sessionService.Setup(x => x.GetDomainOfExpertise(this.iteration)).Returns(domain);

var subscriptionService = new Mock<ISubscriptionService>();
Expand Down Expand Up @@ -281,7 +282,7 @@ public async Task VerifyApplyFilters()
[Test]
public async Task VerifyRefresh()
{
CDPMessageBus.Current.SendMessage(new SessionEvent(null, SessionStatus.EndUpdate));
CDPMessageBus.Current.SendMessage(new SessionEvent(this.session.Object, SessionStatus.EndUpdate));

Assert.Multiple(() =>
{
Expand All @@ -297,19 +298,19 @@ public async Task VerifyRefresh()

this.iteration.Element.Add(elementDefinition);
CDPMessageBus.Current.SendObjectChangeEvent(elementDefinition, EventKind.Added);
CDPMessageBus.Current.SendMessage(new SessionEvent(null, SessionStatus.EndUpdate));
CDPMessageBus.Current.SendMessage(new SessionEvent(this.session.Object, SessionStatus.EndUpdate));

await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);
this.tableViewModel.Verify(x => x.AddRows(It.Is<IEnumerable<Thing>>(c => c.Any())), Times.Once);

CDPMessageBus.Current.SendObjectChangeEvent(elementDefinition, EventKind.Updated);
CDPMessageBus.Current.SendMessage(new SessionEvent(null, SessionStatus.EndUpdate));
CDPMessageBus.Current.SendMessage(new SessionEvent(this.session.Object, SessionStatus.EndUpdate));

await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);
this.tableViewModel.Verify(x => x.UpdateRows(It.Is<IEnumerable<Thing>>(c => c.Any())), Times.Once);

CDPMessageBus.Current.SendObjectChangeEvent(elementDefinition, EventKind.Removed);
CDPMessageBus.Current.SendMessage(new SessionEvent(null, SessionStatus.EndUpdate));
CDPMessageBus.Current.SendMessage(new SessionEvent(this.session.Object, SessionStatus.EndUpdate));

await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);
this.tableViewModel.Verify(x => x.RemoveRows(It.Is<IEnumerable<Thing>>(c => c.Any())), Times.Once);
Expand All @@ -319,7 +320,7 @@ public async Task VerifyRefresh()
Container = new Iteration()
}, EventKind.Removed);

CDPMessageBus.Current.SendMessage(new SessionEvent(null, SessionStatus.EndUpdate));
CDPMessageBus.Current.SendMessage(new SessionEvent(this.session.Object, SessionStatus.EndUpdate));

await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);
this.tableViewModel.Verify(x => x.RemoveRows(It.Is<IEnumerable<Thing>>(c => c.Any())), Times.Once);
Expand Down
Loading