File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,37 @@ describe("E2E Tests - /v1/screenshots", () => {
128128 expect ( fullPageBuffer . byteLength ) . toBeGreaterThan ( partialBuffer . byteLength ) ;
129129 } , 15000 ) ;
130130
131+ test ( "should capture clipped region" , async ( ) => {
132+ const fullResponse = await fetch ( `${ BASE_URL } /v1/screenshots` , {
133+ method : "POST" ,
134+ headers : { "Content-Type" : "application/json" } ,
135+ body : JSON . stringify ( {
136+ url : "https://example.com" ,
137+ } ) ,
138+ } ) ;
139+
140+ const fullBuffer = await fullResponse . arrayBuffer ( ) ;
141+
142+ const clippedResponse = await fetch ( `${ BASE_URL } /v1/screenshots` , {
143+ method : "POST" ,
144+ headers : { "Content-Type" : "application/json" } ,
145+ body : JSON . stringify ( {
146+ url : "https://example.com" ,
147+ clip : {
148+ x : 0 ,
149+ y : 0 ,
150+ width : 400 ,
151+ height : 300 ,
152+ } ,
153+ } ) ,
154+ } ) ;
155+
156+ expect ( clippedResponse . status ) . toBe ( 200 ) ;
157+ const clippedBuffer = await clippedResponse . arrayBuffer ( ) ;
158+
159+ expect ( clippedBuffer . byteLength ) . toBeLessThan ( fullBuffer . byteLength ) ;
160+ } , 15000 ) ;
161+
131162 test ( "should return 400 for malformed JSON" , async ( ) => {
132163 const response = await fetch ( `${ BASE_URL } /v1/screenshots` , {
133164 method : "POST" ,
You can’t perform that action at this time.
0 commit comments