Repository navigation
Add E2E test for legacy TypeScript apphost.ts compatibility - #17504
Sébastien Ros (sebastienros) merged 2 commits into
Conversation
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]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17504Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17504" |
There was a problem hiding this comment.
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/.jsimport 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]>
|
❌ CLI E2E Tests failed — 107 passed, 1 failed, 2 unknown (commit Failed Tests
View all recordings
📹 Recordings uploaded automatically from CI run #26463870964 |
|
✅ No documentation update needed. docs_required → already documented by name Triggered signals (1): The signal fired because the PR body mentions Per-signal documentation evidence:
Additionally, |
Description
TypeScript AppHosts scaffolded before 13.4 ship an
apphost.tsthat 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/.jsextensions 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 fullaspire add-> code generation ->aspire startflow actually works for a legacy project.This PR adds
TypeScriptLegacyAppHostTests.AspireAddAndStartWorkAgainstLegacyAppHostTs, a Hex1b-based CLI E2E test intests/Aspire.Cli.EndToEnd.Tests/that bootstraps a real TypeScript AppHost withaspire init --language typescript --non-interactive, then converts it in place to the legacy layout (deletesapphost.mtsand.aspire/modules/, writes anapphost.tsthat imports./.modules/aspire.jsand callsbuilder.addRedis("cache"), pointsaspire.config.json'sappHost.pathatapphost.ts, and updatestsconfig.apphost.json's include set). The test then drives the real CLI through:aspire add Aspire.Hosting.Redis(config persistence viaWaitForAspireAddSuccessAsyncso a version-picker prompt does not flake the test).aspire restore(triggersBuildAndGenerateSdkAsyncwithappHostFile: null, hitting the disk-scan branch of legacy detection). Asserts.modules/aspire.ts/base.ts/transport.tswere created,.aspire/modules/was NOT created, no.mjsspecifiers remain, no.mtsfiles leaked into.modules/, andaddRedisappears in the generatedaspire.ts.npx tsc --noEmit -p tsconfig.apphost.jsonto prove the rewritten.jsimport specifiers actually resolve.aspire start+aspire describe cache+aspire stop, which exercisesRunAsyncwith an explicitapphost.tsFileInfo(the file-name branch of legacy detection) and confirms the legacy apphost is actually invoked at runtime and thataddRedismaterializes as a container resource.The test follows the established patterns in
TypeScriptCodegenValidationTests(init -> add -> restore -> assert) andTypeScriptStarterSmokeTests(start -> describe -> stop), uses theDotNetDocker variant withmountDockerSocket: 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
<remarks />and<code />elements on your triple slash comments?