Skip to content

Commit 3c0b2d2

Browse files
committed
remove Auth usage from AI test
1 parent cc0fc05 commit 3c0b2d2

File tree

3 files changed

+38
-60
lines changed

3 files changed

+38
-60
lines changed

js-sdk-framework-tests/nextjs/src/components/app_tests/ai/results_display.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export default function ResultsDisplay({ statusString, testResults }) {
2020
<>
2121
<h2 title="testStatus">{statusString}</h2>
2222
<h4 title="initializeAppResult">initializeAppResult: {testResults.initializeAppResult}</h4>
23-
<h4 title="initializeAuthResult">initializeAuthResult: {testResults.initializeAuthResult}</h4>
24-
<h4 title="signInAnonymouslyResult">signInAnonymouslyResult: {testResults.signInAnonymouslyResult}</h4>
2523
<h4 title="getAIResult">getAIResult: {testResults.getAIResult}</h4>
2624
<h4 title="getGenerativeModelResult">getGenerativeModelResult: {testResults.getGenerativeModelResult}</h4>
2725
<h4 title="startChatResult">startChatResult: {testResults.startChatResult}</h4>
@@ -30,7 +28,6 @@ export default function ResultsDisplay({ statusString, testResults }) {
3028
<h4 title="chatSendSecondMessageResult">chatSendSecondMessageResult: {testResults.chatSendSecondMessageResult}</h4>
3129
<h4 title="chatSecondResponseCheckResult">chatSecondResponseCheckResult: {testResults.chatSecondResponseCheckResult}</h4>
3230
<h4 title="getHistoryResult">getHistoryResult: {testResults.getHistoryResult}</h4>
33-
<h4 title="deleteUserResult">deleteUserResult: {testResults.deleteUserResult}</h4>
3431
<p />
3532
<Link href="/">Back to test index</Link>
3633
</>

js-sdk-framework-tests/nextjs/src/lib/app_tests/ai/test.ts

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,11 @@ import {
2525
getGenerativeModel,
2626
GoogleAIBackend
2727
} from 'firebase/ai';
28-
import { getAuth, signInAnonymously } from 'firebase/auth';
2928
import { firebaseConfig } from '@/lib/app_tests/firebase';
3029
import { OK, FAILED } from '@/lib/app_tests/util';
3130

3231
export type TestResults = {
3332
initializeAppResult: string,
34-
initializeAuthResult: string,
35-
signInAnonymouslyResult: string,
3633
getAIResult: string,
3734
getGenerativeModelResult: string,
3835
startChatResult: string,
@@ -41,14 +38,11 @@ export type TestResults = {
4138
chatSendSecondMessageResult: string,
4239
chatSecondResponseCheckResult: string,
4340
getHistoryResult: string,
44-
deleteUserResult: string
4541
};
4642

4743
export function initializeTestResults(): TestResults {
4844
const testAnalyticsResult: TestResults = {
4945
initializeAppResult: FAILED,
50-
initializeAuthResult: FAILED,
51-
signInAnonymouslyResult: FAILED,
5246
getAIResult: FAILED,
5347
getGenerativeModelResult: FAILED,
5448
startChatResult: FAILED,
@@ -57,7 +51,6 @@ export function initializeTestResults(): TestResults {
5751
chatSendSecondMessageResult: FAILED,
5852
chatSecondResponseCheckResult: FAILED,
5953
getHistoryResult: FAILED,
60-
deleteUserResult: FAILED
6154
};
6255
return testAnalyticsResult;
6356
}
@@ -104,53 +97,44 @@ export async function testAI(isServer: boolean = false): Promise<TestResults> {
10497
const firebaseApp = initializeApp(firebaseConfig);
10598
result.initializeAppResult = OK;
10699

107-
const auth = getAuth(firebaseApp);
108-
result.initializeAuthResult = OK;
109-
await signInAnonymously(auth);
110-
if (auth.currentUser) {
111-
result.signInAnonymouslyResult = OK;
112-
113-
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
114-
result.getAIResult = OK;
115-
116-
const model = getGenerativeModel(ai, {
117-
model: "gemini-2.5-flash",
118-
generationConfig: commonGenerationConfig,
119-
safetySettings: commonSafetySettings,
120-
systemInstruction: commonSystemInstruction
121-
});
122-
result.getGenerativeModelResult = OK;
123-
124-
const chat = model.startChat();
125-
result.startChatResult = OK;
126-
127-
const result1 = await chat.sendMessage(
128-
'What is the capital of France?'
129-
);
130-
result.chatSendFirstMessageResult = OK;
131-
132-
const response1 = result1.response;
133-
if (response1.text().length !== 0) {
134-
result.chatFirstResponseCheckResult = OK;
135-
}
136-
137-
const result2 = await chat.sendMessage('And what about Italy?');
138-
result.chatSendSecondMessageResult = OK;
139-
140-
const response2 = result2.response;
141-
if (response2.text().length !== 0) {
142-
result.chatSecondResponseCheckResult = OK;
143-
}
144-
145-
const history = await chat.getHistory();
146-
if(history.length !== 0) {
147-
result.getHistoryResult = OK;
148-
}
149-
150-
if (auth.currentUser) {
151-
await auth.currentUser.delete();
152-
result.deleteUserResult = OK;
153-
}
100+
result.signInAnonymouslyResult = OK;
101+
102+
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
103+
result.getAIResult = OK;
104+
105+
const model = getGenerativeModel(ai, {
106+
model: "gemini-2.5-flash",
107+
generationConfig: commonGenerationConfig,
108+
safetySettings: commonSafetySettings,
109+
systemInstruction: commonSystemInstruction
110+
});
111+
result.getGenerativeModelResult = OK;
112+
113+
const chat = model.startChat();
114+
result.startChatResult = OK;
115+
116+
const result1 = await chat.sendMessage(
117+
'What is the capital of France?'
118+
);
119+
result.chatSendFirstMessageResult = OK;
120+
121+
const response1 = result1.response;
122+
if (response1.text().length !== 0) {
123+
result.chatFirstResponseCheckResult = OK;
154124
}
125+
126+
const result2 = await chat.sendMessage('And what about Italy?');
127+
result.chatSendSecondMessageResult = OK;
128+
129+
const response2 = result2.response;
130+
if (response2.text().length !== 0) {
131+
result.chatSecondResponseCheckResult = OK;
132+
}
133+
134+
const history = await chat.getHistory();
135+
if (history.length !== 0) {
136+
result.getHistoryResult = OK;
137+
}
138+
155139
return result;
156140
}

js-sdk-framework-tests/nextjs/tests/ai.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import { test, expect } from '@playwright/test';
1818

1919
async function commonExpectations(page) {
2020
await expect(page.getByTitle('initializeAppResult')).not.toContainText("FAILED");
21-
await expect(page.getByTitle('initializeAuthResult')).not.toContainText("FAILED");
22-
await expect(page.getByTitle('signInAnonymouslyResult')).not.toContainText("FAILED");
2321
await expect(page.getByTitle('getAIResult')).not.toContainText("FAILED");
2422
await expect(page.getByTitle('getGenerativeModelResult')).not.toContainText("FAILED");
2523
await expect(page.getByTitle('startChatResult')).not.toContainText("FAILED");
@@ -28,7 +26,6 @@ async function commonExpectations(page) {
2826
await expect(page.getByTitle('chatSendSecondMessageResult')).not.toContainText("FAILED");
2927
await expect(page.getByTitle('chatSecondResponseCheckResult')).not.toContainText("FAILED");
3028
await expect(page.getByTitle('getHistoryResult')).not.toContainText("FAILED");
31-
await expect(page.getByTitle('deleteUserResult')).not.toContainText("FAILED");
3229

3330
}
3431

0 commit comments

Comments
 (0)