refactor: add missing await before promise expects

This commit is contained in:
Nicolas Meienberger 2026-02-26 18:47:21 +01:00 committed by Nico
parent ce7afafbf6
commit a2b69323b1
9 changed files with 32 additions and 22 deletions

View file

@ -148,5 +148,13 @@
"builtin": true "builtin": true
}, },
"globals": {}, "globals": {},
"ignorePatterns": ["**/api-client/**"] "ignorePatterns": ["**/api-client/**"],
"overrides": [
{
"files": ["**/*.test.ts", "**/*.test.tsx"],
"rules": {
"typescript/await-thenable": "off"
}
}
]
} }

View file

@ -59,7 +59,7 @@ describe("RepositoryMutex", () => {
controller.abort(); controller.abort();
expect(exclusivePromise).rejects.toThrow(); await expect(exclusivePromise).rejects.toThrow();
expect(results).toEqual(["acquired-shared-1", "aborted-exclusive"]); expect(results).toEqual(["acquired-shared-1", "aborted-exclusive"]);
releaseShared1(); releaseShared1();
@ -83,10 +83,10 @@ describe("RepositoryMutex", () => {
const p3 = repoMutex.acquireExclusive(repoId, "ex-3"); const p3 = repoMutex.acquireExclusive(repoId, "ex-3");
controller2.abort(); controller2.abort();
expect(p2).rejects.toThrow(); await expect(p2).rejects.toThrow();
controller1.abort(); controller1.abort();
expect(p1).rejects.toThrow(); await expect(p1).rejects.toThrow();
releaseShared1(); releaseShared1();
@ -115,7 +115,7 @@ describe("RepositoryMutex", () => {
// Trigger abort while it's waiting // Trigger abort while it's waiting
controller.abort(); controller.abort();
expect(abortedAcquisition).rejects.toThrow(); await expect(abortedAcquisition).rejects.toThrow();
expect(removed).toBe(true); expect(removed).toBe(true);
expect(repoMutex.isLocked(repoId)).toBe(true); expect(repoMutex.isLocked(repoId)).toBe(true);
@ -252,8 +252,8 @@ describe("RepositoryMutex", () => {
const controller = new AbortController(); const controller = new AbortController();
controller.abort(new Error("pre-aborted")); controller.abort(new Error("pre-aborted"));
expect(repoMutex.acquireShared(repoId, "s1", controller.signal)).rejects.toThrow("pre-aborted"); await expect(repoMutex.acquireShared(repoId, "s1", controller.signal)).rejects.toThrow("pre-aborted");
expect(repoMutex.acquireExclusive(repoId, "e1", controller.signal)).rejects.toThrow("pre-aborted"); await expect(repoMutex.acquireExclusive(repoId, "e1", controller.signal)).rejects.toThrow("pre-aborted");
expect(repoMutex.isLocked(repoId)).toBe(false); expect(repoMutex.isLocked(repoId)).toBe(false);
}); });

View file

@ -67,7 +67,7 @@ describe("convertLegacyUserOnFirstLogin", () => {
password: "wrong-password", password: "wrong-password",
}); });
expect(convertLegacyUserOnFirstLogin(ctx)).rejects.toThrow("Invalid credentials"); await expect(convertLegacyUserOnFirstLogin(ctx)).rejects.toThrow("Invalid credentials");
// Verify user still exists (not migrated) // Verify user still exists (not migrated)
const user = await db.query.usersTable.findFirst({ const user = await db.query.usersTable.findFirst({

View file

@ -168,14 +168,14 @@ describe("stop backup", () => {
}); });
// act & assert // act & assert
expect(backupsExecutionService.stopBackup(schedule.id)).rejects.toThrow( await expect(backupsExecutionService.stopBackup(schedule.id)).rejects.toThrow(
"No backup is currently running for this schedule", "No backup is currently running for this schedule",
); );
}); });
test("should throw NotFoundError when schedule does not exist", async () => { test("should throw NotFoundError when schedule does not exist", async () => {
// act & assert // act & assert
expect(backupsExecutionService.stopBackup(99999)).rejects.toThrow("Backup schedule not found"); await expect(backupsExecutionService.stopBackup(99999)).rejects.toThrow("Backup schedule not found");
}); });
}); });
@ -223,14 +223,14 @@ describe("retention policy - runForget", () => {
}); });
// act & assert // act & assert
expect(backupsExecutionService.runForget(schedule.id)).rejects.toThrow( await expect(backupsExecutionService.runForget(schedule.id)).rejects.toThrow(
"No retention policy configured for this schedule", "No retention policy configured for this schedule",
); );
}); });
test("should throw NotFoundError when schedule does not exist", async () => { test("should throw NotFoundError when schedule does not exist", async () => {
// act & assert // act & assert
expect(backupsExecutionService.runForget(99999)).rejects.toThrow("Backup schedule not found"); await expect(backupsExecutionService.runForget(99999)).rejects.toThrow("Backup schedule not found");
}); });
test("should throw NotFoundError when repository does not exist", async () => { test("should throw NotFoundError when repository does not exist", async () => {
@ -242,7 +242,9 @@ describe("retention policy - runForget", () => {
}); });
// act & assert // act & assert
expect(backupsExecutionService.runForget(schedule.id, "non-existent-repo")).rejects.toThrow("Repository not found"); await expect(backupsExecutionService.runForget(schedule.id, "non-existent-repo")).rejects.toThrow(
"Repository not found",
);
}); });
}); });

