Files
SnapOtter/tests/e2e-docker/layout-tools.spec.ts
T
SnapOtter 649ad5db9e test: massive test coverage expansion (+1,437 tests, 22 new files)
Expand test coverage across all layers via 14 parallel agents:

Unit tests (3,378 total, +534):
- First-ever AI sidecar tests (157 tests covering bridge lifecycle, all 12 tool modules)
- API route infrastructure (auth, pipeline, batch, settings, teams, roles, audit, api-keys, files, docs)
- Lib coverage improvements (audit 7%->95%, worker-pool 33%->100%)
- Web store/lib gap fills (features-store, tool-registry)

Integration tests (4,403 total, +903):
- Expanded 19 tool test files with parameter variations, format edge cases, boundary values
- Cross-format matrix: 290 tests covering 14 tools x 17 formats
- Adversarial/edge cases: 63 tests for extreme inputs, concurrent requests, corrupted files

E2E-Docker (125 new tests):
- Expanded 8 spec files + 1 new file covering all 49 tools
- Added HEIC/format handling, auth failures, download verification

GUI E2E (expanded 28 spec files):
- Navigation, responsive layout, keyboard shortcuts
- All 51 tool UIs with settings, processing, display modes
- Batch/pipeline workflows, settings/RBAC, visual regression
- Resilience, accessibility (ARIA, contrast, focus), performance budgets
2026-05-09 09:02:29 +08:00

