rename(phase 1): CapaKraken → Nexus across code, UI, docs, CI (#61)
CI / Architecture Guardrails (push) Successful in 2m38s
CI / Assistant Split Regression (push) Successful in 3m33s
CI / Typecheck (push) Successful in 3m51s
CI / Lint (push) Successful in 5m2s
CI / E2E Tests (push) Has been cancelled
CI / Fresh-Linux Docker Deploy (push) Has been cancelled
CI / Release Images (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Architecture Guardrails (push) Successful in 2m38s
CI / Assistant Split Regression (push) Successful in 3m33s
CI / Typecheck (push) Successful in 3m51s
CI / Lint (push) Successful in 5m2s
CI / E2E Tests (push) Has been cancelled
CI / Fresh-Linux Docker Deploy (push) Has been cancelled
CI / Release Images (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
rename(phase 1): CapaKraken → Nexus across code, UI, docs, CI (#61) Co-authored-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com> Co-committed-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com>
This commit was merged in pull request #61.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { SystemRole } from "@capakraken/shared";
|
||||
import { SystemRole } from "@nexus/shared";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { roleRouter } from "../router/role.js";
|
||||
import { createCallerFactory } from "../trpc.js";
|
||||
@@ -54,9 +54,7 @@ describe("role router authorization", () => {
|
||||
createContext({ role: { create: roleCreate } }, { session: false }),
|
||||
);
|
||||
|
||||
await expect(
|
||||
caller.create({ name: "Art Director" }),
|
||||
).rejects.toMatchObject({
|
||||
await expect(caller.create({ name: "Art Director" })).rejects.toMatchObject({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Authentication required",
|
||||
});
|
||||
@@ -68,13 +66,9 @@ describe("role router authorization", () => {
|
||||
describe("USER role — insufficient permissions for mutations", () => {
|
||||
it("forbids USER from calling create", async () => {
|
||||
const roleCreate = vi.fn();
|
||||
const caller = createCaller(
|
||||
createContext({ role: { create: roleCreate } }),
|
||||
);
|
||||
const caller = createCaller(createContext({ role: { create: roleCreate } }));
|
||||
|
||||
await expect(
|
||||
caller.create({ name: "Art Director" }),
|
||||
).rejects.toMatchObject({
|
||||
await expect(caller.create({ name: "Art Director" })).rejects.toMatchObject({
|
||||
code: "FORBIDDEN",
|
||||
message: "Manager or Admin role required",
|
||||
});
|
||||
@@ -84,9 +78,7 @@ describe("role router authorization", () => {
|
||||
|
||||
it("forbids USER from calling update", async () => {
|
||||
const roleUpdate = vi.fn();
|
||||
const caller = createCaller(
|
||||
createContext({ role: { update: roleUpdate } }),
|
||||
);
|
||||
const caller = createCaller(createContext({ role: { update: roleUpdate } }));
|
||||
|
||||
await expect(
|
||||
caller.update({ id: "role_1", data: { name: "Updated Role" } }),
|
||||
@@ -100,9 +92,7 @@ describe("role router authorization", () => {
|
||||
|
||||
it("forbids USER from calling delete", async () => {
|
||||
const roleDelete = vi.fn();
|
||||
const caller = createCaller(
|
||||
createContext({ role: { delete: roleDelete } }),
|
||||
);
|
||||
const caller = createCaller(createContext({ role: { delete: roleDelete } }));
|
||||
|
||||
await expect(caller.delete({ id: "role_1" })).rejects.toMatchObject({
|
||||
code: "FORBIDDEN",
|
||||
@@ -114,9 +104,7 @@ describe("role router authorization", () => {
|
||||
|
||||
it("forbids USER from calling deactivate", async () => {
|
||||
const roleUpdate = vi.fn();
|
||||
const caller = createCaller(
|
||||
createContext({ role: { update: roleUpdate } }),
|
||||
);
|
||||
const caller = createCaller(createContext({ role: { update: roleUpdate } }));
|
||||
|
||||
await expect(caller.deactivate({ id: "role_1" })).rejects.toMatchObject({
|
||||
code: "FORBIDDEN",
|
||||
@@ -149,9 +137,7 @@ describe("role router authorization", () => {
|
||||
planningEntry: { findMany: planningEntryFindMany },
|
||||
$transaction: vi.fn(async (fn: (tx: unknown) => unknown) => fn(db)),
|
||||
};
|
||||
const caller = createCaller(
|
||||
createContext(db, { role: SystemRole.MANAGER }),
|
||||
);
|
||||
const caller = createCaller(createContext(db, { role: SystemRole.MANAGER }));
|
||||
|
||||
// Should not throw UNAUTHORIZED or FORBIDDEN
|
||||
const result = await caller.create({ name: "Art Director" });
|
||||
@@ -189,9 +175,7 @@ describe("role router authorization", () => {
|
||||
assignment: { findMany: assignmentFindMany },
|
||||
$transaction: vi.fn(async (fn: (tx: unknown) => unknown) => fn(adminDb)),
|
||||
};
|
||||
const caller = createCaller(
|
||||
createContext(adminDb, { role: SystemRole.ADMIN }),
|
||||
);
|
||||
const caller = createCaller(createContext(adminDb, { role: SystemRole.ADMIN }));
|
||||
|
||||
const result = await caller.delete({ id: "role_1" });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user