View file

@ -222,8 +222,10 @@ describe("getScheduleByIdOrShortId", () => {
organizationId: otherOrgId, organizationId: otherOrgId,
}); });
expect(backupsService.getScheduleByIdOrShortId(schedule.shortId)).rejects.toThrow("Backup schedule not found"); await expect(backupsService.getScheduleByIdOrShortId(schedule.shortId)).rejects.toThrow(
expect(backupsService.getScheduleByIdOrShortId(schedule.id)).rejects.toThrow("Backup schedule not found"); "Backup schedule not found",
);
await expect(backupsService.getScheduleByIdOrShortId(schedule.id)).rejects.toThrow("Backup schedule not found");
}); });
}); });

View file

@ -85,7 +85,7 @@ describe("volumeService", () => {
const { organizationId, user } = await createTestSession(); const { organizationId, user } = await createTestSession();
await withContext({ organizationId, userId: user.id }, async () => { await withContext({ organizationId, userId: user.id }, async () => {
expect(volumeService.getVolume(asShortId("nonexistent"))).rejects.toThrow("Volume not found"); await expect(volumeService.getVolume(asShortId("nonexistent"))).rejects.toThrow("Volume not found");
}); });
}); });
}); });
@ -120,7 +120,7 @@ describe("volumeService security", () => {
await withContext({ organizationId, userId: user.id }, async () => { await withContext({ organizationId, userId: user.id }, async () => {
const traversalPath = `../${path.basename(secretPath)}`; const traversalPath = `../${path.basename(secretPath)}`;
expect(volumeService.listFiles(volume.shortId, traversalPath)).rejects.toThrow("Invalid path"); await expect(volumeService.listFiles(volume.shortId, traversalPath)).rejects.toThrow("Invalid path");
}); });
} finally { } finally {
await fs.rm(tempRoot, { recursive: true, force: true }); await fs.rm(tempRoot, { recursive: true, force: true });

View file

@ -79,7 +79,7 @@
"@testing-library/dom": "^10.4.1", "@testing-library/dom": "^10.4.1",
"@testing-library/react": "^16.3.2", "@testing-library/react": "^16.3.2",
"@total-typescript/shoehorn": "^0.1.2", "@total-typescript/shoehorn": "^0.1.2",
"@types/bun": "^1.3.6", "@types/bun": "^1.3.9",
"@types/content-disposition": "^0.5.9", "@types/content-disposition": "^0.5.9",
"@types/node": "^25.3.0", "@types/node": "^25.3.0",
"@types/react": "^19.2.14", "@types/react": "^19.2.14",
@ -87,7 +87,6 @@
"@types/semver": "^7.7.1", "@types/semver": "^7.7.1",
"@vitejs/plugin-react": "^5.1.4", "@vitejs/plugin-react": "^5.1.4",
"babel-plugin-react-compiler": "^1.0.0", "babel-plugin-react-compiler": "^1.0.0",
"bun-types": "^1.3.6",
"dotenv-cli": "^11.0.0", "dotenv-cli": "^11.0.0",
"drizzle-kit": "^1.0.0-beta.15-859cf75", "drizzle-kit": "^1.0.0-beta.15-859cf75",
"lefthook": "^2.1.1", "lefthook": "^2.1.1",

View file

@ -100,7 +100,7 @@
"@testing-library/dom": "^10.4.1", "@testing-library/dom": "^10.4.1",
"@testing-library/react": "^16.3.2", "@testing-library/react": "^16.3.2",
"@total-typescript/shoehorn": "^0.1.2", "@total-typescript/shoehorn": "^0.1.2",
"@types/bun": "^1.3.6", "@types/bun": "^1.3.9",
"@types/content-disposition": "^0.5.9", "@types/content-disposition": "^0.5.9",
"@types/node": "^25.3.0", "@types/node": "^25.3.0",
"@types/react": "^19.2.14", "@types/react": "^19.2.14",
@ -108,7 +108,6 @@
"@types/semver": "^7.7.1", "@types/semver": "^7.7.1",
"@vitejs/plugin-react": "^5.1.4", "@vitejs/plugin-react": "^5.1.4",
"babel-plugin-react-compiler": "^1.0.0", "babel-plugin-react-compiler": "^1.0.0",
"bun-types": "^1.3.6",
"dotenv-cli": "^11.0.0", "dotenv-cli": "^11.0.0",
"drizzle-kit": "^1.0.0-beta.15-859cf75", "drizzle-kit": "^1.0.0-beta.15-859cf75",
"lefthook": "^2.1.1", "lefthook": "^2.1.1",

View file

@ -2,7 +2,7 @@
"include": ["**/*"], "include": ["**/*"],
"compilerOptions": { "compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"], "lib": ["DOM", "DOM.Iterable", "ES2022"],
"types": ["node", "vite/client", "bun-types"], "types": ["node", "vite/client"],
"target": "ES2022", "target": "ES2022",
"module": "ES2022", "module": "ES2022",
"moduleResolution": "bundler", "moduleResolution": "bundler",