Skip to content

Update e2e tests to reflect AI package and new API #9017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2025
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
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"firebase": "11.3.0"
"firebase": "^11.8.0-20250512211235"
},
"devDependencies": {
"@babel/core": "7.26.8",
Expand Down
16 changes: 8 additions & 8 deletions e2e/sample-apps/modular.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import {
onValue,
off
} from 'firebase/database';
import { getGenerativeModel, getVertexAI, VertexAI } from 'firebase/vertexai';
import { getGenerativeModel, getAI, VertexAIBackend } from 'firebase/ai';
import { getDataConnect, DataConnect } from 'firebase/data-connect';

/**
Expand Down Expand Up @@ -307,15 +307,15 @@ function callPerformance(app) {
}

/**
* VertexAI smoke test.
* AI 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' });
async function callAI(app) {
console.log('[AI] start');
const ai = getAI(app, { backend: new VertexAIBackend() });
const model = getGenerativeModel(ai, { model: 'gemini-1.5-flash' });
const result = await model.countTokens('abcdefg');
console.log(`[VERTEXAI] counted tokens: ${result.totalTokens}`);
console.log(`[AI] counted tokens: ${result.totalTokens}`);
}

/**
Expand Down Expand Up @@ -350,7 +350,7 @@ async function main() {
callAnalytics(app);
callPerformance(app);
await callFunctions(app);
await callVertexAI(app);
await callAI(app);
callDataConnect(app);
await authLogout(app);
console.log('DONE');
Expand Down
15 changes: 10 additions & 5 deletions e2e/tests/modular.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ import {
StorageReference,
deleteObject
} from 'firebase/storage';
import { getGenerativeModel, getVertexAI, VertexAI } from 'firebase/vertexai';
import {
getGenerativeModel,
getAI,
AI,
VertexAIBackend
} from 'firebase/vertexai';
import { getDataConnect, DataConnect } from 'firebase/data-connect';
import { config, testAccount } from '../firebase-config';
import 'jest';
Expand Down Expand Up @@ -307,13 +312,13 @@ describe('MODULAR', () => {
});
});

describe('VERTEXAI', () => {
let vertexAI: VertexAI;
describe('AI', () => {
let ai: AI;
it('getVertexAI()', () => {
vertexAI = getVertexAI(app);
ai = getAI(app, { backend: new VertexAIBackend() });
});
it('getGenerativeModel() and countTokens()', async () => {
const model = getGenerativeModel(vertexAI, { model: 'gemini-1.5-flash' });
const model = getGenerativeModel(ai, { model: 'gemini-1.5-flash' });
expect(model.model).toMatch(/gemini-1.5-flash$/);
const result = await model.countTokens('abcdefg');
expect(result.totalTokens).toBeTruthy;
Expand Down
Loading
Loading