This commit is contained in:
Jesse Wierzbinski 2023-09-14 15:22:27 -10:00
parent aad3ee78d1
commit 8162a5050c
No known key found for this signature in database
GPG key ID: F9A1E418934E40B0
19 changed files with 922 additions and 84 deletions

View file

@ -150,6 +150,62 @@ describe("POST /@test/inbox", () => {
published: "2021-01-01T00:00:00.000Z",
});
});
test("should delete the Note object", async () => {
const response = await fetch(
`${config.http.base_url}:${config.http.port}/@test/inbox/`,
{
method: "POST",
headers: {
"Content-Type": "application/activity+json",
},
body: JSON.stringify({
"@context": "https://www.w3.org/ns/activitystreams",
type: "Delete",
id: "https://example.com/notes/1/activity",
actor: `${config.http.base_url}:${config.http.port}/@test`,
to: ["https://www.w3.org/ns/activitystreams#Public"],
cc: [],
published: "2021-01-03T00:00:00.000Z",
object: {
"@context": "https://www.w3.org/ns/activitystreams",
id: "https://example.com/notes/1",
type: "Note",
content: "This note has been deleted!",
summary: null,
inReplyTo: null,
published: "2021-01-01T00:00:00.000Z",
},
}),
}
);
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toBe("application/json");
const activity = await RawActivity.createQueryBuilder("activity")
// Where id is part of the jsonb column 'data'
.where("activity.data->>'id' = :id", {
id: "https://example.com/notes/1/activity",
})
.leftJoinAndSelect("activity.objects", "objects")
// Sort by most recent
.orderBy("activity.data->>'published'", "DESC")
.getOne();
expect(activity).not.toBeUndefined();
expect(activity?.data).toEqual({
"@context": "https://www.w3.org/ns/activitystreams",
type: "Delete",
id: "https://example.com/notes/1/activity",
actor: `${config.http.base_url}:${config.http.port}/@test`,
to: ["https://www.w3.org/ns/activitystreams#Public"],
cc: [],
published: "2021-01-03T00:00:00.000Z",
});
expect(activity?.objects).toHaveLength(0);
});
});
afterAll(async () => {

View file

@ -89,7 +89,7 @@ describe("POST /auth/login/", () => {
});
});
describe("POST /v1/oauth/token/", () => {
describe("POST /oauth/token/", () => {
test("should get an access token", async () => {
const formData = new FormData();
@ -101,7 +101,7 @@ describe("POST /v1/oauth/token/", () => {
formData.append("scope", "read write");
const response = await fetch(
`${config.http.base_url}:${config.http.port}/v1/oauth/token/`,
`${config.http.base_url}:${config.http.port}/oauth/token/`,
{
method: "POST",
body: formData,

0
tests/test-utils.ts Normal file
View file