Skip to content

Commit c6fb8e2

Browse files
committed
test: enhance database action counting tests to verify accurate totals after action creation and error removal
1 parent c74920f commit c6fb8e2

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

tests/database.test.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ describe("Database Operations", () => {
448448
});
449449

450450
it("should count total actions excluding errors", async () => {
451+
// Get baseline count
452+
const countBefore = await getTotalActionCount();
453+
454+
// Create 3 new actions
451455
const action1 = await createModerationAction({
452456
type: ActionType.WARN,
453457
targetDiscordId: "target017",
@@ -460,15 +464,23 @@ describe("Database Operations", () => {
460464
moderatorDiscordId: "mod017",
461465
});
462466

467+
await createModerationAction({
468+
type: ActionType.KICK,
469+
targetDiscordId: "target017",
470+
moderatorDiscordId: "mod017",
471+
});
472+
473+
// Count should have increased by 3
474+
const countAfterCreate = await getTotalActionCount();
475+
assert.strictEqual(countAfterCreate, countBefore + 3);
476+
463477
// Mark one as error
464478
await removeActionByError(action1.id, "corrector003", "Error");
465479

466-
// Count should exclude the removed one
467-
const total = await getTotalActionCount();
468-
469-
// Hard to test exact number since other tests create actions too
470-
// Just verify it's a positive number
471-
assert.ok(total > 0);
480+
// Count should decrease by 1 (original action marked as REMOVED_BY_ERROR)
481+
// Note: The correction record is created with REMOVED_BY_ERROR status, so it's never counted
482+
const countAfterRemoval = await getTotalActionCount();
483+
assert.strictEqual(countAfterRemoval, countBefore + 2);
472484
});
473485
});
474486

0 commit comments

Comments
 (0)