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,41 @@
|
||||
// @vitest-environment node
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { LoaderFunctionArgs } from "react-router";
|
||||
|
||||
vi.mock("~/locale/i18next.server", () => ({
|
||||
getTranslations: vi.fn(async () => ({ t: (key: string) => key })),
|
||||
}));
|
||||
|
||||
vi.mock("~/utils/helpers/.server/PermissionsService", () => ({
|
||||
verifyUserHasPermission: vi.fn(),
|
||||
}));
|
||||
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import { loader } from "./notifications";
|
||||
|
||||
function callLoader() {
|
||||
return loader({
|
||||
request: new Request("https://admin.example.test/notifications"),
|
||||
params: {},
|
||||
context: {},
|
||||
unstable_pattern: "admin/notifications",
|
||||
} as LoaderFunctionArgs);
|
||||
}
|
||||
|
||||
describe("admin notifications route", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.stubEnv("APP_NAME", "Toolctrl");
|
||||
vi.stubEnv("NOTIFICATIONS_NOVU_API_KEY", "");
|
||||
vi.mocked(verifyUserHasPermission).mockResolvedValue(undefined as never);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
it("does not require the optional external notification provider key", async () => {
|
||||
await expect(callLoader()).resolves.toEqual({ title: "notifications.title | Toolctrl" });
|
||||
expect(verifyUserHasPermission).toHaveBeenCalledWith(expect.any(Request), "admin.notifications.view");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user