diff --git a/e2e/sample-apps/modular.js b/e2e/sample-apps/modular.js index cf08ca53d9d..9e943e04494 100644 --- a/e2e/sample-apps/modular.js +++ b/e2e/sample-apps/modular.js @@ -58,6 +58,9 @@ import { onValue, off } from 'firebase/database'; +import { getGenerativeModel, getVertexAI, VertexAI } from 'firebase/vertexai'; +import { getDataConnect, DataConnect } from 'firebase/data-connect'; + /** * The config file should look like: * @@ -287,7 +290,7 @@ function callAppCheck(app) { } /** - * Analytics smoke test. + * Performance smoke test. * Just make sure some functions can be called without obvious errors. */ function callPerformance(app) { @@ -303,6 +306,32 @@ function callPerformance(app) { ); } +/** + * VertexAI smoke test. + * Just make sure some functions can be called without obvious errors. + */ +async function callVertexAI(app) { + console.log('[VERTEXAI] start'); + const vertexAI = getVertexAI(app); + const model = getGenerativeModel(vertexAI, { model: 'gemini-1.5-flash' }); + const result = await model.countTokens('abcdefg'); + console.log(`[VERTEXAI] counted tokens: ${result.totalTokens}`); +} + +/** + * DataConnect smoke test. + * Just make sure some functions can be called without obvious errors. + */ +function callDataConnect(app) { + console.log('[DATACONNECT] start'); + getDataConnect(app, { + location: 'a-location', + connector: 'a-connector', + service: 'service' + }); + console.log('[DATACONNECT] initialized'); +} + /** * Run smoke tests for all products. * Comment out any products you want to ignore. @@ -321,6 +350,8 @@ async function main() { callAnalytics(app); callPerformance(app); await callFunctions(app); + await callVertexAI(app); + callDataConnect(app); await authLogout(app); console.log('DONE'); } diff --git a/e2e/tests/modular.test.ts b/e2e/tests/modular.test.ts index 24432604119..005fadef19a 100644 --- a/e2e/tests/modular.test.ts +++ b/e2e/tests/modular.test.ts @@ -86,6 +86,8 @@ import { StorageReference, deleteObject } from 'firebase/storage'; +import { getGenerativeModel, getVertexAI, VertexAI } from 'firebase/vertexai'; +import { getDataConnect, DataConnect } from 'firebase/data-connect'; import { config, testAccount } from '../firebase-config'; import 'jest'; @@ -304,4 +306,31 @@ describe('MODULAR', () => { expect(trace.getAttribute('testattr')).toBe('perftestvalue'); }); }); + + describe('VERTEXAI', () => { + let vertexAI: VertexAI; + it('getVertexAI()', () => { + vertexAI = getVertexAI(app); + }); + it('getGenerativeModel() and countTokens()', async () => { + const model = getGenerativeModel(vertexAI, { model: 'gemini-1.5-flash' }); + expect(model.model).toMatch(/gemini-1.5-flash$/); + const result = await model.countTokens('abcdefg'); + expect(result.totalTokens).toBeTruthy; + }); + }); + + describe('DATA CONNECT', () => { + let dataConnect: DataConnect; + it('getDataConnect()', () => { + dataConnect = getDataConnect(app, { + location: 'a-location', + connector: 'a-connector', + service: 'service' + }); + }); + it('dataConnect.getSettings()', () => { + expect(dataConnect.getSettings().location).toBe('a-location'); + }); + }); });