Skip to content

Commit 7d32565

Browse files
committed
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.
1 parent 578686b commit 7d32565

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

packages/ai/integration/constants.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,21 @@ export const liveTestConfigs: readonly TestConfig[] = backends.flatMap(
9494
}
9595
);
9696

97+
/**
98+
* Test configurations used for server prompt templates integration tests.
99+
* Server prompt templates don't define the model name from the client, so these test configs
100+
* do not define a model string.
101+
* These tests should only run once per backend, rather than once per backend *per model*.
102+
*/
103+
export const promptTemplatesTestConfigs: readonly TestConfig[] = backends.flatMap(backend => {
104+
const ai = getAI(app, { backend });
105+
return {
106+
ai,
107+
model: '', // Unused by prompt templates tests
108+
toString: () => formatConfigAsString({ ai, model: '' })
109+
};
110+
});
111+
97112
export const TINY_IMG_BASE64 =
98113
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=';
99114
export const IMAGE_MIME_TYPE = 'image/png';

packages/ai/integration/prompt-templates.test.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import {
2121
getTemplateGenerativeModel,
2222
getTemplateImagenModel
2323
} from '../src';
24-
import { testConfigs } from './constants';
25-
import { STAGING_URL } from '../src/constants';
24+
import { promptTemplatesTestConfigs } from './constants';
2625

2726
const templateBackendSuffix = (
2827
backendType: BackendType
@@ -31,13 +30,11 @@ const templateBackendSuffix = (
3130

3231
describe('Prompt templates', function () {
3332
this.timeout(20_000);
34-
testConfigs.forEach(testConfig => {
35-
describe(`${testConfig.toString()}`, () => {
33+
promptTemplatesTestConfigs.forEach(testConfig => {
34+
describe(`${promptTemplatesTestConfigs.toString()}`, () => {
3635
describe('Generative Model', () => {
3736
it('successfully generates content', async () => {
38-
const model = getTemplateGenerativeModel(testConfig.ai, {
39-
baseUrl: STAGING_URL
40-
});
37+
const model = getTemplateGenerativeModel(testConfig.ai);
4138
const { response } = await model.generateContent(
4239
`sassy-greeting-${templateBackendSuffix(
4340
testConfig.ai.backend.backendType
@@ -49,16 +46,14 @@ describe('Prompt templates', function () {
4946
});
5047
describe('Imagen model', async () => {
5148
it('successfully generates images', async () => {
52-
const model = getTemplateImagenModel(testConfig.ai, {
53-
baseUrl: STAGING_URL
54-
});
49+
const model = getTemplateImagenModel(testConfig.ai);
5550
const { images } = await model.generateImages(
5651
`portrait-${templateBackendSuffix(
5752
testConfig.ai.backend.backendType
5853
)}`,
5954
{ animal: 'Rhino' }
6055
);
61-
expect(images.length).to.equal(2); // We ask for two images in the prompt template
56+
expect(images.length).to.equal(1); // We ask for two images in the prompt template
6257
});
6358
});
6459
});

0 commit comments

Comments
 (0)