feat(ai-character): 관리자 인증 셸 구현
This commit is contained in:
58
src/shared/api/__tests__/query-client.test.ts
Normal file
58
src/shared/api/__tests__/query-client.test.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { ApiError } from "../api-error";
|
||||
import { createQueryClient, shouldRetryQuery } from "../query-client";
|
||||
|
||||
describe("TanStack Query defaults", () => {
|
||||
test("does not retry unauthenticated query errors", () => {
|
||||
// Given
|
||||
const error = new ApiError({
|
||||
status: 401,
|
||||
message: "인증 정보가 없습니다.",
|
||||
errorProperty: null,
|
||||
});
|
||||
|
||||
// When
|
||||
const shouldRetry = shouldRetryQuery(0, error);
|
||||
|
||||
// Then
|
||||
expect(shouldRetry).toBe(false);
|
||||
});
|
||||
|
||||
test("does not retry access-denied query errors", () => {
|
||||
// Given
|
||||
const error = new ApiError({
|
||||
status: 403,
|
||||
message: "접근 권한이 없습니다.",
|
||||
errorProperty: null,
|
||||
});
|
||||
|
||||
// When
|
||||
const shouldRetry = shouldRetryQuery(0, error);
|
||||
|
||||
// Then
|
||||
expect(shouldRetry).toBe(false);
|
||||
});
|
||||
|
||||
test("limits retries for other query errors", () => {
|
||||
// Given
|
||||
const error = new Error("network failure");
|
||||
|
||||
// When
|
||||
const shouldRetry = shouldRetryQuery(2, error);
|
||||
|
||||
// Then
|
||||
expect(shouldRetry).toBe(false);
|
||||
});
|
||||
|
||||
test("disables mutation retries", () => {
|
||||
// Given
|
||||
const queryClient = createQueryClient();
|
||||
|
||||
// When
|
||||
const retry = queryClient.getDefaultOptions().mutations?.retry;
|
||||
|
||||
// Then
|
||||
expect(retry).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user