1+ import { Actor } from 'apify' ;
12import { log } from 'crawlee' ;
23import { afterEach , describe , expect , it , vi } from 'vitest' ;
34
@@ -6,6 +7,12 @@ import { parseParameters } from '../src/utils.js';
67
78process . env . ACTOR_FULL_NAME = 'apify/rag-web-browser' ;
89
10+ // A custom proxy keeps `Actor.createProxyConfiguration` off the network.
11+ const CALLER_PROXY = encodeURIComponent ( JSON . stringify ( {
12+ useApifyProxy : false ,
13+ proxyUrls : [ 'http://caller.invalid:8000' ] ,
14+ } ) ) ;
15+
916describe ( 'warnIfLowMemoryForPlaywright' , ( ) => {
1017 afterEach ( ( ) => {
1118 vi . restoreAllMocks ( ) ;
@@ -38,15 +45,26 @@ describe('warnIfLowMemoryForPlaywright', () => {
3845
3946describe ( 'the log level' , ( ) => {
4047 it ( 'ignores a caller\'s debugMode, which would switch logging for everyone sharing the run' , async ( ) => {
41- // A custom proxy keeps `Actor.createProxyConfiguration` off the network.
42- const proxy = encodeURIComponent ( JSON . stringify ( {
43- useApifyProxy : false ,
44- proxyUrls : [ 'http://log-level.invalid:8000' ] ,
45- } ) ) ;
4648 log . setLevel ( log . LEVELS . INFO ) ;
4749
48- await processInput ( parseParameters ( `?query=hello&debugMode=true&proxyConfiguration=${ proxy } ` ) ) ;
50+ await processInput ( parseParameters ( `?query=hello&debugMode=true&proxyConfiguration=${ CALLER_PROXY } ` ) ) ;
4951
5052 expect ( log . getLevel ( ) ) . toBe ( log . LEVELS . INFO ) ;
5153 } ) ;
5254} ) ;
55+
56+ describe ( 'the shared crawler pool' , ( ) => {
57+ afterEach ( ( ) => {
58+ vi . restoreAllMocks ( ) ;
59+ } ) ;
60+
61+ it ( 'is sized by the run, not by whichever caller happens to build it' , async ( ) => {
62+ vi . spyOn ( Actor , 'getEnv' ) . mockReturnValue ( { metaOrigin : 'STANDBY' } as never ) ;
63+
64+ const { contentCrawlerOptions } = await processInput (
65+ parseParameters ( `?query=hello&desiredConcurrency=17&proxyConfiguration=${ CALLER_PROXY } ` ) ,
66+ ) ;
67+
68+ expect ( contentCrawlerOptions . crawlerOptions . autoscaledPoolOptions ?. desiredConcurrency ) . toBe ( 5 ) ;
69+ } ) ;
70+ } ) ;
0 commit comments