mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 23:02:10 +03:00
Resets 68 files to release/v3.8.0 state to prevent: - Auth: allExpired detection, apiKeyHealth sync, terminal connection handling - Security: federation leaderboard auth, pbkdf2 hashing, antiCheat zScore - Executor: fixToolPairs after fixToolAdjacency (Claude tool adjacency) - Provider: apiKeyHealth cleanup on key rotation - UI: NotificationToast onClick stopPropagation - i18n: ~50 deleted keys in en.json + all 41 locales - Tests: 500+ lines of deleted tests restored New features (t3.chat, combo exhaustion, Kiro multi-account, Zed Docker, context window filter, CLI rotate, E2E failover) remain intact.
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { addXp, getXp } from "../../../src/lib/db/gamification";
|
|
import { calculateLevel } from "../../../src/lib/gamification/xp";
|
|
import { getDbInstance } from "../../../src/lib/db/core";
|
|
|
|
describe("DB Gamification — addXp level computation", () => {
|
|
it("sets correct level for large initial XP", () => {
|
|
const testKey = `test-addxp-level-${Date.now()}`;
|
|
addXp(testKey, "invite_redeem", 50000);
|
|
|
|
const xp = getXp(testKey);
|
|
assert.ok(xp);
|
|
assert.equal(xp.currentLevel, calculateLevel(50000));
|
|
|
|
// Cleanup
|
|
const db = getDbInstance();
|
|
db.prepare("DELETE FROM user_levels WHERE api_key_id = ?").run(testKey);
|
|
db.prepare("DELETE FROM xp_audit_log WHERE api_key_id = ?").run(testKey);
|
|
});
|
|
|
|
it("sets level 1 for small initial XP", () => {
|
|
const testKey = `test-addxp-small-${Date.now()}`;
|
|
addXp(testKey, "request", 1);
|
|
|
|
const xp = getXp(testKey);
|
|
assert.ok(xp);
|
|
assert.equal(xp.currentLevel, 1);
|
|
|
|
// Cleanup
|
|
const db = getDbInstance();
|
|
db.prepare("DELETE FROM user_levels WHERE api_key_id = ?").run(testKey);
|
|
db.prepare("DELETE FROM xp_audit_log WHERE api_key_id = ?").run(testKey);
|
|
});
|
|
});
|