Refactor portfolio admin and views

This commit is contained in:
MOH
2026-03-11 17:46:35 +01:00
parent 3c53430b12
commit 7956b073e9
27 changed files with 1972 additions and 1779 deletions
+36
View File
@@ -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({
+15
View File
@@ -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");
});
});