feat(m9/T26b): TemplateEdit full multi-level inherited set + read-only staleness banner

This commit is contained in:
Joseph Doherty
2026-06-18 13:01:38 -04:00
parent ca6e5da34b
commit 6bc2bb5430
5 changed files with 579 additions and 0 deletions
@@ -14,6 +14,7 @@
@inject ICentralUiRepository CentralUiRepository
@inject TemplateService TemplateService
@inject ZB.MOM.WW.ScadaBridge.CentralUI.ScriptAnalysis.ScriptAnalysisService AnalysisService
@inject ZB.MOM.WW.ScadaBridge.CentralUI.Services.ITemplateInheritanceQueryService InheritanceQuery
@inject AuthenticationStateProvider AuthStateProvider
@inject NavigationManager NavigationManager
@inject IDialogService Dialog
@@ -62,6 +63,12 @@
private Template? _ownerTemplate;
private TemplateComposition? _ownerComposition;
// M9-T26b: the FULL transitively-resolved inherited member set (multi-level
// chain + post-creation base additions) + staleness, fetched read-only via
// GetResolvedTemplateMembersCommand. Populated only for derived templates;
// null when the read failed (editor falls back to the stored-row view).
private Commons.Messages.Management.ResolvedTemplateMembers? _resolved;
private bool _loading = true;
private string? _loadError;
private string _activeTab = "attributes";
@@ -195,6 +202,7 @@
_baseTemplate = null;
_ownerTemplate = null;
_ownerComposition = null;
_resolved = null;
if (_selectedTemplate.IsDerived && _selectedTemplate.ParentTemplateId.HasValue)
{
_baseTemplate = await TemplateEngineRepository.GetTemplateByIdAsync(_selectedTemplate.ParentTemplateId.Value);
@@ -218,6 +226,14 @@
}
}
}
// M9-T26b: resolve the FULL inherited member set (whole chain +
// post-creation base additions) read-only. The stored-row tables
// above only carry the IMMEDIATE base; this surfaces the rest with
// origin annotation + a base-changed staleness banner. Read-only:
// a failed read leaves _resolved null and the editor degrades to
// the stored-row view.
_resolved = await InheritanceQuery.ResolveAsync(Id);
}
// Editor metadata: child compositions + every parent that
@@ -270,6 +286,32 @@
</div>
</div>
}
@* M9-T26b: read-only base-changed banner. Informational only — surfaced
when the freshly-resolved inherited set differs from this template's
stored copy (a multi-level inherited member, or a base member added
after this template was created). No action button: a deploy already
resolves fresh, so this is purely an authoring heads-up. *@
@if (_resolved?.Staleness.IsStale == true)
{
<div class="alert alert-info py-2 mb-3" role="status">
<i class="bi bi-info-circle me-1"></i>
<strong>Base template changed</strong> —
@_resolved.Staleness.DifferingMemberCount inherited member(s) differ from this template's stored copy.
The effective set below reflects the live base; a deploy resolves fresh.
</div>
}
@* M9-T26b: the FULL transitively-resolved inherited member set — the whole
chain (grandparent + further ancestors) plus base members added after
this template was created, which the immediate-base tables below cannot
show. Read-only preview; each row carries its origin template + lock
state, and alarms surface the merged effective trigger configuration. *@
@if (_resolved != null)
{
@RenderInheritedSet()
}
<div class="d-flex justify-content-between align-items-center mb-3">
<div>
<h4 class="d-inline mb-0">@_selectedTemplate.Name</h4>
@@ -419,6 +461,115 @@
}
};
// ---- M9-T26b: full resolved inherited set (read-only preview) ----
/// <summary>
/// Renders the FULL transitively-resolved effective member set (attributes,
/// alarms, scripts, native alarm sources) for a derived template. Read-only:
/// no edit / override / deploy actions — purely an authoring view that shows
/// what the whole inheritance chain resolves to (multi-level + post-creation
/// base additions), which the immediate-base tables below cannot surface.
/// </summary>
private RenderFragment RenderInheritedSet() => __builder =>
{
var r = _resolved!;
<div class="card mb-3 border-info-subtle">
<div class="card-header bg-info-subtle d-flex align-items-center">
<i class="bi bi-diagram-3 me-2"></i>
<span class="fw-semibold">Effective inherited set</span>
<span class="text-muted small ms-2">
Resolved across the full inheritance chain (read-only). Edits stay on the per-tab tables below.
</span>
</div>
<div class="card-body">
@RenderInheritedMemberTable("Attributes", r.Attributes, showTrigger: false)
@RenderInheritedMemberTable("Alarms", r.Alarms, showTrigger: true)
@RenderInheritedMemberTable("Scripts", r.Scripts, showTrigger: false)
@RenderInheritedMemberTable("Native Alarm Sources", r.NativeAlarmSources, showTrigger: false)
@if (r.Attributes.Count == 0 && r.Alarms.Count == 0
&& r.Scripts.Count == 0 && r.NativeAlarmSources.Count == 0)
{
<p class="text-muted small mb-0">No resolved members.</p>
}
</div>
</div>
};
/// <summary>
/// Renders one section (attributes / alarms / scripts / native sources) of the
/// resolved inherited set. Each row shows the effective value (for alarms, the
/// merged <c>EffectiveTriggerConfiguration</c> when <paramref name="showTrigger"/>),
/// the origin template, and inherited / locked / base-locked annotations.
/// </summary>
private RenderFragment RenderInheritedMemberTable(
string title,
IReadOnlyList<Commons.Messages.Management.ResolvedTemplateMemberInfo> members,
bool showTrigger) => __builder =>
{
@if (members.Count > 0)
{
<h6 class="mt-2 mb-2">@title <span class="badge bg-secondary">@members.Count</span></h6>
<table class="table table-sm table-striped mb-3">
<thead class="table-light">
<tr>
<th>Name</th>
<th>Effective value</th>
@if (showTrigger)
{
<th>Trigger config (effective)</th>
}
<th>Source</th>
<th>Lock</th>
</tr>
</thead>
<tbody>
@foreach (var m in members)
{
<tr>
<td>@m.Name</td>
<td class="small">@(m.EffectiveValue ?? "—")</td>
@if (showTrigger)
{
<td class="small text-muted font-monospace text-truncate"
style="max-width: 220px;" title="@m.EffectiveTriggerConfiguration">
@(string.IsNullOrEmpty(m.EffectiveTriggerConfiguration) ? "—" : m.EffectiveTriggerConfiguration)
</td>
}
<td>
@if (m.IsInherited)
{
<span class="badge bg-secondary"
title="@($"Inherited from {m.OriginTemplateName}")">
Inherited from @m.OriginTemplateName
</span>
}
else
{
<span class="badge bg-light text-dark">Local</span>
}
</td>
<td>
@if (m.IsBaseLocked)
{
<span class="badge bg-warning text-dark" title="A base template forbids overriding this member.">🔒 Base-locked</span>
}
else if (m.IsLocked)
{
<span class="badge bg-danger" aria-label="Locked">Locked</span>
}
else
{
<span class="badge bg-light text-dark" aria-label="Unlocked">Unlocked</span>
}
</td>
</tr>
}
</tbody>
</table>
}
};
private async Task DeleteTemplate()
{
if (_selectedTemplate == null) return;
@@ -141,6 +141,13 @@ public static class ServiceCollectionExtensions
// DbContext). Read-only; no mutation goes through it.
services.AddScoped<ISchemaLibraryQueryService, SchemaLibraryQueryService>();
// Template inheritance preview (M9-T26b): a read-only facade that dispatches
// GetResolvedTemplateMembersCommand to the central ManagementActor through the
// in-process ManagementActorHolder seam (same Ask path as the HTTP /management
// endpoint). Powers the template editor's FULL transitively-inherited member set
// + base-changed staleness banner; never mutates rows, not on the deploy path.
services.AddScoped<ITemplateInheritanceQueryService, TemplateInheritanceQueryService>();
// Roslyn-backed C# analysis for the Monaco script editor.
// Scoped because SharedScriptCatalog wraps a scoped service.
services.AddMemoryCache(o => o.SizeLimit = 200);
@@ -0,0 +1,35 @@
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Management;
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Services;
/// <summary>
/// Read-only CentralUI facade over the template-inheritance resolve query
/// (M9-T26b). Dispatches the <see cref="GetResolvedTemplateMembersCommand"/> to
/// the central <c>ManagementActor</c> through the in-process
/// <c>ManagementActorHolder</c> seam — the SAME Ask path the HTTP
/// <c>/management</c> endpoint uses — and returns the freshly-resolved
/// <see cref="ResolvedTemplateMembers"/> (the full transitively-inherited member
/// set + staleness summary) so the template editor can render the effective
/// inherited view and a base-changed banner.
/// </summary>
/// <remarks>
/// This is a pure authoring-preview read: it never mutates stored rows and is
/// not on the deploy path. A read failure (transport fault, actor not started)
/// yields <c>null</c> (logged) so the editor degrades to its stored-row view
/// rather than throwing. Mirrors <see cref="ISchemaLibraryService"/>'s read
/// path / the other <c>ManagementActorHolder</c>-backed query facades.
/// </remarks>
public interface ITemplateInheritanceQueryService
{
/// <summary>
/// Resolves the effective inherited member set for a template.
/// </summary>
/// <param name="templateId">The template to resolve.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
/// The freshly-resolved <see cref="ResolvedTemplateMembers"/>, or <c>null</c>
/// when the read failed (the editor then falls back to its stored-row view).
/// </returns>
Task<ResolvedTemplateMembers?> ResolveAsync(
int templateId, CancellationToken cancellationToken = default);
}
@@ -0,0 +1,133 @@
using System.Security.Claims;
using System.Text.Json;
using Akka.Actor;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Logging;
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Management;
using ZB.MOM.WW.ScadaBridge.ManagementService;
using ZB.MOM.WW.ScadaBridge.Security;
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Services;
/// <summary>
/// Default <see cref="ITemplateInheritanceQueryService"/> implementation — a thin
/// read-only facade that dispatches the <see cref="GetResolvedTemplateMembersCommand"/>
/// to the central <c>ManagementActor</c> through the in-process
/// <see cref="ManagementActorHolder"/> (the same Ask seam the HTTP <c>/management</c>
/// endpoint uses). The actor walks the full inheritance chain and returns the
/// effective member set + staleness; none of that is re-implemented here. Mirrors
/// <see cref="SchemaLibraryService"/>'s read path.
/// </summary>
public sealed class TemplateInheritanceQueryService : ITemplateInheritanceQueryService
{
/// <summary>
/// camelCase + case-insensitive, matching <c>ManagementActor.SerializeResult</c>'s
/// options. <see cref="ManagementSuccess.JsonData"/> is produced with those settings,
/// so the deserializer must mirror them to bind every property.
/// </summary>
private static readonly JsonSerializerOptions ResultDeserializerOptions = new()
{
PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
private static readonly TimeSpan AskTimeout = TimeSpan.FromSeconds(30);
private readonly ManagementActorHolder _holder;
private readonly AuthenticationStateProvider _auth;
private readonly ILogger<TemplateInheritanceQueryService> _logger;
/// <summary>
/// Initializes a new instance of the <see cref="TemplateInheritanceQueryService"/>.
/// </summary>
/// <param name="holder">Holder for the central <c>ManagementActor</c> reference.</param>
/// <param name="auth">Authentication state provider used to project the current principal.</param>
/// <param name="logger">Logger instance.</param>
public TemplateInheritanceQueryService(
ManagementActorHolder holder,
AuthenticationStateProvider auth,
ILogger<TemplateInheritanceQueryService> logger)
{
_holder = holder ?? throw new ArgumentNullException(nameof(holder));
_auth = auth ?? throw new ArgumentNullException(nameof(auth));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
/// <inheritdoc/>
public async Task<ResolvedTemplateMembers?> ResolveAsync(
int templateId, CancellationToken cancellationToken = default)
{
var response = await SendAsync(new GetResolvedTemplateMembersCommand(templateId), cancellationToken);
if (response is ManagementSuccess success)
{
return JsonSerializer.Deserialize<ResolvedTemplateMembers>(
success.JsonData, ResultDeserializerOptions);
}
// Read path: log + return null so the editor falls back to its stored-row view.
_logger.LogWarning(
"GetResolvedTemplateMembers failed for template {TemplateId}: {Response}",
templateId, DescribeFailure(response));
return null;
}
/// <summary>
/// Wraps <paramref name="command"/> in a <see cref="ManagementEnvelope"/> for the
/// current principal and Asks the <c>ManagementActor</c>. Transport faults (timeout,
/// actor not yet started) become a synthetic <see cref="ManagementError"/> so the
/// caller handles one response shape.
/// </summary>
private async Task<object> SendAsync(object command, CancellationToken cancellationToken)
{
var actor = _holder.ActorRef;
if (actor is null)
{
return new ManagementError(
string.Empty, "Management service is not ready.", "SERVICE_UNAVAILABLE");
}
var user = await BuildAuthenticatedUserAsync();
var envelope = new ManagementEnvelope(user, command, Guid.NewGuid().ToString("N"));
try
{
return await actor.Ask<object>(envelope, AskTimeout, cancellationToken);
}
catch (OperationCanceledException)
{
// Caller-initiated cancel (e.g. circuit teardown) — propagate cleanly.
throw;
}
catch (Exception ex)
{
_logger.LogError(ex, "ManagementActor Ask failed for {Command}", command.GetType().Name);
return new ManagementError(string.Empty, ex.Message, "TRANSPORT_ERROR");
}
}
/// <summary>
/// Projects the current Blazor <see cref="ClaimsPrincipal"/> to the
/// <see cref="AuthenticatedUser"/> the actor authorizes against (mirrors the
/// claim set the HTTP endpoint constructs).
/// </summary>
private async Task<AuthenticatedUser> BuildAuthenticatedUserAsync()
{
var state = await _auth.GetAuthenticationStateAsync();
var principal = state.User;
var username = principal.FindFirst(JwtTokenService.UsernameClaimType)?.Value ?? "unknown";
var displayName = principal.FindFirst(JwtTokenService.DisplayNameClaimType)?.Value ?? username;
var roles = principal.FindAll(JwtTokenService.RoleClaimType).Select(c => c.Value).ToArray();
var permittedSiteIds = principal.FindAll(JwtTokenService.SiteIdClaimType).Select(c => c.Value).ToArray();
return new AuthenticatedUser(username, displayName, roles, permittedSiteIds);
}
/// <summary>Renders a fallback description for an unexpected/failure response.</summary>
private static string DescribeFailure(object response) => response switch
{
ManagementUnauthorized unauthorized => unauthorized.Message,
ManagementError error => error.Error,
_ => "Unexpected response from the management service.",
};
}
@@ -0,0 +1,253 @@
using System.Security.Claims;
using Bunit;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using ZB.MOM.WW.ScadaBridge.CentralUI.ScriptAnalysis;
using ZB.MOM.WW.ScadaBridge.CentralUI.Services;
using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Shared;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Instances;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Sites;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Templates;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Services;
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Management;
using ZB.MOM.WW.ScadaBridge.Security;
using ZB.MOM.WW.ScadaBridge.TemplateEngine;
using TemplateEditPage = ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Design.TemplateEdit;
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Design;
/// <summary>
/// bUnit tests for the template editor's READ-ONLY inheritance preview (M9-T26b):
/// rendering the FULL transitively-resolved inherited member set (not just the
/// immediate base) annotated with origin, plus a read-only base-changed staleness
/// banner. The resolve query is dispatched through
/// <see cref="ITemplateInheritanceQueryService"/>, which is substituted here so the
/// tests feed a crafted <see cref="ResolvedTemplateMembers"/> without a real
/// ManagementActor. No mutation / deploy-path behavior is exercised.
/// </summary>
public class TemplateEditInheritedSetTests : BunitContext
{
private readonly ITemplateEngineRepository _repo = Substitute.For<ITemplateEngineRepository>();
private readonly ICentralUiRepository _centralUi = Substitute.For<ICentralUiRepository>();
private readonly IAuditService _audit = Substitute.For<IAuditService>();
private readonly ISharedScriptCatalog _sharedScripts = Substitute.For<ISharedScriptCatalog>();
private readonly ITemplateInheritanceQueryService _resolve =
Substitute.For<ITemplateInheritanceQueryService>();
// The derived template under edit (id 30) and its immediate base (id 20).
private const int DerivedId = 30;
private const int BaseId = 20;
public TemplateEditInheritedSetTests()
{
Services.AddSingleton(_repo);
Services.AddSingleton(_centralUi);
Services.AddSingleton(_audit);
Services.AddSingleton(_resolve);
Services.AddScoped<TemplateService>();
Services.AddScoped<IDialogService, DialogService>();
// ScriptAnalysisService is injected but never exercised on the initial
// render — supply its collaborators so DI can construct it.
Services.AddSingleton(_sharedScripts);
Services.AddSingleton<IMemoryCache>(new MemoryCache(new MemoryCacheOptions()));
Services.AddScoped<ScriptAnalysisService>();
AddTestAuth();
SeedDerivedTemplateRows();
}
private void AddTestAuth()
{
var claims = new[]
{
new Claim(JwtTokenService.UsernameClaimType, "tester"),
new Claim(JwtTokenService.RoleClaimType, "Designer"),
};
var user = new ClaimsPrincipal(new ClaimsIdentity(claims, "TestAuth"));
Services.AddSingleton<AuthenticationStateProvider>(new TestAuthStateProvider(user));
Services.AddAuthorizationCore();
}
/// <summary>
/// Seeds the stored-row repository view of a derived template. The stored rows
/// deliberately omit the transitively-inherited members — those only appear via
/// the resolved set the query service returns.
/// </summary>
private void SeedDerivedTemplateRows()
{
var grandparent = new Template("Root") { Id = 10 };
var baseTemplate = new Template("Base") { Id = BaseId, ParentTemplateId = 10 };
var derived = new Template("Derived")
{
Id = DerivedId,
ParentTemplateId = BaseId,
IsDerived = true,
};
_repo.GetAllTemplatesAsync(Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IReadOnlyList<Template>>(
new List<Template> { grandparent, baseTemplate, derived }));
_repo.GetTemplateWithChildrenAsync(DerivedId, Arg.Any<CancellationToken>())
.Returns(Task.FromResult<Template?>(derived));
_repo.GetTemplateByIdAsync(BaseId, Arg.Any<CancellationToken>())
.Returns(Task.FromResult<Template?>(baseTemplate));
// Stored child rows: empty (the inherited set comes from the resolver).
_repo.GetAttributesByTemplateIdAsync(DerivedId, Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IReadOnlyList<TemplateAttribute>>(new List<TemplateAttribute>()));
_repo.GetAlarmsByTemplateIdAsync(DerivedId, Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IReadOnlyList<TemplateAlarm>>(new List<TemplateAlarm>()));
_repo.GetScriptsByTemplateIdAsync(DerivedId, Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IReadOnlyList<TemplateScript>>(new List<TemplateScript>()));
_repo.GetCompositionsByTemplateIdAsync(DerivedId, Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IReadOnlyList<TemplateComposition>>(new List<TemplateComposition>()));
_repo.GetNativeAlarmSourcesByTemplateIdAsync(DerivedId, Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IReadOnlyList<TemplateNativeAlarmSource>>(
new List<TemplateNativeAlarmSource>()));
_centralUi.GetAllDataConnectionsAsync(Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IReadOnlyList<DataConnection>>(new List<DataConnection>()));
_centralUi.GetInstancesFilteredAsync(
Arg.Any<int?>(), Arg.Any<int?>(), Arg.Any<string?>(), Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IReadOnlyList<Instance>>(new List<Instance>()));
}
private void SeedResolved(ResolvedTemplateMembers resolved) =>
_resolve.ResolveAsync(DerivedId, Arg.Any<CancellationToken>())
.Returns(Task.FromResult<ResolvedTemplateMembers?>(resolved));
[Fact]
public void Renders_TransitivelyInheritedMembers_WithOriginAnnotation()
{
// A grandparent-supplied attribute and a base attribute added AFTER the
// derived template was created — neither is in the stored rows; both must
// appear in the resolved inherited set with their origin template name.
SeedResolved(new ResolvedTemplateMembers
{
TemplateId = DerivedId,
TemplateName = "Derived",
ParentTemplateId = BaseId,
Attributes = new List<ResolvedTemplateMemberInfo>
{
new()
{
Name = "FromRoot",
IsInherited = true,
OriginTemplateId = 10,
OriginTemplateName = "Root",
EffectiveValue = "rootval",
},
new()
{
Name = "AddedLater",
IsInherited = true,
OriginTemplateId = BaseId,
OriginTemplateName = "Base",
EffectiveValue = "latebase",
},
},
Staleness = new ResolvedTemplateStaleness { IsStale = false, DifferingMemberCount = 0 },
});
var cut = Render<TemplateEditPage>(p => p.Add(c => c.Id, DerivedId));
cut.WaitForAssertion(() =>
{
// The transitively-inherited member names render...
Assert.Contains("FromRoot", cut.Markup);
Assert.Contains("AddedLater", cut.Markup);
// ...annotated with their origin template (multi-level + post-creation).
Assert.Contains("Root", cut.Markup);
Assert.Contains("Base", cut.Markup);
});
}
[Fact]
public void Renders_EffectiveAlarmTriggerConfiguration_FromResolvedSet()
{
// A HiLo alarm whose effective (merged) trigger config carries both
// setpoints — the editor must surface the merged EffectiveTriggerConfiguration.
SeedResolved(new ResolvedTemplateMembers
{
TemplateId = DerivedId,
TemplateName = "Derived",
ParentTemplateId = BaseId,
Alarms = new List<ResolvedTemplateMemberInfo>
{
new()
{
Name = "TempAlarm",
IsInherited = true,
OriginTemplateId = BaseId,
OriginTemplateName = "Base",
EffectiveValue = "500",
EffectiveTriggerConfiguration = "{\"hi\":90,\"lo\":10}",
},
},
Staleness = new ResolvedTemplateStaleness { IsStale = false, DifferingMemberCount = 0 },
});
var cut = Render<TemplateEditPage>(p => p.Add(c => c.Id, DerivedId));
cut.WaitForAssertion(() =>
{
Assert.Contains("TempAlarm", cut.Markup);
// The merged effective HiLo config (both setpoints) is shown.
Assert.Contains("hi", cut.Markup);
Assert.Contains("lo", cut.Markup);
});
}
[Fact]
public void Shows_StalenessBanner_WhenResolvedSetIsStale()
{
SeedResolved(new ResolvedTemplateMembers
{
TemplateId = DerivedId,
TemplateName = "Derived",
ParentTemplateId = BaseId,
Attributes = new List<ResolvedTemplateMemberInfo>
{
new()
{
Name = "AddedLater",
IsInherited = true,
OriginTemplateId = BaseId,
OriginTemplateName = "Base",
EffectiveValue = "latebase",
},
},
Staleness = new ResolvedTemplateStaleness { IsStale = true, DifferingMemberCount = 3 },
});
var cut = Render<TemplateEditPage>(p => p.Add(c => c.Id, DerivedId));
cut.WaitForAssertion(() =>
{
// Informational banner naming the base-changed condition + the count.
Assert.Contains("Base template changed", cut.Markup);
Assert.Contains("3", cut.Markup);
});
}
[Fact]
public void NoStalenessBanner_WhenResolvedSetIsNotStale()
{
SeedResolved(new ResolvedTemplateMembers
{
TemplateId = DerivedId,
TemplateName = "Derived",
ParentTemplateId = BaseId,
Staleness = new ResolvedTemplateStaleness { IsStale = false, DifferingMemberCount = 0 },
});
var cut = Render<TemplateEditPage>(p => p.Add(c => c.Id, DerivedId));
cut.WaitForAssertion(() => Assert.Contains("Derived", cut.Markup));
Assert.DoesNotContain("Base template changed", cut.Markup);
}
}