Commit the pending application, help and browser regression work. Pin the patched PKCS dependency for the production release.
137 lines
8.8 KiB
C#
137 lines
8.8 KiB
C#
using PlotLine.Models;
|
|
using PlotLine.Services;
|
|
|
|
internal static class PlotLineWorkspaceTests
|
|
{
|
|
public static void FocusWeaveGapsAndSharedScenes()
|
|
{
|
|
Check(PlotLineColours.ForLine(1, "#2f6f63") != PlotLineColours.ForLine(2, "#2f6f63"), "Legacy default colours should distinguish line identities.");
|
|
Check(PlotLineColours.ForLine(1, "#123456") == "#123456", "Explicit line colours must be preserved.");
|
|
var data = Fixture();
|
|
var focus = PlotLineWorkspaceComposer.Compose(data, [1]);
|
|
Check(focus.Count == 2, "Focus mode should contain the selected line's two scenes.");
|
|
Check(focus[1].GapBefore == 4, "Dormancy should report the four intervening narrative scenes.");
|
|
Check(focus[1].ChapterGapBefore == 2, "Chapter dormancy should report whole intervening chapters.");
|
|
|
|
var weave = PlotLineWorkspaceComposer.Compose(data, [1, 2]);
|
|
Check(weave.Count == 2, "Weave mode should render a shared scene once, not once per line.");
|
|
Check(weave[0].IsShared && weave[0].Memberships.Count == 2, "A shared scene should retain both line memberships.");
|
|
Check(weave[0].Memberships.SelectMany(x => x.Contributions).Any(x =>
|
|
x.CanonicalTitle == "Canonical event" && x.CandidateTitle == "Supporting imported detail"),
|
|
"Imported supporting detail must enrich rather than replace the canonical event.");
|
|
}
|
|
|
|
public static void ThreadFilteringAndInspectorContracts()
|
|
{
|
|
var data = Fixture();
|
|
var filtered = PlotLineWorkspaceComposer.Compose(data, [1, 2], [12]);
|
|
Check(filtered.Count == 1 && filtered[0].SceneID == 101, "Thread filtering should retain only contributions from selected threads.");
|
|
Check(filtered[0].Memberships.Single().PlotLineID == 2, "Thread filtering must not leak another line's events.");
|
|
|
|
// Scenario order is supplied by the read model, rather than inferred from chapter labels.
|
|
foreach (var contribution in data.Contributions) contribution.NarrativeOrder = contribution.SceneID == 102 ? 1 : 9;
|
|
var scenario = PlotLineWorkspaceComposer.Compose(data, [1, 2]);
|
|
Check(scenario[0].SceneID == 102 && scenario[1].SceneID == 101, "Map must preserve supplied scenario ordering.");
|
|
|
|
var root = RepositoryRoot();
|
|
var workspaceView = File.ReadAllText(Path.Combine(root, "PlotLine/Views/PlotLineWorkspace/Index.cshtml"));
|
|
Check(workspaceView.Contains("plotline-shell-wide", StringComparison.Ordinal), "Workspace should use the established full-width shell.");
|
|
var lineEditor = File.ReadAllText(Path.Combine(root, "PlotLine/Views/PlotLines/Edit.cshtml"));
|
|
Check(lineEditor.Contains("asp-for=\"Colour\" type=\"color\"", StringComparison.Ordinal), "Line colour should use the existing persisted editor field.");
|
|
var timeline = File.ReadAllText(Path.Combine(root, "PlotLine/Views/Timeline/Index.cshtml"));
|
|
var settings = File.ReadAllText(Path.Combine(root, "PlotLine/Views/Timeline/Settings.cshtml"));
|
|
var characterEditor = File.ReadAllText(Path.Combine(root, "PlotLine/Views/Shared/SceneInspectorV2/_SceneCharactersEditor.cshtml"));
|
|
var controller = File.ReadAllText(Path.Combine(root, "PlotLine/Controllers/ScenesController.cs"));
|
|
var sql = File.ReadAllText(Path.Combine(root, "PlotLine/Sql/204_PlotLineWorkspaceV1.sql"));
|
|
|
|
Check(!timeline.Contains("Model.PlotLanes", StringComparison.Ordinal) && !timeline.Contains("data-plot-line-svg", StringComparison.Ordinal), "Timeline must not render legacy plot lanes or SVGs.");
|
|
Check(!settings.Contains("ShowPlotLines", StringComparison.Ordinal), "Timeline must not offer obsolete plot lane visibility.");
|
|
var script = File.ReadAllText(Path.Combine(root, "PlotLine/wwwroot/js/site.js"));
|
|
Check(!script.Contains("renderPlotLineSvg", StringComparison.Ordinal) && !script.Contains("const healthFor", StringComparison.Ordinal), "Retired Timeline health rules must not remain executable.");
|
|
Check(timeline.Contains("name=\"PlotLineID\"", StringComparison.Ordinal) && timeline.Contains("name=\"PlotThreadID\"", StringComparison.Ordinal), "Timeline must retain chronological membership filters.");
|
|
Check(!timeline.Contains("character-lane-board", StringComparison.Ordinal), "Timeline must not render Character lane presentation.");
|
|
Check(!settings.Contains("ShowCharacterAppearances", StringComparison.Ordinal), "Timeline settings must not offer Character lanes.");
|
|
Check(characterEditor.Contains("Knowledge notes", StringComparison.Ordinal) && controller.Contains("KnowledgeNotes = row.KnowledgeNotes", StringComparison.Ordinal),
|
|
"Scene Inspector must expose and save character knowledge notes.");
|
|
Check(sql.Contains("cm.NarrativeCandidateID = te.SourceReferenceID AND cm.SceneID = te.SceneID", StringComparison.Ordinal),
|
|
"Imported event enrichment must require SourceReferenceID and SceneID.");
|
|
Check(sql.Contains("nc.Status = N'Pending'", StringComparison.Ordinal), "Suggestions must be restricted to pending candidates.");
|
|
}
|
|
|
|
public static void GeneratedScale()
|
|
{
|
|
const int lineCount = 40;
|
|
const int sceneCount = 1200;
|
|
var lines = Enumerable.Range(1, lineCount).Select(id => new PlotLineWorkspaceLineRow
|
|
{
|
|
PlotLineID = id,
|
|
PlotLineName = $"Generated line {id}",
|
|
SortOrder = id
|
|
}).ToList();
|
|
var contributions = new List<PlotLineWorkspaceContributionRow>(lineCount * 300);
|
|
for (var lineId = 1; lineId <= lineCount; lineId++)
|
|
{
|
|
for (var index = 0; index < 300; index++)
|
|
{
|
|
var sceneId = 10_000 + ((index * 7 + lineId * 13) % sceneCount);
|
|
contributions.Add(Contribution(lineId, lineId * 10, sceneId, sceneId - 9_999, 1 + (sceneId % 40), $"Event {lineId}-{index}", null));
|
|
}
|
|
}
|
|
|
|
var composed = PlotLineWorkspaceComposer.Compose(new PlotLineWorkspaceData { PlotLines = lines, Contributions = contributions }, lines.Select(x => x.PlotLineID).ToArray());
|
|
Check(composed.Count <= sceneCount, "Large weave must still render each scene at most once.");
|
|
Check(composed.Select(x => x.SceneID).Distinct().Count() == composed.Count, "Large weave contains duplicate scene cards.");
|
|
Check(composed.Zip(composed.Skip(1), (left, right) => left.NarrativeOrder <= right.NarrativeOrder).All(x => x), "Large weave lost narrative ordering.");
|
|
}
|
|
|
|
internal static PlotLineWorkspaceData Fixture() => new()
|
|
{
|
|
PlotLines =
|
|
[
|
|
new() { PlotLineID = 1, PlotLineName = "Line A", Colour = "#5bada0", SortOrder = 1 },
|
|
new() { PlotLineID = 2, PlotLineName = "Line B", Colour = "#b36f43", SortOrder = 2 },
|
|
new() { PlotLineID = 3, PlotLineName = "Line C", Colour = "#527bcc", SortOrder = 3 }
|
|
],
|
|
Threads = [new() { PlotThreadID = 11, PlotLineID = 1, ThreadTitle = "First phase", IntroducedSceneID = 101 }],
|
|
Targets = [new() { ThreadEventID = 1011, SourcePlotLineID = 1, TargetPlotLineID = 2, StructuralType = "Branch" }],
|
|
AttributionScenes = [new() { SceneID = 101, SceneTitle = "Shared scene", NarrativeOrder = 2, CanonicalPlotLineCount = 2 }, new() { SceneID = 103, SceneTitle = "Unattributed scene", NarrativeOrder = 3 }],
|
|
Dependencies = [new() { SceneDependencyID = 1, SourceSceneID = 101, TargetSceneID = 102, DependencyType = "Requires" }],
|
|
Contributions =
|
|
[
|
|
Contribution(1, 11, 101, 2, 1, "Canonical event", "Supporting imported detail"),
|
|
Contribution(2, 12, 101, 2, 1, "Other canonical event", null),
|
|
Contribution(1, 11, 102, 7, 4, "Later event", null)
|
|
]
|
|
};
|
|
|
|
private static PlotLineWorkspaceContributionRow Contribution(
|
|
int lineId, int threadId, int sceneId, int order, decimal chapter, string canonicalTitle, string? candidateTitle) => new()
|
|
{
|
|
ThreadEventID = sceneId * 10 + lineId,
|
|
PlotLineID = lineId,
|
|
PlotThreadID = threadId,
|
|
SceneID = sceneId,
|
|
NarrativeOrder = order,
|
|
ChapterNumber = chapter,
|
|
ChapterTitle = $"Chapter {chapter}",
|
|
SceneNumber = order,
|
|
SceneTitle = $"Scene {sceneId}",
|
|
CanonicalTitle = canonicalTitle,
|
|
CandidateTitle = candidateTitle,
|
|
ThreadTitle = $"Thread {threadId}",
|
|
CanonicalRole = "Developed"
|
|
};
|
|
|
|
private static string RepositoryRoot()
|
|
{
|
|
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "PlotLine.slnx"))) directory = directory.Parent;
|
|
return directory?.FullName ?? throw new InvalidOperationException("Repository root not found.");
|
|
}
|
|
|
|
private static void Check(bool condition, string message)
|
|
{
|
|
if (!condition) throw new InvalidOperationException(message);
|
|
}
|
|
}
|