Files
HellionChat/HellionChat/SelfTests/SidebarUnreadDotStep.cs
T
JonKazama-Hellion 5b738e6885 chore: comments say what the code does, not which task produced it
A comment that reads "MUST stay in lockstep with TryGetActiveCrossfade (K8)"
helps nobody outside the plan that used to have a K8 in it, and the plans are
not in this repo. Same for "Spec FR-4", "plan §B.2", "Sub-Task 4.4" and the
F/R/M/A/S round codes scattered through the style engine and the self-tests.

Personal names go too. "tester feedback from Jin (v1.4.7)" and "Flo decision
2026-06-15" carry the reason fine without naming anyone -- the version and the
reason are the parts a reader can act on, and a public repo should not need a
cast list to be read.

The rule applied throughout: keep the why, drop the reference. Version numbers
stay, since those resolve through the changelog. 77 files.

ChunkUtil also carried 281 lines of commented-out code -- an older ToChunks
variant and two helpers with no callers, inherited and never removed. Deleted;
git remembers them.
2026-08-19 21:50:31 +02:00

78 lines
2.7 KiB
C#

using Dalamud.Bindings.ImGui;
using Dalamud.Plugin.SelfTest;
using HellionChat.Code;
namespace HellionChat.SelfTests;
// The unread dot the v1.8.x sidebar rebuild dropped. Drives the REAL
// Sidebar.Draw (render precedent: SidebarGreetedGlyphStep) with a probe tab that
// is inactive and carries Unread>0, then reads the render-observability counter
// so a regressed/absent dot fails. Asserts: dot drawn for an inactive Unseen tab;
// NOT drawn for UnreadMode.None. Uses a local one-tab list so the count is
// unambiguous; restores SidebarWidth in finally.
internal sealed class SidebarUnreadDotStep : ISelfTestStep
{
private readonly Plugin _plugin;
public SidebarUnreadDotStep(Plugin plugin) => _plugin = plugin;
public string Name => "Hellion Chat - Sidebar unread dot";
public SelfTestStepResult RunStep()
{
var sidebar = _plugin.MainWindow.GetSidebarForSelfTest();
if (sidebar is null)
{
ImGui.Text("Sidebar null");
return SelfTestStepResult.Fail;
}
var probe = new Tab
{
Name = "Unread Probe@SelfTest",
UnreadMode = UnreadMode.Unseen,
Unread = 3,
SelectedChannels = new Dictionary<ChatType, (ChatSource, ChatSource)>
{
[ChatType.Say] = (ChatSourceExt.All, ChatSourceExt.All),
},
};
var list = new List<Tab> { probe };
Tab? active = null; // probe is NOT the active tab
var width = (float)Plugin.Config.SidebarAutoSwitchThresholdPx + 100f; // expanded
var savedWidth = Plugin.Config.SidebarWidth;
try
{
Plugin.Config.SidebarWidth = 220;
// (a) an inactive Unseen tab with Unread>0 draws exactly one dot
// (the one-tab list makes the expected count unambiguous).
sidebar.Draw(width, list, ref active);
if (sidebar.LastRenderedUnreadDotCount != 1)
{
ImGui.Text(
$"Expected exactly 1 unread dot, got {sidebar.LastRenderedUnreadDotCount}"
);
return SelfTestStepResult.Fail;
}
// (b) UnreadMode.None opts the tab out — no dot.
probe.UnreadMode = UnreadMode.None;
sidebar.Draw(width, list, ref active);
if (sidebar.LastRenderedUnreadDotCount != 0)
{
ImGui.Text("Unread dot drawn for an UnreadMode.None tab");
return SelfTestStepResult.Fail;
}
}
finally
{
Plugin.Config.SidebarWidth = savedWidth;
}
return SelfTestStepResult.Pass;
}
public void CleanUp() { }
}