fix: link album assignment and narrow errors
This commit is contained in:
1 parent
4af86f6eb9
commit
f6e6018cc1
5 files changed
+123
-42
No files matched your search
@@ -0,0 +1,47 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { expect, test, vi } from "vitest";
|
||||
|
||||
import { EditorialDetailContent } from "@/modules/editorials/admin-detail";
|
||||
import { AlbumGrantError } from "@/modules/albums/grants";
|
||||
import { loadAssignableAlbums } from "./page-content";
|
||||
|
||||
const editorial = {
|
||||
id: "00000000-0000-4000-8000-000000000001",
|
||||
name: "Neue Redaktion",
|
||||
contactName: "Mara Muster",
|
||||
loginEmail: "mara@example.com",
|
||||
status: "pending_approval" as const,
|
||||
emailVerifiedAt: null,
|
||||
currentPriceCents: null,
|
||||
};
|
||||
|
||||
test("the editorial detail links admins to its album-assignment page", () => {
|
||||
render(<EditorialDetailContent editorial={editorial} hasActiveGrant={false} />);
|
||||
|
||||
expect(screen.getByRole("link", { name: /albumrechte verwalten/i }).getAttribute("href")).toBe(
|
||||
"/admin/redaktionen/00000000-0000-4000-8000-000000000001/alben",
|
||||
);
|
||||
expect(screen.queryByText(/folgt im nächsten schritt/i)).toBeNull();
|
||||
});
|
||||
|
||||
test("only an explicit Immich-unavailable error renders the unavailable album state", async () => {
|
||||
const service = {
|
||||
listAssignableAlbums: vi.fn().mockRejectedValue(new AlbumGrantError("IMMICH_UNAVAILABLE")),
|
||||
};
|
||||
|
||||
await expect(loadAssignableAlbums(editorial.id, service)).resolves.toEqual({
|
||||
albums: [],
|
||||
unavailable: true,
|
||||
});
|
||||
});
|
||||
|
||||
test("database and programming errors propagate instead of being displayed as Immich unavailable", async () => {
|
||||
const databaseFailure = new Error("database connection lost");
|
||||
const service = {
|
||||
listAssignableAlbums: vi.fn().mockRejectedValue(databaseFailure),
|
||||
};
|
||||
|
||||
await expect(loadAssignableAlbums(editorial.id, service)).rejects.toBe(databaseFailure);
|
||||
});
|
||||
Reference in new issue
Block a user