Refactor portfolio admin and views
This commit is contained in:
@@ -29,6 +29,7 @@ describe("portfolio validation", () => {
|
||||
projectInputSchema.parse({
|
||||
categoryId: "cat_1",
|
||||
slug: "Invalid Slug",
|
||||
viewMode: "GRID",
|
||||
titleAr: "عنوان",
|
||||
titleEn: "Title",
|
||||
titleDe: "Titel",
|
||||
@@ -123,6 +124,41 @@ describe("portfolio validation", () => {
|
||||
).toBe("IMAGE");
|
||||
});
|
||||
|
||||
it("accepts valid project view modes", () => {
|
||||
expect(
|
||||
projectInputSchema.parse({
|
||||
categoryId: "cat_1",
|
||||
slug: "case-study-entry",
|
||||
viewMode: "CASE_STUDY",
|
||||
titleAr: "عنوان",
|
||||
titleEn: "Title",
|
||||
titleDe: "Titel",
|
||||
summaryAr: "ملخص",
|
||||
summaryEn: "Summary",
|
||||
summaryDe: "Zusammenfassung",
|
||||
clientName: "Client",
|
||||
projectYear: 2025,
|
||||
serviceLabelAr: "خدمة",
|
||||
serviceLabelEn: "Service",
|
||||
serviceLabelDe: "Service",
|
||||
previewUrl: "https://example.com",
|
||||
currentCoverImagePath: "",
|
||||
coverMedia: {
|
||||
mode: "external",
|
||||
assetId: "",
|
||||
url: "https://example.com/cover.jpg",
|
||||
label: "Cover",
|
||||
kind: "IMAGE",
|
||||
},
|
||||
sortOrder: 1,
|
||||
isFeatured: false,
|
||||
isPublished: true,
|
||||
sections: [],
|
||||
assets: [],
|
||||
}).viewMode,
|
||||
).toBe("CASE_STUDY");
|
||||
});
|
||||
|
||||
it("rejects invalid media payloads", () => {
|
||||
expect(() =>
|
||||
assetInputSchema.parse({
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { resolvePortfolioProjectViewMode } from "../lib/portfolio";
|
||||
|
||||
describe("portfolio helpers", () => {
|
||||
it("falls back to GRID when view mode is missing", () => {
|
||||
expect(resolvePortfolioProjectViewMode(undefined)).toBe("GRID");
|
||||
expect(resolvePortfolioProjectViewMode("unexpected")).toBe("GRID");
|
||||
});
|
||||
|
||||
it("keeps supported view modes", () => {
|
||||
expect(resolvePortfolioProjectViewMode("STORY")).toBe("STORY");
|
||||
expect(resolvePortfolioProjectViewMode("CASE_STUDY")).toBe("CASE_STUDY");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user