refactor: trim v2 hardening scaffolding
This commit is contained in:
1 parent
ecfb9d59e0
commit
2eb0baf17e
75 files changed
+334
-2067
No files matched your search
@@ -4,16 +4,13 @@ import { beforeEach, describe, expect, test, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
auth: vi.fn(),
|
||||
env: { CUSTOM_WIDGETS_ENABLED: true },
|
||||
}));
|
||||
|
||||
vi.mock("@homarr/auth/next", () => ({ auth: mocks.auth }));
|
||||
vi.mock("~/env", () => ({ env: mocks.env }));
|
||||
|
||||
import { requireCustomWidgetAdmin } from "./admin";
|
||||
|
||||
beforeEach(() => {
|
||||
mocks.env.CUSTOM_WIDGETS_ENABLED = true;
|
||||
mocks.auth.mockResolvedValue({ user: { permissions: ["admin"] } });
|
||||
});
|
||||
|
||||
@@ -30,11 +27,4 @@ describe("Custom Widget HTTP resource access", () => {
|
||||
const response = await requireCustomWidgetAdmin();
|
||||
expect(response?.status).toBe(403);
|
||||
});
|
||||
|
||||
test("returns an unavailable response when the emergency switch is off", async () => {
|
||||
mocks.env.CUSTOM_WIDGETS_ENABLED = false;
|
||||
const response = await requireCustomWidgetAdmin();
|
||||
expect(response?.status).toBe(503);
|
||||
await expect(response?.json()).resolves.toMatchObject({ error: expect.stringContaining("temporarily disabled") });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user