Skip to content

Centralize some E2E test code#14369

Open
JamesNK wants to merge 2 commits intomainfrom
jamesnk/cli-e2e-refactor
Open

Centralize some E2E test code#14369
JamesNK wants to merge 2 commits intomainfrom
jamesnk/cli-e2e-refactor

Conversation

@JamesNK
Copy link
Member

@JamesNK JamesNK commented Feb 6, 2026

Centralize creating test terminal.

Background: I had a test failing because the test terminal hadn't been updated with a larger size. This method centralizes it.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14369

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14369"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR centralizes E2E test terminal creation by introducing a helper method CreateTestTerminal() in CliE2ETestHelpers, eliminating duplicated Hex1b terminal setup code across 17 test methods in 13 test files. The helper uses [CallerMemberName] to automatically derive the test name for asciinema recording filenames, maintaining the existing recording behavior while reducing code duplication.

Changes:

  • Added CreateTestTerminal() helper method in CliE2ETestHelpers with configurable dimensions (default 160x48) and automatic test name capture via [CallerMemberName]
  • Updated 17 test methods across 13 test files to use the centralized helper instead of inline terminal builder code
  • Removed now-unnecessary using Hex1b; imports from test files (only using Hex1b.Automation; remains where needed)

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2ETestHelpers.cs Added CreateTestTerminal() helper method with CallerMemberName attribute for automatic test name capture
tests/Aspire.Cli.EndToEnd.Tests/AgentCommandTests.cs Replaced 3 instances of inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/BannerTests.cs Replaced 3 instances of inline terminal creation with centralized helper, removed unused import, standardized dimensions to 160x48
tests/Aspire.Cli.EndToEnd.Tests/DockerDeploymentTests.cs Replaced 2 instances of inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/DoctorCommandTests.cs Replaced 2 instances of inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/EmptyAppHostTemplateTests.cs Replaced inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/JsReactTemplateTests.cs Replaced inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishTests.cs Replaced inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/LogsCommandTests.cs Replaced inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/PsCommandTests.cs Replaced inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/PythonReactTemplateTests.cs Replaced inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/ResourcesCommandTests.cs Replaced inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/SmokeTests.cs Replaced inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/StartStopTests.cs Replaced inline terminal creation with centralized helper, removed unused import
tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPolyglotTests.cs Replaced inline terminal creation with centralized helper, removed unused import

Comment on lines +96 to +98
/// <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>
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.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit 9cce7f5:

Test Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
ResourcesCommandShowsRunningResources ▶️ View Recording

📹 Recordings uploaded automatically from CI run #21775607240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant