mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-17 03:10:38 +09:00
71 lines
2.4 KiB
TypeScript
71 lines
2.4 KiB
TypeScript
|
|
import { describe, expect, it } from "vitest";
|
||
|
|
import { shouldSilenceHttpSuccessLog } from "../middleware/http-log-policy.js";
|
||
|
|
|
||
|
|
describe("shouldSilenceHttpSuccessLog", () => {
|
||
|
|
it("silences cached 304 responses", () => {
|
||
|
|
expect(shouldSilenceHttpSuccessLog("GET", "/api/issues/PAP-1383", 304)).toBe(true);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("silences successful polling endpoints", () => {
|
||
|
|
expect(shouldSilenceHttpSuccessLog("GET", "/api/health", 200)).toBe(true);
|
||
|
|
expect(
|
||
|
|
shouldSilenceHttpSuccessLog(
|
||
|
|
"GET",
|
||
|
|
"/api/companies/5cbe79ee-acb3-4597-896e-7662742593cd/heartbeat-runs",
|
||
|
|
200,
|
||
|
|
),
|
||
|
|
).toBe(true);
|
||
|
|
expect(
|
||
|
|
shouldSilenceHttpSuccessLog(
|
||
|
|
"GET",
|
||
|
|
"/api/heartbeat-runs/b7044268-19b6-4b3a-a9f3-9c57dce70253/log?offset=1103894&limitBytes=256000",
|
||
|
|
200,
|
||
|
|
),
|
||
|
|
).toBe(true);
|
||
|
|
expect(
|
||
|
|
shouldSilenceHttpSuccessLog(
|
||
|
|
"GET",
|
||
|
|
"/api/companies/5cbe79ee-acb3-4597-896e-7662742593cd/live-runs?minCount=3",
|
||
|
|
200,
|
||
|
|
),
|
||
|
|
).toBe(true);
|
||
|
|
expect(
|
||
|
|
shouldSilenceHttpSuccessLog(
|
||
|
|
"HEAD",
|
||
|
|
"/api/companies/5cbe79ee-acb3-4597-896e-7662742593cd/sidebar-badges",
|
||
|
|
200,
|
||
|
|
),
|
||
|
|
).toBe(true);
|
||
|
|
expect(
|
||
|
|
shouldSilenceHttpSuccessLog(
|
||
|
|
"GET",
|
||
|
|
"/api/companies/5cbe79ee-acb3-4597-896e-7662742593cd/issues?includeRoutineExecutions=true",
|
||
|
|
200,
|
||
|
|
),
|
||
|
|
).toBe(true);
|
||
|
|
expect(
|
||
|
|
shouldSilenceHttpSuccessLog(
|
||
|
|
"GET",
|
||
|
|
"/api/companies/5cbe79ee-acb3-4597-896e-7662742593cd/activity",
|
||
|
|
200,
|
||
|
|
),
|
||
|
|
).toBe(true);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("silences successful static asset requests", () => {
|
||
|
|
expect(shouldSilenceHttpSuccessLog("GET", "/@fs/Users/dotta/paperclip/ui/src/main.tsx", 200)).toBe(true);
|
||
|
|
expect(shouldSilenceHttpSuccessLog("GET", "/src/App.tsx?t=123", 200)).toBe(true);
|
||
|
|
expect(shouldSilenceHttpSuccessLog("GET", "/site.webmanifest", 200)).toBe(true);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("keeps normal successful application requests", () => {
|
||
|
|
expect(shouldSilenceHttpSuccessLog("GET", "/api/issues/PAP-1383", 200)).toBe(false);
|
||
|
|
expect(shouldSilenceHttpSuccessLog("PATCH", "/api/issues/PAP-1383", 200)).toBe(false);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("keeps failing requests visible", () => {
|
||
|
|
expect(shouldSilenceHttpSuccessLog("GET", "/api/health", 500)).toBe(false);
|
||
|
|
expect(shouldSilenceHttpSuccessLog("GET", "/@fs/Users/dotta/paperclip/ui/src/main.tsx", 404)).toBe(false);
|
||
|
|
});
|
||
|
|
});
|