mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(api): 🎨 Move User methods into their own class similar to Note
This commit is contained in:
parent
abc8f1ae16
commit
9d70778abd
81 changed files with 2055 additions and 1603 deletions
|
|
@ -72,7 +72,7 @@ describe("API Tests", () => {
|
|||
|
||||
const account = (await response.json()) as APIAccount;
|
||||
|
||||
expect(account.username).toBe(user.username);
|
||||
expect(account.username).toBe(user.getUser().username);
|
||||
expect(account.bot).toBe(false);
|
||||
expect(account.locked).toBe(false);
|
||||
expect(account.created_at).toBeDefined();
|
||||
|
|
@ -81,7 +81,10 @@ describe("API Tests", () => {
|
|||
expect(account.statuses_count).toBe(0);
|
||||
expect(account.note).toBe("");
|
||||
expect(account.url).toBe(
|
||||
new URL(`/@${user.username}`, config.http.base_url).toString(),
|
||||
new URL(
|
||||
`/@${user.getUser().username}`,
|
||||
config.http.base_url,
|
||||
).toString(),
|
||||
);
|
||||
expect(account.avatar).toBeDefined();
|
||||
expect(account.avatar_static).toBeDefined();
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ describe("POST /api/auth/login/", () => {
|
|||
test("should get a JWT", async () => {
|
||||
const formData = new FormData();
|
||||
|
||||
formData.append("email", users[0]?.email ?? "");
|
||||
formData.append("email", users[0]?.getUser().email ?? "");
|
||||
formData.append("password", passwords[0]);
|
||||
|
||||
const response = await sendTestRequest(
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
import { randomBytes } from "node:crypto";
|
||||
import { asc, inArray, like } from "drizzle-orm";
|
||||
import type { Status } from "~database/entities/Status";
|
||||
import {
|
||||
type User,
|
||||
type UserWithRelations,
|
||||
createNewLocalUser,
|
||||
} from "~database/entities/User";
|
||||
import { createNewLocalUser } from "~database/entities/User";
|
||||
import { db } from "~drizzle/db";
|
||||
import { Notes, Tokens, Users } from "~drizzle/schema";
|
||||
import { server } from "~index";
|
||||
import { Note } from "~packages/database-interface/note";
|
||||
import type { User } from "~packages/database-interface/user";
|
||||
/**
|
||||
* This allows us to send a test request to the server even when it isnt running
|
||||
* CURRENTLY NOT WORKING, NEEDS TO BE FIXED
|
||||
|
|
@ -30,7 +27,7 @@ export const deleteOldTestUsers = async () => {
|
|||
};
|
||||
|
||||
export const getTestUsers = async (count: number) => {
|
||||
const users: UserWithRelations[] = [];
|
||||
const users: User[] = [];
|
||||
const passwords: string[] = [];
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue