Skip to content

Commit 66d30f4

Browse files
committed
add: more test cases.
1 parent 6fbdd55 commit 66d30f4

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/e2e/endpoints.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff 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",

0 commit comments

Comments
 (0)