@@ -66,13 +66,6 @@ describe("E2E Tests - /v1/screenshots", () => {
6666
6767 const buffer = await response . arrayBuffer ( ) ;
6868 expect ( buffer . byteLength ) . toBeGreaterThan ( 0 ) ;
69-
70- // Verify PNG signature
71- const uint8 = new Uint8Array ( buffer ) ;
72- expect ( uint8 [ 0 ] ) . toBe ( 0x89 ) ;
73- expect ( uint8 [ 1 ] ) . toBe ( 0x50 ) ;
74- expect ( uint8 [ 2 ] ) . toBe ( 0x4e ) ;
75- expect ( uint8 [ 3 ] ) . toBe ( 0x47 ) ;
7669 } , 15000 ) ;
7770
7871 test ( "should capture screenshot with custom viewport" , async ( ) => {
@@ -107,6 +100,75 @@ describe("E2E Tests - /v1/screenshots", () => {
107100 expect ( response . headers . get ( "Content-Type" ) ) . toBe ( "image/jpeg" ) ;
108101 } , 15000 ) ;
109102
103+ test ( "should capture full page screenshot" , async ( ) => {
104+ const partialResponse = await fetch ( `${ BASE_URL } /v1/screenshots` , {
105+ method : "POST" ,
106+ headers : { "Content-Type" : "application/json" } ,
107+ body : JSON . stringify ( {
108+ url : "https://appwrite.io" ,
109+ fullPage : false ,
110+ } ) ,
111+ } ) ;
112+
113+ const partialBuffer = await partialResponse . arrayBuffer ( ) ;
114+
115+ const fullPageResponse = await fetch ( `${ BASE_URL } /v1/screenshots` , {
116+ method : "POST" ,
117+ headers : { "Content-Type" : "application/json" } ,
118+ body : JSON . stringify ( {
119+ url : "https://appwrite.io" ,
120+ fullPage : true ,
121+ } ) ,
122+ } ) ;
123+
124+ expect ( fullPageResponse . status ) . toBe ( 200 ) ;
125+ const fullPageBuffer = await fullPageResponse . arrayBuffer ( ) ;
126+
127+ // Full page screenshot should be larger than partial
128+ expect ( fullPageBuffer . byteLength ) . toBeGreaterThan ( partialBuffer . byteLength ) ;
129+ } , 15000 ) ;
130+
131+ test ( "should return 400 for malformed JSON" , async ( ) => {
132+ const response = await fetch ( `${ BASE_URL } /v1/screenshots` , {
133+ method : "POST" ,
134+ headers : { "Content-Type" : "application/json" } ,
135+ body : "{ invalid json" ,
136+ } ) ;
137+
138+ expect ( response . status ) . toBe ( 400 ) ;
139+ const data = await response . json ( ) ;
140+ expect ( data ) . toHaveProperty ( "error" ) ;
141+ } ) ;
142+
143+ test ( "should return 400 for missing URL parameter" , async ( ) => {
144+ const response = await fetch ( `${ BASE_URL } /v1/screenshots` , {
145+ method : "POST" ,
146+ headers : { "Content-Type" : "application/json" } ,
147+ body : JSON . stringify ( {
148+ format : "png" ,
149+ } ) ,
150+ } ) ;
151+
152+ expect ( response . status ) . toBe ( 400 ) ;
153+ const data = await response . json ( ) ;
154+ expect ( data ) . toHaveProperty ( "error" ) ;
155+ } ) ;
156+
157+ test ( "should return 400 for invalid image format" , async ( ) => {
158+ const response = await fetch ( `${ BASE_URL } /v1/screenshots` , {
159+ method : "POST" ,
160+ headers : { "Content-Type" : "application/json" } ,
161+ body : JSON . stringify ( {
162+ format : "webp" ,
163+ url : "https://example.com" ,
164+ } ) ,
165+ } ) ;
166+
167+ expect ( response . status ) . toBe ( 400 ) ;
168+ const data = await response . json ( ) ;
169+ expect ( data ) . toHaveProperty ( "error" ) ;
170+ } ) ;
171+
110172 test ( "should reject invalid URL" , async ( ) => {
111173 const response = await fetch ( `${ BASE_URL } /v1/screenshots` , {
112174 method : "POST" ,
0 commit comments