@@ -25,6 +25,7 @@ import { DEFAULT_API_VERSION } from '../constants';
25
25
import { VertexAIErrorCode } from '../types' ;
26
26
import { VertexAIError } from '../errors' ;
27
27
import { getMockResponse } from '../../test-utils/mock-response' ;
28
+ import { SDK_VERSION } from '@firebase/app' ;
28
29
29
30
use ( sinonChai ) ;
30
31
use ( chaiAsPromised ) ;
@@ -126,10 +127,6 @@ describe('request methods', () => {
126
127
const headers = await getHeaders ( fakeUrl ) ;
127
128
expect ( headers . get ( 'x-goog-api-key' ) ) . to . equal ( 'key' ) ;
128
129
} ) ;
129
- it ( 'adds app id if automatedDataCollectionEnabled is undefined' , async ( ) => {
130
- const headers = await getHeaders ( fakeUrl ) ;
131
- expect ( headers . get ( 'X-Firebase-AppId' ) ) . to . equal ( 'my-appid' ) ;
132
- } ) ;
133
130
it ( 'adds app id if automatedDataCollectionEnabled is true' , async ( ) => {
134
131
const fakeApiSettings : ApiSettings = {
135
132
apiKey : 'key' ,
@@ -148,7 +145,11 @@ describe('request methods', () => {
148
145
{ }
149
146
) ;
150
147
const headers = await getHeaders ( fakeUrl ) ;
151
- expect ( headers . get ( 'X-Firebase-AppId' ) ) . to . equal ( 'my-appid' ) ;
148
+ expect ( headers . get ( 'X-Firebase-Appid' ) ) . to . equal ( 'my-appid' ) ;
149
+ } ) ;
150
+ it ( 'does not add app id if automatedDataCollectionEnabled is undefined' , async ( ) => {
151
+ const headers = await getHeaders ( fakeUrl ) ;
152
+ expect ( headers . get ( 'X-Firebase-Appid' ) ) . to . be . null ;
152
153
} ) ;
153
154
it ( 'does not add app id if automatedDataCollectionEnabled is false' , async ( ) => {
154
155
const fakeApiSettings : ApiSettings = {
@@ -168,7 +169,51 @@ describe('request methods', () => {
168
169
{ }
169
170
) ;
170
171
const headers = await getHeaders ( fakeUrl ) ;
171
- expect ( headers . get ( 'X-Firebase-AppId' ) ) . to . be . null ;
172
+ expect ( headers . get ( 'X-Firebase-Appid' ) ) . to . be . null ;
173
+ } ) ;
174
+ it ( 'adds app version if automatedDataCollectionEnabled is true' , async ( ) => {
175
+ const fakeApiSettings : ApiSettings = {
176
+ apiKey : 'key' ,
177
+ project : 'myproject' ,
178
+ appId : 'my-appid' ,
179
+ location : 'moon' ,
180
+ automaticDataCollectionEnabled : true ,
181
+ getAuthToken : ( ) => Promise . resolve ( { accessToken : 'authtoken' } ) ,
182
+ getAppCheckToken : ( ) => Promise . resolve ( { token : 'appchecktoken' } )
183
+ } ;
184
+ const fakeUrl = new RequestUrl (
185
+ 'models/model-name' ,
186
+ Task . GENERATE_CONTENT ,
187
+ fakeApiSettings ,
188
+ true ,
189
+ { }
190
+ ) ;
191
+ const headers = await getHeaders ( fakeUrl ) ;
192
+ expect ( headers . get ( 'X-Firebase-Appversion' ) ) . to . equal ( SDK_VERSION ) ;
193
+ } ) ;
194
+ it ( 'does not add app version if automatedDataCollectionEnabled is undefined' , async ( ) => {
195
+ const headers = await getHeaders ( fakeUrl ) ;
196
+ expect ( headers . get ( 'X-Firebase-Appversion' ) ) . to . be . null ;
197
+ } ) ;
198
+ it ( 'does not add app version if automatedDataCollectionEnabled is false' , async ( ) => {
199
+ const fakeApiSettings : ApiSettings = {
200
+ apiKey : 'key' ,
201
+ project : 'myproject' ,
202
+ appId : 'my-appid' ,
203
+ location : 'moon' ,
204
+ automaticDataCollectionEnabled : false ,
205
+ getAuthToken : ( ) => Promise . resolve ( { accessToken : 'authtoken' } ) ,
206
+ getAppCheckToken : ( ) => Promise . resolve ( { token : 'appchecktoken' } )
207
+ } ;
208
+ const fakeUrl = new RequestUrl (
209
+ 'models/model-name' ,
210
+ Task . GENERATE_CONTENT ,
211
+ fakeApiSettings ,
212
+ true ,
213
+ { }
214
+ ) ;
215
+ const headers = await getHeaders ( fakeUrl ) ;
216
+ expect ( headers . get ( 'X-Firebase-Appversion' ) ) . to . be . null ;
172
217
} ) ;
173
218
it ( 'adds app check token if it exists' , async ( ) => {
174
219
const headers = await getHeaders ( fakeUrl ) ;
0 commit comments