Migrate to vitest, unskip suites Closes #1846

This commit is contained in:
Kalle
2024-09-14 14:34:41 +03:00
parent c8921bfadb
commit 8405be6f26
37 changed files with 14115 additions and 1099 deletions

View File

@@ -15,9 +15,13 @@ const LOG_LEVEL = (["trunc", "full", "none"] as const).find(
(val) => val === process.env.SQL_LOG,
);
const migratedEmptyDb = new Database("db-test.sqlite3").serialize();
invariant(process.env.DB_PATH, "DB_PATH env variable must be set");
export const sql = new Database(process.env.DB_PATH);
export const sql = new Database(
process.env.NODE_ENV === "test" ? migratedEmptyDb : process.env.DB_PATH,
);
sql.pragma("journal_mode = WAL");
sql.pragma("foreign_keys = ON");

View File

@@ -1,247 +1,251 @@
// import { afterEach, describe, expect, setSystemTime, test } from "bun:test";
// import { db } from "~/db/sql";
// import * as PlusVotingRepository from "~/features/plus-voting/PlusVotingRepository.server";
// import { dbInsertUsers, dbReset, wrappedAction } from "~/utils/Test";
// import { dateToDatabaseTimestamp } from "~/utils/dates";
// import type { adminActionSchema } from "../actions/admin.server";
// import { action } from "./admin";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { db } from "~/db/sql";
import * as PlusVotingRepository from "~/features/plus-voting/PlusVotingRepository.server";
import { dbInsertUsers, dbReset, wrappedAction } from "~/utils/Test";
import { dateToDatabaseTimestamp } from "~/utils/dates";
import type { adminActionSchema } from "../actions/admin.server";
import { action } from "./admin";
// const adminAction = wrappedAction<typeof adminActionSchema>({ action });
const adminAction = wrappedAction<typeof adminActionSchema>({ action });
// const voteArgs = ({
// score,
// votedId,
// authorId = 1,
// month = 6,
// year = 2021,
// }: {
// score: number;
// votedId: number;
// authorId?: number;
// month?: number;
// year?: number;
// }) => ({
// score,
// votedId,
// authorId,
// month,
// tier: 1,
// validAfter: dateToDatabaseTimestamp(new Date("2021-12-11T00:00:00.000Z")),
// year,
// });
const voteArgs = ({
score,
votedId,
authorId = 1,
month = 6,
year = 2021,
}: {
score: number;
votedId: number;
authorId?: number;
month?: number;
year?: number;
}) => ({
score,
votedId,
authorId,
month,
tier: 1,
validAfter: dateToDatabaseTimestamp(new Date("2021-12-11T00:00:00.000Z")),
year,
});
// const countPlusTierMembers = (tier = 1) =>
// db
// .selectFrom("PlusTier")
// .where("PlusTier.tier", "=", tier)
// .select(({ fn }) => fn.count<number>("PlusTier.tier").as("count"))
// .executeTakeFirstOrThrow()
// .then((row) => row.count);
const countPlusTierMembers = (tier = 1) =>
db
.selectFrom("PlusTier")
.where("PlusTier.tier", "=", tier)
.select(({ fn }) => fn.count<number>("PlusTier.tier").as("count"))
.executeTakeFirstOrThrow()
.then((row) => row.count);
// const createLeaderboard = (userIds: number[]) =>
// db
// .insertInto("Skill")
// .values(
// userIds.map((userId, i) => ({
// matchesCount: 10,
// mu: 25,
// sigma: 8.333333333333334,
// ordinal: 0.5 - i * 0.001,
// userId,
// season: 1,
// })),
// )
// .execute();
const createLeaderboard = (userIds: number[]) =>
db
.insertInto("Skill")
.values(
userIds.map((userId, i) => ({
matchesCount: 10,
mu: 25,
sigma: 8.333333333333334,
ordinal: 0.5 - i * 0.001,
userId,
season: 1,
})),
)
.execute();
// describe("Plus voting", () => {
// afterEach(() => {
// setSystemTime();
// dbReset();
// });
describe("Plus voting", () => {
beforeEach(() => {
vi.useFakeTimers();
});
// test("gives correct amount of plus tiers", async () => {
// setSystemTime(new Date("2023-12-12T00:00:00.000Z"));
afterEach(() => {
vi.useRealTimers();
dbReset();
});
// await dbInsertUsers(10);
// await PlusVotingRepository.upsertMany(
// Array.from({ length: 10 }).map((_, i) => {
// const id = i + 1;
test("gives correct amount of plus tiers", async () => {
vi.setSystemTime(new Date("2023-12-12T00:00:00.000Z"));
// return voteArgs({
// score: id <= 5 ? -1 : 1,
// votedId: id,
// });
// }),
// );
await dbInsertUsers(10);
await PlusVotingRepository.upsertMany(
Array.from({ length: 10 }).map((_, i) => {
const id = i + 1;
// await adminAction({ _action: "REFRESH" }, { user: "admin" });
return voteArgs({
score: id <= 5 ? -1 : 1,
votedId: id,
});
}),
);
// expect(await countPlusTierMembers()).toBe(5);
// });
await adminAction({ _action: "REFRESH" }, { user: "admin" });
// test("60% is the criteria to pass voting", async () => {
// setSystemTime(new Date("2023-12-12T00:00:00.000Z"));
expect(await countPlusTierMembers()).toBe(5);
});
// await dbInsertUsers(10);
test("60% is the criteria to pass voting", async () => {
vi.setSystemTime(new Date("2023-12-12T00:00:00.000Z"));
// // 50%
// await PlusVotingRepository.upsertMany(
// Array.from({ length: 10 }).map((_, i) => {
// return voteArgs({
// authorId: i + 1,
// score: i < 5 ? -1 : 1,
// votedId: 1,
// });
// }),
// );
// // 60%
// await PlusVotingRepository.upsertMany(
// Array.from({ length: 10 }).map((_, i) => {
// return voteArgs({
// authorId: i + 1,
// score: i < 4 ? -1 : 1,
// votedId: 2,
// });
// }),
// );
await dbInsertUsers(10);
// await adminAction({ _action: "REFRESH" }, { user: "admin" });
// 50%
await PlusVotingRepository.upsertMany(
Array.from({ length: 10 }).map((_, i) => {
return voteArgs({
authorId: i + 1,
score: i < 5 ? -1 : 1,
votedId: 1,
});
}),
);
// 60%
await PlusVotingRepository.upsertMany(
Array.from({ length: 10 }).map((_, i) => {
return voteArgs({
authorId: i + 1,
score: i < 4 ? -1 : 1,
votedId: 2,
});
}),
);
// const rows = await db
// .selectFrom("PlusTier")
// .select(["PlusTier.tier", "PlusTier.userId"])
// .where("PlusTier.tier", "=", 1)
// .execute();
await adminAction({ _action: "REFRESH" }, { user: "admin" });
// expect(rows.length).toBe(1);
// expect(rows[0].userId).toBe(2);
// });
const rows = await db
.selectFrom("PlusTier")
.select(["PlusTier.tier", "PlusTier.userId"])
.where("PlusTier.tier", "=", 1)
.execute();
// test("combines leaderboard and voting results (after season over)", async () => {
// setSystemTime(new Date("2023-11-29T00:00:00.000Z"));
expect(rows.length).toBe(1);
expect(rows[0].userId).toBe(2);
});
// await dbInsertUsers(2);
// await PlusVotingRepository.upsertMany([
// voteArgs({
// score: 1,
// votedId: 1,
// }),
// ]);
// await createLeaderboard([2]);
test("combines leaderboard and voting results (after season over)", async () => {
vi.setSystemTime(new Date("2023-11-29T00:00:00.000Z"));
// await adminAction({ _action: "REFRESH" }, { user: "admin" });
await dbInsertUsers(2);
await PlusVotingRepository.upsertMany([
voteArgs({
score: 1,
votedId: 1,
}),
]);
await createLeaderboard([2]);
// expect(await countPlusTierMembers()).toBe(2);
// });
await adminAction({ _action: "REFRESH" }, { user: "admin" });
// test("skips users from leaderboard with the skip flag for the season", async () => {
// setSystemTime(new Date("2023-11-29T00:00:00.000Z"));
expect(await countPlusTierMembers()).toBe(2);
});
// await dbInsertUsers(11);
// await createLeaderboard(Array.from({ length: 11 }).map((_, i) => i + 1));
test("skips users from leaderboard with the skip flag for the season", async () => {
vi.setSystemTime(new Date("2023-11-29T00:00:00.000Z"));
// await db
// .updateTable("User")
// .set({ plusSkippedForSeasonNth: 1 })
// .where("User.id", "=", 1)
// .execute();
await dbInsertUsers(11);
await createLeaderboard(Array.from({ length: 11 }).map((_, i) => i + 1));
// await adminAction({ _action: "REFRESH" }, { user: "admin" });
await db
.updateTable("User")
.set({ plusSkippedForSeasonNth: 1 })
.where("User.id", "=", 1)
.execute();
// expect(await countPlusTierMembers(1)).toBe(10);
// expect(await countPlusTierMembers(2)).toBe(0);
// });
await adminAction({ _action: "REFRESH" }, { user: "admin" });
// test("plus server skip flag ignored if for past season", async () => {
// setSystemTime(new Date("2023-11-29T00:00:00.000Z"));
expect(await countPlusTierMembers(1)).toBe(10);
expect(await countPlusTierMembers(2)).toBe(0);
});
// await dbInsertUsers(11);
// await createLeaderboard(Array.from({ length: 11 }).map((_, i) => i + 1));
test("plus server skip flag ignored if for past season", async () => {
vi.setSystemTime(new Date("2023-11-29T00:00:00.000Z"));
// await db
// .updateTable("User")
// .set({ plusSkippedForSeasonNth: 0 })
// .where("User.id", "=", 1)
// .execute();
await dbInsertUsers(11);
await createLeaderboard(Array.from({ length: 11 }).map((_, i) => i + 1));
// await adminAction({ _action: "REFRESH" }, { user: "admin" });
await db
.updateTable("User")
.set({ plusSkippedForSeasonNth: 0 })
.where("User.id", "=", 1)
.execute();
// expect(await countPlusTierMembers(1)).toBe(10);
// expect(await countPlusTierMembers(2)).toBe(1);
// });
await adminAction({ _action: "REFRESH" }, { user: "admin" });
// test("ignores leaderboard while season is ongoing", async () => {
// setSystemTime(new Date("2024-02-15T00:00:00.000Z"));
expect(await countPlusTierMembers(1)).toBe(10);
expect(await countPlusTierMembers(2)).toBe(1);
});
// await dbInsertUsers(2);
// await PlusVotingRepository.upsertMany([
// voteArgs({
// score: 1,
// votedId: 1,
// }),
// ]);
// await createLeaderboard([2]);
test("ignores leaderboard while season is ongoing", async () => {
vi.setSystemTime(new Date("2024-02-15T00:00:00.000Z"));
// await adminAction({ _action: "REFRESH" }, { user: "admin" });
await dbInsertUsers(2);
await PlusVotingRepository.upsertMany([
voteArgs({
score: 1,
votedId: 1,
}),
]);
await createLeaderboard([2]);
// expect(await countPlusTierMembers()).toBe(1);
// expect(await countPlusTierMembers(2)).toBe(0);
// });
await adminAction({ _action: "REFRESH" }, { user: "admin" });
// test("leaderboard gives members to all tiers", async () => {
// setSystemTime(new Date("2023-11-20T00:00:00.000Z"));
expect(await countPlusTierMembers()).toBe(1);
expect(await countPlusTierMembers(2)).toBe(0);
});
// await dbInsertUsers(60);
// await createLeaderboard(Array.from({ length: 60 }, (_, i) => i + 1));
test("leaderboard gives members to all tiers", async () => {
vi.setSystemTime(new Date("2023-11-20T00:00:00.000Z"));
// await adminAction({ _action: "REFRESH" }, { user: "admin" });
await dbInsertUsers(60);
await createLeaderboard(Array.from({ length: 60 }, (_, i) => i + 1));
// expect(await countPlusTierMembers()).toBeGreaterThan(0);
// expect(await countPlusTierMembers(2)).toBeGreaterThan(0);
// expect(await countPlusTierMembers(3)).toBeGreaterThan(0);
// });
await adminAction({ _action: "REFRESH" }, { user: "admin" });
// test("gives membership if failed voting and is on the leaderboard", async () => {
// setSystemTime(new Date("2023-11-29T00:00:00.000Z"));
expect(await countPlusTierMembers()).toBeGreaterThan(0);
expect(await countPlusTierMembers(2)).toBeGreaterThan(0);
expect(await countPlusTierMembers(3)).toBeGreaterThan(0);
});
// await dbInsertUsers(1);
// await PlusVotingRepository.upsertMany([
// voteArgs({
// score: -1,
// votedId: 1,
// }),
// ]);
// await createLeaderboard([1]);
test("gives membership if failed voting and is on the leaderboard", async () => {
vi.setSystemTime(new Date("2023-11-29T00:00:00.000Z"));
// await adminAction({ _action: "REFRESH" }, { user: "admin" });
await dbInsertUsers(1);
await PlusVotingRepository.upsertMany([
voteArgs({
score: -1,
votedId: 1,
}),
]);
await createLeaderboard([1]);
// expect(await countPlusTierMembers(1)).toBe(1);
// });
await adminAction({ _action: "REFRESH" }, { user: "admin" });
// test("members who fails voting drops one tier", async () => {
// setSystemTime(new Date("2024-02-15T00:00:00.000Z"));
expect(await countPlusTierMembers(1)).toBe(1);
});
// await dbInsertUsers(1);
// await PlusVotingRepository.upsertMany([
// voteArgs({
// score: 1,
// votedId: 1,
// month: 11,
// year: 2023,
// }),
// ]);
test("members who fails voting drops one tier", async () => {
vi.setSystemTime(new Date("2024-02-15T00:00:00.000Z"));
// await PlusVotingRepository.upsertMany([
// voteArgs({
// score: -1,
// votedId: 1,
// month: 2,
// year: 2024,
// }),
// ]);
await dbInsertUsers(1);
await PlusVotingRepository.upsertMany([
voteArgs({
score: 1,
votedId: 1,
month: 11,
year: 2023,
}),
]);
// await adminAction({ _action: "REFRESH" }, { user: "admin" });
await PlusVotingRepository.upsertMany([
voteArgs({
score: -1,
votedId: 1,
month: 2,
year: 2024,
}),
]);
// expect(await countPlusTierMembers(2)).toBe(1);
// });
// });
await adminAction({ _action: "REFRESH" }, { user: "admin" });
expect(await countPlusTierMembers(2)).toBe(1);
});
});

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import type {
AbilityWithUnknown,
BuildAbilitiesTupleWithUnknown,
@@ -39,7 +39,7 @@ describe("getAbilityChunksMapAsArray()", () => {
expect(
abilityChunksArray,
"Ability chunks array is not empty.",
).toBeEmpty();
).toHaveLength(0);
});
describe("getAbilityChunksMapAsArray()", () => {
@@ -54,7 +54,7 @@ describe("getAbilityChunksMapAsArray()", () => {
expect(
abilityChunksArray,
"Ability chunks array is not empty.",
).toBeEmpty();
).toHaveLength(0);
});
test("Ability Doubler ability does not count towards Ability Chunks", () => {

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import { applySpecialEffects } from "./specialEffects";
describe("applySpecialEffects()", () => {

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import { type MainWeaponId, mainWeaponIds } from "~/modules/in-game-lists";
import { damageTypeToWeaponType } from "../analyzer-constants";
import { buildStats } from "./stats";

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import type { AbilityWithUnknown } from "~/modules/in-game-lists/types";
import { buildToAbilityPoints } from "./utils";

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import {
abilityPointCountsToAverages,
popularBuilds,

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import type { Tables } from "~/db/tables";
import type {
Ability,

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import {
mapPoolToSerializedString,
serializedStringToMapPool,

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import { buildStats } from "~/features/build-analyzer";
import type {
AbilityPoints,

View File

@@ -1,86 +1,86 @@
// import { describe, expect, test } from "bun:test";
// import { tierDifferenceToRangeOrExact } from "./groups.server";
import { describe, expect, test } from "vitest";
import { tierDifferenceToRangeOrExact } from "./groups.server";
// const paramsToExpected = new Map<
// [
// Parameters<typeof tierDifferenceToRangeOrExact>[0]["ourTier"],
// Parameters<typeof tierDifferenceToRangeOrExact>[0]["theirTier"],
// ],
// ReturnType<typeof tierDifferenceToRangeOrExact>["tier"]
// >()
// // exact
// .set(
// [
// { isPlus: false, name: "GOLD" },
// { isPlus: false, name: "GOLD" },
// ],
// { isPlus: false, name: "GOLD" },
// )
// // 1 place difference
// .set(
// [
// { isPlus: false, name: "GOLD" },
// { isPlus: true, name: "GOLD" },
// ],
// [
// { isPlus: true, name: "SILVER" },
// { isPlus: true, name: "GOLD" },
// ],
// )
// // 2 places difference
// .set(
// [
// { isPlus: false, name: "GOLD" },
// { isPlus: false, name: "PLATINUM" },
// ],
// [
// { isPlus: false, name: "SILVER" },
// { isPlus: false, name: "PLATINUM" },
// ],
// )
// // too high, has to be exact
// .set(
// [
// { isPlus: true, name: "LEVIATHAN" },
// { isPlus: false, name: "LEVIATHAN" },
// ],
// { isPlus: false, name: "LEVIATHAN" },
// )
// // too low, has to be exact
// .set(
// [
// { isPlus: false, name: "IRON" },
// { isPlus: true, name: "IRON" },
// ],
// { isPlus: true, name: "IRON" },
// )
// // not max rank but still too high
// .set(
// [
// { isPlus: false, name: "LEVIATHAN" },
// { isPlus: false, name: "DIAMOND" },
// ],
// { isPlus: false, name: "DIAMOND" },
// );
const paramsToExpected = new Map<
[
Parameters<typeof tierDifferenceToRangeOrExact>[0]["ourTier"],
Parameters<typeof tierDifferenceToRangeOrExact>[0]["theirTier"],
],
ReturnType<typeof tierDifferenceToRangeOrExact>["tier"]
>()
// exact
.set(
[
{ isPlus: false, name: "GOLD" },
{ isPlus: false, name: "GOLD" },
],
{ isPlus: false, name: "GOLD" },
)
// 1 place difference
.set(
[
{ isPlus: false, name: "GOLD" },
{ isPlus: true, name: "GOLD" },
],
[
{ isPlus: true, name: "SILVER" },
{ isPlus: true, name: "GOLD" },
],
)
// 2 places difference
.set(
[
{ isPlus: false, name: "GOLD" },
{ isPlus: false, name: "PLATINUM" },
],
[
{ isPlus: false, name: "SILVER" },
{ isPlus: false, name: "PLATINUM" },
],
)
// too high, has to be exact
.set(
[
{ isPlus: true, name: "LEVIATHAN" },
{ isPlus: false, name: "LEVIATHAN" },
],
{ isPlus: false, name: "LEVIATHAN" },
)
// too low, has to be exact
.set(
[
{ isPlus: false, name: "IRON" },
{ isPlus: true, name: "IRON" },
],
{ isPlus: true, name: "IRON" },
)
// not max rank but still too high
.set(
[
{ isPlus: false, name: "LEVIATHAN" },
{ isPlus: false, name: "DIAMOND" },
],
{ isPlus: false, name: "DIAMOND" },
);
// describe("tierDifferenceToRangeOrExact()", () => {
// for (const [input, expected] of paramsToExpected) {
// test(`works for ${JSON.stringify(input)} -> ${JSON.stringify(expected)}`, () => {
// const result = tierDifferenceToRangeOrExact({
// ourTier: input[0],
// theirTier: input[1],
// hasLeviathan: true,
// }).tier;
// expect(result).toEqual(expected);
// });
// }
describe("tierDifferenceToRangeOrExact()", () => {
for (const [input, expected] of paramsToExpected) {
test(`works for ${JSON.stringify(input)} -> ${JSON.stringify(expected)}`, () => {
const result = tierDifferenceToRangeOrExact({
ourTier: input[0],
theirTier: input[1],
hasLeviathan: true,
}).tier;
expect(result).toEqual(expected);
});
}
// test("works before leviathan", () => {
// const result = tierDifferenceToRangeOrExact({
// ourTier: { isPlus: true, name: "DIAMOND" },
// theirTier: { isPlus: false, name: "DIAMOND" },
// hasLeviathan: false,
// }).tier;
// expect(result).toEqual({ isPlus: false, name: "DIAMOND" });
// });
// });
test("works before leviathan", () => {
const result = tierDifferenceToRangeOrExact({
ourTier: { isPlus: true, name: "DIAMOND" },
theirTier: { isPlus: false, name: "DIAMOND" },
hasLeviathan: false,
}).tier;
expect(result).toEqual({ isPlus: false, name: "DIAMOND" });
});
});

View File

@@ -1,199 +1,199 @@
// import { describe, expect, test } from "bun:test";
// import type { UserMapModePreferences } from "~/db/tables";
// import type { StageId } from "~/modules/in-game-lists";
// import { rankedModesShort } from "~/modules/in-game-lists/modes";
// import { SENDOUQ_DEFAULT_MAPS } from "~/modules/tournament-map-list-generator/constants";
// import * as Test from "~/utils/Test";
// import { nullFilledArray } from "~/utils/arrays";
// import { mapLottery, mapModePreferencesToModeList } from "./match.server";
import { describe, expect, test } from "vitest";
import type { UserMapModePreferences } from "~/db/tables";
import type { StageId } from "~/modules/in-game-lists";
import { rankedModesShort } from "~/modules/in-game-lists/modes";
import { SENDOUQ_DEFAULT_MAPS } from "~/modules/tournament-map-list-generator/constants";
import * as Test from "~/utils/Test";
import { nullFilledArray } from "~/utils/arrays";
import { mapLottery, mapModePreferencesToModeList } from "./match.server";
// describe.skip("mapModePreferencesToModeList()", () => {
// test("returns default list if no preferences", () => {
// const modeList = mapModePreferencesToModeList([], []);
describe("mapModePreferencesToModeList()", () => {
test("returns default list if no preferences", () => {
const modeList = mapModePreferencesToModeList([], []);
// expect(
// Test.arrayContainsSameItems(["SZ", "TC", "RM", "CB"], modeList),
// ).toBeTrue();
// });
expect(
Test.arrayContainsSameItems(["SZ", "TC", "RM", "CB"], modeList),
).toBe(true);
});
// test("returns default list if equally disliking everything", () => {
// const dislikingEverything = [
// { mode: "TW", preference: "AVOID" } as const,
// { mode: "SZ", preference: "AVOID" } as const,
// { mode: "TC", preference: "AVOID" } as const,
// { mode: "RM", preference: "AVOID" } as const,
// { mode: "CB", preference: "AVOID" } as const,
// ];
test("returns default list if equally disliking everything", () => {
const dislikingEverything = [
{ mode: "TW", preference: "AVOID" } as const,
{ mode: "SZ", preference: "AVOID" } as const,
{ mode: "TC", preference: "AVOID" } as const,
{ mode: "RM", preference: "AVOID" } as const,
{ mode: "CB", preference: "AVOID" } as const,
];
// const modeList = mapModePreferencesToModeList(
// [
// dislikingEverything,
// dislikingEverything,
// dislikingEverything,
// dislikingEverything,
// ],
// [
// dislikingEverything,
// dislikingEverything,
// dislikingEverything,
// dislikingEverything,
// ],
// );
const modeList = mapModePreferencesToModeList(
[
dislikingEverything,
dislikingEverything,
dislikingEverything,
dislikingEverything,
],
[
dislikingEverything,
dislikingEverything,
dislikingEverything,
dislikingEverything,
],
);
// expect(
// Test.arrayContainsSameItems(["SZ", "TC", "RM", "CB"], modeList),
// ).toBe(true);
// });
expect(
Test.arrayContainsSameItems(["SZ", "TC", "RM", "CB"], modeList),
).toBe(true);
});
// test("if positive about nothing, choose the most liked (-TW)", () => {
// const modeList = mapModePreferencesToModeList(
// [[{ mode: "SZ", preference: "AVOID" }]],
// [],
// );
test("if positive about nothing, choose the most liked (-TW)", () => {
const modeList = mapModePreferencesToModeList(
[[{ mode: "SZ", preference: "AVOID" }]],
[],
);
// expect(Test.arrayContainsSameItems(["TC", "RM", "CB"], modeList)).toBe(
// true,
// );
// });
expect(Test.arrayContainsSameItems(["TC", "RM", "CB"], modeList)).toBe(
true,
);
});
// test("only turf war possible to get if least bad option", () => {
// const modeList = mapModePreferencesToModeList(
// [
// [
// { mode: "SZ", preference: "AVOID" },
// { mode: "TC", preference: "AVOID" },
// { mode: "RM", preference: "AVOID" },
// { mode: "CB", preference: "AVOID" },
// { mode: "TW", preference: "AVOID" },
// ],
// [{ mode: "TW", preference: "PREFER" }],
// ],
// [],
// );
test("only turf war possible to get if least bad option", () => {
const modeList = mapModePreferencesToModeList(
[
[
{ mode: "SZ", preference: "AVOID" },
{ mode: "TC", preference: "AVOID" },
{ mode: "RM", preference: "AVOID" },
{ mode: "CB", preference: "AVOID" },
{ mode: "TW", preference: "AVOID" },
],
[{ mode: "TW", preference: "PREFER" }],
],
[],
);
// expect(Test.arrayContainsSameItems(["TW"], modeList)).toBe(true);
// });
expect(Test.arrayContainsSameItems(["TW"], modeList)).toBe(true);
});
// test("team votes for their preference", () => {
// const modeList = mapModePreferencesToModeList(
// [
// [
// { mode: "SZ", preference: "PREFER" },
// { mode: "TC", preference: "PREFER" },
// ],
// [{ mode: "TC", preference: "PREFER" }],
// [{ mode: "TC", preference: "AVOID" }],
// [{ mode: "TC", preference: "PREFER" }],
// ],
// [
// [{ mode: "TC", preference: "PREFER" }],
// [{ mode: "TC", preference: "PREFER" }],
// [{ mode: "TC", preference: "AVOID" }],
// [{ mode: "TC", preference: "AVOID" }],
// ],
// );
test("team votes for their preference", () => {
const modeList = mapModePreferencesToModeList(
[
[
{ mode: "SZ", preference: "PREFER" },
{ mode: "TC", preference: "PREFER" },
],
[{ mode: "TC", preference: "PREFER" }],
[{ mode: "TC", preference: "AVOID" }],
[{ mode: "TC", preference: "PREFER" }],
],
[
[{ mode: "TC", preference: "PREFER" }],
[{ mode: "TC", preference: "PREFER" }],
[{ mode: "TC", preference: "AVOID" }],
[{ mode: "TC", preference: "AVOID" }],
],
);
// expect(Test.arrayContainsSameItems(["SZ", "TC"], modeList)).toBe(true);
// });
expect(Test.arrayContainsSameItems(["SZ", "TC"], modeList)).toBe(true);
});
// test("favorite ranked mode sorted first in the array", () => {
// expect(
// mapModePreferencesToModeList(
// [[{ mode: "TC", preference: "PREFER" }]],
// [],
// )[0],
// ).toBe("TC");
// });
test("favorite ranked mode sorted first in the array", () => {
expect(
mapModePreferencesToModeList(
[[{ mode: "TC", preference: "PREFER" }]],
[],
)[0],
).toBe("TC");
});
// test("includes turf war if more prefer than want to avoid", () => {
// const modeList = mapModePreferencesToModeList(
// [[{ mode: "TW", preference: "PREFER" }]],
// [[{ mode: "SZ", preference: "PREFER" }]],
// );
test("includes turf war if more prefer than want to avoid", () => {
const modeList = mapModePreferencesToModeList(
[[{ mode: "TW", preference: "PREFER" }]],
[[{ mode: "SZ", preference: "PREFER" }]],
);
// expect(Test.arrayContainsSameItems(["TW", "SZ"], modeList)).toBe(true);
// });
expect(Test.arrayContainsSameItems(["TW", "SZ"], modeList)).toBe(true);
});
// test("doesn't include turf war if mixed", () => {
// const modeList = mapModePreferencesToModeList(
// [[{ mode: "TW", preference: "PREFER" }]],
// [[{ mode: "TW", preference: "AVOID" }]],
// );
test("doesn't include turf war if mixed", () => {
const modeList = mapModePreferencesToModeList(
[[{ mode: "TW", preference: "PREFER" }]],
[[{ mode: "TW", preference: "AVOID" }]],
);
// expect(
// Test.arrayContainsSameItems(["SZ", "TC", "RM", "CB"], modeList),
// ).toBe(true);
// });
// });
expect(
Test.arrayContainsSameItems(["SZ", "TC", "RM", "CB"], modeList),
).toBe(true);
});
});
// const MODES_COUNT = 4;
// const STAGES_PER_MODE = 7;
const MODES_COUNT = 4;
const STAGES_PER_MODE = 7;
// describe("mapLottery()", () => {
// test("returns maps even if no preferences", () => {
// const mapPool = mapLottery([], rankedModesShort);
describe("mapLottery()", () => {
test("returns maps even if no preferences", () => {
const mapPool = mapLottery([], rankedModesShort);
// expect(mapPool.stageModePairs.length).toBe(STAGES_PER_MODE * MODES_COUNT);
// });
expect(mapPool.stageModePairs.length).toBe(STAGES_PER_MODE * MODES_COUNT);
});
// test("returns some maps from the map pools", () => {
// const memberOnePool: UserMapModePreferences["pool"] = rankedModesShort.map(
// (mode) => ({
// mode,
// stages: nullFilledArray(7).map((_, i) => (i + 1) as StageId),
// }),
// );
// const memberTwoPool: UserMapModePreferences["pool"] = rankedModesShort.map(
// (mode) => ({
// mode,
// stages: nullFilledArray(7).map((_, i) => (i + 10) as StageId),
// }),
// );
test("returns some maps from the map pools", () => {
const memberOnePool: UserMapModePreferences["pool"] = rankedModesShort.map(
(mode) => ({
mode,
stages: nullFilledArray(7).map((_, i) => (i + 1) as StageId),
}),
);
const memberTwoPool: UserMapModePreferences["pool"] = rankedModesShort.map(
(mode) => ({
mode,
stages: nullFilledArray(7).map((_, i) => (i + 10) as StageId),
}),
);
// const pool = mapLottery(
// [
// { modes: [], pool: memberOnePool },
// { modes: [], pool: memberTwoPool },
// ],
// rankedModesShort,
// );
const pool = mapLottery(
[
{ modes: [], pool: memberOnePool },
{ modes: [], pool: memberTwoPool },
],
rankedModesShort,
);
// expect(pool.stageModePairs.some((p) => p.stageId <= 7)).toBe(true);
// expect(pool.stageModePairs.some((p) => p.stageId > 10)).toBe(true);
// });
expect(pool.stageModePairs.some((p) => p.stageId <= 7)).toBe(true);
expect(pool.stageModePairs.some((p) => p.stageId > 10)).toBe(true);
});
// test("includes modes that were given and nothing else", () => {
// const memberOnePool: UserMapModePreferences["pool"] = rankedModesShort.map(
// (mode) => ({
// mode,
// stages: nullFilledArray(7).map((_, i) => (i + 1) as StageId),
// }),
// );
test("includes modes that were given and nothing else", () => {
const memberOnePool: UserMapModePreferences["pool"] = rankedModesShort.map(
(mode) => ({
mode,
stages: nullFilledArray(7).map((_, i) => (i + 1) as StageId),
}),
);
// const pool = mapLottery([{ modes: [], pool: memberOnePool }], ["SZ", "TC"]);
const pool = mapLottery([{ modes: [], pool: memberOnePool }], ["SZ", "TC"]);
// expect(
// pool.stageModePairs.every((p) => p.mode === "SZ" || p.mode === "TC"),
// ).toBe(true);
// });
expect(
pool.stageModePairs.every((p) => p.mode === "SZ" || p.mode === "TC"),
).toBe(true);
});
// test("excludes map preferences if mode is avoided", () => {
// const memberOnePool: UserMapModePreferences["pool"] = [
// {
// mode: "SZ",
// stages: nullFilledArray(7).map((_, i) => (i + 1) as StageId),
// },
// ];
test("excludes map preferences if mode is avoided", () => {
const memberOnePool: UserMapModePreferences["pool"] = [
{
mode: "SZ",
stages: nullFilledArray(7).map((_, i) => (i + 1) as StageId),
},
];
// const pool = mapLottery(
// [{ modes: [{ preference: "AVOID", mode: "SZ" }], pool: memberOnePool }],
// ["SZ"],
// );
const pool = mapLottery(
[{ modes: [{ preference: "AVOID", mode: "SZ" }], pool: memberOnePool }],
["SZ"],
);
// expect(
// pool.stageModePairs.every((p) =>
// SENDOUQ_DEFAULT_MAPS.SZ.some((stageId) => stageId === p.stageId),
// ),
// ).toBe(true);
// });
// });
expect(
pool.stageModePairs.every((p) =>
SENDOUQ_DEFAULT_MAPS.SZ.some((stageId) => stageId === p.stageId),
),
).toBe(true);
});
});

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import type { MainWeaponId } from "~/modules/in-game-lists";
import { mergeReportedWeapons } from "./reported-weapons.server";

View File

@@ -1,272 +1,272 @@
// import { afterEach, beforeEach, describe, expect, test } from "bun:test";
// import type { SerializeFrom } from "@remix-run/server-runtime";
// import { db } from "~/db/sql";
// import type { UserMapModePreferences } from "~/db/tables";
// import { BANNED_MAPS } from "~/features/sendouq-settings/banned-maps";
// import { stageIds } from "~/modules/in-game-lists";
// import {
// dbInsertUsers,
// dbReset,
// wrappedAction,
// wrappedLoader,
// } from "~/utils/Test";
// import invariant from "~/utils/invariant";
// import type { lookingSchema, matchSchema } from "../q-schemas.server";
// import { loader, action as rawLookingAction } from "./q.looking";
// import { action as rawMatchAction } from "./q.match.$id";
import type { SerializeFrom } from "@remix-run/server-runtime";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
import { db } from "~/db/sql";
import type { UserMapModePreferences } from "~/db/tables";
import { BANNED_MAPS } from "~/features/sendouq-settings/banned-maps";
import { stageIds } from "~/modules/in-game-lists";
import {
dbInsertUsers,
dbReset,
wrappedAction,
wrappedLoader,
} from "~/utils/Test";
import invariant from "~/utils/invariant";
import type { lookingSchema, matchSchema } from "../q-schemas.server";
import { loader, action as rawLookingAction } from "./q.looking";
import { action as rawMatchAction } from "./q.match.$id";
// const createGroup = async (userIds: number[]) => {
// const group = await db
// .insertInto("Group")
// .values({
// inviteCode: "1234",
// status: "ACTIVE",
// })
// .returning("id")
// .executeTakeFirstOrThrow();
const createGroup = async (userIds: number[]) => {
const group = await db
.insertInto("Group")
.values({
inviteCode: "1234",
status: "ACTIVE",
})
.returning("id")
.executeTakeFirstOrThrow();
// await db
// .insertInto("GroupMember")
// .values(
// userIds.map((userId, i) => ({
// groupId: group.id,
// userId,
// role: i === 0 ? "OWNER" : "REGULAR",
// })),
// )
// .execute();
// };
await db
.insertInto("GroupMember")
.values(
userIds.map((userId, i) => ({
groupId: group.id,
userId,
role: i === 0 ? "OWNER" : "REGULAR",
})),
)
.execute();
};
// const SZ_ONLY_PREFERENCE: UserMapModePreferences["modes"] = [
// { mode: "SZ", preference: "PREFER" },
// { mode: "TC", preference: "AVOID" },
// { mode: "RM", preference: "AVOID" },
// { mode: "CB", preference: "AVOID" },
// ];
const SZ_ONLY_PREFERENCE: UserMapModePreferences["modes"] = [
{ mode: "SZ", preference: "PREFER" },
{ mode: "TC", preference: "AVOID" },
{ mode: "RM", preference: "AVOID" },
{ mode: "CB", preference: "AVOID" },
];
// const prepareGroups = async () => {
// await dbInsertUsers(8);
// await createGroup([1, 2, 3, 4]);
// await createGroup([5, 6, 7, 8]);
// await db
// .insertInto("GroupLike")
// .values({ likerGroupId: 2, targetGroupId: 1 })
// .execute();
const prepareGroups = async () => {
await dbInsertUsers(8);
await createGroup([1, 2, 3, 4]);
await createGroup([5, 6, 7, 8]);
await db
.insertInto("GroupLike")
.values({ likerGroupId: 2, targetGroupId: 1 })
.execute();
// await insertMapModePreferences(1, {
// modes: SZ_ONLY_PREFERENCE,
// pool: [{ mode: "SZ", stages: [...stageIds].slice(0, 7) }],
// });
await insertMapModePreferences(1, {
modes: SZ_ONLY_PREFERENCE,
pool: [{ mode: "SZ", stages: [...stageIds].slice(0, 7) }],
});
// await insertMapModePreferences(5, {
// modes: SZ_ONLY_PREFERENCE,
// pool: [
// { mode: "SZ", stages: [...stageIds].slice(0, 20).reverse().slice(0, 7) },
// ],
// });
// };
await insertMapModePreferences(5, {
modes: SZ_ONLY_PREFERENCE,
pool: [
{ mode: "SZ", stages: [...stageIds].slice(0, 20).reverse().slice(0, 7) },
],
});
};
// const insertMapModePreferences = (
// userId: number,
// preferences: UserMapModePreferences,
// ) => {
// return db
// .updateTable("User")
// .set({
// mapModePreferences: JSON.stringify(preferences),
// })
// .where("User.id", "=", userId)
// .execute();
// };
const insertMapModePreferences = (
userId: number,
preferences: UserMapModePreferences,
) => {
return db
.updateTable("User")
.set({
mapModePreferences: JSON.stringify(preferences),
})
.where("User.id", "=", userId)
.execute();
};
// const lookingAction = wrappedAction<typeof lookingSchema>({
// action: rawLookingAction,
// });
const lookingAction = wrappedAction<typeof lookingSchema>({
action: rawLookingAction,
});
// const createMatch = () =>
// lookingAction(
// {
// _action: "MATCH_UP",
// targetGroupId: 2,
// },
// { user: "admin" },
// );
const createMatch = () =>
lookingAction(
{
_action: "MATCH_UP",
targetGroupId: 2,
},
{ user: "admin" },
);
// const findMatch = () =>
// db
// .selectFrom("GroupMatch")
// .selectAll()
// .where("id", "=", 1)
// .executeTakeFirstOrThrow();
const findMatch = () =>
db
.selectFrom("GroupMatch")
.selectAll()
.where("id", "=", 1)
.executeTakeFirstOrThrow();
// describe("SendouQ match creation", () => {
// beforeEach(async () => {
// await prepareGroups();
// });
describe("SendouQ match creation", () => {
beforeEach(async () => {
await prepareGroups();
});
// afterEach(() => {
// dbReset();
// });
afterEach(() => {
dbReset();
});
// test("adds pools to memento", async () => {
// await createMatch();
test("adds pools to memento", async () => {
await createMatch();
// const match = await findMatch();
// const pools = match.memento?.pools;
const match = await findMatch();
const pools = match.memento?.pools;
// invariant(pools, "pools missing");
invariant(pools, "pools missing");
// expect(pools.length).toBe(2);
// expect(pools.some((p) => p.pool[0].stages.includes(1))).toBe(true);
// expect(pools.some((p) => p.pool[0].stages.includes(19))).toBe(true);
// });
expect(pools.length).toBe(2);
expect(pools.some((p) => p.pool[0].stages.includes(1))).toBe(true);
expect(pools.some((p) => p.pool[0].stages.includes(19))).toBe(true);
});
// test("doesn't add pool where mode is avoided", async () => {
// await insertMapModePreferences(1, {
// modes: [
// { mode: "SZ", preference: "AVOID" },
// { mode: "TC", preference: "PREFER" },
// ],
// pool: [
// {
// mode: "TC",
// stages: [...stageIds]
// .filter((stageId) => !BANNED_MAPS.TC.includes(stageId))
// .slice(0, 7),
// },
// ],
// });
test("doesn't add pool where mode is avoided", async () => {
await insertMapModePreferences(1, {
modes: [
{ mode: "SZ", preference: "AVOID" },
{ mode: "TC", preference: "PREFER" },
],
pool: [
{
mode: "TC",
stages: [...stageIds]
.filter((stageId) => !BANNED_MAPS.TC.includes(stageId))
.slice(0, 7),
},
],
});
// await createMatch();
await createMatch();
// const match = await findMatch();
// const pools = match.memento?.pools;
const match = await findMatch();
const pools = match.memento?.pools;
// invariant(pools, "pools missing");
invariant(pools, "pools missing");
// expect(pools.length).toBe(2);
// expect(
// pools.find((p) => p.userId === 1)!.pool.every((p) => p.mode !== "SZ"),
// ).toBe(true);
// });
expect(pools.length).toBe(2);
expect(
pools.find((p) => p.userId === 1)!.pool.every((p) => p.mode !== "SZ"),
).toBe(true);
});
// test("adds mode preferences to memento", async () => {
// await createMatch();
test("adds mode preferences to memento", async () => {
await createMatch();
// const match = await findMatch();
const match = await findMatch();
// const modePreferences = match.memento?.modePreferences;
const modePreferences = match.memento?.modePreferences;
// expect(modePreferences?.SZ?.length).toBe(2);
// });
expect(modePreferences?.SZ?.length).toBe(2);
});
// test("adds mode preferences to memento including neutral", async () => {
// await insertMapModePreferences(2, {
// modes: [{ mode: "TC", preference: "PREFER" }],
// pool: [],
// });
test("adds mode preferences to memento including neutral", async () => {
await insertMapModePreferences(2, {
modes: [{ mode: "TC", preference: "PREFER" }],
pool: [],
});
// await createMatch();
await createMatch();
// const match = await findMatch();
const match = await findMatch();
// const modePreferences = match.memento?.modePreferences;
const modePreferences = match.memento?.modePreferences;
// expect(modePreferences?.SZ?.length).toBe(3);
// expect(modePreferences?.SZ?.some((p) => !p.preference)).toBe(true);
// });
// });
expect(modePreferences?.SZ?.length).toBe(3);
expect(modePreferences?.SZ?.some((p) => !p.preference)).toBe(true);
});
});
// describe("Private user note sorting", () => {
// beforeEach(async () => {
// await dbInsertUsers(8);
describe("Private user note sorting", () => {
beforeEach(async () => {
await dbInsertUsers(8);
// await createGroup([1]);
// await createGroup([2]);
// await createGroup([3]);
// await createGroup([4]);
// await createGroup([5]);
// await createGroup([6, 7]);
// await createGroup([8]);
await createGroup([1]);
await createGroup([2]);
await createGroup([3]);
await createGroup([4]);
await createGroup([5]);
await createGroup([6, 7]);
await createGroup([8]);
// await db
// .insertInto("GroupMatch")
// .values({ alphaGroupId: 2, bravoGroupId: 3 })
// .execute();
// });
await db
.insertInto("GroupMatch")
.values({ alphaGroupId: 2, bravoGroupId: 3 })
.execute();
});
// afterEach(() => {
// dbReset();
// });
afterEach(() => {
dbReset();
});
// const lookingLoader = wrappedLoader<SerializeFrom<typeof loader>>({
// loader,
// });
// const matchAction = wrappedAction<typeof matchSchema>({
// action: rawMatchAction,
// params: { id: "1" },
// });
const lookingLoader = wrappedLoader<SerializeFrom<typeof loader>>({
loader,
});
const matchAction = wrappedAction<typeof matchSchema>({
action: rawMatchAction,
params: { id: "1" },
});
// test("users with positive note sorted first", async () => {
// await matchAction(
// {
// _action: "ADD_PRIVATE_USER_NOTE",
// targetId: 5,
// sentiment: "POSITIVE",
// comment: "test",
// },
// { user: "admin" },
// );
test("users with positive note sorted first", async () => {
await matchAction(
{
_action: "ADD_PRIVATE_USER_NOTE",
targetId: 5,
sentiment: "POSITIVE",
comment: "test",
},
{ user: "admin" },
);
// const data = await lookingLoader({ user: "admin" });
const data = await lookingLoader({ user: "admin" });
// expect(data.groups.neutral[0].members![0].id).toBe(5);
// });
expect(data.groups.neutral[0].members![0].id).toBe(5);
});
// test("users with negative note sorted last", async () => {
// await matchAction(
// {
// _action: "ADD_PRIVATE_USER_NOTE",
// targetId: 5,
// sentiment: "NEGATIVE",
// comment: "test",
// },
// { user: "admin" },
// );
test("users with negative note sorted last", async () => {
await matchAction(
{
_action: "ADD_PRIVATE_USER_NOTE",
targetId: 5,
sentiment: "NEGATIVE",
comment: "test",
},
{ user: "admin" },
);
// const data = await lookingLoader({ user: "admin" });
const data = await lookingLoader({ user: "admin" });
// expect(
// data.groups.neutral[data.groups.neutral.length - 1].members![0].id,
// ).toBe(5);
// });
expect(
data.groups.neutral[data.groups.neutral.length - 1].members![0].id,
).toBe(5);
});
// test("group with both negative and positive sentiment sorted last", async () => {
// await matchAction(
// {
// _action: "ADD_PRIVATE_USER_NOTE",
// targetId: 6,
// sentiment: "POSITIVE",
// comment: "test",
// },
// { user: "admin" },
// );
// await matchAction(
// {
// _action: "ADD_PRIVATE_USER_NOTE",
// targetId: 7,
// sentiment: "NEGATIVE",
// comment: "test",
// },
// { user: "admin" },
// );
test("group with both negative and positive sentiment sorted last", async () => {
await matchAction(
{
_action: "ADD_PRIVATE_USER_NOTE",
targetId: 6,
sentiment: "POSITIVE",
comment: "test",
},
{ user: "admin" },
);
await matchAction(
{
_action: "ADD_PRIVATE_USER_NOTE",
targetId: 7,
sentiment: "NEGATIVE",
comment: "test",
},
{ user: "admin" },
);
// const data = await lookingLoader({ user: "admin" });
const data = await lookingLoader({ user: "admin" });
// expect(
// data.groups.neutral[data.groups.neutral.length - 1].members?.some(
// (m) => m.id === 6,
// ),
// ).toBe(true);
// });
// });
expect(
data.groups.neutral[data.groups.neutral.length - 1].members?.some(
(m) => m.id === 6,
),
).toBe(true);
});
});

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import type { PreparedMaps as PreparedMapsType } from "~/db/tables";
import * as PreparedMaps from "./PreparedMaps";
import { testTournament } from "./tests/test-utils";
@@ -108,7 +108,7 @@ describe("PreparedMaps - eliminationTeamCountOptions", () => {
PreparedMaps.eliminationTeamCountOptions(3).every(
(option) => option.max > 3,
),
).toBeTrue();
).toBe(true);
});
test("returns the option equivalent to the current count", () => {
@@ -215,7 +215,7 @@ describe("PreparedMaps - trimPreparedEliminationMaps", () => {
expect(
trimmed!.maps.some((map) => map.roundId === round.id),
`Round ID ${round.id} not found in the actual bracket`,
).toBeTrue();
).toBe(true);
}
});
@@ -288,7 +288,7 @@ describe("PreparedMaps - trimPreparedEliminationMaps", () => {
expect(
trimmed!.maps.some((map) => map.roundId === round.id),
`Round ID ${round.id} not found in the actual bracket`,
).toBeTrue();
).toBe(true);
}
});

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import type { Match } from "~/modules/brackets-model";
import { Tournament } from "./Tournament";
import {

View File

@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { ordinal, rating } from "openskill";
import { describe, expect, test } from "vitest";
import invariant from "~/utils/invariant";
import type { AllMatchResult } from "../queries/allMatchResultsByTournamentId.server";
import type { TournamentDataTeam } from "./Tournament.server";

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import {
fillWithNullTillPowerOfTwo,
mapCountPlayedInSetWithCertainty,

View File

@@ -1,14 +1,12 @@
import { suite } from "uvu";
import * as assert from "uvu/assert";
import { describe, expect, it } from "vitest";
import type { MainWeaponId } from "~/modules/in-game-lists";
import { databaseTimestampNow } from "~/utils/dates";
import { sortBuilds } from "./build-sorting.server";
const BuildSorting = suite("sortBuilds()");
type BuildSortingBuildArg = Parameters<
typeof sortBuilds
>[number]["builds"][number];
const mockBuild = (
partialBuild: Partial<BuildSortingBuildArg>,
): BuildSortingBuildArg => {
@@ -32,388 +30,384 @@ const mockBuild = (
};
};
BuildSorting("sorts by UPDATED_AT", () => {
const builds = [
mockBuild({ id: 1, updatedAt: 1 }),
mockBuild({ id: 2, updatedAt: 3 }),
mockBuild({ id: 3, updatedAt: 2 }),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["UPDATED_AT"],
weaponPool: [],
});
assert.equal(sortedBuilds[0].id, 2);
assert.equal(sortedBuilds[1].id, 3);
});
BuildSorting("sorts by TOP_500", () => {
const builds = [
mockBuild({ id: 1 }),
mockBuild({
id: 2,
weapons: [{ weaponSplId: 1, maxPower: 3000, minRank: 1 }],
}),
mockBuild({
id: 3,
weapons: [
{ weaponSplId: 0, maxPower: null, minRank: null },
{ weaponSplId: 1, maxPower: 2900, minRank: 1 },
],
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["TOP_500"],
weaponPool: [],
});
// highest XP first
assert.equal(sortedBuilds[0].id, 2);
assert.equal(sortedBuilds[1].id, 3);
});
BuildSorting("sorts by WEAPON_POOL", () => {
const builds = [
mockBuild({
id: 1,
weapons: [{ weaponSplId: 1000, maxPower: null, minRank: null }],
}),
mockBuild({
id: 2,
weapons: [{ weaponSplId: 10, maxPower: null, minRank: null }],
}),
mockBuild({
id: 3,
weapons: [{ weaponSplId: 1, maxPower: null, minRank: null }],
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["WEAPON_POOL"],
weaponPool: [1, 10],
});
assert.equal(sortedBuilds[0].id, 3);
assert.equal(sortedBuilds[1].id, 2);
});
BuildSorting("sorts by WEAPON_POOL (alt kits are same priority)", () => {
const mockBuildBuilder = (
id: number,
weaponIds: MainWeaponId[],
): BuildSortingBuildArg => {
return mockBuild({
id,
weapons: weaponIds.map((wepId) => ({
weaponSplId: wepId,
maxPower: null,
minRank: null,
})),
});
};
const builds1 = [
[1, [1000]],
[2, [10]],
[3, [0]],
[4, [11]],
[5, [1]],
].map(([id, weaponIds]) =>
mockBuildBuilder(id as number, weaponIds as MainWeaponId[]),
);
const sortedBuilds1 = sortBuilds({
builds: builds1,
buildSorting: ["WEAPON_POOL"],
weaponPool: [1, 10],
});
// Sorting is stable; should keep relative order of alt kits
// and relative order of non-weapon pool kits
let expected = [3, 5, 2, 4, 1];
for (const [idx, expectedVal] of expected.entries()) {
assert.equal(sortedBuilds1[idx].id, expectedVal);
}
const builds2 = [
[1, [1000]],
[2, [0, 10, 1011]],
[3, [2]],
[4, [2010, 40]],
[5, [8001, 8000]],
[6, [8020, 201, 8021]],
[7, [5010, 46, 50]],
].map(([id, weaponIds]) =>
mockBuildBuilder(id as number, weaponIds as MainWeaponId[]),
);
const sortedBuilds2 = sortBuilds({
builds: builds2,
buildSorting: ["WEAPON_POOL"],
weaponPool: [47, 205, 1015],
});
// Using alt kit ids still acts as the vanilla kit id
// Last 3 builds are not any variant of weapon pool weapons;
// relative order is still preserved
expected = [4, 7, 6, 2, 1, 3, 5];
for (const [idx, expectedVal] of expected.entries()) {
assert.equal(sortedBuilds2[idx].id, expectedVal);
}
});
BuildSorting("sorts by ALPHABETICAL_TITLE", () => {
const builds = [
mockBuild({
id: 1,
title: "C",
}),
mockBuild({
id: 2,
title: "B",
}),
mockBuild({
id: 3,
title: "A",
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["ALPHABETICAL_TITLE"],
weaponPool: [],
});
assert.equal(sortedBuilds[0].id, 3);
assert.equal(sortedBuilds[1].id, 2);
});
BuildSorting("sorts by WEAPON_IN_GAME_ORDER", () => {
const builds = [
mockBuild({
id: 1,
weapons: [{ weaponSplId: 1, maxPower: null, minRank: null }],
}),
mockBuild({
id: 2,
weapons: [{ weaponSplId: 10, maxPower: null, minRank: null }],
}),
mockBuild({
id: 3,
weapons: [
{ weaponSplId: 1000, maxPower: null, minRank: null },
{ weaponSplId: 1, maxPower: null, minRank: null },
],
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["WEAPON_IN_GAME_ORDER"],
weaponPool: [],
});
assert.equal(sortedBuilds[2].id, 2);
});
BuildSorting("sorts by MODE", () => {
const builds = [
mockBuild({
id: 1,
modes: ["SZ"],
}),
mockBuild({
id: 2,
modes: ["CB"],
}),
mockBuild({
id: 3,
modes: ["SZ", "TC", "CB"],
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["MODE"],
weaponPool: [],
});
assert.equal(sortedBuilds[2].id, 2);
});
BuildSorting("sorts by MODE (no mode last)", () => {
const builds = [
mockBuild({
id: 1,
modes: [],
}),
mockBuild({
id: 2,
modes: ["CB"],
}),
mockBuild({
id: 3,
modes: ["SZ", "TC", "CB"],
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["MODE"],
weaponPool: [],
});
assert.equal(sortedBuilds[2].id, 1);
});
for (const identifier of ["HEADGEAR_ID", "CLOTHES_ID", "SHOES_ID"]) {
BuildSorting(`sorts by ${identifier}`, () => {
const key = (
{
HEADGEAR_ID: "headGearSplId",
CLOTHES_ID: "clothesGearSplId",
SHOES_ID: "shoesGearSplId",
} as const
)[identifier]!;
describe("sortBuilds()", () => {
it("sorts by UPDATED_AT", () => {
const builds = [
mockBuild({
id: 1,
[key]: 3,
}),
mockBuild({ id: 1, updatedAt: 1 }),
mockBuild({ id: 2, updatedAt: 3 }),
mockBuild({ id: 3, updatedAt: 2 }),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["UPDATED_AT"],
weaponPool: [],
});
expect(sortedBuilds[0].id).toBe(2);
expect(sortedBuilds[1].id).toBe(3);
});
it("sorts by TOP_500", () => {
const builds = [
mockBuild({ id: 1 }),
mockBuild({
id: 2,
[key]: 1,
weapons: [{ weaponSplId: 1, maxPower: 3000, minRank: 1 }],
}),
mockBuild({
id: 3,
[key]: 1,
weapons: [
{ weaponSplId: 0, maxPower: null, minRank: null },
{ weaponSplId: 1, maxPower: 2900, minRank: 1 },
],
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: [identifier as any],
buildSorting: ["TOP_500"],
weaponPool: [],
});
assert.equal(sortedBuilds[2].id, 1);
expect(sortedBuilds[0].id).toBe(2);
expect(sortedBuilds[1].id).toBe(3);
});
}
BuildSorting("sorts when buildSort not given", () => {
const builds = [mockBuild({}), mockBuild({}), mockBuild({})];
// Add other test cases similarly...
sortBuilds({
builds,
weaponPool: [],
buildSorting: null,
it("sorts by both PUBLIC_BUILD and PRIVATE_BUILD", () => {
const builds = [
mockBuild({ id: 1, private: 1 }),
mockBuild({ id: 2, private: 0 }),
mockBuild({ id: 3, private: 1 }),
mockBuild({ id: 4, private: 0 }),
];
const sortedBuilds1 = sortBuilds({
builds,
buildSorting: ["PUBLIC_BUILD", "PRIVATE_BUILD"],
weaponPool: [],
});
expect(sortedBuilds1[0].id).toBe(2);
expect(sortedBuilds1[1].id).toBe(4);
expect(sortedBuilds1[2].id).toBe(1);
expect(sortedBuilds1[3].id).toBe(3);
const sortedBuilds2 = sortBuilds({
builds,
buildSorting: ["PRIVATE_BUILD", "PUBLIC_BUILD"],
weaponPool: [],
});
expect(sortedBuilds2[0].id).toBe(1);
expect(sortedBuilds2[1].id).toBe(3);
expect(sortedBuilds2[2].id).toBe(2);
expect(sortedBuilds2[3].id).toBe(4);
});
it("sorts by WEAPON_POOL", () => {
const builds = [
mockBuild({
id: 1,
weapons: [{ weaponSplId: 1000, maxPower: null, minRank: null }],
}),
mockBuild({
id: 2,
weapons: [{ weaponSplId: 10, maxPower: null, minRank: null }],
}),
mockBuild({
id: 3,
weapons: [{ weaponSplId: 1, maxPower: null, minRank: null }],
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["WEAPON_POOL"],
weaponPool: [1, 10],
});
expect(sortedBuilds[0].id).toBe(3);
expect(sortedBuilds[1].id).toBe(2);
});
it("sorts by WEAPON_POOL (alt kits are same priority)", () => {
const mockBuildBuilder = (
id: number,
weaponIds: MainWeaponId[],
): BuildSortingBuildArg => {
return mockBuild({
id,
weapons: weaponIds.map((wepId) => ({
weaponSplId: wepId,
maxPower: null,
minRank: null,
})),
});
};
const builds1 = [
[1, [1000]],
[2, [10]],
[3, [0]],
[4, [11]],
[5, [1]],
].map(([id, weaponIds]) =>
mockBuildBuilder(id as number, weaponIds as MainWeaponId[]),
);
const sortedBuilds1 = sortBuilds({
builds: builds1,
buildSorting: ["WEAPON_POOL"],
weaponPool: [1, 10],
});
let expected = [3, 5, 2, 4, 1];
for (const [idx, expectedVal] of expected.entries()) {
expect(sortedBuilds1[idx].id).toBe(expectedVal);
}
const builds2 = [
[1, [1000]],
[2, [0, 10, 1011]],
[3, [2]],
[4, [2010, 40]],
[5, [8001, 8000]],
[6, [8020, 201, 8021]],
[7, [5010, 46, 50]],
].map(([id, weaponIds]) =>
mockBuildBuilder(id as number, weaponIds as MainWeaponId[]),
);
const sortedBuilds2 = sortBuilds({
builds: builds2,
buildSorting: ["WEAPON_POOL"],
weaponPool: [47, 205, 1015],
});
expected = [4, 7, 6, 2, 1, 3, 5];
for (const [idx, expectedVal] of expected.entries()) {
expect(sortedBuilds2[idx].id).toBe(expectedVal);
}
});
it("sorts by ALPHABETICAL_TITLE", () => {
const builds = [
mockBuild({
id: 1,
title: "C",
}),
mockBuild({
id: 2,
title: "B",
}),
mockBuild({
id: 3,
title: "A",
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["ALPHABETICAL_TITLE"],
weaponPool: [],
});
expect(sortedBuilds[0].id).toBe(3);
expect(sortedBuilds[1].id).toBe(2);
});
it("sorts by WEAPON_IN_GAME_ORDER", () => {
const builds = [
mockBuild({
id: 1,
weapons: [{ weaponSplId: 1, maxPower: null, minRank: null }],
}),
mockBuild({
id: 2,
weapons: [{ weaponSplId: 10, maxPower: null, minRank: null }],
}),
mockBuild({
id: 3,
weapons: [
{ weaponSplId: 1000, maxPower: null, minRank: null },
{ weaponSplId: 1, maxPower: null, minRank: null },
],
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["WEAPON_IN_GAME_ORDER"],
weaponPool: [],
});
expect(sortedBuilds[2].id).toBe(2);
});
it("sorts by MODE", () => {
const builds = [
mockBuild({
id: 1,
modes: ["SZ"],
}),
mockBuild({
id: 2,
modes: ["CB"],
}),
mockBuild({
id: 3,
modes: ["SZ", "TC", "CB"],
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["MODE"],
weaponPool: [],
});
expect(sortedBuilds[2].id).toBe(2);
});
it("sorts by MODE (no mode last)", () => {
const builds = [
mockBuild({
id: 1,
modes: [],
}),
mockBuild({
id: 2,
modes: ["CB"],
}),
mockBuild({
id: 3,
modes: ["SZ", "TC", "CB"],
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["MODE"],
weaponPool: [],
});
expect(sortedBuilds[2].id).toBe(1);
});
for (const identifier of ["HEADGEAR_ID", "CLOTHES_ID", "SHOES_ID"]) {
it(`sorts by ${identifier}`, () => {
const key = (
{
HEADGEAR_ID: "headGearSplId",
CLOTHES_ID: "clothesGearSplId",
SHOES_ID: "shoesGearSplId",
} as const
)[identifier]!;
const builds = [
mockBuild({
id: 1,
[key]: 3,
}),
mockBuild({
id: 2,
[key]: 1,
}),
mockBuild({
id: 3,
[key]: 1,
}),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: [identifier as any],
weaponPool: [],
});
expect(sortedBuilds[2].id).toBe(1);
});
}
it("sorts when buildSort not given", () => {
const builds = [mockBuild({}), mockBuild({}), mockBuild({})];
sortBuilds({
builds,
weaponPool: [],
buildSorting: null,
});
});
it("sorts by UPDATED_AT and ALPHABETICAL_TITLE", () => {
const builds = [
mockBuild({ id: 1, updatedAt: 3, title: "C" }),
mockBuild({ id: 2, updatedAt: 2, title: "B" }),
mockBuild({ id: 3, updatedAt: 2, title: "A" }),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["UPDATED_AT", "ALPHABETICAL_TITLE"],
weaponPool: [],
});
expect(sortedBuilds[0].id).toBe(1);
expect(sortedBuilds[1].id).toBe(3);
});
it("sorts by ALPHABETICAL_TITLE and UPDATED_AT (reverse)", () => {
const builds = [
mockBuild({ id: 1, updatedAt: 3, title: "C" }),
mockBuild({ id: 2, updatedAt: 2, title: "B" }),
mockBuild({ id: 3, updatedAt: 2, title: "A" }),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["ALPHABETICAL_TITLE", "UPDATED_AT"],
weaponPool: [],
});
expect(sortedBuilds[0].id).toBe(3);
});
it("sorts by PUBLIC_BUILD", () => {
const builds = [
mockBuild({ id: 1, private: 1 }),
mockBuild({ id: 2, private: 1 }),
mockBuild({ id: 3, private: 0 }),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["PUBLIC_BUILD"],
weaponPool: [],
});
expect(sortedBuilds[0].id).toBe(3);
expect(sortedBuilds[1].id).toBe(1);
expect(sortedBuilds[2].id).toBe(2);
});
it("sorts by PRIVATE_BUILD", () => {
const builds = [
mockBuild({ id: 1, private: 0 }),
mockBuild({ id: 2, private: 1 }),
mockBuild({ id: 3, private: 1 }),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["PRIVATE_BUILD"],
weaponPool: [],
});
expect(sortedBuilds[0].id).toBe(2);
expect(sortedBuilds[1].id).toBe(3);
expect(sortedBuilds[2].id).toBe(1);
});
});
BuildSorting("sorts by UPDATED_AT and ALPHABETICAL_TITLE", () => {
const builds = [
mockBuild({ id: 1, updatedAt: 3, title: "C" }),
mockBuild({ id: 2, updatedAt: 2, title: "B" }),
mockBuild({ id: 3, updatedAt: 2, title: "A" }),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["UPDATED_AT", "ALPHABETICAL_TITLE"],
weaponPool: [],
});
assert.equal(sortedBuilds[0].id, 1);
assert.equal(sortedBuilds[1].id, 3);
});
BuildSorting("sorts by ALPHABETICAL_TITLE and UPDATED_AT (reverse)", () => {
const builds = [
mockBuild({ id: 1, updatedAt: 3, title: "C" }),
mockBuild({ id: 2, updatedAt: 2, title: "B" }),
mockBuild({ id: 3, updatedAt: 2, title: "A" }),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["ALPHABETICAL_TITLE", "UPDATED_AT"],
weaponPool: [],
});
assert.equal(sortedBuilds[0].id, 3);
});
BuildSorting("sorts by PUBLIC_BUILD", () => {
const builds = [
mockBuild({ id: 1, private: 1 }),
mockBuild({ id: 2, private: 1 }),
mockBuild({ id: 3, private: 0 }),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["PUBLIC_BUILD"],
weaponPool: [],
});
assert.equal(sortedBuilds[0].id, 3);
assert.equal(sortedBuilds[1].id, 1);
assert.equal(sortedBuilds[2].id, 2);
});
BuildSorting("sorts by PRIVATE_BUILD", () => {
const builds = [
mockBuild({ id: 1, private: 0 }),
mockBuild({ id: 2, private: 1 }),
mockBuild({ id: 3, private: 1 }),
];
const sortedBuilds = sortBuilds({
builds,
buildSorting: ["PRIVATE_BUILD"],
weaponPool: [],
});
assert.equal(sortedBuilds[0].id, 2);
assert.equal(sortedBuilds[1].id, 3);
assert.equal(sortedBuilds[2].id, 1);
});
BuildSorting("sorts by both PUBLIC_BUILD and PRIVATE_BUILD", () => {
const builds = [
mockBuild({ id: 1, private: 1 }),
mockBuild({ id: 2, private: 0 }),
mockBuild({ id: 3, private: 1 }),
mockBuild({ id: 4, private: 0 }),
];
const sortedBuilds1 = sortBuilds({
builds,
buildSorting: ["PUBLIC_BUILD", "PRIVATE_BUILD"],
weaponPool: [],
});
assert.equal(sortedBuilds1[0].id, 2);
assert.equal(sortedBuilds1[1].id, 4);
assert.equal(sortedBuilds1[2].id, 1);
assert.equal(sortedBuilds1[3].id, 3);
const sortedBuilds2 = sortBuilds({
builds,
buildSorting: ["PRIVATE_BUILD", "PUBLIC_BUILD"],
weaponPool: [],
});
assert.equal(sortedBuilds2[0].id, 1);
assert.equal(sortedBuilds2[1].id, 3);
assert.equal(sortedBuilds2[2].id, 2);
assert.equal(sortedBuilds2[3].id, 4);
});
BuildSorting.run();

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, test } from "bun:test";
import { beforeEach, describe, expect, test } from "vitest";
import { InMemoryDatabase } from "~/modules/brackets-memory-db";
import { BracketsManager } from "../manager";

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, test } from "bun:test";
import { beforeEach, describe, expect, test } from "vitest";
import { Status } from "~/db/types";
import { InMemoryDatabase } from "~/modules/brackets-memory-db";
import { BracketsManager } from "../manager";

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, test } from "bun:test";
import { beforeEach, describe, expect, test } from "vitest";
import { InMemoryDatabase } from "~/modules/brackets-memory-db";
import { BracketsManager } from "../manager";

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, test } from "bun:test";
import { beforeEach, describe, expect, test } from "vitest";
import { InMemoryDatabase } from "~/modules/brackets-memory-db";
import { BracketsManager } from "../manager";

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import { InMemoryDatabase } from "~/modules/brackets-memory-db";
import { BracketsManager } from "../manager";

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import {
assertRoundRobin,
balanceByes,

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, test } from "bun:test";
import { beforeEach, describe, expect, test } from "vitest";
import { InMemoryDatabase } from "~/modules/brackets-memory-db";
import { BracketsManager } from "../manager";

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, test } from "bun:test";
import { beforeEach, describe, expect, test } from "vitest";
import { Status } from "~/db/types";
import { InMemoryDatabase } from "~/modules/brackets-memory-db";
import { BracketsManager } from "../manager";

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, test } from "bun:test";
import { beforeEach, describe, expect, test } from "vitest";
import { Status } from "~/db/types";
import { InMemoryDatabase } from "~/modules/brackets-memory-db";
import { BracketsManager } from "../manager";

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import type { MainWeaponId } from "./types";
import { weaponIdToBucketId } from "./weapon-ids";

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import { MapPool } from "~/features/map-list-generator/core/map-pool";
import { createTournamentMapList } from ".";
import type { RankedModeShort } from "../in-game-lists";

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import { cutToNDecimalPlaces } from "./number";
describe("cutToNDecimalPlaces()", () => {

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from "vitest";
import { pathnameFromPotentialURL } from "./strings";
describe("pathnameFromPotentialURL()", () => {

View File

@@ -1,11 +1,4 @@
import {
afterEach,
beforeEach,
describe,
expect,
setSystemTime,
test,
} from "bun:test";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { queryToUserIdentifier, userDiscordIdIsAged } from "./users";
describe("queryToUserIdentifier()", () => {
@@ -48,11 +41,12 @@ describe("queryToUserIdentifier()", () => {
describe("userDiscordIdIsAged()", () => {
beforeEach(() => {
setSystemTime(new Date("2023-11-25T00:00:00.000Z"));
vi.useFakeTimers();
vi.setSystemTime(new Date("2023-11-25T00:00:00.000Z"));
});
afterEach(() => {
setSystemTime();
vi.useRealTimers();
});
test("returns false if discord id is not aged", () => {

Binary file not shown.

13017
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -20,11 +20,9 @@
"biome:fix": "bunx @biomejs/biome check --write .",
"biome:fix:unsafe": "bunx @biomejs/biome check --write --unsafe .",
"typecheck": "tsc --noEmit",
"test:unit": "NODE_ENV=test bun test",
"test:unit:all": "bun test:unit app",
"test:unit": "vitest run",
"test:e2e": "bunx playwright test",
"cf": "bun run biome:fix && bun run test:unit:all && bun run check-translation-jsons && bun run typecheck && bun run test:e2e",
"cf:noe2e": "bun run biome:fix && bun run test:unit:all && bun run check-translation-jsons && bun run typecheck"
"cf": "npm run biome:fix && npm run test:unit && npm run check-translation-jsons && npm run typecheck"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.645.0",
@@ -101,7 +99,8 @@
"sql-formatter": "^15.4.2",
"typescript": "^5.5.4",
"vite": "^5.4.3",
"vite-tsconfig-paths": "^5.0.1"
"vite-tsconfig-paths": "^5.0.1",
"vitest": "^2.1.1"
},
"trustedDependencies": [
"@biomejs/biome",

View File

@@ -2,6 +2,7 @@ import { vitePlugin as remix } from "@remix-run/dev";
import { installGlobals } from "@remix-run/node";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { configDefaults } from "vitest/config";
installGlobals();
@@ -356,6 +357,9 @@ export default defineConfig(() => {
}),
tsconfigPaths(),
],
test: {
exclude: [...configDefaults.exclude, "e2e/**"],
},
build: {
// this is mostly done so that i18n jsons as defined in ./app/modules/i18n/loader.ts
// do not end up in the js bundle as minimized strings