Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
79 lines
2.7 KiB
TypeScript
79 lines
2.7 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { buildQueryString } from "./auditLog";
|
|
|
|
describe("buildQueryString", () => {
|
|
it("converts page 1 to page=0 for the 0-based mobile-api", () => {
|
|
const qs = buildQueryString({ page: 1, pageSize: 20 });
|
|
expect(qs).toContain("page=0");
|
|
});
|
|
|
|
it("converts page 2 to page=1", () => {
|
|
const qs = buildQueryString({ page: 2, pageSize: 20 });
|
|
expect(qs).toContain("page=1");
|
|
});
|
|
|
|
it("clamps page 0 to 0 (Math.max guard)", () => {
|
|
const qs = buildQueryString({ page: 0, pageSize: 20 });
|
|
expect(qs).toContain("page=0");
|
|
});
|
|
|
|
it("only sends allow-listed filters — actor", () => {
|
|
const qs = buildQueryString({ page: 1, pageSize: 20, actor: "admin1" });
|
|
expect(qs).toContain("actor=admin1");
|
|
});
|
|
|
|
it("only sends allow-listed filters — actorType", () => {
|
|
const qs = buildQueryString({ page: 1, pageSize: 20, actorType: "ADMIN" });
|
|
expect(qs).toContain("actorType=ADMIN");
|
|
});
|
|
|
|
it("only sends allow-listed filters — module", () => {
|
|
const qs = buildQueryString({ page: 1, pageSize: 20, module: "BO_MEMBERS" });
|
|
expect(qs).toContain("module=BO_MEMBERS");
|
|
});
|
|
|
|
it("only sends allow-listed filters — action", () => {
|
|
const qs = buildQueryString({ page: 1, pageSize: 20, action: "CREATE" });
|
|
expect(qs).toContain("action=CREATE");
|
|
});
|
|
|
|
it("only sends allow-listed filters — from", () => {
|
|
const qs = buildQueryString({ page: 1, pageSize: 20, from: "2026-09-01" });
|
|
expect(qs).toContain("from=2026-09-01");
|
|
});
|
|
|
|
it("only sends allow-listed filters — to", () => {
|
|
const qs = buildQueryString({ page: 1, pageSize: 20, to: "2026-09-28" });
|
|
expect(qs).toContain("to=2026-09-28");
|
|
});
|
|
|
|
it("only sends allow-listed filters — ip", () => {
|
|
const qs = buildQueryString({ page: 1, pageSize: 20, ip: "203.0.113.1" });
|
|
expect(qs).toContain("ip=203.0.113.1");
|
|
});
|
|
|
|
it("does not send sortBy or sortDir (removed)", () => {
|
|
const qs = buildQueryString({ page: 1, pageSize: 20, sortBy: "occurredAt", sortDir: "desc" });
|
|
expect(qs).not.toContain("sortBy");
|
|
expect(qs).not.toContain("sortDir");
|
|
});
|
|
|
|
it("sends size", () => {
|
|
const qs = buildQueryString({ page: 1, pageSize: 50 });
|
|
expect(qs).toContain("size=50");
|
|
});
|
|
|
|
it("does not send undefined filters", () => {
|
|
const qs = buildQueryString({ page: 1, pageSize: 20 });
|
|
expect(qs).not.toContain("actor");
|
|
expect(qs).not.toContain("actorType");
|
|
expect(qs).not.toContain("module");
|
|
expect(qs).not.toContain("action");
|
|
expect(qs).not.toContain("from");
|
|
expect(qs).not.toContain("to");
|
|
expect(qs).not.toContain("ip");
|
|
expect(qs).not.toContain("sortBy");
|
|
expect(qs).not.toContain("sortDir");
|
|
});
|
|
});
|