Skip to content

Commit 1daf8b4

Browse files
authored
Add Vertex and DataConnect E2E smoke tests (#8805)
1 parent 9d82665 commit 1daf8b4

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

e2e/sample-apps/modular.js

+32-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ import {
5858
onValue,
5959
off
6060
} from 'firebase/database';
61+
import { getGenerativeModel, getVertexAI, VertexAI } from 'firebase/vertexai';
62+
import { getDataConnect, DataConnect } from 'firebase/data-connect';
63+
6164
/**
6265
* The config file should look like:
6366
*
@@ -287,7 +290,7 @@ function callAppCheck(app) {
287290
}
288291

289292
/**
290-
* Analytics smoke test.
293+
* Performance smoke test.
291294
* Just make sure some functions can be called without obvious errors.
292295
*/
293296
function callPerformance(app) {
@@ -303,6 +306,32 @@ function callPerformance(app) {
303306
);
304307
}
305308

309+
/**
310+
* VertexAI smoke test.
311+
* Just make sure some functions can be called without obvious errors.
312+
*/
313+
async function callVertexAI(app) {
314+
console.log('[VERTEXAI] start');
315+
const vertexAI = getVertexAI(app);
316+
const model = getGenerativeModel(vertexAI, { model: 'gemini-1.5-flash' });
317+
const result = await model.countTokens('abcdefg');
318+
console.log(`[VERTEXAI] counted tokens: ${result.totalTokens}`);
319+
}
320+
321+
/**
322+
* DataConnect smoke test.
323+
* Just make sure some functions can be called without obvious errors.
324+
*/
325+
function callDataConnect(app) {
326+
console.log('[DATACONNECT] start');
327+
getDataConnect(app, {
328+
location: 'a-location',
329+
connector: 'a-connector',
330+
service: 'service'
331+
});
332+
console.log('[DATACONNECT] initialized');
333+
}
334+
306335
/**
307336
* Run smoke tests for all products.
308337
* Comment out any products you want to ignore.
@@ -321,6 +350,8 @@ async function main() {
321350
callAnalytics(app);
322351
callPerformance(app);
323352
await callFunctions(app);
353+
await callVertexAI(app);
354+
callDataConnect(app);
324355
await authLogout(app);
325356
console.log('DONE');
326357
}

e2e/tests/modular.test.ts

+29
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ import {
8686
StorageReference,
8787
deleteObject
8888
} from 'firebase/storage';
89+
import { getGenerativeModel, getVertexAI, VertexAI } from 'firebase/vertexai';
90+
import { getDataConnect, DataConnect } from 'firebase/data-connect';
8991
import { config, testAccount } from '../firebase-config';
9092
import 'jest';
9193

@@ -304,4 +306,31 @@ describe('MODULAR', () => {
304306
expect(trace.getAttribute('testattr')).toBe('perftestvalue');
305307
});
306308
});
309+
310+
describe('VERTEXAI', () => {
311+
let vertexAI: VertexAI;
312+
it('getVertexAI()', () => {
313+
vertexAI = getVertexAI(app);
314+
});
315+
it('getGenerativeModel() and countTokens()', async () => {
316+
const model = getGenerativeModel(vertexAI, { model: 'gemini-1.5-flash' });
317+
expect(model.model).toMatch(/gemini-1.5-flash$/);
318+
const result = await model.countTokens('abcdefg');
319+
expect(result.totalTokens).toBeTruthy;
320+
});
321+
});
322+
323+
describe('DATA CONNECT', () => {
324+
let dataConnect: DataConnect;
325+
it('getDataConnect()', () => {
326+
dataConnect = getDataConnect(app, {
327+
location: 'a-location',
328+
connector: 'a-connector',
329+
service: 'service'
330+
});
331+
});
332+
it('dataConnect.getSettings()', () => {
333+
expect(dataConnect.getSettings().location).toBe('a-location');
334+
});
335+
});
307336
});

0 commit comments

Comments
 (0)