mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-29 10:28:04 +03:00
clean up t.throws/t.rejects
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import winston, { format, transports, Logger, LeveledLogMethod } from "winston";
|
||||
import fs from "fs";
|
||||
import { EscapeStringRegexp } from "../../utils/misc";
|
||||
import { LOG_LEVEL } from "../setup/config";
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import p from "prudence";
|
||||
import t from "tap";
|
||||
import db from "../../../../external/mongo/db";
|
||||
import CreateLogCtx from "../../../logger/logger";
|
||||
import { prAssert } from "../../../../test-utils/asserts";
|
||||
import {
|
||||
@@ -11,8 +10,6 @@ import {
|
||||
TestingSDVXSingleDryScore,
|
||||
} from "../../../../test-utils/test-data";
|
||||
import { CreateCalculatedData, CalculateDataForGamePT } from "./calculated-data";
|
||||
import deepmerge from "deepmerge";
|
||||
import ResetDBState from "../../../../test-utils/resets";
|
||||
import { CloseAllConnections } from "../../../../test-utils/close-connections";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
@@ -285,7 +285,7 @@ async function CalculateDataDDR(
|
||||
};
|
||||
}
|
||||
|
||||
async function CalculateDataBMS14K(
|
||||
export async function CalculateDataBMS14K(
|
||||
dryScore: DryScore,
|
||||
chart: AnyChartDocument,
|
||||
defaultTierlistID: string | undefined,
|
||||
@@ -296,7 +296,7 @@ async function CalculateDataBMS14K(
|
||||
};
|
||||
}
|
||||
|
||||
async function CalculateDataBMS7K(
|
||||
export async function CalculateDataBMS7K(
|
||||
dryScore: DryScore,
|
||||
chart: AnyChartDocument,
|
||||
defaultTierlistID: string | undefined,
|
||||
|
||||
@@ -144,19 +144,6 @@ export function CalculateMFCP(dryScore: DryScore, chartData: AnyChartDocument, l
|
||||
return null;
|
||||
}
|
||||
|
||||
const VF4GradeCoefficients = {
|
||||
S: 1.0,
|
||||
"AAA+": 0.99,
|
||||
AAA: 0.98,
|
||||
"AA+": 0.97,
|
||||
AA: 0.96,
|
||||
"A+": 0.95,
|
||||
A: 0.94,
|
||||
B: 0.93,
|
||||
C: 0.92,
|
||||
D: 0.91,
|
||||
};
|
||||
|
||||
const VF5GradeCoefficients = {
|
||||
S: 1.05,
|
||||
"AAA+": 1.02,
|
||||
@@ -410,6 +397,19 @@ function LampRatingNoTierlistInfo(
|
||||
|
||||
// deprecated calcs
|
||||
|
||||
// const VF4GradeCoefficients = {
|
||||
// S: 1.0,
|
||||
// "AAA+": 0.99,
|
||||
// AAA: 0.98,
|
||||
// "AA+": 0.97,
|
||||
// AA: 0.96,
|
||||
// "A+": 0.95,
|
||||
// A: 0.94,
|
||||
// B: 0.93,
|
||||
// C: 0.92,
|
||||
// D: 0.91,
|
||||
// };
|
||||
|
||||
// export function CalculateVF4(
|
||||
// grade: Grades["sdvx:Single"],
|
||||
// per: number,
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
import db from "../../../../external/mongo/db";
|
||||
import { BulkWriteUpdateOneOperation } from "mongodb";
|
||||
import { CalculateMilestoneOutOf, GetGoalIDsFromMilestone } from "../../../../utils/milestone";
|
||||
import { RedisPub, RedisSub } from "../../../../external/redis/redis-IPC";
|
||||
import { RedisPub } from "../../../../external/redis/redis-IPC";
|
||||
|
||||
/**
|
||||
* Processes and updates a user's milestones from their Goal Import Info (i.e. what is returned
|
||||
|
||||
@@ -67,7 +67,7 @@ t.test("#ConvertAPIArcDDR", (t) => {
|
||||
),
|
||||
{
|
||||
message: /Invalid ARC Score:/iu,
|
||||
} as any
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -84,7 +84,7 @@ t.test("#ConvertAPIArcDDR", (t) => {
|
||||
),
|
||||
{
|
||||
message: /Could not find chart/iu,
|
||||
} as any
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
|
||||
@@ -53,7 +53,7 @@ t.test("#ConvertAPIArcIIDX", (t) => {
|
||||
),
|
||||
{
|
||||
message: /Invalid ARC Score:/iu,
|
||||
} as any
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -70,7 +70,7 @@ t.test("#ConvertAPIArcIIDX", (t) => {
|
||||
),
|
||||
{
|
||||
message: /Could not find chart/iu,
|
||||
} as any
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
|
||||
@@ -65,7 +65,7 @@ t.test("#ConvertAPIArcSDVX", (t) => {
|
||||
),
|
||||
{
|
||||
message: /Invalid ARC Score:/iu,
|
||||
} as any
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -82,7 +82,7 @@ t.test("#ConvertAPIArcSDVX", (t) => {
|
||||
),
|
||||
{
|
||||
message: /Could not find chart/iu,
|
||||
} as any
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
|
||||
@@ -60,7 +60,7 @@ t.test("#ConvertAPIKaiIIDX", (t) => {
|
||||
),
|
||||
{
|
||||
message: /Could not find chart with songID 0 \(SP ANOTHER - Version 26\)/u,
|
||||
} as any
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -77,7 +77,7 @@ t.test("#ConvertAPIKaiIIDX", (t) => {
|
||||
),
|
||||
{
|
||||
message: /Error: music_id.*Expected a positive integer.* received foo \[string\]/iu,
|
||||
} as any
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -88,7 +88,7 @@ t.test("#ConvertAPIKaiIIDX", (t) => {
|
||||
|
||||
t.rejects(() => ConvertAPIKaiIIDX(iidxScore, { service: "FLO" }, "api/flo-iidx", logger), {
|
||||
message: /Song-Chart desync/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ t.test("#ConvertAPIKaiSDVX", (t) => {
|
||||
),
|
||||
{
|
||||
message: /Could not find chart with songID 0 \(ADV - Version vivid\)/u,
|
||||
} as any
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -78,7 +78,7 @@ t.test("#ConvertAPIKaiSDVX", (t) => {
|
||||
),
|
||||
{
|
||||
message: /Error: music_id.*Expected a positive integer.* received foo \[string\]/iu,
|
||||
} as any
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -89,7 +89,7 @@ t.test("#ConvertAPIKaiSDVX", (t) => {
|
||||
|
||||
t.rejects(() => ConvertAPIKaiSDVX(sdvxScore, { service: "FLO" }, "api/flo-sdvx", logger), {
|
||||
message: /Song-Chart desync/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import { CloseAllConnections } from "../../../../../test-utils/close-connections
|
||||
import { agta } from "../../../../../test-utils/misc";
|
||||
import { MockJSONFetch } from "../../../../../test-utils/mock-fetch";
|
||||
import ResetDBState from "../../../../../test-utils/resets";
|
||||
import { NodeFetch } from "../../../../../utils/fetch";
|
||||
import CreateLogCtx from "../../../../logger/logger";
|
||||
import ScoreImportFatalError from "../../../framework/score-importing/score-import-error";
|
||||
import { TraverseKaiAPI } from "./traverse-api";
|
||||
@@ -65,7 +66,7 @@ t.test("#TraverseKaiAPI", (t) => {
|
||||
});
|
||||
|
||||
t.test("Should throw on invalid response JSON", (t) => {
|
||||
const mockKaiAPI = () => ({ json: null } as any);
|
||||
const mockKaiAPI = (() => ({ json: null })) as unknown as NodeFetch;
|
||||
const res = TraverseKaiAPI("http://url.com", "/sub", fakeAuth, logger, mockKaiAPI);
|
||||
|
||||
t.rejects(() => agta(res));
|
||||
|
||||
@@ -4,10 +4,14 @@ import { GetKTDataJSON, Testing511Song, Testing511SPA } from "../../../../../tes
|
||||
import { ResolveChartFromSong, ResolveMatchTypeToKTData, ConverterBatchManual } from "./converter";
|
||||
import deepmerge from "deepmerge";
|
||||
import { EscapeStringRegexp } from "../../../../../utils/misc";
|
||||
import { Game } from "tachi-common";
|
||||
import { Game, ImportTypes } from "tachi-common";
|
||||
import ResetDBState from "../../../../../test-utils/resets";
|
||||
import { InvalidScoreFailure } from "../../../framework/common/converter-failures";
|
||||
import {
|
||||
InvalidScoreFailure,
|
||||
KTDataNotFoundFailure,
|
||||
} from "../../../framework/common/converter-failures";
|
||||
import { CloseAllConnections } from "../../../../../test-utils/close-connections";
|
||||
import { BatchManualContext } from "./types";
|
||||
|
||||
const baseBatchManualScore = {
|
||||
score: 500,
|
||||
@@ -25,6 +29,7 @@ const context = {
|
||||
version: null,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const ktdWrap = (msg: string, game: Game = "iidx", version = null): any => ({
|
||||
importType: "file/batch-manual",
|
||||
message: new RegExp(EscapeStringRegexp(msg), "u"),
|
||||
@@ -106,7 +111,7 @@ t.test("#ResolveMatchTypeToKTData", (t) => {
|
||||
const gazerSong = GetKTDataJSON("./tachi/bms-gazer-song.json");
|
||||
const gazerChart = GetKTDataJSON("./tachi/bms-gazer-chart.json");
|
||||
|
||||
const bmsContext: any = deepmerge(context, { game: "bms", playtype: "7K" });
|
||||
const bmsContext: BatchManualContext = deepmerge(context, { game: "bms", playtype: "7K" });
|
||||
|
||||
const resMD5 = await ResolveMatchTypeToKTData(
|
||||
deepmerge(baseBatchManualScore, {
|
||||
@@ -169,7 +174,7 @@ t.test("#ResolveMatchTypeToKTData", (t) => {
|
||||
importType,
|
||||
logger
|
||||
),
|
||||
new InvalidScoreFailure("Cannot use ddrSongHash lookup on iidx.") as any
|
||||
new InvalidScoreFailure("Cannot use ddrSongHash lookup on iidx.")
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -229,7 +234,7 @@ t.test("#ResolveMatchTypeToKTData", (t) => {
|
||||
importType,
|
||||
logger
|
||||
),
|
||||
new InvalidScoreFailure(`Invalid matchType BAD_MATCHTYPE`) as any
|
||||
new InvalidScoreFailure(`Invalid matchType BAD_MATCHTYPE`)
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -265,7 +270,7 @@ t.test("#ResolveChartFromSong", (t) => {
|
||||
),
|
||||
new InvalidScoreFailure(
|
||||
`Missing 'difficulty' field, but was necessary for this lookup.`
|
||||
) as any
|
||||
)
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -283,7 +288,7 @@ t.test("#ResolveChartFromSong", (t) => {
|
||||
),
|
||||
new InvalidScoreFailure(
|
||||
`Invalid Difficulty for iidx SP - Expected any of BEGINNER, NORMAL, HYPER, ANOTHER, LEGGENDARIA`
|
||||
) as any
|
||||
)
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -369,7 +374,7 @@ t.test("#ConverterFn", (t) => {
|
||||
importType,
|
||||
logger
|
||||
),
|
||||
{ message: /Invalid percent/u } as any
|
||||
{ message: /Invalid percent/u }
|
||||
);
|
||||
|
||||
t.end();
|
||||
|
||||
+20
-23
@@ -1,32 +1,29 @@
|
||||
import t from "tap";
|
||||
import CreateLogCtx from "../../../../logger/logger";
|
||||
import ResetDBState from "../../../../../test-utils/resets";
|
||||
import { CloseAllConnections } from "../../../../../test-utils/close-connections";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
// const valid511Score = {
|
||||
// bp: "12",
|
||||
// difficulty: "ANOTHER" as const, // lol
|
||||
// exscore: "192",
|
||||
// great: "42",
|
||||
// pgreat: "75",
|
||||
// lamp: "HARD CLEAR",
|
||||
// level: "10",
|
||||
// };
|
||||
|
||||
const valid511Score = {
|
||||
bp: "12",
|
||||
difficulty: "ANOTHER" as const, // lol
|
||||
exscore: "192",
|
||||
great: "42",
|
||||
pgreat: "75",
|
||||
lamp: "HARD CLEAR",
|
||||
level: "10",
|
||||
};
|
||||
// const converterContext = {
|
||||
// playtype: "SP" as const,
|
||||
// hasBeginnerAndLegg: false,
|
||||
// importVersion: "27",
|
||||
// service: "e-amusement",
|
||||
// };
|
||||
|
||||
const converterContext = {
|
||||
playtype: "SP" as const,
|
||||
hasBeginnerAndLegg: false,
|
||||
importVersion: "27",
|
||||
service: "e-amusement",
|
||||
};
|
||||
|
||||
const data = {
|
||||
scores: [valid511Score],
|
||||
timestamp: "Tue, 27 Apr 2021 21:35:35 GMT",
|
||||
title: "5.1.1",
|
||||
};
|
||||
// const data = {
|
||||
// scores: [valid511Score],
|
||||
// timestamp: "Tue, 27 Apr 2021 21:35:35 GMT",
|
||||
// title: "5.1.1",
|
||||
// };
|
||||
|
||||
t.todo("#ConverterFn", async (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
@@ -94,7 +94,7 @@ t.test("#ConvertFileMerIIDX", (t) => {
|
||||
t.test("Invalid Chart", (t) => {
|
||||
t.rejects(() => merc({ diff_type: "LEGGENDARIA" }), {
|
||||
message: /Could not find chart with musicID 1000 \(SP LEGGENDARIA/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -102,7 +102,7 @@ t.test("#ConvertFileMerIIDX", (t) => {
|
||||
t.test("Invalid Song", (t) => {
|
||||
t.rejects(() => merc({ music_id: 0 }), {
|
||||
message: /Could not find chart with musicID 0/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -112,7 +112,7 @@ t.test("#ConvertFileMerIIDX", (t) => {
|
||||
|
||||
t.rejects(() => merc(), {
|
||||
message: /Song-Chart Desync on songID 1/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -120,7 +120,7 @@ t.test("#ConvertFileMerIIDX", (t) => {
|
||||
t.test("Invalid Percent", (t) => {
|
||||
t.rejects(() => merc({ score: 9999 }), {
|
||||
message: /Invalid percent/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -128,7 +128,7 @@ t.test("#ConvertFileMerIIDX", (t) => {
|
||||
t.test("Invalid Date", (t) => {
|
||||
t.rejects(() => merc({ update_time: "INVALID" }), {
|
||||
message: /Invalid\/Unparsable score timestamp of INVALID/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ t.test("#ParseMerIIDX", (t) => {
|
||||
return ParseMerIIDX(MockMulterFile(buffer, "buffer.json"), {}, logger);
|
||||
}
|
||||
|
||||
function mrfj(obj: any) {
|
||||
function mrfj(obj: unknown) {
|
||||
return ParseMerIIDX(
|
||||
MockMulterFile(Buffer.from(JSON.stringify(obj)), "buffer.json"),
|
||||
{},
|
||||
|
||||
@@ -79,7 +79,7 @@ t.test("#ConvertFileS3", (t) => {
|
||||
chart: Testing511SPA,
|
||||
song: Testing511Song,
|
||||
dryScore: deepmerge(dryScore, { comment: "FOO BAR" }),
|
||||
} as any,
|
||||
},
|
||||
"Should correctly return the song, chart and DryScore."
|
||||
);
|
||||
|
||||
@@ -107,7 +107,7 @@ t.test("#ConvertFileS3", (t) => {
|
||||
t.test("Should reject invalid styles in S3 scores", (t) => {
|
||||
t.rejects(mfile({ styles: "3rd,4th,INVALID" }), {
|
||||
message: /Song has invalid style INVALID/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -115,7 +115,7 @@ t.test("#ConvertFileS3", (t) => {
|
||||
t.test("Should throw ktdatanf if no song", (t) => {
|
||||
t.rejects(mfile({ songname: "INVALID SONG TITLE" }), {
|
||||
message: /Could not find song with title INVALID SONG TITLE/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -123,7 +123,7 @@ t.test("#ConvertFileS3", (t) => {
|
||||
t.test("Should throw ktdatanf if no song", (t) => {
|
||||
t.rejects(mfile({ diff: "B" }), {
|
||||
message: /Could not find chart 5\.1\.1\. \(SP LEGGENDARIA/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -131,31 +131,34 @@ t.test("#ConvertFileS3", (t) => {
|
||||
t.test("Should throw a skipscore if the song is 5key", (t) => {
|
||||
t.rejects(mfile({ diff: 5 }), {
|
||||
message: /5KEY scores are not supported/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Should throw an invalidscore if the difficulty is invalid", (t) => {
|
||||
t.rejects(mfile({ diff: "INVALID" as any }), {
|
||||
t.rejects(mfile({ diff: "INVALID" } as unknown as S3Score), {
|
||||
message: /Invalid difficulty INVALID/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Should throw an invalidscore if the hardeasy is invalid", (t) => {
|
||||
t.rejects(mfile({ mods: { hardeasy: "INVALID" } as any, cleartype: "cleared" }), {
|
||||
message: /Invalid cleartype of 'cleared' with hardeasy of INVALID/u,
|
||||
} as any);
|
||||
t.rejects(
|
||||
mfile({ mods: { hardeasy: "INVALID" }, cleartype: "cleared" } as unknown as S3Score),
|
||||
{
|
||||
message: /Invalid cleartype of 'cleared' with hardeasy of INVALID/u,
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Should throw an invalidscore if the cleartype is invalid", (t) => {
|
||||
t.rejects(mfile({ cleartype: "INVALID" as any }), {
|
||||
t.rejects(mfile({ cleartype: "INVALID" } as unknown as S3Score), {
|
||||
message: /Invalid cleartype of INVALID/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -163,7 +166,7 @@ t.test("#ConvertFileS3", (t) => {
|
||||
t.test("Should throw an invalidscore if the exscore is greater than MAX", (t) => {
|
||||
t.rejects(mfile({ exscore: 10000 }), {
|
||||
message: /Invalid percent of 636/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -171,7 +174,7 @@ t.test("#ConvertFileS3", (t) => {
|
||||
t.test("Should throw an invalidscore if the date is invalid.", (t) => {
|
||||
t.rejects(mfile({ date: "INVALID" }), {
|
||||
message: /Invalid\/Unparsable score timestamp of INVALID/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -213,9 +216,12 @@ t.test("#ResolveS3Lamp", (t) => {
|
||||
t.equal(ResolveS3Lamp({ cleartype: "perfect" } as S3Score, logger), "FULL COMBO");
|
||||
t.equal(ResolveS3Lamp({ cleartype: "perfected" } as S3Score, logger), "FULL COMBO");
|
||||
|
||||
t.throws(() => ResolveS3Lamp({ cleartype: "invalid" } as any, logger));
|
||||
t.throws(() => ResolveS3Lamp({ cleartype: "invalid" } as unknown as S3Score, logger));
|
||||
t.throws(() =>
|
||||
ResolveS3Lamp({ cleartype: "cleared", mods: { hardeasy: "invalid" } } as any, logger)
|
||||
ResolveS3Lamp(
|
||||
{ cleartype: "cleared", mods: { hardeasy: "invalid" } } as unknown as S3Score,
|
||||
logger
|
||||
)
|
||||
);
|
||||
|
||||
t.end();
|
||||
|
||||
@@ -113,7 +113,7 @@ t.test("#ParseSolidStateXML", (t) => {
|
||||
{},
|
||||
logger
|
||||
),
|
||||
{ message: /Invalid S3 XML/u } as any
|
||||
{ message: /Invalid S3 XML/u }
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -127,7 +127,7 @@ t.test("#ParseSolidStateXML", (t) => {
|
||||
{},
|
||||
logger
|
||||
),
|
||||
{ message: /Invalid S3 XML.*cleartype.*BAD LAMP/u } as any
|
||||
{ message: /Invalid S3 XML.*cleartype.*BAD LAMP/u }
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -144,7 +144,7 @@ t.test("#ParseSolidStateXML", (t) => {
|
||||
{},
|
||||
logger
|
||||
),
|
||||
{ message: /Invalid S3 XML.*object.*1/u } as any
|
||||
{ message: /Invalid S3 XML.*object.*1/u }
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -161,7 +161,7 @@ t.test("#ParseSolidStateXML", (t) => {
|
||||
{},
|
||||
logger
|
||||
),
|
||||
{ message: /Invalid S3 XML.*object.*1/u } as any
|
||||
{ message: /Invalid S3 XML.*object.*1/u }
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -178,7 +178,7 @@ t.test("#ParseSolidStateXML", (t) => {
|
||||
{},
|
||||
logger
|
||||
),
|
||||
{ message: /Invalid S3 XML.*exscore.*positive integer.*-1/u } as any
|
||||
{ message: /Invalid S3 XML.*exscore.*positive integer.*-1/u }
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -197,7 +197,7 @@ t.test("#ParseSolidStateXML", (t) => {
|
||||
{},
|
||||
logger
|
||||
),
|
||||
{ message: /Invalid S3 XML/u } as any
|
||||
{ message: /Invalid S3 XML/u }
|
||||
);
|
||||
|
||||
t.end();
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ConverterIRBarbatos } from "./converter";
|
||||
import deepmerge from "deepmerge";
|
||||
import { barbScore } from "../../../../../test-utils/test-data";
|
||||
import { CloseAllConnections } from "../../../../../test-utils/close-connections";
|
||||
import { BarbatosScore } from "./types";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
@@ -77,7 +78,7 @@ t.test("#ConverterIRBarbatos", (t) => {
|
||||
inSkillAnalyser: false,
|
||||
},
|
||||
},
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -86,14 +87,14 @@ t.test("#ConverterIRBarbatos", (t) => {
|
||||
t.rejects(
|
||||
() =>
|
||||
ConverterIRBarbatos(
|
||||
deepmerge(barbScore, { song_id: 1000 } as any),
|
||||
deepmerge(barbScore, { song_id: 1000 }) as BarbatosScore,
|
||||
{},
|
||||
"ir/barbatos",
|
||||
logger
|
||||
),
|
||||
{
|
||||
message: /Could not find chart with songID 1000/u,
|
||||
} as any
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -104,7 +105,7 @@ t.test("#ConverterIRBarbatos", (t) => {
|
||||
|
||||
t.rejects(() => ConverterIRBarbatos(barbScore, {}, "ir/barbatos", logger), {
|
||||
message: /Song 1 \(sdvx\) has no parent song/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ t.test("#ParseBarbatosSingle", (t) => {
|
||||
t.test("Should reject invalid scores", (t) => {
|
||||
t.throws(() => ParseBarbatosSingle({}, logger), {
|
||||
message: "Invalid Barbatos Request",
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -4,7 +4,6 @@ import p from "prudence";
|
||||
import ScoreImportFatalError from "../../../framework/score-importing/score-import-error";
|
||||
import { FormatPrError } from "../../../../../utils/prudence";
|
||||
import { BarbatosScore } from "./types";
|
||||
import { ConverterIRBarbatos } from "./converter";
|
||||
import { ParserFunctionReturns } from "../../common/types";
|
||||
|
||||
const PR_Barbatos = {
|
||||
|
||||
@@ -3,7 +3,6 @@ import p from "prudence";
|
||||
import ScoreImportFatalError from "../../../framework/score-importing/score-import-error";
|
||||
import { FormatPrError } from "../../../../../utils/prudence";
|
||||
import { BeatorajaChart, BeatorajaContext, BeatorajaScore } from "./types";
|
||||
import { ConverterIRBeatoraja } from "./converter";
|
||||
import { ParserFunctionReturns } from "../../common/types";
|
||||
|
||||
const PR_BeatorajaScore = {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { CloseAllConnections } from "../../../../../test-utils/close-connections
|
||||
import ResetDBState from "../../../../../test-utils/resets";
|
||||
import CreateLogCtx from "../../../../logger/logger";
|
||||
import { CreateFerStaticClassHandler } from "./class-handler";
|
||||
import { Playtypes, Game } from "tachi-common";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
@@ -53,7 +54,7 @@ t.test("#FerStaticClassHandler", (t) => {
|
||||
|
||||
t.test("Should skip if playtype is invalid", (t) => {
|
||||
const fn = CreateFerStaticClassHandler({ sp_dan: 5, dp_dan: 7 });
|
||||
const res = fn("iidx", "INVALID" as any, 1, {}, logger);
|
||||
const res = fn("iidx", "INVALID" as Playtypes[Game], 1, {}, logger);
|
||||
|
||||
t.equal(res, undefined, "Should skip over as a failsafe.");
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { KtLogger } from "../../../../logger/logger";
|
||||
import p, { PrudenceSchema } from "prudence";
|
||||
import ScoreImportFatalError from "../../../framework/score-importing/score-import-error";
|
||||
import { FormatPrError } from "../../../../../utils/prudence";
|
||||
import { ConverterIRFervidexStatic } from "./converter";
|
||||
import { FervidexStaticContext, FervidexStaticScore } from "./types";
|
||||
import { FerHeaders, SoftwareIDToVersion } from "../fervidex/parser";
|
||||
import { AssertStrAsPositiveInt } from "../../../framework/common/string-asserts";
|
||||
|
||||
@@ -31,7 +31,7 @@ t.test("#SplitFervidexChartRef", (t) => {
|
||||
|
||||
t.throws(
|
||||
() => SplitFervidexChartRef("INVALID" as "spn"),
|
||||
new InternalFailure(`Invalid fervidex difficulty of INVALID`) as any
|
||||
new InternalFailure(`Invalid fervidex difficulty of INVALID`)
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -152,7 +152,7 @@ t.test("#ConverterIRFervidex", (t) => {
|
||||
"ir/fervidex",
|
||||
logger
|
||||
),
|
||||
{ message: /could not find chart/giu } as any
|
||||
{ message: /could not find chart/giu }
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -163,7 +163,7 @@ t.test("#ConverterIRFervidex", (t) => {
|
||||
|
||||
t.rejects(
|
||||
ConverterIRFervidex(baseFervidexScore, { version: "27" }, "ir/fervidex", logger),
|
||||
{ message: /Song 1 \(iidx\) has no parent song/giu } as any
|
||||
{ message: /Song 1 \(iidx\) has no parent song/giu }
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -178,7 +178,7 @@ t.test("#ConverterIRFervidex", (t) => {
|
||||
"ir/fervidex",
|
||||
logger
|
||||
),
|
||||
{ message: /Invalid percent/giu } as any
|
||||
{ message: /Invalid percent/giu }
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -193,7 +193,7 @@ t.test("#ConverterIRFervidex", (t) => {
|
||||
"ir/fervidex",
|
||||
logger
|
||||
),
|
||||
{ message: /Invalid value of gauge 150/giu } as any
|
||||
{ message: /Invalid value of gauge 150/giu }
|
||||
);
|
||||
|
||||
t.end();
|
||||
@@ -215,7 +215,7 @@ t.test("#ConverterIRFervidex", (t) => {
|
||||
dryScore: deepmerge(baseDryScore, {
|
||||
scoreData: { hitMeta: { gauge: null, gaugeHistory: [10, 5, null, null] } },
|
||||
}),
|
||||
} as any, // broken
|
||||
}, // broken
|
||||
"Should return a dry score."
|
||||
);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import p, { PrudenceSchema, ValidSchemaValue } from "prudence";
|
||||
import ScoreImportFatalError from "../../../framework/score-importing/score-import-error";
|
||||
import { FormatPrError, optNull } from "../../../../../utils/prudence";
|
||||
import { FervidexContext, FervidexScore } from "./types";
|
||||
import { ConverterIRFervidex } from "./converter";
|
||||
import { ParseEA3SoftID } from "../../../../../utils/ea3id";
|
||||
import {
|
||||
EXT_HEROIC_VERSE,
|
||||
|
||||
@@ -75,7 +75,7 @@ t.test("#DeriveNoteMod", (t) => {
|
||||
t.end();
|
||||
});
|
||||
|
||||
const dm = (p: Partial<USCClientScore> | any) =>
|
||||
const dm = (p: Partial<USCClientScore>) =>
|
||||
ConverterIRUSC(d(uscScore, p), { chart: uscChart }, "ir/usc", logger);
|
||||
|
||||
t.test("#ConverterIRUSC", (t) => {
|
||||
@@ -98,17 +98,17 @@ t.test("#ConverterIRUSC", (t) => {
|
||||
});
|
||||
|
||||
t.test("Should reject scores with invalid hit windows", (t) => {
|
||||
t.rejects(dm({ windows: { perfect: 0 } }));
|
||||
t.rejects(dm({ windows: { good: 0 } }));
|
||||
t.rejects(dm({ windows: { hold: 0 } }));
|
||||
t.rejects(dm({ windows: { miss: 0 } }));
|
||||
t.rejects(dm({ windows: { slam: 0 } }));
|
||||
t.rejects(dm({ windows: { perfect: 0 } } as USCClientScore));
|
||||
t.rejects(dm({ windows: { good: 0 } } as USCClientScore));
|
||||
t.rejects(dm({ windows: { hold: 0 } } as USCClientScore));
|
||||
t.rejects(dm({ windows: { miss: 0 } } as USCClientScore));
|
||||
t.rejects(dm({ windows: { slam: 0 } } as USCClientScore));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("Should reject scores with invalid autoflags", (t) => {
|
||||
t.rejects(dm({ options: { autoFlags: 1 } }));
|
||||
t.rejects(dm({ options: { autoFlags: 1 } } as USCClientScore));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -4,7 +4,6 @@ import p, { PrudenceSchema } from "prudence";
|
||||
import { FormatPrError } from "../../../../../utils/prudence";
|
||||
import { USCClientScore } from "../../../../../server/router/ir/usc/types";
|
||||
import { IRUSCContext } from "./types";
|
||||
import { ConverterIRUSC } from "./converter";
|
||||
import { ParserFunctionReturns } from "../../common/types";
|
||||
import ScoreImportFatalError from "../../../framework/score-importing/score-import-error";
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import crypto from "crypto";
|
||||
import bcrypt from "bcrypt";
|
||||
import { InviteCodeDocument, PrivateUserDocument, PublicUserDocument } from "tachi-common";
|
||||
import { InsertResult } from "monk";
|
||||
|
||||
@@ -81,7 +81,7 @@ router.put(
|
||||
*
|
||||
* @name GET /api/v1/users/:userID/banner
|
||||
*/
|
||||
router.get("/", async (req, res) => {
|
||||
router.get("/", (req, res) => {
|
||||
const user = req[SYMBOL_TachiData]!.requestedUser!;
|
||||
|
||||
if (!user.customBanner) {
|
||||
|
||||
@@ -180,7 +180,7 @@ t.test("#TachiPBScoreToBeatorajaFormat", (t) => {
|
||||
|
||||
t.rejects(() => TachiPBScoreToBeatorajaFormat(pbScore, gazerChart, 2), {
|
||||
message: /User 1's PB on.*has no lampPB/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import { CloseAllConnections } from "../../../../../test-utils/close-connections
|
||||
import ResetDBState from "../../../../../test-utils/resets";
|
||||
import mockApi from "../../../../../test-utils/mock-api";
|
||||
import db from "../../../../../external/mongo/db";
|
||||
import { ScoreDocument, PBScoreDocument } from "tachi-common";
|
||||
|
||||
t.test("GET /ir/beatoraja/charts/:chartSHA256/scores", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -23,7 +24,7 @@ t.test("GET /ir/beatoraja/charts/:chartSHA256/scores", (t) => {
|
||||
scoreMeta: {},
|
||||
chartID: GAZER_CHARTID,
|
||||
userID: 1,
|
||||
} as any); // very lazy fake scores
|
||||
} as unknown as PBScoreDocument); // very lazy fake scores
|
||||
|
||||
await db.scores.insert({
|
||||
scoreID: "mock_lampPB",
|
||||
@@ -31,7 +32,7 @@ t.test("GET /ir/beatoraja/charts/:chartSHA256/scores", (t) => {
|
||||
inputDevice: "BM_CONTROLLER",
|
||||
random: "MIRROR",
|
||||
},
|
||||
} as any);
|
||||
} as ScoreDocument);
|
||||
|
||||
const res = await mockApi
|
||||
.get(`/ir/beatoraja/charts/${GAZER_SHA256}/scores`)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import t from "tap";
|
||||
import db from "../../../../external/mongo/db";
|
||||
import { RequireNeutralAuthentication } from "../../../../test-utils/api-common";
|
||||
import { CloseAllConnections } from "../../../../test-utils/close-connections";
|
||||
import { CreateFakeAuthCookie } from "../../../../test-utils/fake-auth";
|
||||
import mockApi from "../../../../test-utils/mock-api";
|
||||
|
||||
@@ -3,7 +3,6 @@ import { UpdateClassIfGreater } from "../../../../utils/class";
|
||||
import { GetUserWithIDGuaranteed } from "../../../../utils/user";
|
||||
import { ParseEA3SoftID } from "../../../../utils/ea3id";
|
||||
import { EXT_HEROIC_VERSE, MODEL_INFINITAS_2, REV_2DXBMS } from "../../../../lib/constants/ea3id";
|
||||
import { RequireLoggedInSession } from "../../../middleware/require-logged-in";
|
||||
import { ExpressWrappedScoreImportMain } from "../../../../lib/score-import/framework/express-wrapper";
|
||||
import { ParseFervidexStatic } from "../../../../lib/score-import/import-types/ir/fervidex-static/parser";
|
||||
import { ParseFervidexSingle } from "../../../../lib/score-import/import-types/ir/fervidex/parser";
|
||||
|
||||
@@ -2,7 +2,7 @@ import t from "tap";
|
||||
import db from "../../../../external/mongo/db";
|
||||
import ResetDBState from "../../../../test-utils/resets";
|
||||
import { CreatePOSTScoresResponseBody, TachiScoreToServerScore } from "./usc";
|
||||
import { ChartDocument, PBScoreDocument, ScoreDocument } from "tachi-common";
|
||||
import { ChartDocument, PBScoreDocument, ScoreDocument, PrivateUserDocument } from "tachi-common";
|
||||
import deepmerge from "deepmerge";
|
||||
import { CloseAllConnections } from "../../../../test-utils/close-connections";
|
||||
|
||||
@@ -107,9 +107,12 @@ t.test("#TachiScoreToServerScore", (t) => {
|
||||
});
|
||||
|
||||
t.test("Should throw if user document does not exist.", (t) => {
|
||||
t.rejects(() => TachiScoreToServerScore(deepmerge(mockScorePB, { userID: 2 } as any)), {
|
||||
message: /User 2 from PB on chart.*has no user document\?/u,
|
||||
} as any);
|
||||
t.rejects(
|
||||
() => TachiScoreToServerScore(deepmerge(mockScorePB, { userID: 2 } as ScoreDocument)),
|
||||
{
|
||||
message: /User 2 from PB on chart.*has no user document\?/u,
|
||||
}
|
||||
);
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -118,7 +121,7 @@ t.test("#TachiScoreToServerScore", (t) => {
|
||||
t.rejects(() => TachiScoreToServerScore(mockScorePB), {
|
||||
message:
|
||||
/Score USC_EXAMPLE_SCORE_PB_ID does not exist, but is referenced in 1's PBDoc on/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -228,12 +231,12 @@ const uscScorePBsSet = [
|
||||
outOf: 10,
|
||||
},
|
||||
},
|
||||
].map((e) => deepmerge(mockScorePB, e) as any);
|
||||
].map((e) => deepmerge(mockScorePB, e) as unknown as PBScoreDocument);
|
||||
|
||||
const mockUserDocs = [2, 3, 4, 5, 6, 7, 8, 9, 10].map((e) => ({
|
||||
id: e,
|
||||
username: e.toString(),
|
||||
})) as any;
|
||||
})) as PrivateUserDocument[];
|
||||
|
||||
t.test("#CreatePOSTScoresResponseBody", async (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
@@ -251,7 +254,7 @@ t.test("#CreatePOSTScoresResponseBody", async (t) => {
|
||||
scoreMeta: {
|
||||
replayID: "foo_bar",
|
||||
},
|
||||
} as any);
|
||||
} as unknown as ScoreDocument);
|
||||
|
||||
const res = await CreatePOSTScoresResponseBody(
|
||||
1,
|
||||
@@ -296,7 +299,7 @@ t.test("#CreatePOSTScoresResponseBody", async (t) => {
|
||||
|
||||
await db.scores.insert({
|
||||
scoreID: "USER_4_SCORE_PB",
|
||||
} as any);
|
||||
} as ScoreDocument);
|
||||
|
||||
const res = await CreatePOSTScoresResponseBody(4, chartDoc, "USER_4_SCORE_PB");
|
||||
|
||||
@@ -335,7 +338,7 @@ t.test("#CreatePOSTScoresResponseBody", async (t) => {
|
||||
|
||||
await db.scores.insert({
|
||||
scoreID: "USER_3_SCORE_PB",
|
||||
} as any);
|
||||
} as ScoreDocument);
|
||||
|
||||
const res = await CreatePOSTScoresResponseBody(3, chartDoc, "USER_3_SCORE_PB");
|
||||
|
||||
@@ -377,11 +380,11 @@ t.test("#CreatePOSTScoresResponseBody", async (t) => {
|
||||
scoreMeta: {
|
||||
replayID: "foo_bar",
|
||||
},
|
||||
} as any);
|
||||
} as unknown as ScoreDocument);
|
||||
|
||||
t.rejects(() => CreatePOSTScoresResponseBody(1, chartDoc, "USER_1_SCORE_PB"), {
|
||||
message: /Score was imported for chart, but no ScorePB was available on this chart/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -401,7 +404,7 @@ t.test("#CreatePOSTScoresResponseBody", async (t) => {
|
||||
|
||||
t.rejects(() => CreatePOSTScoresResponseBody(1, chartDoc, "USER_1_SCORE_PB"), {
|
||||
message: /Score with ID USER_1_SCORE_PB is not in the database/u,
|
||||
} as any);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -14,8 +14,10 @@ const logger = CreateLogCtx(__filename);
|
||||
|
||||
const DATA_DIR = path.join(__dirname, "./mock-db");
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const CACHE: Record<string, any[]> = {};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
async function ResetState(data: any[], collection: any) {
|
||||
await collection.remove({});
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ import ResetDBState from "../test-utils/resets";
|
||||
import deepmerge from "deepmerge";
|
||||
import { CloseAllConnections } from "../test-utils/close-connections";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
t.todo("#CreateFolderChartLookup");
|
||||
t.todo("#GetFolderCharts");
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UserGameStats, Game, Playtypes, GetGamePTConfig, GamePTConfig } from "tachi-common";
|
||||
import { Game, Playtypes, GetGamePTConfig, GamePTConfig } from "tachi-common";
|
||||
import { IsString } from "./misc";
|
||||
|
||||
const isIntegerRegex = /^-?\d+$/u;
|
||||
|
||||
Reference in New Issue
Block a user