11import { onCall , CallableRequest , CallableResponse , HttpsError } from 'firebase-functions/v2/https' ;
22import { logger } from 'firebase-functions/v2' ;
3+ import { E2E_TEST_FUNCTION_TIMEOUT_SECONDS } from './e2eCallOptions' ;
34import SAMPLE_DATA from './sample-data' ;
45
6+ const e2eOnCall = (
7+ handler : ( req : CallableRequest < any > , response ?: CallableResponse < any > ) => unknown ,
8+ ) => onCall ( { timeoutSeconds : E2E_TEST_FUNCTION_TIMEOUT_SECONDS } , handler ) ;
9+
510/**
611 * Test streaming callable function that sends multiple chunks of data
712 * This function demonstrates Server-Sent Events (SSE) streaming
813 */
9- export const testStreamingCallable = onCall (
14+ export const testStreamingCallable = e2eOnCall (
1015 async (
1116 req : CallableRequest < { count ?: number ; delay ?: number } > ,
1217 response ?: CallableResponse < any > ,
@@ -43,7 +48,7 @@ export const testStreamingCallable = onCall(
4348/**
4449 * Test streaming callable that sends progressive updates
4550 */
46- export const testProgressStream = onCall (
51+ export const testProgressStream = e2eOnCall (
4752 async ( req : CallableRequest < { task ?: string } > , response ?: CallableResponse < any > ) => {
4853 const task = req . data . task || 'Processing' ;
4954
@@ -71,7 +76,7 @@ export const testProgressStream = onCall(
7176/**
7277 * Test streaming with complex data types
7378 */
74- export const testComplexDataStream = onCall (
79+ export const testComplexDataStream = e2eOnCall (
7580 async ( req : CallableRequest , response ?: CallableResponse < any > ) => {
7681 logger . info ( 'testComplexDataStream called' ) ;
7782
@@ -126,7 +131,7 @@ export const testComplexDataStream = onCall(
126131/**
127132 * Test streaming with error handling
128133 */
129- export const testStreamWithError = onCall (
134+ export const testStreamWithError = e2eOnCall (
130135 async (
131136 req : CallableRequest < { shouldError ?: boolean ; errorAfter ?: number } > ,
132137 response ?: CallableResponse < any > ,
@@ -161,7 +166,7 @@ export const testStreamWithError = onCall(
161166 * Test streaming callable that returns the type of data sent
162167 * Similar to Dart's testStreamResponse - sends back the type of input data
163168 */
164- export const testStreamResponse = onCall (
169+ export const testStreamResponse = e2eOnCall (
165170 async ( req : CallableRequest < any > , response ?: CallableResponse < any > ) => {
166171 logger . info ( 'testStreamResponse called' , { data : req . data } ) ;
167172
@@ -207,7 +212,7 @@ export const testStreamResponse = onCall(
207212 * Test streaming callable that handles null data
208213 * This function specifically accepts null and returns success: true
209214 */
210- export const testStreamingCallableWithNull = onCall (
215+ export const testStreamingCallableWithNull = e2eOnCall (
211216 async ( req : CallableRequest < any > , response ?: CallableResponse < any > ) => {
212217 logger . info ( 'testStreamingCallableWithNull called' , { data : req . data } ) ;
213218
@@ -228,7 +233,7 @@ export const testStreamingCallableWithNull = onCall(
228233 * Streaming callable that throws HttpsError (for testing stream-by-name).
229234 * Only throws: invalid-argument (bad/missing type), or cancelled with details (when asError).
230235 */
231- export const testStreamWithHttpsError = onCall (
236+ export const testStreamWithHttpsError = e2eOnCall (
232237 async (
233238 req : CallableRequest < { type ?: string ; asError ?: boolean ; inputData ?: any } > ,
234239 response ?: CallableResponse < any > ,
@@ -263,7 +268,7 @@ export const testStreamWithHttpsError = onCall(
263268 * Streaming callable that throws HttpsError (for testing stream-from-URL).
264269 * Same behaviour as testStreamWithHttpsError; separate export for httpsCallableFromUrl.stream() e2e.
265270 */
266- export const testStreamWithHttpsErrorFromUrl = onCall (
271+ export const testStreamWithHttpsErrorFromUrl = e2eOnCall (
267272 async (
268273 req : CallableRequest < { type ?: string ; asError ?: boolean ; inputData ?: any } > ,
269274 response ?: CallableResponse < any > ,
0 commit comments