Add admin site settings sections and locale defaults
This commit is contained in:
@@ -9,6 +9,8 @@ describe("site settings helpers", () => {
|
||||
it("builds defaults from the fallback site name", () => {
|
||||
const settings = buildDefaultSiteSettings("Studio Moh");
|
||||
|
||||
expect(settings.defaultLocale).toBe("de");
|
||||
expect(settings.brand.primaryColor).toBe("#dc5a35");
|
||||
expect(settings.locales.ar.siteName).toBe("Studio Moh");
|
||||
expect(settings.locales.ar.titleTemplate).toBe("{pageTitle} | {siteName}");
|
||||
expect(settings.locales.en.siteDescription).toBe("Multilingual Next.js base project");
|
||||
@@ -18,6 +20,10 @@ describe("site settings helpers", () => {
|
||||
it("merges stored values with safe defaults", () => {
|
||||
const settings = parseSiteSettingsValue(
|
||||
JSON.stringify({
|
||||
defaultLocale: "ar",
|
||||
brand: {
|
||||
primaryColor: "#112233",
|
||||
},
|
||||
locales: {
|
||||
en: {
|
||||
siteName: "Brand EN",
|
||||
@@ -34,6 +40,8 @@ describe("site settings helpers", () => {
|
||||
"Fallback Name",
|
||||
);
|
||||
|
||||
expect(settings.defaultLocale).toBe("ar");
|
||||
expect(settings.brand.primaryColor).toBe("#112233");
|
||||
expect(settings.locales.en.siteName).toBe("Brand EN");
|
||||
expect(settings.locales.en.titleTemplate).toBe("{pageTitle} - {siteName}");
|
||||
expect(settings.locales.en.siteDescription).toBe("English description");
|
||||
@@ -66,4 +74,19 @@ describe("site settings helpers", () => {
|
||||
|
||||
expect(settings.locales.ar.titleTemplate).toBe("{pageTitle} | {siteName}");
|
||||
});
|
||||
|
||||
it("falls back for invalid default locale and invalid primary color", () => {
|
||||
const settings = parseSiteSettingsValue(
|
||||
JSON.stringify({
|
||||
defaultLocale: "fr",
|
||||
brand: {
|
||||
primaryColor: "red",
|
||||
},
|
||||
}),
|
||||
"Fallback Name",
|
||||
);
|
||||
|
||||
expect(settings.defaultLocale).toBe("de");
|
||||
expect(settings.brand.primaryColor).toBe("#dc5a35");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,6 +17,8 @@ describe("metadata helpers", () => {
|
||||
|
||||
it("builds root metadata with dynamic icons and social preview", () => {
|
||||
const settings = buildDefaultSiteSettings("Studio Moh");
|
||||
settings.defaultLocale = "ar";
|
||||
settings.locales.ar.siteName = "Studio Moh AR";
|
||||
const metadata = buildAppMetadataFromConfig(settings, {
|
||||
siteLogoLight: null,
|
||||
siteLogoDark: null,
|
||||
@@ -32,12 +34,16 @@ describe("metadata helpers", () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(metadata.title).toBe("Studio Moh");
|
||||
expect(metadata.title).toBe("Studio Moh AR");
|
||||
expect(metadata.icons).toEqual({
|
||||
icon: [{ url: "/favicon.ico?v=v1" }],
|
||||
shortcut: [{ url: "/favicon.ico?v=v1" }],
|
||||
apple: [{ url: "/apple-icon.png?v=v1" }],
|
||||
});
|
||||
expect(metadata.openGraph).toMatchObject({
|
||||
locale: "ar",
|
||||
url: "https://mohfarawati.de/",
|
||||
});
|
||||
expect(metadata.twitter).toMatchObject({
|
||||
card: "summary_large_image",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user