fix(central-ui): LogsTruncated clears once a refresh merges in more log rows; badge reworded (Task 13 review)
This commit is contained in:
@@ -989,7 +989,7 @@ public class FlowDebuggerPageTests : BunitContext
|
||||
|
||||
var cut = RunWith(LoggedOutcome(infos: 1, logsTruncated: true));
|
||||
|
||||
Assert.Contains("Replay is complete", cut.Find("[data-test='flow-logs-truncated']").TextContent);
|
||||
Assert.Contains("inline log lines capped", cut.Find("[data-test='flow-logs-truncated']").TextContent);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -1053,8 +1053,109 @@ public class FlowDebuggerPageTests : BunitContext
|
||||
|
||||
hint.Click();
|
||||
|
||||
// The page owns the selection: clicking the hint moves the detail panel to the sibling step.
|
||||
// The page owns the selection: clicking the hint moves the detail panel AND the graph's
|
||||
// highlight to the sibling step.
|
||||
Assert.NotEqual(before, otherTitle);
|
||||
Assert.Equal(otherTitle, cut.Find("[data-test='flow-step-title']").TextContent.Trim());
|
||||
var selected = cut.Find("[data-test='flow-node'].selected");
|
||||
Assert.Equal("e:" + writeId.ToString("N"), selected.GetAttribute("data-key"));
|
||||
}
|
||||
|
||||
// ---- D7: the inline cap flag is only true while the page is still short of lines --------------
|
||||
|
||||
/// <summary>
|
||||
/// A Live run that reported inline log truncation, plus the Replay a refresh reads back — sharing the
|
||||
/// run's own event objects (stable ids, as real audit rows are) and, when asked, one more log row than
|
||||
/// the run held.
|
||||
/// </summary>
|
||||
private static (FlowDebugOutcome Run, FlowDebugOutcome Refreshed, Guid Root) TruncatedThenRefreshed(bool refreshAddsALine)
|
||||
{
|
||||
var root = Guid.NewGuid();
|
||||
var child = Guid.NewGuid();
|
||||
var t0 = DateTime.UtcNow.AddSeconds(-5);
|
||||
var events = new List<AuditEvent>
|
||||
{
|
||||
ScadaBridgeAuditEventFactory.Create(AuditChannel.ApiInbound, AuditKind.InboundRequest, AuditStatus.Delivered,
|
||||
occurredAtUtc: t0, target: "POST /api/DelmiaRecipeDownload", executionId: root, durationMs: 100,
|
||||
requestSummary: "{}", responseSummary: "{}"),
|
||||
ScadaBridgeAuditEventFactory.Create(AuditChannel.ScriptTrace, AuditKind.RouteCall, AuditStatus.Delivered,
|
||||
occurredAtUtc: t0.AddMilliseconds(1), target: "Sim01.Process", executionId: root, durationMs: 90,
|
||||
extra: new ScriptTraceExtra { ChildExecutionId = child }.ToJson()),
|
||||
ScadaBridgeAuditEventFactory.Create(AuditChannel.ScriptTrace, AuditKind.ScriptRun, AuditStatus.Delivered,
|
||||
occurredAtUtc: t0.AddMilliseconds(2), target: "Process", executionId: child, parentExecutionId: root,
|
||||
sourceSiteId: "site-a", sourceInstanceId: "Sim01", durationMs: 80),
|
||||
LogLine(child, "info", 3),
|
||||
};
|
||||
var raw = new FlowDebugRunResult(root, true, null, null, events, false, t0, t0.AddSeconds(1), true);
|
||||
var run = new FlowDebugOutcome(FlowGraphBuilder.Build(events, false, true), raw, null, null, true);
|
||||
|
||||
// The audit store is never truncated, so the re-read's own flag is false whatever it holds.
|
||||
var reread = new List<AuditEvent>(events);
|
||||
if (refreshAddsALine)
|
||||
reread.Add(LogLine(child, "warn", 4));
|
||||
var rereadRaw = new FlowDebugRunResult(root, true, null, null, reread, false, t0, t0.AddSeconds(1));
|
||||
var refreshed = new FlowDebugOutcome(FlowGraphBuilder.Build(reread), rereadRaw, null, null);
|
||||
return (run, refreshed, root);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RefreshOutcomes_ClearsTheInlineCapBadge_OnceItMergesInMoreLogRows()
|
||||
{
|
||||
RegisterServices();
|
||||
var (run, refreshed, root) = TruncatedThenRefreshed(refreshAddsALine: true);
|
||||
_flow.ReplayAsync(root, Arg.Any<CancellationToken>()).Returns(refreshed);
|
||||
var cut = RunWith(run);
|
||||
cut.Instance.Delay = (_, _) => Task.CompletedTask;
|
||||
Assert.NotNull(cut.Find("[data-test='flow-logs-truncated']"));
|
||||
|
||||
cut.Find("button[data-test='flow-refresh']").Click();
|
||||
|
||||
cut.WaitForAssertion(() => Assert.Empty(cut.FindAll("[data-test='flow-logs-truncated']")));
|
||||
Assert.Equal("0 errors · 1 warnings · 1 info", cut.Find("[data-test='flow-log-counts']").TextContent.Trim());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RefreshOutcomes_KeepsTheInlineCapBadge_WhenTheReReadBringsBackNoNewLines()
|
||||
{
|
||||
// The site's rows reach central by telemetry seconds later — a refresh that adds nothing
|
||||
// has not proven the page holds every line.
|
||||
RegisterServices();
|
||||
var (run, refreshed, root) = TruncatedThenRefreshed(refreshAddsALine: false);
|
||||
_flow.ReplayAsync(root, Arg.Any<CancellationToken>()).Returns(refreshed);
|
||||
var cut = RunWith(run);
|
||||
cut.Instance.Delay = (_, _) => Task.CompletedTask;
|
||||
|
||||
cut.Find("button[data-test='flow-refresh']").Click();
|
||||
|
||||
cut.WaitForAssertion(() => _flow.Received(1).ReplayAsync(root, Arg.Any<CancellationToken>()));
|
||||
Assert.NotNull(cut.Find("[data-test='flow-logs-truncated']"));
|
||||
Assert.Equal("0 errors · 0 warnings · 1 info", cut.Find("[data-test='flow-log-counts']").TextContent.Trim());
|
||||
}
|
||||
|
||||
// ---- CountLogs: the level buckets, straight ---------------------------------------------------
|
||||
|
||||
[Fact]
|
||||
public void CountLogs_BucketsByLevel_CaseInsensitively_WithEverythingElseAsInfo()
|
||||
{
|
||||
var execution = Guid.NewGuid();
|
||||
var t0 = DateTime.UtcNow;
|
||||
var graph = FlowGraphBuilder.Build([
|
||||
ScadaBridgeAuditEventFactory.Create(AuditChannel.ScriptTrace, AuditKind.ScriptRun, AuditStatus.Delivered,
|
||||
occurredAtUtc: t0, target: "Process", executionId: execution,
|
||||
sourceSiteId: "site-a", sourceInstanceId: "Sim01", durationMs: 80),
|
||||
LogLine(execution, "ERROR", 1),
|
||||
LogLine(execution, "Warn", 2),
|
||||
LogLine(execution, "info", 3),
|
||||
LogLine(execution, "debug", 4),
|
||||
LogLine(execution, "trace", 5), // an unknown level is still a line — it lands in info
|
||||
]);
|
||||
|
||||
Assert.Equal((1, 1, 3, 5), FlowDebuggerPage.CountLogs(graph));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CountLogs_NullGraph_IsAllZeroes()
|
||||
{
|
||||
Assert.Equal((0, 0, 0, 0), FlowDebuggerPage.CountLogs(null));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user