Skip to content

Commit a2ae656

Browse files
committed
Merge branch 'master' into constants
2 parents 3e2ce3c + 2d558d1 commit a2ae656

85 files changed

Lines changed: 1454 additions & 1121 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,5 @@ frontend/static/webfonts-preview
131131

132132
.turbo
133133
frontend/.env.sentry-build-plugin
134-
.claude/worktrees
134+
.claude/worktrees
135+
1024MiB

backend/__tests__/__integration__/dal/preset.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe("PresetDal", () => {
6969
//WHEN / THEN
7070
await expect(() =>
7171
PresetDal.addPreset(uid, { name: "max", config: {} }),
72-
).rejects.toThrowError("Too many presets");
72+
).rejects.toThrow("Too many presets");
7373
});
7474
it("should add preset", async () => {
7575
//GIVEN
@@ -358,7 +358,7 @@ describe("PresetDal", () => {
358358
const uid = new ObjectId().toHexString();
359359
await expect(() =>
360360
PresetDal.removePreset(uid, new ObjectId().toHexString()),
361-
).rejects.toThrowError("Preset not found");
361+
).rejects.toThrow("Preset not found");
362362
});
363363
it("should remove", async () => {
364364
//GIVEN
@@ -421,7 +421,7 @@ describe("PresetDal", () => {
421421
//WHEN
422422
await expect(() =>
423423
PresetDal.removePreset(decoyUid, first),
424-
).rejects.toThrowError("Preset not found");
424+
).rejects.toThrow("Preset not found");
425425

426426
//THEN
427427
const read = await PresetDal.getPresets(uid);

backend/__tests__/__integration__/dal/user.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ describe("UserDal", () => {
11751175
it("should throw for unknown user", async () => {
11761176
await expect(async () =>
11771177
UserDAL.getPartialUser("1234", "stack", []),
1178-
).rejects.toThrowError("User not found\nStack: stack");
1178+
).rejects.toThrow("User not found\nStack: stack");
11791179
});
11801180

11811181
it("should get streak", async () => {
@@ -1228,7 +1228,7 @@ describe("UserDal", () => {
12281228
it("throws for nonexisting user", async () => {
12291229
await expect(async () =>
12301230
UserDAL.updateEmail("unknown", "test@example.com"),
1231-
).rejects.toThrowError("User not found\nStack: update email");
1231+
).rejects.toThrow("User not found\nStack: update email");
12321232
});
12331233
it("should update", async () => {
12341234
//given
@@ -1244,7 +1244,7 @@ describe("UserDal", () => {
12441244
});
12451245
describe("resetPb", () => {
12461246
it("throws for nonexisting user", async () => {
1247-
await expect(async () => UserDAL.resetPb("unknown")).rejects.toThrowError(
1247+
await expect(async () => UserDAL.resetPb("unknown")).rejects.toThrow(
12481248
"User not found\nStack: reset pb",
12491249
);
12501250
});
@@ -1272,7 +1272,7 @@ describe("UserDal", () => {
12721272
it("throws for nonexisting user", async () => {
12731273
await expect(async () =>
12741274
UserDAL.linkDiscord("unknown", "", ""),
1275-
).rejects.toThrowError("User not found\nStack: link discord");
1275+
).rejects.toThrow("User not found\nStack: link discord");
12761276
});
12771277
it("should update", async () => {
12781278
//given
@@ -1308,7 +1308,7 @@ describe("UserDal", () => {
13081308
it("throws for nonexisting user", async () => {
13091309
await expect(async () =>
13101310
UserDAL.unlinkDiscord("unknown"),
1311-
).rejects.toThrowError("User not found\nStack: unlink discord");
1311+
).rejects.toThrow("User not found\nStack: unlink discord");
13121312
});
13131313
it("should update", async () => {
13141314
//given

backend/__tests__/api/controllers/admin.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ describe("AdminController", () => {
323323
data: null,
324324
});
325325

326-
expect(addToInboxMock).toBeCalledTimes(2);
326+
expect(addToInboxMock).toHaveBeenCalledTimes(2);
327327
expect(deleteReportsMock).toHaveBeenCalledWith(["1", "2"]);
328328
});
329329
it("should fail wihtout mandatory properties", async () => {

backend/__tests__/api/controllers/user.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,7 @@ describe("user controller test", () => {
18141814
//THEN
18151815
expect(result.body.message).toEqual("The Discord account is blocked");
18161816

1817-
expect(blocklistContainsMock).toBeCalledWith({
1817+
expect(blocklistContainsMock).toHaveBeenCalledWith({
18181818
discordId: "discordUserId",
18191819
});
18201820
});

backend/__tests__/middlewares/auth.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ describe("middlewares/auth", () => {
154154
{ headers: { authorization: "ApeKey aWQua2V5" } },
155155
{ acceptApeKeys: false },
156156
),
157-
).rejects.toThrowError("This endpoint does not accept ApeKeys");
157+
).rejects.toThrow("This endpoint does not accept ApeKeys");
158158

159159
//THEN
160160
});
@@ -170,7 +170,7 @@ describe("middlewares/auth", () => {
170170
{ headers: { authorization: "ApeKey aWQua2V5" } },
171171
{ acceptApeKeys: false },
172172
),
173-
).rejects.toThrowError("ApeKeys are not being accepted at this time");
173+
).rejects.toThrow("ApeKeys are not being accepted at this time");
174174

175175
//THEN
176176
});
@@ -253,7 +253,7 @@ describe("middlewares/auth", () => {
253253
);
254254
});
255255
it("should fail without authentication", async () => {
256-
await expect(() => authenticate({ headers: {} })).rejects.toThrowError(
256+
await expect(() => authenticate({ headers: {} })).rejects.toThrow(
257257
"Unauthorized\nStack: endpoint: /api/v1 no authorization header found",
258258
);
259259

@@ -269,7 +269,7 @@ describe("middlewares/auth", () => {
269269
it("should fail with empty authentication", async () => {
270270
await expect(() =>
271271
authenticate({ headers: { authorization: "" } }),
272-
).rejects.toThrowError(
272+
).rejects.toThrow(
273273
"Unauthorized\nStack: endpoint: /api/v1 no authorization header found",
274274
);
275275

@@ -285,7 +285,7 @@ describe("middlewares/auth", () => {
285285
it("should fail with missing authentication token", async () => {
286286
await expect(() =>
287287
authenticate({ headers: { authorization: "Bearer" } }),
288-
).rejects.toThrowError(
288+
).rejects.toThrow(
289289
"Missing authentication token\nStack: authenticateWithAuthHeader",
290290
);
291291

@@ -301,7 +301,7 @@ describe("middlewares/auth", () => {
301301
it("should fail with unknown authentication scheme", async () => {
302302
await expect(() =>
303303
authenticate({ headers: { authorization: "unknown format" } }),
304-
).rejects.toThrowError(
304+
).rejects.toThrow(
305305
'Unknown authentication scheme\nStack: The authentication scheme "unknown" is not implemented',
306306
);
307307

@@ -417,7 +417,7 @@ describe("middlewares/auth", () => {
417417
//THEN
418418
await expect(() =>
419419
authenticate({ headers: {} }, { isPublicOnDev: true }),
420-
).rejects.toThrowError("Unauthorized");
420+
).rejects.toThrow("Unauthorized");
421421
});
422422
it("should allow with apeKey on dev public endpoint in production", async () => {
423423
//WHEN
@@ -476,7 +476,7 @@ describe("middlewares/auth", () => {
476476
},
477477
{ isGithubWebhook: true },
478478
),
479-
).rejects.toThrowError("Github webhook signature invalid");
479+
).rejects.toThrow("Github webhook signature invalid");
480480

481481
//THEH
482482
expect(prometheusIncrementAuthMock).not.toHaveBeenCalled();
@@ -497,7 +497,7 @@ describe("middlewares/auth", () => {
497497
},
498498
{ isGithubWebhook: true },
499499
),
500-
).rejects.toThrowError("Missing Github signature header");
500+
).rejects.toThrow("Missing Github signature header");
501501

502502
//THEH
503503
expect(prometheusIncrementAuthMock).not.toHaveBeenCalled();
@@ -518,7 +518,7 @@ describe("middlewares/auth", () => {
518518
},
519519
{ isGithubWebhook: true },
520520
),
521-
).rejects.toThrowError("Missing Github Webhook Secret");
521+
).rejects.toThrow("Missing Github Webhook Secret");
522522

523523
//THEH
524524
expect(prometheusIncrementAuthMock).not.toHaveBeenCalled();
@@ -542,7 +542,7 @@ describe("middlewares/auth", () => {
542542
},
543543
{ isGithubWebhook: true },
544544
),
545-
).rejects.toThrowError(
545+
).rejects.toThrow(
546546
"Failed to authenticate Github webhook: could not validate",
547547
);
548548

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"testcontainers": "11.11.0",
8888
"tsx": "4.21.0",
8989
"typescript": "6.0.0-beta",
90-
"vitest": "4.0.15"
90+
"vitest": "4.1.0"
9191
},
9292
"engines": {
9393
"node": ">=24.0.0 <25"

frontend/__tests__/utils/url-handler.spec.ts renamed to frontend/__tests__/controllers/url-handler.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import * as Notifications from "../../src/ts/stores/notifications";
66
import * as TestLogic from "../../src/ts/test/test-logic";
77
import * as TestState from "../../src/ts/test/test-state";
88
import * as Misc from "../../src/ts/utils/misc";
9-
import { loadTestSettingsFromUrl } from "../../src/ts/utils/url-handler";
109
import { FunboxName } from "@monkeytype/schemas/configs";
1110
import { CustomTextSettings } from "@monkeytype/schemas/results";
11+
import { loadTestSettingsFromUrl } from "../../src/ts/controllers/url-handler";
1212

1313
//mock modules to avoid dependencies
1414
vi.mock("../../src/ts/test/test-logic", () => ({

frontend/__tests__/elements/test-activity-calendar.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ describe("test-activity-calendar.ts", () => {
11501150
);
11511151

11521152
//WHEN
1153-
expect(() => calendar.increment(getDate("2024-04-09"))).toThrowError(
1153+
expect(() => calendar.increment(getDate("2024-04-09"))).toThrow(
11541154
new Error("cannot alter data in the past."),
11551155
);
11561156
});

frontend/__tests__/root/config.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, it, expect, beforeEach, afterAll, vi } from "vitest";
22
import * as Config from "../../src/ts/config";
33
import * as Misc from "../../src/ts/utils/misc";
4+
import * as Env from "../../src/ts/utils/env";
45
import {
56
ConfigKey,
67
Config as ConfigType,
@@ -14,7 +15,7 @@ import * as Notifications from "../../src/ts/stores/notifications";
1415
const { replaceConfig, getConfig } = Config.__testing;
1516

1617
describe("Config", () => {
17-
const isDevEnvironmentMock = vi.spyOn(Misc, "isDevEnvironment");
18+
const isDevEnvironmentMock = vi.spyOn(Env, "isDevEnvironment");
1819
beforeEach(() => {
1920
isDevEnvironmentMock.mockClear();
2021
replaceConfig({});
@@ -73,9 +74,7 @@ describe("Config", () => {
7374
it("should throw if config key in not found in metadata", () => {
7475
expect(() => {
7576
Config.setConfig("nonExistentKey" as ConfigKey, true);
76-
}).toThrowError(
77-
`Config metadata for key "nonExistentKey" is not defined.`,
78-
);
77+
}).toThrow(`Config metadata for key "nonExistentKey" is not defined.`);
7978
});
8079

8180
it("fails if test is active and funbox no_quit", () => {

0 commit comments

Comments
 (0)