feat: add a Tools page printer for note merge and print presets
Chapter officers can merge a markdown note onto filtered students, teams, or events and save the recipe. Extra student-note columns are additional fields (any ## … fields heading) so they work as print tokens whether imported or typed by hand. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using Core.Printing;
|
||||
|
||||
namespace Tests.Printing;
|
||||
|
||||
[TestFixture]
|
||||
public class PrintTokenMap_Tests
|
||||
{
|
||||
[Test]
|
||||
public void Build_BuiltInWinsOverImportedSameName()
|
||||
{
|
||||
var map = PrintTokenMap.Build(
|
||||
new Dictionary<string, string?> { ["Grade"] = "imported" },
|
||||
new Dictionary<string, string?> { ["Grade"] = "9" },
|
||||
null);
|
||||
|
||||
Assert.That(map["Grade"], Is.EqualTo("9"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Build_IncludesAllImportedCatalogKeys()
|
||||
{
|
||||
var imported = new Dictionary<string, string?>
|
||||
{
|
||||
["Interview Time"] = "3:20-3:35",
|
||||
["Application"] = null
|
||||
};
|
||||
|
||||
var map = PrintTokenMap.Build(imported, null, null);
|
||||
|
||||
Assert.That(map.ContainsKey("Interview Time"), Is.True);
|
||||
Assert.That(map["Interview Time"], Is.EqualTo("3:20-3:35"));
|
||||
Assert.That(map.ContainsKey("Application"), Is.True);
|
||||
Assert.That(map["Application"], Is.EqualTo(string.Empty));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Escape_MasksMarkdownAndHtml()
|
||||
{
|
||||
var escaped = PrintTokenMap.Escape("A *B* <script>");
|
||||
|
||||
Assert.That(escaped, Does.Contain("\\*"));
|
||||
Assert.That(escaped, Does.Contain("<"));
|
||||
Assert.That(escaped, Does.Contain(">"));
|
||||
Assert.That(escaped, Does.Not.Contain("<script>"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Merge_EscapedAsteriskDoesNotStayRaw()
|
||||
{
|
||||
var map = PrintTokenMap.Build(
|
||||
null,
|
||||
new Dictionary<string, string?> { ["FirstName"] = "A*ria" },
|
||||
null);
|
||||
|
||||
var merged = NoteTemplateMerger.Merge("Hi {{FirstName}}", map);
|
||||
|
||||
Assert.That(merged, Is.EqualTo("Hi A\\*ria"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user