Add reblog and unreblog endpoints

This commit is contained in:
Jesse Wierzbinski 2023-11-11 22:28:06 -10:00
parent 5bba96435c
commit ca94c35bc4
No known key found for this signature in database
GPG key ID: F9A1E418934E40B0
9 changed files with 368 additions and 7 deletions

View file

@ -503,6 +503,56 @@ describe("API Tests", () => {
});
});
describe("DELETE /api/v1/profile/avatar", () => {
test("should delete the avatar of the authenticated user and return the updated account object", async () => {
const response = await fetch(
`${config.http.base_url}/api/v1/profile/avatar`,
{
method: "DELETE",
headers: {
Authorization: `Bearer ${token.access_token}`,
"Content-Type": "application/json",
},
}
);
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toBe(
"application/json"
);
const account = (await response.json()) as APIAccount;
expect(account.id).toBeDefined();
expect(account.avatar).toBe("");
});
});
describe("DELETE /api/v1/profile/header", () => {
test("should delete the header of the authenticated user and return the updated account object", async () => {
const response = await fetch(
`${config.http.base_url}/api/v1/profile/header`,
{
method: "DELETE",
headers: {
Authorization: `Bearer ${token.access_token}`,
"Content-Type": "application/json",
},
}
);
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toBe(
"application/json"
);
const account = (await response.json()) as APIAccount;
expect(account.id).toBeDefined();
expect(account.header).toBe("");
});
});
describe("GET /api/v1/accounts/familiar_followers", () => {
test("should follow the user", async () => {
const response = await fetch(

View file

@ -200,6 +200,57 @@ describe("API Tests", () => {
});
});
describe("POST /api/v1/statuses/:id/reblog", () => {
test("should reblog the specified status and return the reblogged status object", async () => {
const response = await fetch(
`${config.http.base_url}/api/v1/statuses/${status?.id}/reblog`,
{
method: "POST",
headers: {
Authorization: `Bearer ${token.access_token}`,
"Content-Type": "application/json",
},
}
);
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toBe(
"application/json"
);
const rebloggedStatus = (await response.json()) as APIStatus;
expect(rebloggedStatus.id).toBeDefined();
expect(rebloggedStatus.reblog?.id).toEqual(status?.id ?? "");
expect(rebloggedStatus.reblog?.reblogged).toBe(true);
});
});
describe("POST /api/v1/statuses/:id/unreblog", () => {
test("should unreblog the specified status and return the original status object", async () => {
const response = await fetch(
`${config.http.base_url}/api/v1/statuses/${status?.id}/unreblog`,
{
method: "POST",
headers: {
Authorization: `Bearer ${token.access_token}`,
"Content-Type": "application/json",
},
}
);
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toBe(
"application/json"
);
const unrebloggedStatus = (await response.json()) as APIStatus;
expect(unrebloggedStatus.id).toBeDefined();
expect(unrebloggedStatus.reblogged).toBe(false);
});
});
describe("GET /api/v1/statuses/:id/context", () => {
test("should return the context of the specified status", async () => {
const response = await fetch(