mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(database): ♻️ Move Token to its own ORM abstraction, optimize familiar_followers route
This commit is contained in:
parent
962c159ddd
commit
845041e4db
55 changed files with 694 additions and 504 deletions
|
|
@ -27,7 +27,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -40,7 +40,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -56,7 +56,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -46,7 +46,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -64,7 +64,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ beforeAll(async () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -33,7 +33,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", users[1].id),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -54,7 +54,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -65,7 +65,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", users[1].id),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ beforeAll(async () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -33,7 +33,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", users[0].id),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -54,7 +54,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -65,7 +65,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", users[0].id),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ beforeAll(async () => {
|
|||
await fakeRequest(`/api/v1/statuses/${status.id}/favourite`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -46,7 +46,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -64,7 +64,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ beforeAll(async () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -33,7 +33,7 @@ describe(meta.route, () => {
|
|||
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -53,7 +53,7 @@ describe(meta.route, () => {
|
|||
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -72,7 +72,7 @@ describe(meta.route, () => {
|
|||
const replyResponse = await fakeRequest("/api/v1/statuses", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Reply",
|
||||
|
|
@ -88,7 +88,7 @@ describe(meta.route, () => {
|
|||
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -108,7 +108,7 @@ describe(meta.route, () => {
|
|||
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -126,7 +126,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -138,7 +138,7 @@ describe(meta.route, () => {
|
|||
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ beforeAll(async () => {
|
|||
await fakeRequest(`/api/v1/accounts/${users[0].id}/mute`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
@ -36,7 +36,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -49,7 +49,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -65,7 +65,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
156
api/api/v1/accounts/familiar_followers/index.test.ts
Normal file
156
api/api/v1/accounts/familiar_followers/index.test.ts
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
||||
import { fakeRequest, getTestUsers } from "~/tests/utils.ts";
|
||||
import { meta } from "./index.ts";
|
||||
|
||||
const { users, tokens, deleteUsers } = await getTestUsers(5);
|
||||
|
||||
beforeAll(async () => {
|
||||
// Create followers relationships
|
||||
const result1 = await fakeRequest(
|
||||
`/api/v1/accounts/${users[1].id}/follow`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(result1.status).toBe(200);
|
||||
|
||||
const result2 = await fakeRequest(
|
||||
`/api/v1/accounts/${users[2].id}/follow`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(result2.status).toBe(200);
|
||||
|
||||
const result3 = await fakeRequest(
|
||||
`/api/v1/accounts/${users[3].id}/follow`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(result3.status).toBe(200);
|
||||
|
||||
const result4 = await fakeRequest(
|
||||
`/api/v1/accounts/${users[2].id}/follow`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(result4.status).toBe(200);
|
||||
|
||||
const result5 = await fakeRequest(
|
||||
`/api/v1/accounts/${users[3].id}/follow`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(result5.status).toBe(200);
|
||||
|
||||
const result6 = await fakeRequest(
|
||||
`/api/v1/accounts/${users[3].id}/follow`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[2].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(result6.status).toBe(200);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await deleteUsers();
|
||||
});
|
||||
|
||||
describe(meta.route, () => {
|
||||
test("should return 0 familiar followers", async () => {
|
||||
const response = await fakeRequest(`${meta.route}?id=${users[4].id}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
const data = await response.json();
|
||||
expect(data.length).toBe(1);
|
||||
expect(data[0].id).toBe(users[4].id);
|
||||
expect(data[0].accounts).toBeArrayOfSize(0);
|
||||
});
|
||||
|
||||
test("should return 1 familiar follower", async () => {
|
||||
const response = await fakeRequest(`${meta.route}?id=${users[2].id}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
const data = await response.json();
|
||||
expect(data.length).toBe(1);
|
||||
expect(data[0].id).toBe(users[2].id);
|
||||
expect(data[0].accounts[0].id).toBe(users[1].id);
|
||||
});
|
||||
|
||||
test("should return 2 familiar followers", async () => {
|
||||
const response = await fakeRequest(`${meta.route}?id=${users[3].id}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
const data = await response.json();
|
||||
expect(data.length).toBe(1);
|
||||
expect(data[0].id).toBe(users[3].id);
|
||||
expect(data[0].accounts).toBeArrayOfSize(2);
|
||||
expect(data[0].accounts[0].id).toBe(users[2].id);
|
||||
expect(data[0].accounts[1].id).toBe(users[1].id);
|
||||
});
|
||||
|
||||
test("should work with multiple ids", async () => {
|
||||
const response = await fakeRequest(
|
||||
`${meta.route}?id[]=${users[2].id}&id[]=${users[3].id}&id[]=${users[4].id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
const data = await response.json();
|
||||
expect(data.length).toBe(3);
|
||||
expect(data[0].id).toBe(users[2].id);
|
||||
expect(data[0].accounts[0].id).toBe(users[1].id);
|
||||
expect(data[1].id).toBe(users[3].id);
|
||||
expect(data[1].accounts[0].id).toBe(users[2].id);
|
||||
expect(data[1].accounts[1].id).toBe(users[1].id);
|
||||
expect(data[2].id).toBe(users[4].id);
|
||||
expect(data[2].accounts).toBeArrayOfSize(0);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import { apiRoute, applyConfig, auth, qsQuery } from "@/api";
|
||||
import { createRoute } from "@hono/zod-openapi";
|
||||
import { User, db } from "@versia/kit/db";
|
||||
import { RolePermissions, Users } from "@versia/kit/tables";
|
||||
import { type SQL, inArray } from "drizzle-orm";
|
||||
import { RolePermissions, type Users } from "@versia/kit/tables";
|
||||
import { type InferSelectModel, sql } from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
import { ErrorSchema } from "~/types/api";
|
||||
|
||||
|
|
@ -23,7 +23,12 @@ export const meta = applyConfig({
|
|||
|
||||
export const schemas = {
|
||||
query: z.object({
|
||||
id: z.array(z.string().uuid()).min(1).max(10).or(z.string().uuid()),
|
||||
id: z
|
||||
.array(z.string().uuid())
|
||||
.min(1)
|
||||
.max(10)
|
||||
.or(z.string().uuid())
|
||||
.transform((v) => (Array.isArray(v) ? v : [v])),
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
@ -42,7 +47,12 @@ const route = createRoute({
|
|||
description: "Familiar followers",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.array(User.schema),
|
||||
schema: z.array(
|
||||
z.object({
|
||||
id: z.string().uuid(),
|
||||
accounts: z.array(User.schema),
|
||||
}),
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -66,53 +76,35 @@ export default apiRoute((app) =>
|
|||
return context.json({ error: "Unauthorized" }, 401);
|
||||
}
|
||||
|
||||
const idFollowerRelationships = await db.query.Relationships.findMany({
|
||||
columns: {
|
||||
ownerId: true,
|
||||
},
|
||||
where: (relationship, { inArray, and, eq }): SQL | undefined =>
|
||||
and(
|
||||
inArray(
|
||||
relationship.subjectId,
|
||||
Array.isArray(ids) ? ids : [ids],
|
||||
),
|
||||
eq(relationship.following, true),
|
||||
// Find followers of the accounts in "ids", that you also follow
|
||||
const finalUsers = await Promise.all(
|
||||
ids.map(async (id) => ({
|
||||
id,
|
||||
accounts: await User.fromIds(
|
||||
(
|
||||
await db.execute(sql<InferSelectModel<typeof Users>>`
|
||||
SELECT "Users"."id" FROM "Users"
|
||||
INNER JOIN "Relationships" AS "SelfFollowing"
|
||||
ON "SelfFollowing"."subjectId" = "Users"."id"
|
||||
WHERE "SelfFollowing"."ownerId" = ${self.id}
|
||||
AND "SelfFollowing"."following" = true
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM "Relationships" AS "IdsFollowers"
|
||||
WHERE "IdsFollowers"."subjectId" = ${id}
|
||||
AND "IdsFollowers"."ownerId" = "Users"."id"
|
||||
AND "IdsFollowers"."following" = true
|
||||
)
|
||||
`)
|
||||
).rows.map((u) => u.id as string),
|
||||
),
|
||||
});
|
||||
|
||||
if (idFollowerRelationships.length === 0) {
|
||||
return context.json([], 200);
|
||||
}
|
||||
|
||||
// Find users that you follow in idFollowerRelationships
|
||||
const relevantRelationships = await db.query.Relationships.findMany({
|
||||
columns: {
|
||||
subjectId: true,
|
||||
},
|
||||
where: (relationship, { inArray, and, eq }): SQL | undefined =>
|
||||
and(
|
||||
eq(relationship.ownerId, self.id),
|
||||
inArray(
|
||||
relationship.subjectId,
|
||||
idFollowerRelationships.map((f) => f.ownerId),
|
||||
),
|
||||
eq(relationship.following, true),
|
||||
),
|
||||
});
|
||||
|
||||
if (relevantRelationships.length === 0) {
|
||||
return context.json([], 200);
|
||||
}
|
||||
|
||||
const finalUsers = await User.manyFromSql(
|
||||
inArray(
|
||||
Users.id,
|
||||
relevantRelationships.map((r) => r.subjectId),
|
||||
),
|
||||
})),
|
||||
);
|
||||
|
||||
return context.json(
|
||||
finalUsers.map((o) => o.toApi()),
|
||||
finalUsers.map((u) => ({
|
||||
...u,
|
||||
accounts: u.accounts.map((a) => a.toApi()),
|
||||
})),
|
||||
200,
|
||||
);
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?acct=${users[0].data.username}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ beforeAll(async () => {
|
|||
const res1 = await fakeRequest(`/api/v1/accounts/${users[0].id}/follow`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -30,7 +30,7 @@ beforeAll(async () => {
|
|||
const res2 = await fakeRequest(`/api/v1/accounts/${users[2].id}/follow`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -56,7 +56,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?id[]=${users[2].id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -86,7 +86,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?id[]=${users[1].id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?q=${users[0].data.username}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,9 @@ export default apiRoute((app) =>
|
|||
return context.json({ error: "Unauthorized" }, 401);
|
||||
}
|
||||
|
||||
const application = await Application.getFromToken(token);
|
||||
const application = await Application.getFromToken(
|
||||
token.data.accessToken,
|
||||
);
|
||||
|
||||
if (!application) {
|
||||
return context.json({ error: "Unauthorized" }, 401);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ beforeAll(async () => {
|
|||
// Upload one emoji as admin, then one as each user
|
||||
const response = await fakeRequest("/api/v1/emojis", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "POST",
|
||||
|
|
@ -29,7 +29,7 @@ beforeAll(async () => {
|
|||
|
||||
await fakeRequest("/api/v1/emojis", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "POST",
|
||||
|
|
@ -41,7 +41,7 @@ beforeAll(async () => {
|
|||
|
||||
await fakeRequest("/api/v1/emojis", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "POST",
|
||||
|
|
@ -64,7 +64,7 @@ describe(meta.route, () => {
|
|||
test("should return all global emojis", async () => {
|
||||
const response = await fakeRequest(meta.route, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ describe(meta.route, () => {
|
|||
test("should return all user emojis", async () => {
|
||||
const response = await fakeRequest(meta.route, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ beforeAll(async () => {
|
|||
// Create an emoji
|
||||
const response = await fakeRequest("/api/v1/emojis", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "POST",
|
||||
|
|
@ -55,7 +55,7 @@ describe(meta.route, () => {
|
|||
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
method: "GET",
|
||||
},
|
||||
|
|
@ -67,7 +67,7 @@ describe(meta.route, () => {
|
|||
test("should not work if the user is trying to update an emoji they don't own", async () => {
|
||||
const response = await fakeRequest(meta.route.replace(":id", id), {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "PATCH",
|
||||
|
|
@ -82,7 +82,7 @@ describe(meta.route, () => {
|
|||
test("should return the emoji", async () => {
|
||||
const response = await fakeRequest(meta.route.replace(":id", id), {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
method: "GET",
|
||||
});
|
||||
|
|
@ -95,7 +95,7 @@ describe(meta.route, () => {
|
|||
test("should update the emoji", async () => {
|
||||
const response = await fakeRequest(meta.route.replace(":id", id), {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "PATCH",
|
||||
|
|
@ -112,7 +112,7 @@ describe(meta.route, () => {
|
|||
test("should update the emoji with another url, but keep the shortcode", async () => {
|
||||
const response = await fakeRequest(meta.route.replace(":id", id), {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "PATCH",
|
||||
|
|
@ -129,7 +129,7 @@ describe(meta.route, () => {
|
|||
test("should update the emoji to be non-global", async () => {
|
||||
const response = await fakeRequest(meta.route.replace(":id", id), {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "PATCH",
|
||||
|
|
@ -143,7 +143,7 @@ describe(meta.route, () => {
|
|||
// Check if the other user can see it
|
||||
const response2 = await fakeRequest("/api/v1/custom_emojis", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
method: "GET",
|
||||
});
|
||||
|
|
@ -156,7 +156,7 @@ describe(meta.route, () => {
|
|||
test("should delete the emoji", async () => {
|
||||
const response = await fakeRequest(meta.route.replace(":id", id), {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
method: "DELETE",
|
||||
});
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
|
@ -83,7 +83,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
|
@ -95,7 +95,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
|
|
@ -118,7 +118,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
|
@ -136,7 +136,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
|
@ -155,7 +155,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
|
@ -171,7 +171,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[2].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[2].data.accessToken}`,
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -45,7 +45,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -69,7 +69,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ beforeAll(async () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -41,7 +41,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
|
|
@ -62,7 +62,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -73,7 +73,7 @@ describe(meta.route, () => {
|
|||
const response2 = await fakeRequest(meta.route, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
expect(response2.status).toBe(200);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ beforeAll(async () => {
|
|||
await fakeRequest(`/api/v1/accounts/${users[0].id}/follow`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -19,7 +19,7 @@ beforeAll(async () => {
|
|||
|
||||
notifications = await fakeRequest("/api/v1/notifications", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
}).then((r) => r.json());
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -60,7 +60,7 @@ describe(meta.route, () => {
|
|||
test("should not display dismissed notification", async () => {
|
||||
const response = await fakeRequest("/api/v1/notifications", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ beforeAll(async () => {
|
|||
await fakeRequest(`/api/v1/accounts/${users[0].id}/follow`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -19,7 +19,7 @@ beforeAll(async () => {
|
|||
|
||||
notifications = await fakeRequest("/api/v1/notifications", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
}).then((r) => r.json());
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", "invalid"),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -57,7 +57,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", "00000000-0000-0000-0000-000000000000"),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -70,7 +70,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", notifications[0].id),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ beforeAll(async () => {
|
|||
await fakeRequest(`/api/v1/accounts/${users[0].id}/follow`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -19,7 +19,7 @@ beforeAll(async () => {
|
|||
|
||||
notifications = await fakeRequest("/api/v1/notifications", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
}).then((r) => r.json());
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ describe(meta.route, () => {
|
|||
|
||||
const newNotifications = await fakeRequest("/api/v1/notifications", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
}).then((r) => r.json());
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ beforeAll(async () => {
|
|||
await fakeRequest(`/api/v1/accounts/${users[0].id}/follow`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -22,7 +22,7 @@ beforeAll(async () => {
|
|||
await fakeRequest(`/api/v1/statuses/${statuses[i].id}/favourite`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -31,7 +31,7 @@ beforeAll(async () => {
|
|||
|
||||
notifications = await fakeRequest("/api/v1/notifications", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
}).then((r) => r.json());
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -76,7 +76,7 @@ describe(meta.route, () => {
|
|||
test("should not display dismissed notification", async () => {
|
||||
const response = await fakeRequest("/api/v1/notifications", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ beforeAll(async () => {
|
|||
const res1 = await fakeRequest(`/api/v1/accounts/${users[0].id}/follow`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -31,7 +31,7 @@ beforeAll(async () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
|
|
@ -45,7 +45,7 @@ beforeAll(async () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
body: getFormData({}),
|
||||
},
|
||||
|
|
@ -56,7 +56,7 @@ beforeAll(async () => {
|
|||
const res4 = await fakeRequest("/api/v1/statuses", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: `@${users[0].data.username} test mention`,
|
||||
|
|
@ -83,7 +83,7 @@ describe(meta.route, () => {
|
|||
test("should return 200 with notifications", async () => {
|
||||
const response = await fakeRequest(meta.route, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ describe(meta.route, () => {
|
|||
const filterResponse = await fakeRequest("/api/v2/filters", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
|
|
@ -132,7 +132,7 @@ describe(meta.route, () => {
|
|||
|
||||
const response = await fakeRequest(`${meta.route}?limit=20`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -89,7 +89,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route.replace(":id", role.id), {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -133,7 +133,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -144,7 +144,7 @@ describe(meta.route, () => {
|
|||
const response2 = await fakeRequest("/api/v1/roles", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route.replace(":id", role.id), {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ describe(meta.route, () => {
|
|||
const response2 = await fakeRequest("/api/v1/roles", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -47,7 +47,7 @@ describe(meta.route, () => {
|
|||
`/api/v1/statuses/${timeline[0].id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ beforeAll(async () => {
|
|||
await fakeRequest(`/api/v1/statuses/${status.id}/favourite`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", timeline[0].id),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ beforeAll(async () => {
|
|||
await fakeRequest(`/api/v1/statuses/${status.id}/reblog`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", timeline[0].id),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -42,7 +42,7 @@ describe(meta.route, () => {
|
|||
await fakeRequest(`/api/v1/statuses/${timeline[1].id}/favourite`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
@ -52,7 +52,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -70,7 +70,7 @@ describe(meta.route, () => {
|
|||
`/api/v1/statuses/${timeline[1].id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[1].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[1].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams(),
|
||||
});
|
||||
|
|
@ -51,7 +51,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "a".repeat(config.validation.max_note_size + 1),
|
||||
|
|
@ -66,7 +66,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world!",
|
||||
|
|
@ -82,7 +82,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world!",
|
||||
|
|
@ -98,7 +98,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world!",
|
||||
|
|
@ -114,7 +114,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world!",
|
||||
|
|
@ -130,7 +130,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world!",
|
||||
|
|
@ -146,7 +146,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world!",
|
||||
|
|
@ -169,7 +169,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
|
|
@ -194,7 +194,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world!",
|
||||
|
|
@ -207,7 +207,7 @@ describe(meta.route, () => {
|
|||
const response2 = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world again!",
|
||||
|
|
@ -231,7 +231,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world!",
|
||||
|
|
@ -244,7 +244,7 @@ describe(meta.route, () => {
|
|||
const response2 = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world again!",
|
||||
|
|
@ -268,7 +268,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, :test:!",
|
||||
|
|
@ -295,7 +295,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: `Hello, @${users[1].data.username}!`,
|
||||
|
|
@ -322,7 +322,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: `Hello, @${users[1].data.username}@${
|
||||
|
|
@ -353,7 +353,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hi! <script>alert('Hello, world!');</script>",
|
||||
|
|
@ -377,7 +377,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "Hello, world!",
|
||||
|
|
@ -403,7 +403,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
status: "<img src='https://example.com/image.jpg'> <video src='https://example.com/video.mp4'> Test!",
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ describe(meta.route, () => {
|
|||
test("should correctly parse limit", async () => {
|
||||
const response = await fakeRequest(`${meta.route}?limit=5`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ describe(meta.route, () => {
|
|||
test("should return 200 with statuses", async () => {
|
||||
const response = await fakeRequest(meta.route, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ describe(meta.route, () => {
|
|||
test("should send correct Link header", async () => {
|
||||
const response = await fakeRequest(`${meta.route}?limit=20`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?limit=20&max_id=${timeline[19].id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -104,7 +104,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?limit=20&max_id=${timeline[19].id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -119,7 +119,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?limit=20&min_id=${timeline[20].id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -145,7 +145,7 @@ describe(meta.route, () => {
|
|||
const filterResponse = await fakeRequest("/api/v2/filters", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
|
|
@ -162,7 +162,7 @@ describe(meta.route, () => {
|
|||
|
||||
const response = await fakeRequest(`${meta.route}?limit=20`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ describe(meta.route, () => {
|
|||
test("should correctly parse limit", async () => {
|
||||
const response = await fakeRequest(`${meta.route}?limit=5`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ describe(meta.route, () => {
|
|||
test("should return 200 with statuses", async () => {
|
||||
const response = await fakeRequest(meta.route, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?limit=20&local=true`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -85,7 +85,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?remote=true&allow_local_only=false&only_media=false`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -104,7 +104,7 @@ describe(meta.route, () => {
|
|||
test("should send correct Link header", async () => {
|
||||
const response = await fakeRequest(`${meta.route}?limit=20`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?limit=20&max_id=${timeline[19].id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -145,7 +145,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?limit=20&max_id=${timeline[19].id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -160,7 +160,7 @@ describe(meta.route, () => {
|
|||
`${meta.route}?limit=20&min_id=${timeline[20].id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -187,7 +187,7 @@ describe(meta.route, () => {
|
|||
const filterResponse = await fakeRequest("/api/v2/filters", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
|
|
@ -206,7 +206,7 @@ describe(meta.route, () => {
|
|||
|
||||
const response = await fakeRequest(`${meta.route}?limit=20`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const { tokens, deleteUsers } = await getTestUsers(2);
|
|||
const response = await fakeRequest("/api/v2/filters", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
|
|
@ -49,7 +49,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", filter.id),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -75,7 +75,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "PUT",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
|
|
@ -111,7 +111,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "PUT",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
"keywords_attributes[0][id]": filter.keywords[0].id,
|
||||
|
|
@ -131,7 +131,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", filter.id),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
@ -148,7 +148,7 @@ describe(meta.route, () => {
|
|||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
body: formData,
|
||||
},
|
||||
|
|
@ -161,7 +161,7 @@ describe(meta.route, () => {
|
|||
meta.route.replace(":id", filter.id),
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ describe(meta.route, () => {
|
|||
test("should return user filters (none)", async () => {
|
||||
const response = await fakeRequest(meta.route, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ describe(meta.route, () => {
|
|||
const response = await fakeRequest(meta.route, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens[0].accessToken}`,
|
||||
Authorization: `Bearer ${tokens[0].data.accessToken}`,
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue