Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/SandboxWorkerDeploymentTests.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
Comment/XML-doc changes only:
- add summaries to ~10k test methods, fixtures, fakes and helpers
  (+ <param> on theories, <returns> on async Task methods,
  <inheritdoc/> on interface implementations the checker can resolve)
- strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N,
  #NN, Component-0NN) from comments, keeping the explanatory text;
  reword false positives in comments only
- real docs on fakes implementing BCL/library interfaces
  (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime)
- reword the last 5 src/ false positives (CWE-1236, failures-1,
  year-0001, M365)

Only non-comment edits: four one-line nested classes split across lines
so members can carry docs. Build 0 errors / 0 warnings.
2026-10-07 15:05:49 -04:00

44 lines
2.3 KiB
C#

using System.Text.Json;
namespace ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests;
/// <summary>Verifies worker publication and termination in the deployed Linux runtime image.</summary>
[Collection("Playwright")]
public class SandboxWorkerDeploymentTests(PlaywrightFixture fixture)
{
/// <summary>Verifies that the worker runs scripts, bounds their output and recovers after a noncooperative script.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Medium_WorkerRunsBoundsOutputAndRecoversAfterNoncooperativeScript()
{
var page = await fixture.NewAuthenticatedPageAsync();
try
{
async Task<JsonElement> Run(string code) => await page.EvaluateAsync<JsonElement>("""
async code => {
const response = await fetch('/api/script-analysis/run', {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ code, timeoutSeconds: 10 })
});
if (!response.ok) throw new Error(`Test Run HTTP ${response.status}`);
return await response.json();
}
""", code);
var first = await Run("return 42;");
Assert.True(first.GetProperty("success").GetBoolean(), first.ToString());
Assert.Equal("42", first.GetProperty("returnValueJson").GetString());
var bounded = await Run("Console.Write(new string('x', 100000)); return new string('y', 100000);");
Assert.True(bounded.GetProperty("consoleOutput").GetString()!.Length <= 32768 + "\n… (truncated)".Length);
Assert.Contains("truncated", bounded.GetProperty("consoleOutput").GetString());
Assert.True(bounded.GetRawText().Length < 100000);
var timeout = await Run("while (true) { }");
Assert.False(timeout.GetProperty("success").GetBoolean());
Assert.Equal(4, timeout.GetProperty("errorKind").GetInt32());
var recovered = await Run("return 43;");
Assert.True(recovered.GetProperty("success").GetBoolean(), recovered.ToString());
Assert.Equal("43", recovered.GetProperty("returnValueJson").GetString());
}
finally { await page.CloseAsync(); }
}
}