@@ -117,21 +117,22 @@ test.skipIf(!enabled)("workspace import inside a snippet", async () => {
117117 expect ( JSON . parse ( result . result ) ) . toBe ( "bcode-be" )
118118} )
119119
120- test . skipIf ( ! enabled ) ( "Page.captureScreenshot is collected into result.screenshots " , async ( ) => {
120+ test . skipIf ( ! enabled ) ( "Page.captureScreenshot can stay out of model context " , async ( ) => {
121121 const result = await Effect . runPromise (
122122 Effect . scoped (
123123 Effect . gen ( function * ( ) {
124124 const impl = yield * BrowserExecute . make ( dataDir )
125125 return yield * impl . execute (
126126 {
127- description : "Capture two screenshots" ,
127+ description : "Capture context screenshots" ,
128128 code : `await session.Page.enable();
129129 const loaded = session.waitFor("Page.loadEventFired", { timeoutMs: 5000 });
130130 await session.Page.navigate({ url: "data:text/html,<title>shot</title><body>hi" });
131131 await loaded;
132132 const a = await session.Page.captureScreenshot({ format: "png" });
133133 const b = await session.Page.captureScreenshot({ format: "jpeg", quality: 50 });
134- return { aLen: a.data.length, bLen: b.data.length };` ,
134+ const local = await session.Page.captureScreenshot({ format: "webp", attachToContext: false });
135+ return { aLen: a.data.length, bLen: b.data.length, localLen: local.data.length };` ,
135136 } ,
136137 { sessionID, workspaceDir } ,
137138 )
@@ -141,7 +142,10 @@ test.skipIf(!enabled)("Page.captureScreenshot is collected into result.screensho
141142 expect ( result . screenshots ) . toHaveLength ( 2 )
142143 expect ( result . screenshots [ 0 ] ! . mime ) . toBe ( "image/png" )
143144 expect ( result . screenshots [ 1 ] ! . mime ) . toBe ( "image/jpeg" )
144- // base64 must round-trip back to non-empty bytes for both shots.
145+ // The local-only screenshot still returned data to the snippet but was not
146+ // collected into model-context attachments.
147+ expect ( JSON . parse ( result . result ) . localLen ) . toBeGreaterThan ( 0 )
148+ // Attached base64 must round-trip back to non-empty bytes for both shots.
145149 expect ( Buffer . from ( result . screenshots [ 0 ] ! . base64 , "base64" ) . length ) . toBeGreaterThan ( 0 )
146150 expect ( Buffer . from ( result . screenshots [ 1 ] ! . base64 , "base64" ) . length ) . toBeGreaterThan ( 0 )
147151} )
@@ -151,20 +155,21 @@ test.skipIf(!enabled)("BCODE_SCREENSHOT_DIR dumps screenshots to disk", async ()
151155 const prev = process . env . BCODE_SCREENSHOT_DIR
152156 process . env . BCODE_SCREENSHOT_DIR = dump
153157 try {
154- await Effect . runPromise (
158+ const result = await Effect . runPromise (
155159 Effect . scoped (
156160 Effect . gen ( function * ( ) {
157161 const impl = yield * BrowserExecute . make ( dataDir )
158162 return yield * impl . execute (
159163 {
160164 description : "Dump screenshot to disk" ,
161- code : `await session.Page.captureScreenshot({ format: "png" });` ,
165+ code : `await session.Page.captureScreenshot({ format: "png", attachToContext: false });` ,
162166 } ,
163167 { sessionID, workspaceDir } ,
164168 )
165169 } ) ,
166170 ) ,
167171 )
172+ expect ( result . screenshots ) . toHaveLength ( 0 )
168173 // Disk dump is fire-and-forget; give it a tick to land.
169174 await new Promise ( ( r ) => setTimeout ( r , 150 ) )
170175 const files = await fs . readdir ( dump )
0 commit comments