feat: reorganize settings and add synced appearance preferences

This commit is contained in:
NoSetViolin committed 2026-10-12 18:26:53 +09:00
1 parent 28c128d0c9
commit 8d750d19b0
30 files changed
+835 -98

No files matched your search

+23 -1
View File
@@ -37,13 +37,35 @@ describe("database", () => {
const userCols = botDb.db.prepare("PRAGMA table_info(users)").all() as Array<{ name: string }>;
const userColNames = userCols.map((c) => c.name).sort();
expect(userColNames).toEqual(["createdAt", "id", "passwordHash", "role", "updatedAt", "username"]);
expect(userColNames).toEqual(["accentColor", "createdAt", "id", "passwordHash", "role", "updatedAt", "username"]);
const sessionCols = botDb.db.prepare("PRAGMA table_info(sessions)").all() as Array<{ name: string }>;
const sessionColNames = sessionCols.map((c) => c.name).sort();
expect(sessionColNames).toEqual(["createdAt", "expiresAt", "id", "lastSeenAt", "userId"]);
});
it("migrates existing accounts and preserves their accent across database reopen", async () => {
const dir = mkdtempSync(join(tmpdir(), 'tsmb-accent-'));
const path = join(dir, 'test.db');
let db = createDatabase(path);
try {
const user = await createUserStore(db.db).createUser('alice', 'test-password', 'member');
db.db.exec('ALTER TABLE users DROP COLUMN accentColor');
db.close();
db = createDatabase(path);
const users = createUserStore(db.db);
expect(users.getAccentColor(user.id)).toBe('#335eea');
users.setAccentColor(user.id, '#0891b2');
db.close();
db = createDatabase(path);
expect(createUserStore(db.db).getAccentColor(user.id)).toBe('#0891b2');
expect(createUserStore(db.db).findById(user.id)?.username).toBe('alice');
} finally {
db.close();
rmSync(dir, { recursive: true, force: true });
}
});
it("creates user_audit table on init", () => {
const tables = botDb.db
.prepare("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name")