Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/skills/cli-e2e-testing/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,8 @@ public sealed class SmokeTests : IAsyncDisposable
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(nameof(MyCliTest));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down Expand Up @@ -275,7 +269,6 @@ Use `CliE2ETestHelpers` for CI environment variables:
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber(); // GITHUB_PR_NUMBER (0 when local)
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha(); // GITHUB_PR_HEAD_SHA ("local0000" when local)
var isCI = CliE2ETestHelpers.IsRunningInCI; // true when both env vars set
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath("test-name"); // Appropriate path for CI vs local
```

## DON'T: Use Hard-coded Delays
Expand Down
34 changes: 3 additions & 31 deletions tests/Aspire.Cli.EndToEnd.Tests/AgentCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Aspire.Cli.EndToEnd.Tests.Helpers;
using Aspire.Cli.Tests.Utils;
using Hex1b;
using Hex1b.Automation;
using Xunit;

Expand Down Expand Up @@ -31,16 +30,7 @@ public async Task AgentCommands_AllHelpOutputs_AreCorrect()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(
nameof(AgentCommands_AllHelpOutputs_AreCorrect));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down Expand Up @@ -136,16 +126,7 @@ public async Task AgentInitCommand_MigratesDeprecatedConfig()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(
nameof(AgentInitCommand_MigratesDeprecatedConfig));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down Expand Up @@ -255,16 +236,7 @@ public async Task DoctorCommand_DetectsDeprecatedAgentConfig()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(
nameof(DoctorCommand_DetectsDeprecatedAgentConfig));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down
26 changes: 3 additions & 23 deletions tests/Aspire.Cli.EndToEnd.Tests/BannerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Aspire.Cli.EndToEnd.Tests.Helpers;
using Aspire.Cli.Tests.Utils;
using Hex1b;
using Hex1b.Automation;
using Xunit;

Expand All @@ -23,15 +22,8 @@ public async Task Banner_DisplayedOnFirstRun()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(nameof(Banner_DisplayedOnFirstRun));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down Expand Up @@ -94,14 +86,8 @@ public async Task Banner_DisplayedWithExplicitFlag()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(nameof(Banner_DisplayedWithExplicitFlag));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down Expand Up @@ -160,14 +146,8 @@ public async Task Banner_NotDisplayedWithNoLogoFlag()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(nameof(Banner_NotDisplayedWithNoLogoFlag));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down
21 changes: 2 additions & 19 deletions tests/Aspire.Cli.EndToEnd.Tests/DockerDeploymentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Aspire.Cli.EndToEnd.Tests.Helpers;
using Aspire.Cli.Tests.Utils;
using Hex1b;
using Hex1b.Automation;
using Xunit;

Expand All @@ -26,15 +25,7 @@ public async Task CreateAndDeployToDockerCompose()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(nameof(CreateAndDeployToDockerCompose));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down Expand Up @@ -203,15 +194,7 @@ public async Task CreateAndDeployToDockerComposeInteractive()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(nameof(CreateAndDeployToDockerComposeInteractive));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down
23 changes: 2 additions & 21 deletions tests/Aspire.Cli.EndToEnd.Tests/DoctorCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Aspire.Cli.EndToEnd.Tests.Helpers;
using Aspire.Cli.Tests.Utils;
using Hex1b;
using Hex1b.Automation;
using Xunit;

Expand All @@ -23,16 +22,7 @@ public async Task DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(
nameof(DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down Expand Up @@ -87,16 +77,7 @@ public async Task DoctorCommand_WithSslCertDir_ShowsTrusted()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(
nameof(DoctorCommand_WithSslCertDir_ShowsTrusted));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down
11 changes: 1 addition & 10 deletions tests/Aspire.Cli.EndToEnd.Tests/EmptyAppHostTemplateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Aspire.Cli.EndToEnd.Tests.Helpers;
using Aspire.Cli.Tests.Utils;
using Hex1b;
using Hex1b.Automation;
using Xunit;

Expand All @@ -23,15 +22,7 @@ public async Task CreateEmptyAppHostProject()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(nameof(CreateEmptyAppHostProject));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down
23 changes: 23 additions & 0 deletions tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.

#pragma warning disable IDE0005 // Incorrectly flagged as unused due to types spread across namespaces
using System.Runtime.CompilerServices;
using Aspire.Cli.Tests.Utils;
using Hex1b;
using Hex1b.Automation;
#pragma warning restore IDE0005
using Xunit;
Expand Down Expand Up @@ -87,6 +89,27 @@ internal static string GetTestResultsRecordingPath(string testName)
return Path.Combine(recordingsDir, $"{testName}.cast");
}

/// <summary>
/// Creates a headless Hex1b terminal configured for E2E testing with asciinema recording.
/// Uses default dimensions of 160x48 unless overridden.
/// </summary>
/// <param name="testName">The test name used for the recording file path. Defaults to the calling method name.</param>
/// <param name="width">The terminal width in columns. Defaults to 160.</param>
/// <param name="height">The terminal height in rows. Defaults to 48.</param>
Comment on lines +96 to +98
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter documentation order doesn't match the actual parameter order in the method signature. The documentation lists parameters as: testName, width, height, but the actual signature has: width, height, testName. While the code will work correctly, this inconsistency could confuse developers reading the documentation. Consider reordering the param tags to match the actual signature order.

Suggested change
/// <param name="testName">The test name used for the recording file path. Defaults to the calling method name.</param>
/// <param name="width">The terminal width in columns. Defaults to 160.</param>
/// <param name="height">The terminal height in rows. Defaults to 48.</param>
/// <param name="width">The terminal width in columns. Defaults to 160.</param>
/// <param name="height">The terminal height in rows. Defaults to 48.</param>
/// <param name="testName">The test name used for the recording file path. Defaults to the calling method name.</param>

Copilot uses AI. Check for mistakes.
/// <returns>A configured <see cref="Hex1bTerminal"/> instance. Caller is responsible for disposal.</returns>
internal static Hex1bTerminal CreateTestTerminal(int width = 160, int height = 48, [CallerMemberName] string testName = "")
{
var recordingPath = GetTestResultsRecordingPath(testName);

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(width, height)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

return builder.Build();
}

internal static Hex1bTerminalInputSequenceBuilder PrepareEnvironment(
this Hex1bTerminalInputSequenceBuilder builder, TemporaryWorkspace workspace, SequenceCounter counter)
{
Expand Down
11 changes: 1 addition & 10 deletions tests/Aspire.Cli.EndToEnd.Tests/JsReactTemplateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Aspire.Cli.EndToEnd.Tests.Helpers;
using Aspire.Cli.Tests.Utils;
using Hex1b;
using Hex1b.Automation;
using Xunit;

Expand All @@ -23,15 +22,7 @@ public async Task CreateAndRunJsReactProject()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(nameof(CreateAndRunJsReactProject));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down
10 changes: 1 addition & 9 deletions tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Aspire.Cli.EndToEnd.Tests.Helpers;
using Aspire.Cli.Tests.Utils;
using Hex1b;
using Hex1b.Automation;
using Xunit;

Expand Down Expand Up @@ -34,20 +33,13 @@ public async Task CreateAndPublishToKubernetes()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(nameof(CreateAndPublishToKubernetes));
var clusterName = GenerateUniqueClusterName();

output.WriteLine($"Using KinD version: {KindVersion}");
output.WriteLine($"Using Helm version: {HelmVersion}");
output.WriteLine($"Using cluster name: {clusterName}");

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down
11 changes: 1 addition & 10 deletions tests/Aspire.Cli.EndToEnd.Tests/LogsCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Aspire.Cli.EndToEnd.Tests.Helpers;
using Aspire.Cli.Tests.Utils;
using Hex1b;
using Hex1b.Automation;
using Xunit;

Expand All @@ -23,15 +22,7 @@ public async Task LogsCommandShowsResourceLogs()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(nameof(LogsCommandShowsResourceLogs));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down
11 changes: 1 addition & 10 deletions tests/Aspire.Cli.EndToEnd.Tests/PsCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Aspire.Cli.EndToEnd.Tests.Helpers;
using Aspire.Cli.Tests.Utils;
using Hex1b;
using Hex1b.Automation;
using Xunit;

Expand All @@ -23,15 +22,7 @@ public async Task PsCommandListsRunningAppHost()
var prNumber = CliE2ETestHelpers.GetRequiredPrNumber();
var commitSha = CliE2ETestHelpers.GetRequiredCommitSha();
var isCI = CliE2ETestHelpers.IsRunningInCI;
var recordingPath = CliE2ETestHelpers.GetTestResultsRecordingPath(nameof(PsCommandListsRunningAppHost));

var builder = Hex1bTerminal.CreateBuilder()
.WithHeadless()
.WithDimensions(160, 48)
.WithAsciinemaRecording(recordingPath)
.WithPtyProcess("/bin/bash", ["--norc"]);

using var terminal = builder.Build();
using var terminal = CliE2ETestHelpers.CreateTestTerminal();

var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

Expand Down
Loading