diff --git a/api/api/v1/accounts/:id/block.test.ts b/api/api/v1/accounts/:id/block.test.ts index 41d3a0c7..7bad98cd 100644 --- a/api/api/v1/accounts/:id/block.test.ts +++ b/api/api/v1/accounts/:id/block.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/accounts/:id/follow.test.ts b/api/api/v1/accounts/:id/follow.test.ts index 4c8d8b48..a8c5efcf 100644 --- a/api/api/v1/accounts/:id/follow.test.ts +++ b/api/api/v1/accounts/:id/follow.test.ts @@ -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({}), diff --git a/api/api/v1/accounts/:id/followers.test.ts b/api/api/v1/accounts/:id/followers.test.ts index 11326ca7..b356e528 100644 --- a/api/api/v1/accounts/:id/followers.test.ts +++ b/api/api/v1/accounts/:id/followers.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/accounts/:id/following.test.ts b/api/api/v1/accounts/:id/following.test.ts index fd7c1ee0..a1273c1a 100644 --- a/api/api/v1/accounts/:id/following.test.ts +++ b/api/api/v1/accounts/:id/following.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/accounts/:id/index.test.ts b/api/api/v1/accounts/:id/index.test.ts index 60aba2bd..c1508677 100644 --- a/api/api/v1/accounts/:id/index.test.ts +++ b/api/api/v1/accounts/:id/index.test.ts @@ -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({}), diff --git a/api/api/v1/accounts/:id/mute.test.ts b/api/api/v1/accounts/:id/mute.test.ts index 74d86faf..c1b8bc3b 100644 --- a/api/api/v1/accounts/:id/mute.test.ts +++ b/api/api/v1/accounts/:id/mute.test.ts @@ -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({}), diff --git a/api/api/v1/accounts/:id/statuses.test.ts b/api/api/v1/accounts/:id/statuses.test.ts index 4981e644..95562ae8 100644 --- a/api/api/v1/accounts/:id/statuses.test.ts +++ b/api/api/v1/accounts/:id/statuses.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/accounts/:id/unmute.test.ts b/api/api/v1/accounts/:id/unmute.test.ts index 50923736..c7212347 100644 --- a/api/api/v1/accounts/:id/unmute.test.ts +++ b/api/api/v1/accounts/:id/unmute.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/accounts/familiar_followers/index.test.ts b/api/api/v1/accounts/familiar_followers/index.test.ts new file mode 100644 index 00000000..f3450023 --- /dev/null +++ b/api/api/v1/accounts/familiar_followers/index.test.ts @@ -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); + }); +}); diff --git a/api/api/v1/accounts/familiar_followers/index.ts b/api/api/v1/accounts/familiar_followers/index.ts index c7d6f589..3935b910 100644 --- a/api/api/v1/accounts/familiar_followers/index.ts +++ b/api/api/v1/accounts/familiar_followers/index.ts @@ -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), - ), - }); - - 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), + // 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>` + 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 (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, ); }), diff --git a/api/api/v1/accounts/lookup/index.test.ts b/api/api/v1/accounts/lookup/index.test.ts index 1ba4833c..b880b8c3 100644 --- a/api/api/v1/accounts/lookup/index.test.ts +++ b/api/api/v1/accounts/lookup/index.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/accounts/relationships/index.test.ts b/api/api/v1/accounts/relationships/index.test.ts index 6967c36e..1071cfde 100644 --- a/api/api/v1/accounts/relationships/index.test.ts +++ b/api/api/v1/accounts/relationships/index.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/accounts/search/index.test.ts b/api/api/v1/accounts/search/index.test.ts index 6fa40148..8ab0b144 100644 --- a/api/api/v1/accounts/search/index.test.ts +++ b/api/api/v1/accounts/search/index.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/apps/verify_credentials/index.ts b/api/api/v1/apps/verify_credentials/index.ts index de44cf3d..bfed5f6d 100644 --- a/api/api/v1/apps/verify_credentials/index.ts +++ b/api/api/v1/apps/verify_credentials/index.ts @@ -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); diff --git a/api/api/v1/custom_emojis/index.test.ts b/api/api/v1/custom_emojis/index.test.ts index 187efdf6..31113326 100644 --- a/api/api/v1/custom_emojis/index.test.ts +++ b/api/api/v1/custom_emojis/index.test.ts @@ -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}`, }, }); diff --git a/api/api/v1/emojis/:id/index.test.ts b/api/api/v1/emojis/:id/index.test.ts index 0fbb3b5f..0264f1af 100644 --- a/api/api/v1/emojis/:id/index.test.ts +++ b/api/api/v1/emojis/:id/index.test.ts @@ -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", }); diff --git a/api/api/v1/emojis/index.test.ts b/api/api/v1/emojis/index.test.ts index 3f4b6e29..2382ffe2 100644 --- a/api/api/v1/emojis/index.test.ts +++ b/api/api/v1/emojis/index.test.ts @@ -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, }); diff --git a/api/api/v1/markers/index.test.ts b/api/api/v1/markers/index.test.ts index ea8196ad..bc91a3c9 100644 --- a/api/api/v1/markers/index.test.ts +++ b/api/api/v1/markers/index.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/mutes/index.test.ts b/api/api/v1/mutes/index.test.ts index e8c8778c..48731c3c 100644 --- a/api/api/v1/mutes/index.test.ts +++ b/api/api/v1/mutes/index.test.ts @@ -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); diff --git a/api/api/v1/notifications/:id/dismiss.test.ts b/api/api/v1/notifications/:id/dismiss.test.ts index fd676e66..b938fcbc 100644 --- a/api/api/v1/notifications/:id/dismiss.test.ts +++ b/api/api/v1/notifications/:id/dismiss.test.ts @@ -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}`, }, }); diff --git a/api/api/v1/notifications/:id/index.test.ts b/api/api/v1/notifications/:id/index.test.ts index 13a37349..682c9fc7 100644 --- a/api/api/v1/notifications/:id/index.test.ts +++ b/api/api/v1/notifications/:id/index.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/notifications/clear/index.test.ts b/api/api/v1/notifications/clear/index.test.ts index 1b6a918d..404e6240 100644 --- a/api/api/v1/notifications/clear/index.test.ts +++ b/api/api/v1/notifications/clear/index.test.ts @@ -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()); diff --git a/api/api/v1/notifications/destroy_multiple/index.test.ts b/api/api/v1/notifications/destroy_multiple/index.test.ts index b576642e..998347b5 100644 --- a/api/api/v1/notifications/destroy_multiple/index.test.ts +++ b/api/api/v1/notifications/destroy_multiple/index.test.ts @@ -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}`, }, }); diff --git a/api/api/v1/notifications/index.test.ts b/api/api/v1/notifications/index.test.ts index 7c06f11d..1f6aab61 100644 --- a/api/api/v1/notifications/index.test.ts +++ b/api/api/v1/notifications/index.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/roles/:id/index.test.ts b/api/api/v1/roles/:id/index.test.ts index 707bf8d4..574dad93 100644 --- a/api/api/v1/roles/:id/index.test.ts +++ b/api/api/v1/roles/:id/index.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/roles/index.test.ts b/api/api/v1/roles/index.test.ts index e8f1d0e3..79e90650 100644 --- a/api/api/v1/roles/index.test.ts +++ b/api/api/v1/roles/index.test.ts @@ -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}`, }, }); diff --git a/api/api/v1/statuses/:id/favourite.test.ts b/api/api/v1/statuses/:id/favourite.test.ts index fd729077..1aedeaa5 100644 --- a/api/api/v1/statuses/:id/favourite.test.ts +++ b/api/api/v1/statuses/:id/favourite.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/statuses/:id/favourited_by.test.ts b/api/api/v1/statuses/:id/favourited_by.test.ts index fdfafa9d..cb834697 100644 --- a/api/api/v1/statuses/:id/favourited_by.test.ts +++ b/api/api/v1/statuses/:id/favourited_by.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/statuses/:id/reblogged_by.test.ts b/api/api/v1/statuses/:id/reblogged_by.test.ts index 1bdafe38..4b2c2c5e 100644 --- a/api/api/v1/statuses/:id/reblogged_by.test.ts +++ b/api/api/v1/statuses/:id/reblogged_by.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/statuses/:id/unfavourite.test.ts b/api/api/v1/statuses/:id/unfavourite.test.ts index f72b9ea1..9ace9bfc 100644 --- a/api/api/v1/statuses/:id/unfavourite.test.ts +++ b/api/api/v1/statuses/:id/unfavourite.test.ts @@ -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}`, }, }, ); diff --git a/api/api/v1/statuses/index.test.ts b/api/api/v1/statuses/index.test.ts index b19e373a..4452cfb9 100644 --- a/api/api/v1/statuses/index.test.ts +++ b/api/api/v1/statuses/index.test.ts @@ -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! ", @@ -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: "