From 013946fb68231cbd407e4efa1f61890a2f7dca2b Mon Sep 17 00:00:00 2001 From: Amaad Martin Date: Sun, 2 Aug 2026 20:38:04 -0700 Subject: [PATCH] Test: fail webui_test fast when the repo has not been built The suite serves built output over HTTP: the CLI variant spawns dev/dist/esm/cli_entrypoint.js and the in-process variant mounts dev/dist/browser as the /dev-ui static root. On a partially built tree the failures describe the symptom, not the cause - 'expected 404 to be 200' when the adk-web bundle is absent, 'CLI exited prematurely with code 1' when the entrypoint is. Check both artifacts in an outer beforeAll and throw once, naming the missing paths and the build command. --- tests/integration/adk_web/webui_test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/integration/adk_web/webui_test.ts b/tests/integration/adk_web/webui_test.ts index 207c5620a..bf2ffd872 100644 --- a/tests/integration/adk_web/webui_test.ts +++ b/tests/integration/adk_web/webui_test.ts @@ -5,6 +5,7 @@ */ import {AdkApiServer} from '@google/adk-devtools'; +import * as fs from 'node:fs'; import * as http from 'node:http'; import * as path from 'node:path'; import {fileURLToPath} from 'node:url'; @@ -28,7 +29,30 @@ const SERVER_START_TIMEOUT = 20000; */ const SERVER_STOP_TIMEOUT = 10000; +/** + * Built artifacts this suite serves over HTTP: the CLI entrypoint spawned by + * `AdkTsApiServer`, and the adk-web bundle `AdkApiServer` mounts at `/dev-ui`. + * `dist/browser` is a downloaded release asset rather than a compile output, + * so it can be missing from an otherwise-built tree. + */ +const REQUIRED_BUILD_ARTIFACTS = [ + path.resolve(__dirname, '../../../dev/dist/esm/cli_entrypoint.js'), + path.resolve(__dirname, '../../../dev/dist/browser/index.html'), +]; + +function assertRepoIsBuilt(): void { + const missing = REQUIRED_BUILD_ARTIFACTS.filter((p) => !fs.existsSync(p)); + if (missing.length > 0) { + throw new Error( + 'webui_test.ts exercises built output; run `npm run build` first. ' + + `Missing: ${missing.join(', ')}`, + ); + } +} + describe('WebUI Integration Test', () => { + beforeAll(assertRepoIsBuilt); + describe.each([ { name: 'Run from ADK CLI',