Files
EpicNext-Cms/src/lib/auth/session-user.test.ts
T
openhands 17847545dd
Deploy / release (push) Skipped
Deploy / deploy (push) Successful in 1m52s
Improvements: remove dead config, fix ESM, add URL validation, unify types, add missing logging
- Remove .prettierrc (dead config, Biome replaces Prettier)
- Rename lighthouserc.json to lighthouserc.cjs with module.exports for ESM compat
- Add logger.warn to empty catch blocks in auth, register, site-settings, prisma-cache, redis, security, rate-limit
- Unify ActionResult type: action-helper.ts uses 'ok' consistent with safe-action-shared.ts
- Add noUnusedLocals + noUnusedParameters to tsconfig + fix 25 pre-existing unused vars
- Replace barrel export src/types/index.ts with direct @/types/common imports
- Make trustHost conditional (development only) in auth.ts
- Add pre-flight URL validation to update-Nitrov3.sh to catch image.library.url misconfigurations
- Improve NITRO_IMAGE_LIBRARY_URL content validation in pre-flight & post-compute checks
2026-07-26 20:28:11 +02:00

35 lines
777 B
TypeScript

import { describe, expect, it } from "vitest";
import { databaseUserId, sessionUserId } from "@/lib/auth/session-user";
describe("sessionUserId", () => {
it("returns a positive safe integer from a valid session id", () => {
expect(sessionUserId("42")).toBe(42);
});
it.each([
undefined,
null,
"",
"0",
"-1",
"1.5",
"abc",
Number.MAX_SAFE_INTEGER + 1,
])("rejects invalid session id %s", (value) => {
expect(sessionUserId(value)).toBeNull();
});
});
describe("databaseUserId", () => {
it("converts a safe positive database id", () => {
expect(databaseUserId(42n)).toBe(42);
});
it.each([0n, -1n, BigInt(Number.MAX_SAFE_INTEGER) + 1n])(
"rejects unsafe database id %s",
(value) => {
expect(databaseUserId(value)).toBeNull();
},
);
});