mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-30 02:48:01 +03:00
fix: maybe fix flakey test with kshook
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import deepmerge from "deepmerge";
|
||||
import db from "external/mongo/db";
|
||||
import { ALL_PERMISSIONS } from "tachi-common";
|
||||
import t from "tap";
|
||||
import { InsertFakeTokenWithAllPerms } from "test-utils/fake-auth";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
@@ -8,7 +9,15 @@ import { TestingKsHookSV6CScore, TestingKsHookSV6CStaticScore } from "test-utils
|
||||
|
||||
t.test("POST /ir/kshook/sv6c/score/save", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
t.beforeEach(InsertFakeTokenWithAllPerms("mock_token"));
|
||||
t.beforeEach(() =>
|
||||
db["api-tokens"].insert({
|
||||
userID: 1,
|
||||
identifier: "Mock API Token",
|
||||
permissions: ALL_PERMISSIONS,
|
||||
token: "mock_token",
|
||||
fromAPIClient: null,
|
||||
})
|
||||
);
|
||||
|
||||
t.test("Should import a valid score to the database.", async (t) => {
|
||||
const res = await mockApi
|
||||
@@ -107,7 +116,15 @@ t.test("POST /ir/kshook/sv6c/score/save", (t) => {
|
||||
|
||||
t.test("POST /ir/kshook/sv6c/score/export", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
t.beforeEach(InsertFakeTokenWithAllPerms("mock_token"));
|
||||
t.beforeEach(() =>
|
||||
db["api-tokens"].insert({
|
||||
userID: 1,
|
||||
identifier: "Mock API Token",
|
||||
permissions: ALL_PERMISSIONS,
|
||||
token: "mock_token",
|
||||
fromAPIClient: null,
|
||||
})
|
||||
);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
const validSubmit = (data: object) =>
|
||||
|
||||
@@ -34,16 +34,13 @@ export async function CreateFakeAuthCookie(mockApi: supertest.SuperTest<supertes
|
||||
return setCookieHeader;
|
||||
}
|
||||
|
||||
// my local dev env hates this part because of pnpm
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function InsertFakeTokenWithAllPerms(token: string): () => any {
|
||||
return async () => {
|
||||
await db["api-tokens"].insert({
|
||||
export function InsertFakeTokenWithAllPerms(token: string): () => Promise<any> {
|
||||
return () =>
|
||||
db["api-tokens"].insert({
|
||||
userID: 1,
|
||||
identifier: "Mock API Token",
|
||||
permissions: ALL_PERMISSIONS,
|
||||
token,
|
||||
fromAPIClient: null,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user