test(runtime): add deterministic world gate artifacts
This commit is contained in:
parent
db45b81f75
commit
354c2adc2e
11 changed files with 703 additions and 10 deletions
|
|
@ -24,6 +24,32 @@ public sealed class RetailUiAutomationProbeTests
|
|||
=> LastDrop = (targetList, targetCell, payload);
|
||||
}
|
||||
|
||||
private sealed class FakeRuntime : IRetailUiAutomationRuntime
|
||||
{
|
||||
public bool IsWorldReady { get; set; }
|
||||
public bool IsWorldViewportVisible { get; set; }
|
||||
public int PortalMaterializationCount { get; set; }
|
||||
public List<string> Checkpoints { get; } = new();
|
||||
public HashSet<string> ScreenshotRequests { get; } = new();
|
||||
public HashSet<string> CompletedScreenshots { get; } = new();
|
||||
|
||||
public bool TryWriteCheckpoint(string name, out string error)
|
||||
{
|
||||
Checkpoints.Add(name);
|
||||
error = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TryRequestScreenshot(string name, out string error)
|
||||
{
|
||||
ScreenshotRequests.Add(name);
|
||||
error = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsScreenshotComplete(string name) => CompletedScreenshots.Contains(name);
|
||||
}
|
||||
|
||||
private static (UiRoot root, UiItemList source, UiItemList target, SpyHandler handler, ClientObjectTable objects)
|
||||
RootWithTwoItemLists()
|
||||
{
|
||||
|
|
@ -527,4 +553,86 @@ public sealed class RetailUiAutomationProbeTests
|
|||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ScriptRunner_worldLifecycleCommands_waitForCanonicalRuntimeState()
|
||||
{
|
||||
var (root, _, _, _, objects) = RootWithTwoItemLists();
|
||||
var runtime = new FakeRuntime();
|
||||
var probe = new RetailUiAutomationProbe(root, objects);
|
||||
string path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".ui-probe.txt");
|
||||
File.WriteAllLines(path,
|
||||
[
|
||||
"wait world-ready 1000",
|
||||
"wait world-visible 1000",
|
||||
"wait materialized 2 1000",
|
||||
"checkpoint stable",
|
||||
"screenshot stable 1000",
|
||||
]);
|
||||
|
||||
try
|
||||
{
|
||||
using var runner = new RetailUiAutomationScriptRunner(
|
||||
probe,
|
||||
path,
|
||||
dumpOnStart: false,
|
||||
runtime: runtime);
|
||||
|
||||
runner.Tick(0d);
|
||||
Assert.False(runner.Completed);
|
||||
|
||||
runtime.IsWorldReady = true;
|
||||
runner.Tick(0.001d);
|
||||
Assert.False(runner.Completed);
|
||||
|
||||
runtime.IsWorldViewportVisible = true;
|
||||
runtime.PortalMaterializationCount = 2;
|
||||
runner.Tick(0.001d);
|
||||
|
||||
Assert.Equal(["stable"], runtime.Checkpoints);
|
||||
Assert.Contains("stable", runtime.ScreenshotRequests);
|
||||
Assert.False(runner.Completed);
|
||||
|
||||
runtime.CompletedScreenshots.Add("stable");
|
||||
runner.Tick(0.001d);
|
||||
|
||||
Assert.True(runner.Completed);
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ScriptRunner_worldReadyTimeout_stopsWithActionableLine()
|
||||
{
|
||||
var (root, _, _, _, objects) = RootWithTwoItemLists();
|
||||
var runtime = new FakeRuntime();
|
||||
var probe = new RetailUiAutomationProbe(root, objects);
|
||||
var logs = new List<string>();
|
||||
string path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".ui-probe.txt");
|
||||
File.WriteAllText(path, "wait world-ready 10");
|
||||
|
||||
try
|
||||
{
|
||||
using var runner = new RetailUiAutomationScriptRunner(
|
||||
probe,
|
||||
path,
|
||||
dumpOnStart: false,
|
||||
log: logs.Add,
|
||||
runtime: runtime);
|
||||
|
||||
runner.Tick(0d);
|
||||
runner.Tick(0.011d);
|
||||
|
||||
Assert.True(runner.Completed);
|
||||
Assert.Contains(logs, line =>
|
||||
line.Contains("timed out waiting for world readiness", StringComparison.Ordinal));
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue