Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion e2e/sample-apps/modular.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down Expand Up @@ -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) {
Expand All @@ -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.
Expand All @@ -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');
}
Expand Down
29 changes: 29 additions & 0 deletions e2e/tests/modular.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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');
});
});
});
Loading