1
0
forked from baron/baron-sso

코드체크 실패 케이스 해결. 배치잡 야간 배정

This commit is contained in:
2026-05-29 16:44:46 +09:00
parent 5b345fcf6a
commit 5ddfc6c81b
9 changed files with 546 additions and 80 deletions

View File

@@ -25,6 +25,23 @@ vi.mock("react-oidc-context", () => ({
vi.mock("../../lib/i18n", () => createI18nMock());
vi.mock("../../../../common/core/components/audit", () => ({
AuditLogTable: ({
logs,
}: {
logs: Array<{ user_id: string; event_type: string }>;
}) => (
<div>
{logs.map((log) => (
<div key={`${log.user_id}-${log.event_type}`}>
<span>{log.user_id}</span>
<span>{log.event_type}</span>
</div>
))}
</div>
),
}));
vi.mock("../../lib/adminApi", () => ({
fetchAuditLogs: vi.fn(async () => ({
items: [

View File

@@ -1,5 +1,10 @@
import { describe, expect, it } from "vitest";
import { cn } from "./utils";
import { afterEach, describe, expect, it, vi } from "vitest";
import { cn, generateSecurePassword } from "./utils";
afterEach(() => {
vi.restoreAllMocks();
vi.unstubAllGlobals();
});
describe("cn utility", () => {
it("merges class names correctly", () => {
@@ -11,3 +16,23 @@ describe("cn utility", () => {
expect(cn("px-2 py-2", "px-4")).toBe("py-2 px-4");
});
});
describe("generateSecurePassword", () => {
it("uses crypto random values when available", () => {
vi.stubGlobal("crypto", {
getRandomValues: vi.fn((values: Uint32Array) => {
values.set([0, 1, 2, 3]);
return values;
}),
});
expect(generateSecurePassword(4)).toBe("abcd");
});
it("falls back to Math.random when crypto is unavailable", () => {
vi.stubGlobal("crypto", undefined);
vi.spyOn(Math, "random").mockReturnValue(0);
expect(generateSecurePassword(3)).toBe("aaa");
});
});