Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,52 @@
|
||||
// @vitest-environment node
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { ActionFunctionArgs } from "react-router";
|
||||
|
||||
vi.mock("~/utils/helpers/.server/PermissionsService", () => ({
|
||||
verifyUserHasPermission: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("~/utils/session.server", () => ({
|
||||
getUserInfo: vi.fn(async () => ({ userId: "user_123" })),
|
||||
validateCSRFToken: vi.fn(async () => undefined),
|
||||
}));
|
||||
|
||||
vi.mock("~/utils/db/users.db.server", () => ({
|
||||
getUser: vi.fn(async () => ({ id: "user_123", email: "user@example.com" })),
|
||||
}));
|
||||
|
||||
vi.mock("~/modules/notifications/services/.server/NotificationService", () => ({
|
||||
default: {
|
||||
deleteNotificationTemplate: vi.fn(async () => null),
|
||||
getNotificationTemplates: vi.fn(async () => null),
|
||||
send: vi.fn(async () => null),
|
||||
},
|
||||
}));
|
||||
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import { action } from "./channels";
|
||||
|
||||
function callAction() {
|
||||
const form = new FormData();
|
||||
form.set("action", "create");
|
||||
return action({
|
||||
request: new Request("https://admin.example.test/notifications/channels", {
|
||||
method: "POST",
|
||||
body: form,
|
||||
}),
|
||||
params: {},
|
||||
context: {},
|
||||
} as ActionFunctionArgs);
|
||||
}
|
||||
|
||||
describe("admin notification channels action", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.mocked(verifyUserHasPermission).mockResolvedValue(undefined as never);
|
||||
});
|
||||
|
||||
it("requires manage permission for mutations", async () => {
|
||||
await callAction();
|
||||
expect(verifyUserHasPermission).toHaveBeenCalledWith(expect.any(Request), "admin.notifications.manage");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user