735 lines
26 KiB
TypeScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { expect, test } from "@playwright/test";
// ─── Layout Tools ──────────────────────────────────────────────────
// Extended tests for: collage (templates, gaps, formats), stitch
// (alignment, large sets), split (asymmetric grids, edge cases),
// border (rounded, gradient, asymmetric sizes)
// Complements creative-tools.spec.ts with deeper layout coverage.
const FIXTURES = join(process.cwd(), "tests", "fixtures");
const FORMATS = join(FIXTURES, "formats");
const CONTENT = join(FIXTURES, "content");
let token: string;
test.beforeAll(async ({ request }) => {
const res = await request.post("/api/auth/login", {
data: { username: "admin", password: "admin" },
});
const body = await res.json();
token = body.token;
});
function fixture(name: string): Buffer {
return readFileSync(join(FIXTURES, name));
}
function formatFixture(name: string): Buffer {
return readFileSync(join(FORMATS, name));
}
function contentFixture(name: string): Buffer {
return readFileSync(join(CONTENT, name));
}
/**
* Build a raw multipart/form-data body for multi-file uploads.
*/
function buildMultipart(
files: Array<{ name: string; filename: string; contentType: string; buffer: Buffer }>,
fields: Array<{ name: string; value: string }>,
): { body: Buffer; contentType: string } {
const boundary = `----PlaywrightBoundary${Date.now()}`;
const parts: Buffer[] = [];
for (const file of files) {
parts.push(
Buffer.from(
`--${boundary}\r\nContent-Disposition: form-data; name="${file.name}"; filename="${file.filename}"\r\nContent-Type: ${file.contentType}\r\n\r\n`,
),
);
parts.push(file.buffer);
parts.push(Buffer.from("\r\n"));
}
for (const field of fields) {
parts.push(
Buffer.from(
`--${boundary}\r\nContent-Disposition: form-data; name="${field.name}"\r\n\r\n${field.value}\r\n`,
),
);
}
parts.push(Buffer.from(`--${boundary}--\r\n`));
return {
body: Buffer.concat(parts),
contentType: `multipart/form-data; boundary=${boundary}`,
};
}
const PNG_200x150 = fixture("test-200x150.png");
const JPG_100x100 = fixture("test-100x100.jpg");
const WEBP_50x50 = fixture("test-50x50.webp");
const HEIC_200x150 = fixture("test-200x150.heic");
const JPG_PORTRAIT = fixture("test-portrait.jpg");
const JPG_SAMPLE = formatFixture("sample.jpg");
// ─── Collage — Extended Templates ──────────────────────────────────
test.describe("Collage — extended", () => {
test("3-image collage with vertical layout", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
{ name: "file", filename: "c.webp", contentType: "image/webp", buffer: WEBP_50x50 },
],
[
{
name: "settings",
value: JSON.stringify({
templateId: "3-v-equal",
width: 400,
height: 600,
format: "png",
}),
},
],
);
const res = await request.post("/api/v1/tools/collage", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
expect(json.processedSize).toBeGreaterThan(0);
});
test("collage with wide gap and dark background", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
],
[
{
name: "settings",
value: JSON.stringify({
templateId: "2-h-equal",
gap: 30,
backgroundColor: "#1a1a1a",
outputFormat: "jpeg",
}),
},
],
);
const res = await request.post("/api/v1/tools/collage", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
});
test("collage with 4 images", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
{ name: "file", filename: "c.webp", contentType: "image/webp", buffer: WEBP_50x50 },
{ name: "file", filename: "d.jpg", contentType: "image/jpeg", buffer: JPG_PORTRAIT },
],
[
{
name: "settings",
value: JSON.stringify({
templateId: "4-grid",
width: 800,
height: 800,
gap: 5,
format: "png",
}),
},
],
);
const res = await request.post("/api/v1/tools/collage", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
});
test("collage with zero gap", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
],
[
{
name: "settings",
value: JSON.stringify({
templateId: "2-h-equal",
gap: 0,
outputFormat: "png",
}),
},
],
);
const res = await request.post("/api/v1/tools/collage", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
});
test("collage with single image still succeeds", async ({ request }) => {
const { body, contentType } = buildMultipart(
[{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 }],
[
{
name: "settings",
value: JSON.stringify({ templateId: "2-h-equal", width: 400 }),
},
],
);
const res = await request.post("/api/v1/tools/collage", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
});
});
// ─── Stitch — Extended ─────────────────────────────────────────────
test.describe("Stitch — extended", () => {
test("stitch 4 images horizontally", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
{ name: "file", filename: "c.webp", contentType: "image/webp", buffer: WEBP_50x50 },
{ name: "file", filename: "d.jpg", contentType: "image/jpeg", buffer: JPG_PORTRAIT },
],
[{ name: "settings", value: JSON.stringify({ direction: "horizontal", gap: 5 }) }],
);
const res = await request.post("/api/v1/tools/stitch", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
expect(json.processedSize).toBeGreaterThan(0);
});
test("stitch 4 images vertically", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
{ name: "file", filename: "c.webp", contentType: "image/webp", buffer: WEBP_50x50 },
{ name: "file", filename: "d.jpg", contentType: "image/jpeg", buffer: JPG_PORTRAIT },
],
[{ name: "settings", value: JSON.stringify({ direction: "vertical", gap: 10 }) }],
);
const res = await request.post("/api/v1/tools/stitch", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
});
test("stitch with wide gap and custom background", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
],
[
{
name: "settings",
value: JSON.stringify({
direction: "horizontal",
gap: 50,
backgroundColor: "#00FF00",
}),
},
],
);
const res = await request.post("/api/v1/tools/stitch", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
});
test("stitch in grid mode with 4 images and 2 columns", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
{ name: "file", filename: "c.webp", contentType: "image/webp", buffer: WEBP_50x50 },
{ name: "file", filename: "d.jpg", contentType: "image/jpeg", buffer: JPG_PORTRAIT },
],
[
{
name: "settings",
value: JSON.stringify({ direction: "grid", gridColumns: 2, gap: 5 }),
},
],
);
const res = await request.post("/api/v1/tools/stitch", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
});
test("stitch 5 images in grid with 3 columns", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
{ name: "file", filename: "c.webp", contentType: "image/webp", buffer: WEBP_50x50 },
{ name: "file", filename: "d.jpg", contentType: "image/jpeg", buffer: JPG_PORTRAIT },
{
name: "file",
filename: "e.heic",
contentType: "image/heic",
buffer: HEIC_200x150,
},
],
[
{
name: "settings",
value: JSON.stringify({ direction: "grid", gridColumns: 3, gap: 8 }),
},
],
);
const res = await request.post("/api/v1/tools/stitch", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
});
test("stitch with HEIC images", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.heic", contentType: "image/heic", buffer: HEIC_200x150 },
{ name: "file", filename: "b.png", contentType: "image/png", buffer: PNG_200x150 },
],
[{ name: "settings", value: JSON.stringify({ direction: "horizontal", gap: 0 }) }],
);
const res = await request.post("/api/v1/tools/stitch", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
});
});
// ─── Split — Extended ──────────────────────────────────────────────
test.describe("Split — extended", () => {
test("split into 1x3 columns (vertical strips)", async ({ request }) => {
const res = await request.post("/api/v1/tools/split", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
settings: JSON.stringify({ columns: 3, rows: 1 }),
},
});
expect(res.ok()).toBe(true);
// Split returns a ZIP file (PK magic bytes), not JSON
const buffer = Buffer.from(await res.body());
expect(buffer.length).toBeGreaterThan(0);
expect(buffer[0]).toBe(0x50); // 'P'
expect(buffer[1]).toBe(0x4b); // 'K'
});
test("split into 1x2 rows (horizontal strips)", async ({ request }) => {
const res = await request.post("/api/v1/tools/split", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
settings: JSON.stringify({ columns: 1, rows: 2 }),
},
});
expect(res.ok()).toBe(true);
// Split returns a ZIP file
const buffer = Buffer.from(await res.body());
expect(buffer.length).toBeGreaterThan(0);
expect(buffer[0]).toBe(0x50);
expect(buffer[1]).toBe(0x4b);
});
test("split into 4x4 tiles", async ({ request }) => {
const res = await request.post("/api/v1/tools/split", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "sample.jpg", mimeType: "image/jpeg", buffer: JPG_SAMPLE },
settings: JSON.stringify({ columns: 4, rows: 4 }),
},
});
expect(res.ok()).toBe(true);
// Split returns a ZIP file
const buffer = Buffer.from(await res.body());
expect(buffer.length).toBeGreaterThan(0);
expect(buffer[0]).toBe(0x50);
expect(buffer[1]).toBe(0x4b);
});
test("split JPEG image", async ({ request }) => {
const res = await request.post("/api/v1/tools/split", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.jpg", mimeType: "image/jpeg", buffer: JPG_100x100 },
settings: JSON.stringify({ columns: 2, rows: 2 }),
},
});
expect(res.ok()).toBe(true);
// Split returns a ZIP file
const buffer = Buffer.from(await res.body());
expect(buffer.length).toBeGreaterThan(0);
expect(buffer[0]).toBe(0x50);
expect(buffer[1]).toBe(0x4b);
});
test("split WebP image", async ({ request }) => {
const webpSample = formatFixture("sample.webp");
const res = await request.post("/api/v1/tools/split", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "sample.webp", mimeType: "image/webp", buffer: webpSample },
settings: JSON.stringify({ columns: 3, rows: 2 }),
},
});
expect(res.ok()).toBe(true);
// Split returns a ZIP file
const buffer = Buffer.from(await res.body());
expect(buffer.length).toBeGreaterThan(0);
expect(buffer[0]).toBe(0x50);
expect(buffer[1]).toBe(0x4b);
});
test("split portrait-oriented image", async ({ request }) => {
const res = await request.post("/api/v1/tools/split", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "portrait.jpg", mimeType: "image/jpeg", buffer: JPG_PORTRAIT },
settings: JSON.stringify({ columns: 2, rows: 3 }),
},
});
expect(res.ok()).toBe(true);
// Split returns a ZIP file
const buffer = Buffer.from(await res.body());
expect(buffer.length).toBeGreaterThan(0);
expect(buffer[0]).toBe(0x50);
expect(buffer[1]).toBe(0x4b);
});
test("split HEIC image into tiles", async ({ request }) => {
const res = await request.post("/api/v1/tools/split", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.heic", mimeType: "image/heic", buffer: HEIC_200x150 },
settings: JSON.stringify({ columns: 2, rows: 2 }),
},
});
expect(res.ok()).toBe(true);
// Split returns a ZIP file
const buffer = Buffer.from(await res.body());
expect(buffer.length).toBeGreaterThan(0);
expect(buffer[0]).toBe(0x50);
expect(buffer[1]).toBe(0x4b);
});
});
// ─── Border — Extended ─────────────────────────────────────────────
test.describe("Border — extended", () => {
test("border on HEIC image", async ({ request }) => {
const res = await request.post("/api/v1/tools/border", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.heic", mimeType: "image/heic", buffer: HEIC_200x150 },
settings: JSON.stringify({ size: 15, color: "#336699" }),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.downloadUrl).toBeTruthy();
expect(body.processedSize).toBeGreaterThan(0);
});
test("border on WebP image", async ({ request }) => {
const webpSample = formatFixture("sample.webp");
const res = await request.post("/api/v1/tools/border", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "sample.webp", mimeType: "image/webp", buffer: webpSample },
settings: JSON.stringify({ size: 25, color: "#FF6633" }),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.downloadUrl).toBeTruthy();
});
test("very wide border (100px)", async ({ request }) => {
const res = await request.post("/api/v1/tools/border", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.jpg", mimeType: "image/jpeg", buffer: JPG_100x100 },
settings: JSON.stringify({ size: 100, color: "#CCCCCC" }),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.downloadUrl).toBeTruthy();
expect(body.processedSize).toBeGreaterThan(0);
});
test("border with transparent color on PNG", async ({ request }) => {
const res = await request.post("/api/v1/tools/border", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
settings: JSON.stringify({ size: 20, color: "#00000000" }),
},
});
// May succeed with transparent border or reject — both valid
if (res.ok()) {
const body = await res.json();
expect(body.downloadUrl).toBeTruthy();
} else {
const body = await res.json();
expect(body.error).toBeDefined();
}
});
test("border on large content image", async ({ request }) => {
const portrait = contentFixture("portrait-color.jpg");
const res = await request.post("/api/v1/tools/border", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "portrait.jpg", mimeType: "image/jpeg", buffer: portrait },
settings: JSON.stringify({ size: 30, color: "#FFFFFF" }),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.downloadUrl).toBeTruthy();
expect(body.processedSize).toBeGreaterThan(0);
});
});
// ─── Collage — Output Verification ──────────────────────────────
test.describe("Collage — output verification", () => {
test("collage output can be downloaded", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
],
[
{
name: "settings",
value: JSON.stringify({
templateId: "2-h-equal",
width: 400,
outputFormat: "png",
}),
},
],
);
const res = await request.post("/api/v1/tools/collage", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
// Verify the collage can be downloaded
const dlRes = await request.get(json.downloadUrl, {
headers: { Authorization: `Bearer ${token}` },
});
expect(dlRes.ok()).toBe(true);
const buffer = Buffer.from(await dlRes.body());
expect(buffer.length).toBeGreaterThan(0);
});
test("collage with HEIC images", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.heic", contentType: "image/heic", buffer: HEIC_200x150 },
{ name: "file", filename: "b.png", contentType: "image/png", buffer: PNG_200x150 },
],
[
{
name: "settings",
value: JSON.stringify({
templateId: "2-h-equal",
width: 400,
outputFormat: "png",
}),
},
],
);
const res = await request.post("/api/v1/tools/collage", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
});
});
// ─── Stitch — Output Verification ───────────────────────────────
test.describe("Stitch — output verification", () => {
test("stitched image can be downloaded", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
],
[{ name: "settings", value: JSON.stringify({ direction: "horizontal", gap: 0 }) }],
);
const res = await request.post("/api/v1/tools/stitch", {
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
data: body,
});
expect(res.ok()).toBe(true);
const json = await res.json();
expect(json.downloadUrl).toBeTruthy();
const dlRes = await request.get(json.downloadUrl, {
headers: { Authorization: `Bearer ${token}` },
});
expect(dlRes.ok()).toBe(true);
const buffer = Buffer.from(await dlRes.body());
expect(buffer.length).toBeGreaterThan(0);
});
});
// ─── Border — Output Verification ───────────────────────────────
test.describe("Border — output verification", () => {
test("bordered image can be downloaded and is larger", async ({ request }) => {
const res = await request.post("/api/v1/tools/border", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
settings: JSON.stringify({ size: 20, color: "#FF0000" }),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.downloadUrl).toBeTruthy();
// Download and verify the bordered image
const dlRes = await request.get(body.downloadUrl, {
headers: { Authorization: `Bearer ${token}` },
});
expect(dlRes.ok()).toBe(true);
const buffer = Buffer.from(await dlRes.body());
expect(buffer.length).toBeGreaterThan(0);
});
test("border with minimum size (1px)", async ({ request }) => {
const res = await request.post("/api/v1/tools/border", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.jpg", mimeType: "image/jpeg", buffer: JPG_100x100 },
settings: JSON.stringify({ size: 1, color: "#000000" }),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.downloadUrl).toBeTruthy();
});
});
// ─── Auth Failure ──────────────────────────────────────────────────
test.describe("Auth failure", () => {
test("split without token returns 401", async ({ request }) => {
const res = await request.post("/api/v1/tools/split", {
multipart: {
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
settings: JSON.stringify({ columns: 2, rows: 2 }),
},
});
expect(res.status()).toBe(401);
});
test("border without token returns 401", async ({ request }) => {
const res = await request.post("/api/v1/tools/border", {
multipart: {
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
settings: JSON.stringify({ size: 10, color: "#ff0000" }),
},
});
expect(res.status()).toBe(401);
});
test("collage without token returns 401", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
],
[
{
name: "settings",
value: JSON.stringify({ templateId: "2-h-equal", width: 400 }),
},
],
);
const res = await request.post("/api/v1/tools/collage", {
headers: { "Content-Type": contentType },
data: body,
});
expect(res.status()).toBe(401);
});
test("stitch without token returns 401", async ({ request }) => {
const { body, contentType } = buildMultipart(
[
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
],
[{ name: "settings", value: JSON.stringify({ direction: "horizontal" }) }],
);
const res = await request.post("/api/v1/tools/stitch", {
headers: { "Content-Type": contentType },
data: body,
});
expect(res.status()).toBe(401);
});
});