Skip to content

Commit e9a1545

Browse files
committed
Add playbook preflight error coverage
1 parent edb84f1 commit e9a1545

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

TweakHub.Tests/AutomatedScriptsPageTests.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,49 @@ public async Task PlaybookExecutionStopsOnFirstFailureAndPreservesOrder()
8787
});
8888
}
8989

90+
[Test]
91+
public void PlaybookPreflightFlagsMissingReferencesInvalidWingetAndEmptySteps()
92+
{
93+
var broken = PlaybookService.Instance.Preflight(new Playbook
94+
{
95+
Name = "Broken",
96+
Steps =
97+
[
98+
new() { Type = PlaybookStepType.Tweak, ReferenceId = "builtin:not-a-real-tweak", Name = "Missing tweak" },
99+
new() { Type = PlaybookStepType.Script, ReferenceId = "not-on-this-pc", Name = "Missing script" },
100+
new() { Type = PlaybookStepType.Winget, WingetId = "not a winget id", Name = "Bad winget" }
101+
]
102+
});
103+
Assert.Multiple(() =>
104+
{
105+
Assert.That(broken.CanRun, Is.False);
106+
Assert.That(broken.Errors, Has.Count.EqualTo(3));
107+
});
108+
109+
var empty = PlaybookService.Instance.Preflight(new Playbook { Name = "Empty" });
110+
Assert.Multiple(() =>
111+
{
112+
Assert.That(empty.CanRun, Is.False);
113+
Assert.That(empty.Errors, Has.Count.EqualTo(1));
114+
});
115+
116+
var valid = PlaybookService.Instance.Preflight(new Playbook
117+
{
118+
Name = "Valid",
119+
Steps =
120+
[
121+
new() { Type = PlaybookStepType.Tweak, ReferenceId = "builtin:cpu_priority_separation", Name = "CPU priority" },
122+
new() { Type = PlaybookStepType.Winget, WingetId = "Microsoft.PowerToys", Name = "PowerToys" }
123+
]
124+
});
125+
Assert.Multiple(() =>
126+
{
127+
Assert.That(valid.CanRun, Is.True);
128+
Assert.That(valid.Errors, Is.Empty);
129+
Assert.That(valid.Lines, Has.Count.EqualTo(2));
130+
});
131+
}
132+
90133
[Test]
91134
public void StructurallyValidPlaybookPreservesUnavailableReferences()
92135
{

0 commit comments

Comments
 (0)