mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(api): ✨ Add user emoji upload capabilities
This commit is contained in:
parent
980f4c8021
commit
da2520e60e
36 changed files with 5440 additions and 3340 deletions
|
|
@ -1,12 +1,5 @@
|
|||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
||||
import { afterAll, describe, expect, test } from "bun:test";
|
||||
import { config } from "config-manager";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "~drizzle/db";
|
||||
import { Emojis } from "~drizzle/schema";
|
||||
import type { Emoji as APIEmoji } from "~types/mastodon/emoji";
|
||||
import { getTestUsers, sendTestRequest, wrapRelativeUrl } from "./utils";
|
||||
|
||||
const base_url = config.http.base_url;
|
||||
|
|
@ -18,49 +11,6 @@ describe("API Tests", () => {
|
|||
await deleteUsers();
|
||||
});
|
||||
|
||||
describe("GET /api/v1/custom_emojis", () => {
|
||||
beforeAll(async () => {
|
||||
await db.insert(Emojis).values({
|
||||
shortcode: "test",
|
||||
url: "https://example.com/test.png",
|
||||
contentType: "image/png",
|
||||
visibleInPicker: true,
|
||||
});
|
||||
});
|
||||
|
||||
test("should return an array of at least one custom emoji", async () => {
|
||||
const response = await sendTestRequest(
|
||||
new Request(
|
||||
wrapRelativeUrl(
|
||||
`${base_url}/api/v1/custom_emojis`,
|
||||
base_url,
|
||||
),
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.headers.get("content-type")).toBe(
|
||||
"application/json",
|
||||
);
|
||||
|
||||
const emojis = (await response.json()) as APIEmoji[];
|
||||
|
||||
expect(emojis.length).toBeGreaterThan(0);
|
||||
expect(emojis[0].shortcode).toBeString();
|
||||
expect(emojis[0].url).toBeString();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await db.delete(Emojis).where(eq(Emojis.shortcode, "test"));
|
||||
});
|
||||
});
|
||||
|
||||
test("Try sending FormData without a boundary", async () => {
|
||||
const formData = new FormData();
|
||||
formData.append("test", "test");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue