moh/admin-portfolio-ux-improvements
CI / quality (push) Waiting to run

This commit is contained in:
MOH
2026-03-15 04:42:09 +01:00
parent 364f761420
commit 3eb9238268
7 changed files with 1352 additions and 482 deletions
+89
View File
@@ -1,5 +1,11 @@
import { describe, expect, it } from "vitest";
import {
getFirstIncompleteWizardStep,
getPortfolioWizardProgress,
isPortfolioAssetReady,
isPortfolioSectionReady,
} from "../lib/portfolio-form-progress";
import {
assetInputSchema,
categoryInputSchema,
@@ -203,4 +209,87 @@ describe("portfolio validation", () => {
}),
).toThrow(/link/i);
});
it("calculates wizard progress and points to the first incomplete step", () => {
const progress = getPortfolioWizardProgress({
basics: {
categoryId: "cat_1",
slug: "case-study-entry",
clientName: "Client",
projectYear: "2025",
sortOrder: "1",
viewMode: "GRID",
},
content: {
titleAr: "عنوان",
titleEn: "Title",
titleDe: "Titel",
serviceLabelAr: "خدمة",
serviceLabelEn: "Service",
serviceLabelDe: "Service",
summaryAr: "",
summaryEn: "",
summaryDe: "",
},
sections: [
{
type: "RICH_TEXT",
titleAr: "العنوان",
titleEn: "Title",
titleDe: "Titel",
bodyAr: "النص",
bodyEn: "Body",
bodyDe: "Text",
linkUrl: "",
mediaAssetId: "",
},
],
assets: [
{
mediaAssetId: "asset_1",
altAr: "بديل",
altEn: "Alt",
altDe: "Alt",
},
],
});
expect(progress.find((step) => step.key === "basics")?.complete).toBe(true);
expect(progress.find((step) => step.key === "content")?.complete).toBe(false);
expect(getFirstIncompleteWizardStep(progress)).toBe("content");
});
it("marks sections and assets ready only when required fields are present", () => {
expect(
isPortfolioSectionReady({
type: "LINK",
titleAr: "رابط",
titleEn: "Link",
titleDe: "Link",
bodyAr: "",
bodyEn: "",
bodyDe: "",
linkUrl: "https://example.com",
mediaAssetId: "",
}),
).toBe(true);
expect(
isPortfolioAssetReady({
mediaAssetId: "asset_1",
altAr: "بديل",
altEn: "Alt",
altDe: "Alt",
}),
).toBe(true);
expect(
isPortfolioAssetReady({
mediaAssetId: "",
altAr: "بديل",
altEn: "Alt",
altDe: "Alt",
}),
).toBe(false);
});
});