mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
Tweaks to test
This commit is contained in:
parent
dbf855df18
commit
3c289dd3de
|
|
@ -4,7 +4,7 @@ import { User } from "~database/entities/User";
|
||||||
import { applyConfig } from "@api";
|
import { applyConfig } from "@api";
|
||||||
|
|
||||||
export const meta = applyConfig({
|
export const meta = applyConfig({
|
||||||
allowedMethods: ["POST"],
|
allowedMethods: ["GET"],
|
||||||
ratelimits: {
|
ratelimits: {
|
||||||
max: 30,
|
max: 30,
|
||||||
duration: 60,
|
duration: 60,
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,9 @@ describe("GET /api/v1/accounts/verify_credentials", () => {
|
||||||
expect(account.following_count).toBe(0);
|
expect(account.following_count).toBe(0);
|
||||||
expect(account.statuses_count).toBe(0);
|
expect(account.statuses_count).toBe(0);
|
||||||
expect(account.note).toBe("");
|
expect(account.note).toBe("");
|
||||||
expect(account.url).toBe(`${config.http.base_url}/users/${user.username}`);
|
expect(account.url).toBe(
|
||||||
|
`${config.http.base_url}/users/${user.username}`
|
||||||
|
);
|
||||||
expect(account.avatar).toBeDefined();
|
expect(account.avatar).toBeDefined();
|
||||||
expect(account.avatar_static).toBeDefined();
|
expect(account.avatar_static).toBeDefined();
|
||||||
expect(account.header).toBeDefined();
|
expect(account.header).toBeDefined();
|
||||||
|
|
|
||||||
|
|
@ -23,34 +23,38 @@ describe("POST /@test/inbox", () => {
|
||||||
test("should store a new Note object", async () => {
|
test("should store a new Note object", async () => {
|
||||||
const activityId = `https://example.com/objects/${crypto.randomUUID()}`;
|
const activityId = `https://example.com/objects/${crypto.randomUUID()}`;
|
||||||
|
|
||||||
const response = await fetch(`${config.http.base_url}/users/test/inbox/`, {
|
const response = await fetch(
|
||||||
method: "POST",
|
`${config.http.base_url}/users/test/inbox/`,
|
||||||
headers: {
|
{
|
||||||
"Content-Type": "application/activity+json",
|
method: "POST",
|
||||||
},
|
headers: {
|
||||||
body: JSON.stringify({
|
"Content-Type": "application/activity+json",
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
Origin: "http://lysand-test.localhost",
|
||||||
type: "Create",
|
|
||||||
id: activityId,
|
|
||||||
actor: {
|
|
||||||
id: `${config.http.base_url}/users/test`,
|
|
||||||
type: "Person",
|
|
||||||
preferredUsername: "test",
|
|
||||||
},
|
},
|
||||||
to: ["https://www.w3.org/ns/activitystreams#Public"],
|
body: JSON.stringify({
|
||||||
cc: [],
|
|
||||||
published: "2021-01-01T00:00:00.000Z",
|
|
||||||
object: {
|
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
id: "https://example.com/notes/1",
|
type: "Create",
|
||||||
type: "Note",
|
id: activityId,
|
||||||
content: "Hello, world!",
|
actor: {
|
||||||
summary: null,
|
id: `${config.http.base_url}/users/test`,
|
||||||
inReplyTo: null,
|
type: "Person",
|
||||||
|
preferredUsername: "test",
|
||||||
|
},
|
||||||
|
to: ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
|
cc: [],
|
||||||
published: "2021-01-01T00:00:00.000Z",
|
published: "2021-01-01T00:00:00.000Z",
|
||||||
},
|
object: {
|
||||||
}),
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
});
|
id: "https://example.com/notes/1",
|
||||||
|
type: "Note",
|
||||||
|
content: "Hello, world!",
|
||||||
|
summary: null,
|
||||||
|
inReplyTo: null,
|
||||||
|
published: "2021-01-01T00:00:00.000Z",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
expect(response.headers.get("content-type")).toBe("application/json");
|
expect(response.headers.get("content-type")).toBe("application/json");
|
||||||
|
|
@ -82,34 +86,38 @@ describe("POST /@test/inbox", () => {
|
||||||
test("should try to update that Note object", async () => {
|
test("should try to update that Note object", async () => {
|
||||||
const activityId = `https://example.com/objects/${crypto.randomUUID()}`;
|
const activityId = `https://example.com/objects/${crypto.randomUUID()}`;
|
||||||
|
|
||||||
const response = await fetch(`${config.http.base_url}/users/test/inbox/`, {
|
const response = await fetch(
|
||||||
method: "POST",
|
`${config.http.base_url}/users/test/inbox/`,
|
||||||
headers: {
|
{
|
||||||
"Content-Type": "application/activity+json",
|
method: "POST",
|
||||||
},
|
headers: {
|
||||||
body: JSON.stringify({
|
"Content-Type": "application/activity+json",
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
Origin: "http://lysand-test.localhost",
|
||||||
type: "Update",
|
|
||||||
id: activityId,
|
|
||||||
actor: {
|
|
||||||
id: `${config.http.base_url}/users/test`,
|
|
||||||
type: "Person",
|
|
||||||
preferredUsername: "test",
|
|
||||||
},
|
},
|
||||||
to: ["https://www.w3.org/ns/activitystreams#Public"],
|
body: JSON.stringify({
|
||||||
cc: [],
|
|
||||||
published: "2021-01-02T00:00:00.000Z",
|
|
||||||
object: {
|
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
id: "https://example.com/notes/1",
|
type: "Update",
|
||||||
type: "Note",
|
id: activityId,
|
||||||
content: "This note has been edited!",
|
actor: {
|
||||||
summary: null,
|
id: `${config.http.base_url}/users/test`,
|
||||||
inReplyTo: null,
|
type: "Person",
|
||||||
published: "2021-01-01T00:00:00.000Z",
|
preferredUsername: "test",
|
||||||
},
|
},
|
||||||
}),
|
to: ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
});
|
cc: [],
|
||||||
|
published: "2021-01-02T00:00:00.000Z",
|
||||||
|
object: {
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
id: "https://example.com/notes/1",
|
||||||
|
type: "Note",
|
||||||
|
content: "This note has been edited!",
|
||||||
|
summary: null,
|
||||||
|
inReplyTo: null,
|
||||||
|
published: "2021-01-01T00:00:00.000Z",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
expect(response.headers.get("content-type")).toBe("application/json");
|
expect(response.headers.get("content-type")).toBe("application/json");
|
||||||
|
|
@ -140,34 +148,38 @@ describe("POST /@test/inbox", () => {
|
||||||
|
|
||||||
test("should delete the Note object", async () => {
|
test("should delete the Note object", async () => {
|
||||||
const activityId = `https://example.com/objects/${crypto.randomUUID()}`;
|
const activityId = `https://example.com/objects/${crypto.randomUUID()}`;
|
||||||
const response = await fetch(`${config.http.base_url}/users/test/inbox/`, {
|
const response = await fetch(
|
||||||
method: "POST",
|
`${config.http.base_url}/users/test/inbox/`,
|
||||||
headers: {
|
{
|
||||||
"Content-Type": "application/activity+json",
|
method: "POST",
|
||||||
},
|
headers: {
|
||||||
body: JSON.stringify({
|
"Content-Type": "application/activity+json",
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
Origin: "http://lysand-test.localhost",
|
||||||
type: "Delete",
|
|
||||||
id: activityId,
|
|
||||||
actor: {
|
|
||||||
id: `${config.http.base_url}/users/test`,
|
|
||||||
type: "Person",
|
|
||||||
preferredUsername: "test",
|
|
||||||
},
|
},
|
||||||
to: ["https://www.w3.org/ns/activitystreams#Public"],
|
body: JSON.stringify({
|
||||||
cc: [],
|
|
||||||
published: "2021-01-03T00:00:00.000Z",
|
|
||||||
object: {
|
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
id: "https://example.com/notes/1",
|
type: "Delete",
|
||||||
type: "Note",
|
id: activityId,
|
||||||
content: "This note has been edited!",
|
actor: {
|
||||||
summary: null,
|
id: `${config.http.base_url}/users/test`,
|
||||||
inReplyTo: null,
|
type: "Person",
|
||||||
published: "2021-01-01T00:00:00.000Z",
|
preferredUsername: "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 edited!",
|
||||||
|
summary: null,
|
||||||
|
inReplyTo: null,
|
||||||
|
published: "2021-01-01T00:00:00.000Z",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
expect(response.headers.get("content-type")).toBe("application/json");
|
expect(response.headers.get("content-type")).toBe("application/json");
|
||||||
|
|
@ -226,30 +238,34 @@ describe("POST /@test/inbox", () => {
|
||||||
test("should return a 404 error when trying to delete a non-existent Note object", async () => {
|
test("should return a 404 error when trying to delete a non-existent Note object", async () => {
|
||||||
const activityId = `https://example.com/objects/${crypto.randomUUID()}`;
|
const activityId = `https://example.com/objects/${crypto.randomUUID()}`;
|
||||||
|
|
||||||
const response = await fetch(`${config.http.base_url}/users/test/inbox/`, {
|
const response = await fetch(
|
||||||
method: "POST",
|
`${config.http.base_url}/users/test/inbox/`,
|
||||||
headers: {
|
{
|
||||||
"Content-Type": "application/activity+json",
|
method: "POST",
|
||||||
},
|
headers: {
|
||||||
body: JSON.stringify({
|
"Content-Type": "application/activity+json",
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
Origin: "http://lysand-test.localhost",
|
||||||
type: "Delete",
|
|
||||||
id: activityId,
|
|
||||||
actor: {
|
|
||||||
id: `${config.http.base_url}/users/test`,
|
|
||||||
type: "Person",
|
|
||||||
preferredUsername: "test",
|
|
||||||
},
|
},
|
||||||
to: ["https://www.w3.org/ns/activitystreams#Public"],
|
body: JSON.stringify({
|
||||||
cc: [],
|
|
||||||
published: "2021-01-03T00:00:00.000Z",
|
|
||||||
object: {
|
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
id: "https://example.com/notes/2345678909876543",
|
type: "Delete",
|
||||||
type: "Note",
|
id: activityId,
|
||||||
},
|
actor: {
|
||||||
}),
|
id: `${config.http.base_url}/users/test`,
|
||||||
});
|
type: "Person",
|
||||||
|
preferredUsername: "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/2345678909876543",
|
||||||
|
type: "Note",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
expect(response.status).toBe(404);
|
expect(response.status).toBe(404);
|
||||||
expect(response.headers.get("content-type")).toBe("application/json");
|
expect(response.headers.get("content-type")).toBe("application/json");
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
"strictFunctionTypes": true,
|
"strictFunctionTypes": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": false,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"types": [
|
"types": [
|
||||||
"bun-types" // add Bun global
|
"bun-types" // add Bun global
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue