@@ -25,14 +25,11 @@ import {
2525 getGenerativeModel ,
2626 GoogleAIBackend
2727} from 'firebase/ai' ;
28- import { getAuth , signInAnonymously } from 'firebase/auth' ;
2928import { firebaseConfig } from '@/lib/app_tests/firebase' ;
3029import { OK , FAILED } from '@/lib/app_tests/util' ;
3130
3231export 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
4743export 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}
0 commit comments