From 7d32565a6672e3a6c15963f1ceede39eaec04225 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Mon, 17 Nov 2025 12:53:47 -0500 Subject: [PATCH 1/2] test(ai): run prompt templates integration tests against prod endpoint The integration tests were originally written to run against staging. Now that this feature is in prod, we should test against the prod endpoint. --- packages/ai/integration/constants.ts | 15 +++++++++++++++ .../ai/integration/prompt-templates.test.ts | 17 ++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/packages/ai/integration/constants.ts b/packages/ai/integration/constants.ts index 3e84f360a03..fea30601090 100644 --- a/packages/ai/integration/constants.ts +++ b/packages/ai/integration/constants.ts @@ -94,6 +94,21 @@ export const liveTestConfigs: readonly TestConfig[] = backends.flatMap( } ); +/** + * Test configurations used for server prompt templates integration tests. + * Server prompt templates don't define the model name from the client, so these test configs + * do not define a model string. + * These tests should only run once per backend, rather than once per backend *per model*. + */ +export const promptTemplatesTestConfigs: readonly TestConfig[] = backends.flatMap(backend => { + const ai = getAI(app, { backend }); + return { + ai, + model: '', // Unused by prompt templates tests + toString: () => formatConfigAsString({ ai, model: '' }) + }; +}); + export const TINY_IMG_BASE64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII='; export const IMAGE_MIME_TYPE = 'image/png'; diff --git a/packages/ai/integration/prompt-templates.test.ts b/packages/ai/integration/prompt-templates.test.ts index 3a7f9038561..e63219e1683 100644 --- a/packages/ai/integration/prompt-templates.test.ts +++ b/packages/ai/integration/prompt-templates.test.ts @@ -21,8 +21,7 @@ import { getTemplateGenerativeModel, getTemplateImagenModel } from '../src'; -import { testConfigs } from './constants'; -import { STAGING_URL } from '../src/constants'; +import { promptTemplatesTestConfigs } from './constants'; const templateBackendSuffix = ( backendType: BackendType @@ -31,13 +30,11 @@ const templateBackendSuffix = ( describe('Prompt templates', function () { this.timeout(20_000); - testConfigs.forEach(testConfig => { - describe(`${testConfig.toString()}`, () => { + promptTemplatesTestConfigs.forEach(testConfig => { + describe(`${promptTemplatesTestConfigs.toString()}`, () => { describe('Generative Model', () => { it('successfully generates content', async () => { - const model = getTemplateGenerativeModel(testConfig.ai, { - baseUrl: STAGING_URL - }); + const model = getTemplateGenerativeModel(testConfig.ai); const { response } = await model.generateContent( `sassy-greeting-${templateBackendSuffix( testConfig.ai.backend.backendType @@ -49,16 +46,14 @@ describe('Prompt templates', function () { }); describe('Imagen model', async () => { it('successfully generates images', async () => { - const model = getTemplateImagenModel(testConfig.ai, { - baseUrl: STAGING_URL - }); + const model = getTemplateImagenModel(testConfig.ai); const { images } = await model.generateImages( `portrait-${templateBackendSuffix( testConfig.ai.backend.backendType )}`, { animal: 'Rhino' } ); - expect(images.length).to.equal(2); // We ask for two images in the prompt template + expect(images.length).to.equal(1); // We ask for two images in the prompt template }); }); }); From 4369b12b1f41a1c73b6f372679365376653f3d73 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Mon, 17 Nov 2025 13:03:16 -0500 Subject: [PATCH 2/2] Fixes --- packages/ai/integration/constants.ts | 17 +++++++++-------- .../ai/integration/prompt-templates.test.ts | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/ai/integration/constants.ts b/packages/ai/integration/constants.ts index fea30601090..c1bf74770c9 100644 --- a/packages/ai/integration/constants.ts +++ b/packages/ai/integration/constants.ts @@ -100,14 +100,15 @@ export const liveTestConfigs: readonly TestConfig[] = backends.flatMap( * do not define a model string. * These tests should only run once per backend, rather than once per backend *per model*. */ -export const promptTemplatesTestConfigs: readonly TestConfig[] = backends.flatMap(backend => { - const ai = getAI(app, { backend }); - return { - ai, - model: '', // Unused by prompt templates tests - toString: () => formatConfigAsString({ ai, model: '' }) - }; -}); +export const promptTemplatesTestConfigs: readonly TestConfig[] = + backends.flatMap(backend => { + const ai = getAI(app, { backend }); + return { + ai, + model: '', // Unused by prompt templates tests + toString: () => formatConfigAsString({ ai, model: '' }).trim() + }; + }); export const TINY_IMG_BASE64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII='; diff --git a/packages/ai/integration/prompt-templates.test.ts b/packages/ai/integration/prompt-templates.test.ts index e63219e1683..a73f17eee27 100644 --- a/packages/ai/integration/prompt-templates.test.ts +++ b/packages/ai/integration/prompt-templates.test.ts @@ -31,7 +31,7 @@ const templateBackendSuffix = ( describe('Prompt templates', function () { this.timeout(20_000); promptTemplatesTestConfigs.forEach(testConfig => { - describe(`${promptTemplatesTestConfigs.toString()}`, () => { + describe(`${testConfig.toString()}`, () => { describe('Generative Model', () => { it('successfully generates content', async () => { const model = getTemplateGenerativeModel(testConfig.ai); @@ -53,7 +53,7 @@ describe('Prompt templates', function () { )}`, { animal: 'Rhino' } ); - expect(images.length).to.equal(1); // We ask for two images in the prompt template + expect(images.length).to.equal(1); // The template is configured to generate one image. }); }); });