Skip to content

Commit c2913dd

Browse files
committed
Keep CLI preflight and manifest checks covered by real command paths
The earlier DX work added manifest-based bridge consistency and `--preflight-only`, but the highest-value tests still needed to assert the user-visible command behavior and manifest payload. This follow-up hardens the suite by checking the generated manifest fields and ensuring `dev`/`package` surface consistency warnings through the actual CLI path. Constraint: Must leave `.omx/` session state untracked and out of the repo history Constraint: Must keep verification serial because local native build steps can fail under concurrent test runs Rejected: Rely on helper-only assertions | would miss regressions in CLI output shape and end-to-end artifact emission Rejected: Re-run CLI through `dotnet run --project` in tests | nested builds were less stable than executing the built tool dll directly Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep end-to-end CLI tests focused on user-visible guarantees (artifacts written, manifest fields, preflight messaging) rather than internal implementation details Tested: `dotnet test tests/Agibuild.Fulora.UnitTests/Agibuild.Fulora.UnitTests.csproj -v minimal` (2177 passed) Not-tested: GitHub Actions behavior after this follow-up commit until remote CI finishes Related: 42a61cc
1 parent 42a61cc commit c2913dd

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/Agibuild.Fulora.UnitTests/CliToolTests.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics;
22
using System.Reflection;
3+
using System.Text.Json;
34
using Agibuild.Fulora.Cli.Commands;
45
using Xunit;
56

@@ -318,7 +319,15 @@ public async Task Generate_types_command_writes_artifacts_and_manifest_end_to_en
318319
Assert.True(File.Exists(Path.Combine(workspace.OutputDirectory, "bridge.d.ts")));
319320
Assert.True(File.Exists(Path.Combine(workspace.OutputDirectory, "bridge.client.ts")));
320321
Assert.True(File.Exists(Path.Combine(workspace.OutputDirectory, "bridge.mock.ts")));
321-
Assert.True(File.Exists(Path.Combine(workspace.OutputDirectory, "bridge.manifest.json")));
322+
var manifestPath = Path.Combine(workspace.OutputDirectory, "bridge.manifest.json");
323+
Assert.True(File.Exists(manifestPath));
324+
325+
using var manifestDoc = JsonDocument.Parse(File.ReadAllText(manifestPath));
326+
var root = manifestDoc.RootElement;
327+
Assert.Equal(1, root.GetProperty("SchemaVersion").GetInt32());
328+
Assert.Equal(Path.GetFileName(workspace.BridgeProjectPath), root.GetProperty("BridgeProjectFileName").GetString());
329+
Assert.Equal("net10.0", root.GetProperty("TargetFramework").GetString());
330+
Assert.True(root.GetProperty("Artifacts").TryGetProperty("bridge.client.ts", out _));
322331
}
323332
finally
324333
{
@@ -429,6 +438,8 @@ public async Task Dev_command_preflight_only_runs_checks_and_exits_without_start
429438
var workspace = CreateScaffoldWorkspace(tempDir, "SampleApp");
430439
MakeBridgeProjectBuildable(workspace.BridgeProjectPath);
431440
var webDir = Path.GetDirectoryName(workspace.WebSrcPath)!;
441+
var generatedDir = Path.Combine(webDir, "src", "bridge", "generated");
442+
Directory.CreateDirectory(generatedDir);
432443

433444
var (stdout, stderr, exitCode) = await RunCliAsync(
434445
$"dev --preflight-only --web \"{webDir}\" --desktop \"{workspace.DesktopProjectPath}\"",
@@ -438,6 +449,7 @@ public async Task Dev_command_preflight_only_runs_checks_and_exits_without_start
438449
Assert.Equal(string.Empty, stderr);
439450
Assert.Contains("Refreshing bridge artifacts", stdout, StringComparison.Ordinal);
440451
Assert.Contains("Preflight complete.", stdout, StringComparison.Ordinal);
452+
Assert.Contains("Bridge consistency:", stdout, StringComparison.Ordinal);
441453
Assert.DoesNotContain("Starting dev server", stdout, StringComparison.Ordinal);
442454
}
443455
finally
@@ -790,6 +802,10 @@ public async Task Package_command_preflight_only_runs_checks_and_exits_without_p
790802
try
791803
{
792804
var workspace = CreateScaffoldWorkspace(tempDir, "SampleApp");
805+
MakeBridgeProjectBuildable(workspace.BridgeProjectPath);
806+
var webDir = Path.GetDirectoryName(workspace.WebSrcPath)!;
807+
var generatedDir = Path.Combine(webDir, "src", "bridge", "generated");
808+
Directory.CreateDirectory(generatedDir);
793809

794810
var (stdout, stderr, exitCode) = await RunCliAsync(
795811
$"package --project \"{workspace.DesktopProjectPath}\" --profile desktop-public --preflight-only",
@@ -798,6 +814,7 @@ public async Task Package_command_preflight_only_runs_checks_and_exits_without_p
798814
Assert.Equal(0, exitCode);
799815
Assert.Equal(string.Empty, stderr);
800816
Assert.Contains("Preflight:", stdout, StringComparison.Ordinal);
817+
Assert.Contains("Bridge consistency:", stdout, StringComparison.Ordinal);
801818
Assert.Contains("Preflight complete.", stdout, StringComparison.Ordinal);
802819
Assert.DoesNotContain("Running: dotnet publish", stdout, StringComparison.Ordinal);
803820
}

0 commit comments

Comments
 (0)