mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
Add tests for status context
This commit is contained in:
parent
80a3e4c92d
commit
2e7ab312e0
|
|
@ -247,7 +247,7 @@ export class Status extends BaseEntity {
|
|||
where: {
|
||||
id: id,
|
||||
},
|
||||
relations: statusRelations,
|
||||
relations: statusAndUserRelations,
|
||||
});
|
||||
|
||||
if (currentStatus) {
|
||||
|
|
@ -295,7 +295,7 @@ export class Status extends BaseEntity {
|
|||
id: status.id,
|
||||
},
|
||||
},
|
||||
relations: statusRelations,
|
||||
relations: statusAndUserRelations,
|
||||
});
|
||||
|
||||
for (const status of currentStatus) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { applyConfig } from "@api";
|
||||
import { errorResponse, jsonResponse } from "@response";
|
||||
import { MatchedRoute } from "bun";
|
||||
import { Status, statusRelations } from "~database/entities/Status";
|
||||
import { Status, statusAndUserRelations } from "~database/entities/Status";
|
||||
import { User } from "~database/entities/User";
|
||||
import { APIRouteMeta } from "~types/api";
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ export default async (
|
|||
where: {
|
||||
id,
|
||||
},
|
||||
relations: statusRelations,
|
||||
relations: statusAndUserRelations,
|
||||
});
|
||||
} catch (e) {
|
||||
return errorResponse("Invalid ID", 404);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { RawActivity } from "~database/entities/RawActivity";
|
|||
import { Token, TokenType } from "~database/entities/Token";
|
||||
import { User } from "~database/entities/User";
|
||||
import { APIAccount } from "~types/entities/account";
|
||||
import { APIContext } from "~types/entities/context";
|
||||
import { APIEmoji } from "~types/entities/emoji";
|
||||
import { APIInstance } from "~types/entities/instance";
|
||||
import { APIRelationship } from "~types/entities/relationship";
|
||||
|
|
@ -756,6 +757,34 @@ describe("API Tests", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("GET /api/v1/statuses/:id/context", () => {
|
||||
test("should return the context of the specified status", async () => {
|
||||
const response = await fetch(
|
||||
`${config.http.base_url}/api/v1/statuses/${status?.id}/context`,
|
||||
{
|
||||
method: "GET",
|
||||
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 context = (await response.json()) as APIContext;
|
||||
|
||||
expect(context.ancestors.length).toBe(0);
|
||||
expect(context.descendants.length).toBe(1);
|
||||
|
||||
// First descendant should be status2
|
||||
expect(context.descendants[0].id).toBe(status2?.id);
|
||||
});
|
||||
});
|
||||
|
||||
describe("DELETE /api/v1/statuses/:id", () => {
|
||||
test("should delete the specified status object", async () => {
|
||||
const response = await fetch(
|
||||
|
|
|
|||
Loading…
Reference in a new issue