feat(api): 🎨 Allow login with either username or email

This commit is contained in:
Jesse Wierzbinski 2024-05-08 08:02:05 +00:00
parent 47c88dd7dd
commit f9c9a7d527
No known key found for this signature in database
7 changed files with 260 additions and 62 deletions

View file

@ -1,9 +1,11 @@
/**
* @deprecated
*/
import { afterAll, describe, expect, test } from "bun:test";
import { config } from "config-manager";
import { getTestUsers, sendTestRequest, wrapRelativeUrl } from "~tests/utils";
import type { Account as APIAccount } from "~types/mastodon/account";
import type { Relationship as APIRelationship } from "~types/mastodon/relationship";
import type { Status as APIStatus } from "~types/mastodon/status";
const base_url = config.http.base_url;
@ -105,33 +107,6 @@ describe("API Tests", () => {
});
});
describe("GET /api/v1/accounts/:id/statuses", () => {
test("should return the statuses of the specified user", async () => {
const response = await sendTestRequest(
new Request(
wrapRelativeUrl(
`/api/v1/accounts/${user.id}/statuses`,
base_url,
),
{
headers: {
Authorization: `Bearer ${token.accessToken}`,
},
},
),
);
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toBe(
"application/json",
);
const statuses = (await response.json()) as APIStatus[];
expect(statuses.length).toBe(0);
});
});
describe("POST /api/v1/accounts/:id/remove_from_followers", () => {
test("should remove the specified user from the authenticated user's followers and return an APIRelationship object", async () => {
const response = await sendTestRequest(

View file

@ -1,3 +1,6 @@
/**
* @deprecated
*/
import { afterAll, describe, expect, test } from "bun:test";
import { config } from "config-manager";
import { getTestUsers, sendTestRequest, wrapRelativeUrl } from "~tests/utils";