Sections manifest: parse chatTabs (server default chat tabs)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7caafc72af
commit
f2d7f0464c
2 changed files with 120 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ internal static class Program
|
|||
WindowTakeOver();
|
||||
WindowFrameless();
|
||||
ManifestBarMenu();
|
||||
ManifestChatTabs();
|
||||
BarMenuHoverTiming();
|
||||
BarMenuReload();
|
||||
StackCheckAfterPluginDraw();
|
||||
|
|
@ -594,6 +595,58 @@ internal static class Program
|
|||
"{ \"version\": 1, \"windows\": [ { \"id\": \"server\", \"title\": \"DreamWeave\", \"surface\": \"window:server\", \"bar\": true"
|
||||
+ windowExtra + " } ] }";
|
||||
|
||||
private static void ManifestChatTabs()
|
||||
{
|
||||
Case("manifest: chatTabs (2026-11-15)");
|
||||
const string good = """
|
||||
{ "chatTabs": [ { "server": "dreamweave", "id": "dereth-network", "name": "Network", "pinned": true,
|
||||
"globalRoomFallback": "Roleplay",
|
||||
"rules": [ { "action": "copy", "when": "type:3", "mode": "", "pattern": "^x", "globalRoom": false },
|
||||
{ "action": "copy", "when": "", "mode": "startswith", "pattern": "", "globalRoom": true } ] } ] }
|
||||
""";
|
||||
SectionManifest m = SectionManifestParser.Parse("DW", good, out string err);
|
||||
Check(err.Length == 0 && m.ChatTabs.Length == 1, "one entry parses: " + err);
|
||||
SectionChatTabDecl t = m.ChatTabs[0];
|
||||
Check(t.Server == "dreamweave" && t.Id == "dereth-network" && t.Name == "Network" && t.Pinned && t.GlobalRoomFallback == "Roleplay",
|
||||
"entry fields");
|
||||
Check(t.Rules.Length == 2 && t.Rules[1].GlobalRoom && t.Rules[1].Pattern == "", "rules: global-room rule with an empty pattern");
|
||||
Check(t.Rules[0].Action == "copy" && t.Rules[0].When == "type:3" && t.Rules[0].Pattern == "^x" && !t.Rules[0].GlobalRoom, "rule 0 fields");
|
||||
|
||||
Check(SectionManifestParser.Parse("DW", """{ "contributions": [] }""", out _).ChatTabs.Length == 0, "no chatTabs key = empty array");
|
||||
|
||||
// Each reject drops the entry, reports it in error, and still parses the other keys.
|
||||
string section = """ "sections": [ { "id": "quests", "label": "Quests", "order": 150 } ] """;
|
||||
string[] bad =
|
||||
{
|
||||
"""{ "id": "a", "name": "A", "globalRoomFallback": "General", "rules": [] }""",
|
||||
"""{ "server": "dw", "name": "A", "globalRoomFallback": "General", "rules": [] }""",
|
||||
"""{ "server": "dw", "id": "Bad Id", "name": "A", "globalRoomFallback": "General", "rules": [] }""",
|
||||
"""{ "server": "dw", "id": "a", "name": "A", "globalRoomFallback": "General", "rules": [ { "action": "delete", "when": "", "mode": "", "pattern": "x" } ] }""",
|
||||
"""{ "server": "dw", "id": "a", "name": "A", "globalRoomFallback": "Sports", "rules": [] }""",
|
||||
};
|
||||
string[] why = { "missing server", "missing id", "bad id", "bad action", "bad fallback" };
|
||||
for (int i = 0; i < bad.Length; i++)
|
||||
{
|
||||
m = SectionManifestParser.Parse("DW", "{ " + section + ", \"chatTabs\": [" + bad[i] + "] }", out err);
|
||||
Check(m.ChatTabs.Length == 0 && err.Length > 0 && m.Sections.Length == 1, "dropped, error set, other keys kept: " + why[i]);
|
||||
}
|
||||
|
||||
var entries = new System.Text.StringBuilder();
|
||||
for (int i = 0; i < 9; i++)
|
||||
entries.Append(i > 0 ? "," : "").Append($"{{ \"server\": \"dw\", \"id\": \"t{i}\", \"name\": \"T{i}\", \"globalRoomFallback\": \"General\", \"rules\": [] }}");
|
||||
m = SectionManifestParser.Parse("DW", "{ \"chatTabs\": [" + entries + "] }", out err);
|
||||
Check(m.ChatTabs.Length == SectionManifestParser.MaxChatTabs && SectionManifestParser.MaxChatTabs == 8 && err.Length > 0,
|
||||
"more than 8 entries: the cap holds and error is set: " + m.ChatTabs.Length);
|
||||
|
||||
var rules = new System.Text.StringBuilder();
|
||||
for (int i = 0; i < 17; i++)
|
||||
rules.Append(i > 0 ? "," : "").Append($"{{ \"action\": \"copy\", \"when\": \"\", \"mode\": \"\", \"pattern\": \"r{i}\" }}");
|
||||
m = SectionManifestParser.Parse("DW", "{ " + section + ", \"chatTabs\": [ { \"server\": \"dw\", \"id\": \"a\", \"name\": \"A\", \"globalRoomFallback\": \"General\", \"rules\": ["
|
||||
+ rules + "] } ] }", out err);
|
||||
Check(SectionManifestParser.MaxChatRules == 16 && m.ChatTabs.Length == 0 && err.Length > 0 && m.Sections.Length == 1,
|
||||
"17 rules: entry dropped, error set");
|
||||
}
|
||||
|
||||
private static void ManifestBarMenu()
|
||||
{
|
||||
Case("plugin windows: barMenu (v95)");
|
||||
|
|
|
|||
Loading…
Reference in a new issue