Skip to content

Add E2E test for legacy TypeScript apphost.ts compatibility - #17504

Merged
Sébastien Ros (sebastienros) merged 2 commits into
mainfrom
sebastienros/sebros-typescript-legacy-apphost-e2e
May 26, 2026
Merged

Sébastien Ros (sebastienros) merged 2 commits into
mainfrom
sebastienros/sebros-typescript-legacy-apphost-e2e

Conversation

@sebastienros

Copy link
Copy Markdown
Contributor

Description

TypeScript AppHosts scaffolded before 13.4 ship an apphost.ts that imports the generated SDK from ./.modules/aspire.js. The CLI has a compatibility path (GuestAppHostProject.ShouldEmitLegacyTypeScriptGeneratedFiles + ConvertGeneratedFilesForLegacyTypeScriptAppHost) that routes generated SDK files to ./.modules/ with .ts/.js extensions instead of the modern ./.aspire/modules/ with .mts/.mjs, so existing imports keep resolving. Until now this path was only exercised by a single conversion-level unit test — there was no end-to-end coverage that the full aspire add -> code generation -> aspire start flow actually works for a legacy project.

This PR adds TypeScriptLegacyAppHostTests.AspireAddAndStartWorkAgainstLegacyAppHostTs, a Hex1b-based CLI E2E test in tests/Aspire.Cli.EndToEnd.Tests/ that bootstraps a real TypeScript AppHost with aspire init --language typescript --non-interactive, then converts it in place to the legacy layout (deletes apphost.mts and .aspire/modules/, writes an apphost.ts that imports ./.modules/aspire.js and calls builder.addRedis("cache"), points aspire.config.json's appHost.path at apphost.ts, and updates tsconfig.apphost.json's include set). The test then drives the real CLI through:

  • aspire add Aspire.Hosting.Redis (config persistence via WaitForAspireAddSuccessAsync so a version-picker prompt does not flake the test).
  • aspire restore (triggers BuildAndGenerateSdkAsync with appHostFile: null, hitting the disk-scan branch of legacy detection). Asserts .modules/aspire.ts/base.ts/transport.ts were created, .aspire/modules/ was NOT created, no .mjs specifiers remain, no .mts files leaked into .modules/, and addRedis appears in the generated aspire.ts.
  • npx tsc --noEmit -p tsconfig.apphost.json to prove the rewritten .js import specifiers actually resolve.
  • aspire start + aspire describe cache + aspire stop, which exercises RunAsync with an explicit apphost.ts FileInfo (the file-name branch of legacy detection) and confirms the legacy apphost is actually invoked at runtime and that addRedis materializes as a container resource.

The test follows the established patterns in TypeScriptCodegenValidationTests (init -> add -> restore -> assert) and TypeScriptStarterSmokeTests (start -> describe -> stop), uses the DotNet Docker variant with mountDockerSocket: true (needed for the Redis container), and is annotated [CaptureWorkspaceOnFailure] so the full generated project (including .modules/ and _aspire-start.json) is captured on failure for debugging.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Adds a CLI end-to-end test that validates the legacy compatibility path
for TypeScript AppHosts created before the move to apphost.mts. Such
projects import the generated SDK from ./.modules/aspire.js, and the CLI
must continue to route generated SDK files to ./.modules/ (with .ts/.js
extensions) instead of ./.aspire/modules/ (.mts/.mjs) so that existing
imports keep resolving.

The test bootstraps a modern AppHost via aspire init, converts it in
place to the legacy layout (deletes apphost.mts and .aspire/modules,
writes an apphost.ts that imports ./.modules/aspire.js, updates
aspire.config.json and tsconfig.apphost.json), then exercises:
- aspire add Aspire.Hosting.Redis (config persistence)
- aspire restore (legacy code generation, .modules/ layout, .js imports,
  addRedis surfaced in the generated aspire.ts)
- npx tsc --noEmit (rewritten .js specifiers resolve)
- aspire start + describe + stop (apphost.ts is actually invoked and
  addRedis materializes as a real container resource)

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings May 26, 2026 16:49
@github-actions

github-actions Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

🚀 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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17504

Or

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an end-to-end CLI E2E test to validate the legacy TypeScript AppHost compatibility path (pre-13.4 apphost.ts importing ./.modules/aspire.js) across the real aspire add → codegen/restore → tsc validation → aspire start/describe/stop flow.

Changes:

  • Introduces a new Hex1b-based E2E test that scaffolds a TypeScript AppHost, mutates it into the legacy layout, and verifies the CLI generates SDK output into ./.modules/ with legacy .ts/.js import semantics.
  • Validates the generated output structure/content and confirms runtime behavior by starting the apphost and asserting the Redis resource is materialized.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

❌ CLI E2E Tests failed — 107 passed, 1 failed, 2 unknown (commit 9279343)

Failed Tests

View all recordings
Status Test Recording
✅ AddPackageInteractiveWhileAppHostRunningDetached ✅ ▶️ View recording
✅ AddPackageWhileAppHostRunningDetached ✅ ▶️ View recording
✅ AgentCommands_AllHelpOutputs_AreCorrect ✅ ▶️ View recording
✅ AgentInitCommand_DefaultSelection_InstallsDefaultSkills ✅ ▶️ View recording
✅ AgentInitCommand_MigratesDeprecatedConfig ✅ ▶️ View recording
✅ AgentMcpListStructuredLogsReturnsLogsFromStarterApp ✅ ▶️ View recording
✅ AgentMcpListStructuredLogsReturnsLogsFromStarterApp_DevLocalhost ✅ ▶️ View recording
✅ AgentMcpListStructuredLogsReturnsLogsFromStarterApp_Isolated ✅ ▶️ View recording
✅ AllPublishMethodsBuildDockerImages ✅ ▶️ View recording
✅ AspireAddAndStartWorkAgainstLegacyAppHostTs ✅ ▶️ View recording
✅ AspireAddPackageVersionToDirectoryPackagesProps ✅ ▶️ View recording
✅ AspireInitSingleFileAppHostRunsViaDotnetRunAppHost ✅ ▶️ View recording
✅ AspireInitWithExistingAppHostDirRecreatesMissingNuGetConfigAndPreservesFiles ✅ ▶️ View recording
❔ AspireInitWithSolutionFileGeneratesAppHostThatBuildsAgainstChannelHive ❔ ▶️ View recording
✅ AspireStartUpdatesStaleTypeScriptAppHostPath ✅ ▶️ View recording
✅ AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ✅ ▶️ View recording
✅ AspireUpdateRemovesOrphanAppHostPackageVersionWhenSdkAlreadyCurrent ✅ ▶️ View recording
✅ Banner_DisplayedOnFirstRun ✅ ▶️ View recording
✅ Banner_DisplayedWithExplicitFlag ✅ ▶️ View recording
✅ Banner_NotDisplayedWithNoLogoFlag ✅ ▶️ View recording
✅ CertificatesClean_RemovesCertificates ✅ ▶️ View recording
✅ CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ✅ ▶️ View recording
✅ CertificatesTrust_WithUntrustedCert_TrustsCertificate ✅ ▶️ View recording
✅ ConfigSetGet_CreatesNestedJsonFormat ✅ ▶️ View recording
✅ CreateAndRunAspireStarterProject ✅ ▶️ View recording
✅ CreateAndRunAspireStarterProjectWithBundle ✅ ▶️ View recording
✅ CreateAndRunEmptyAppHostProject ✅ ▶️ View recording
✅ CreateAndRunJavaEmptyAppHostProject ✅ ▶️ View recording
✅ CreateAndRunJsReactProject ✅ ▶️ View recording
✅ CreateAndRunPythonReactProject ✅ ▶️ View recording
✅ CreateAndRunTypeScriptEmptyAppHostProject ✅ ▶️ View recording
✅ CreateAndRunTypeScriptStarterProject ✅ ▶️ View recording
✅ CreateJavaAppHostWithViteApp ✅ ▶️ View recording
✅ CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ✅ ▶️ View recording
✅ DashboardRunWithAgentMcpListTracesReturnsNoTraces ✅ ▶️ View recording
✅ DashboardRunWithAgentMcpListTracesReturnsNoTraces_DevLocalhost ✅ ▶️ View recording
✅ DashboardRunWithOtelTracesReturnsNoTraces ✅ ▶️ View recording
✅ DashboardRunWithOtelTracesReturnsNoTraces_DevLocalhost ✅ ▶️ View recording
✅ DeployK8sBasicApiService ✅ ▶️ View recording
✅ DeployK8sWithExternalHelmChart ✅ ▶️ View recording
✅ DeployK8sWithGarnet ✅ ▶️ View recording
✅ DeployK8sWithMongoDB ✅ ▶️ View recording
✅ DeployK8sWithMySql ✅ ▶️ View recording
✅ DeployK8sWithPostgres ✅ ▶️ View recording
✅ DeployK8sWithRabbitMQ ✅ ▶️ View recording
✅ DeployK8sWithRedis ✅ ▶️ View recording
✅ DeployK8sWithSqlServer ✅ ▶️ View recording
✅ DeployK8sWithValkey ✅ ▶️ View recording
✅ DeployTypeScriptAppToKubernetes ✅ ▶️ View recording
✅ DescribeCommandResolvesReplicaNames ✅ ▶️ View recording
✅ DescribeCommandShowsRunningResources ✅ ▶️ View recording
✅ DetachFormatJsonProducesValidJson ✅ ▶️ View recording
✅ DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ✅ ▶️ View recording
✅ DoListStepsShowsPipelineSteps ✅ ▶️ View recording
✅ DocsCommand_RendersInteractiveMarkdownFromLocalSource ✅ ▶️ View recording
✅ DoctorCommand_DetectsDeprecatedAgentConfig ✅ ▶️ View recording
✅ DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ✅ ▶️ View recording
✅ DoctorCommand_WithSslCertDir_ShowsTrusted ✅ ▶️ View recording
✅ DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ✅ ▶️ View recording
✅ GatewayWithoutExternalEndpoint_FailsPublishWithGuidance ✅ ▶️ View recording
✅ GeneratedAspireDevScript_StartsWatchMode_WithConfiguredToolchain ✅ ▶️ View recording
✅ GlobalMigration_HandlesCommentsAndTrailingCommas ✅ ▶️ View recording
✅ GlobalMigration_HandlesMalformedLegacyJson ✅ ▶️ View recording
✅ GlobalMigration_PreservesAllValueTypes ✅ ▶️ View recording
✅ GlobalMigration_SkipsWhenNewConfigExists ✅ ▶️ View recording
✅ GlobalSettings_MigratedFromLegacyFormat ✅ ▶️ View recording
✅ IngressWithoutExternalEndpoint_FailsPublishWithGuidance ✅ ▶️ View recording
✅ InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ✅ ▶️ View recording
✅ InteractiveCSharpInitCreatesExpectedFiles ✅ ▶️ View recording
✅ InvalidAppHostPathWithComments_IsHealedOnRun ✅ ▶️ View recording
✅ JavaScriptHostingApisRunFromTypeScriptAppHost ✅ ▶️ View recording
❌ LatestCliCanStartStableChannelAppHost ❌ ▶️ View failure recording
✅ LatestCliCanStartStableChannelTypeScriptAppHost ✅ ▶️ View recording
✅ LegacySettingsMigration_AdjustsRelativeAppHostPath ✅ ▶️ View recording
✅ LogLevelTrace_ProducesTraceEntriesInCliLogFile ✅ ▶️ View recording
✅ LogsCommandShowsResourceLogs ✅ ▶️ View recording
✅ OtelLogsReturnsStructuredLogsFromStarterApp ✅ ▶️ View recording
✅ OtelLogsReturnsStructuredLogsFromStarterAppIsolated ✅ ▶️ View recording
✅ PsCommandListsRunningAppHost ✅ ▶️ View recording
✅ PsFormatJsonOutputsOnlyJsonToStdout ✅ ▶️ View recording
✅ PublishJavaScriptPatternsGeneratesExpectedDockerComposeArtifacts ✅ ▶️ View recording
✅ PublishWithConfigureEnvFileUpdatesEnvOutput ✅ ▶️ View recording
✅ PublishWithDockerComposeServiceCallbackSucceeds ✅ ▶️ View recording
✅ PublishWithoutOutputPathUsesAppHostDirectoryDefault ✅ ▶️ View recording
✅ ResourceCommand_FailedExecution_DisplaysAppHostLogPathAndLogContainsEntries ✅ ▶️ View recording
✅ ResourceCommand_FailsWhenInteractionServiceIsRequired ✅ ▶️ View recording
✅ ResourceCommand_SetAndDeleteParameterUpdatesDescribeOutput ✅ ▶️ View recording
✅ RestoreGeneratesSdkFiles ✅ ▶️ View recording
✅ RestoreGeneratesSdkFiles_WithConfiguredToolchain ✅ ▶️ View recording
✅ RestoreRefreshesGeneratedSdkAfterAddingIntegration ✅ ▶️ View recording
✅ RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ✅ ▶️ View recording
✅ RunFromParentDirectory_UsesExistingConfigNearAppHost ✅ ▶️ View recording
✅ RunReportsSyntaxErrorsForDotNetAppHost ✅ ▶️ View recording
✅ RunReportsSyntaxErrorsForTypeScriptAppHost ✅ ▶️ View recording
✅ SecretCrudOnDotNetAppHost ✅ ▶️ View recording
✅ SecretCrudOnTypeScriptAppHost ✅ ▶️ View recording
✅ StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ✅ ▶️ View recording
✅ StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ✅ ▶️ View recording
✅ StartReportsSyntaxErrorsForDotNetAppHost ✅ ▶️ View recording
✅ StartReportsSyntaxErrorsForTypeScriptAppHost ✅ ▶️ View recording
✅ StopAllAppHostsFromAppHostDirectory ✅ ▶️ View recording
✅ StopJavaPolyglotAppHostUsingApphostDirectory ✅ ▶️ View recording
✅ StopNonInteractiveSingleAppHost ✅ ▶️ View recording
✅ StopTypeScriptPolyglotAppHostUsingApphostDirectory ✅ ▶️ View recording
✅ StopWithNoRunningAppHostExitsSuccessfully ✅ ▶️ View recording
✅ UnAwaitedChainsCompileWithAutoResolvePromises ✅ ▶️ View recording
❔ UpdateProjectChannelToStable_CSharpEmptyAppHost_PreservesAspireConfigChannel ❔ ▶️ View recording
✅ UpdateProjectChannelToStable_CSharpSingleFileInit_PreservesAspireConfigChannel ✅ ▶️ View recording
✅ UpdateProjectChannelToStable_TypeScriptSingleFileInit_PreservesAspireConfigChannel ✅ ▶️ View recording
✅ UpdateProjectChannelToStable_TypeScript_PreviewsStablePackagesAndPreservesChannel ✅ ▶️ View recording

📹 Recordings uploaded automatically from CI run #26463870964

@sebastienros Sébastien Ros (sebastienros) added this to the 13.4 milestone May 26, 2026
@sebastienros
Sébastien Ros (sebastienros) merged commit 02c33b0 into main May 26, 2026
618 of 621 checks passed
@sebastienros
Sébastien Ros (sebastienros) deleted the sebastienros/sebros-typescript-legacy-apphost-e2e branch May 26, 2026 23:01
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

docs_required → already documented by name

Triggered signals (1): pr_body_has_cli_flag_mention

The signal fired because the PR body mentions aspire init --language typescript --non-interactive — but these are existing CLI flags used only to describe the test setup, not new surface.

Per-signal documentation evidence:

  • --language: documented in src/frontend/src/content/docs/reference/cli/commands/aspire-init.mdx line 65: - **\--language`**` with a TypeScript example at line 93.
  • --non-interactive: documented via include at src/frontend/src/content/docs/reference/cli/commands/aspire-init.mdx line 73: <Include relativePath="reference/cli/includes/option-non-interactive.md" />.

Additionally, only_test_or_build_changes is true — the sole changed file is an E2E test under tests/Aspire.Cli.EndToEnd.Tests/. No new public types, CLI flags, commands, options, or user-facing behavior were introduced. No documentation update is needed.

@github-actions github-actions Bot locked and limited conversation to collaborators Jun 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants