-

-
-
- {instanceTitle}
-
- {profile.version && (
-
- {t("common.version")}
- {versionLabel}
-
- )}
- {profile.demo && {t("about.demo")}}
-
+
+
+ {(profile.version || profile.demo) && (
+
+ {profile.version && (
+
+ {t("common.version")}
+ {versionLabel}
+
+ )}
+ {profile.demo && {t("about.demo")}}
+
+ )}
-
+
{customProfile?.description || (
<>
Your thoughts, your data, shared on your terms.
diff --git a/web/tests/about-page.test.tsx b/web/tests/about-page.test.tsx
index 948718367..51ebb7b61 100644
--- a/web/tests/about-page.test.tsx
+++ b/web/tests/about-page.test.tsx
@@ -50,6 +50,8 @@ describe("", () => {
renderAbout();
expect(screen.getByRole("heading", { name: "Memos" })).toBeInTheDocument();
+ expect(document.querySelector(".memos-mark")).toHaveAttribute("fill", "currentColor");
+ expect(document.querySelector(".memos-mark")).toHaveAttribute("height", "48");
expect(screen.getByText(/Your thoughts, your data/i)).toBeInTheDocument();
expect(screen.getByText("about.description")).toBeInTheDocument();
expect(screen.getByRole("link", { name: /Version\s*v0\.25\.0/ })).toHaveAttribute(
diff --git a/web/tests/app-branding.test.tsx b/web/tests/app-branding.test.tsx
new file mode 100644
index 000000000..8ab3dd2bc
--- /dev/null
+++ b/web/tests/app-branding.test.tsx
@@ -0,0 +1,94 @@
+import { act, render } from "@testing-library/react";
+import type { ReactNode } from "react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import App from "@/App";
+
+const instance = vi.hoisted(() => ({
+ profile: {},
+ generalSetting: { customProfile: undefined as { title: string; logoUrl: string } | undefined },
+}));
+
+vi.mock("@/contexts/InstanceContext", () => ({ useInstance: () => instance }));
+vi.mock("@/contexts/ViewContext", () => ({ TimelineViewProvider: ({ children }: { children: ReactNode }) => children }));
+vi.mock("@/hooks/useNavigateTo", () => ({ default: () => vi.fn() }));
+vi.mock("@/hooks/useUserLocale", () => ({ useUserLocale: () => "ltr" }));
+vi.mock("@/hooks/useUserTheme", () => ({ useUserTheme: vi.fn() }));
+vi.mock("@/utils/oauth", () => ({ cleanupExpiredOAuthState: vi.fn() }));
+vi.mock("react-router-dom", () => ({ Outlet: () => null, ScrollRestoration: () => null }));
+
+describe("instance favicon", () => {
+ let icon: HTMLLinkElement;
+ let colorScheme: MediaQueryList;
+
+ beforeEach(() => {
+ instance.generalSetting.customProfile = undefined;
+ colorScheme = Object.assign(new EventTarget(), {
+ matches: false,
+ media: "(prefers-color-scheme: dark)",
+ onchange: null,
+ addListener: vi.fn(),
+ removeListener: vi.fn(),
+ });
+ vi.stubGlobal(
+ "matchMedia",
+ vi.fn(() => colorScheme),
+ );
+ icon = document.createElement("link");
+ icon.rel = "icon";
+ icon.type = "image/svg+xml";
+ document.head.appendChild(icon);
+ });
+
+ afterEach(() => {
+ icon.remove();
+ vi.unstubAllGlobals();
+ });
+
+ it.each(["", "/logo.webp", "/logo.svg"])("uses the SVG favicon for built-in logo %s", (logoUrl) => {
+ instance.generalSetting.customProfile = { title: "Memos", logoUrl };
+ render();
+
+ expect(icon).toHaveAttribute("href", "/favicon.svg?v=bird-blue");
+ expect(icon).toHaveAttribute("type", "image/svg+xml");
+ });
+
+ it("preserves custom image formats and restores the default when branding is cleared", () => {
+ instance.generalSetting.customProfile = { title: "Team Notes", logoUrl: "/custom.png" };
+ const { rerender } = render();
+
+ expect(document.title).toBe("Team Notes");
+ expect(icon).toHaveAttribute("href", "/custom.png");
+ expect(icon).not.toHaveAttribute("type");
+
+ act(() => {
+ Object.assign(colorScheme, { matches: true });
+ colorScheme.dispatchEvent(new Event("change"));
+ });
+ expect(icon).toHaveAttribute("href", "/custom.png");
+
+ instance.generalSetting.customProfile = undefined;
+ rerender();
+
+ expect(document.title).toBe("Memos");
+ expect(icon).toHaveAttribute("href", "/favicon.svg?v=bird-blue");
+ expect(icon).toHaveAttribute("type", "image/svg+xml");
+ });
+
+ it("keeps the same favicon across system color schemes", () => {
+ Object.assign(colorScheme, { matches: true });
+ render();
+ expect(icon).toHaveAttribute("href", "/favicon.svg?v=bird-blue");
+
+ act(() => {
+ Object.assign(colorScheme, { matches: false });
+ colorScheme.dispatchEvent(new Event("change"));
+ });
+ expect(icon).toHaveAttribute("href", "/favicon.svg?v=bird-blue");
+
+ act(() => {
+ Object.assign(colorScheme, { matches: true });
+ colorScheme.dispatchEvent(new Event("change"));
+ });
+ expect(icon).toHaveAttribute("href", "/favicon.svg?v=bird-blue");
+ });
+});
diff --git a/web/tests/auth-page-layout.test.tsx b/web/tests/auth-page-layout.test.tsx
index 353675ace..042b3f58e 100644
--- a/web/tests/auth-page-layout.test.tsx
+++ b/web/tests/auth-page-layout.test.tsx
@@ -5,9 +5,10 @@ import AuthPageLayout from "@/components/AuthPageLayout";
import { InstanceAccessMode } from "@/types/proto/api/instance_service_pb";
const instance = vi.hoisted(() => ({ instanceUrl: "https://notes.example.com", accessMode: 1 }));
+const settings = vi.hoisted(() => ({ customProfile: undefined as { title?: string; logoUrl?: string } | undefined }));
vi.mock("@/contexts/InstanceContext", () => ({
- useInstance: () => ({ profile: instance, generalSetting: {} }),
+ useInstance: () => ({ profile: instance, generalSetting: settings }),
}));
vi.mock("@/utils/i18n", () => ({
@@ -29,6 +30,7 @@ const renderLayout = (props?: { hideExplore?: boolean }) =>
describe(" explore band", () => {
beforeEach(() => {
instance.accessMode = InstanceAccessMode.PRIVATE;
+ settings.customProfile = undefined;
});
it("links to Explore on public instances", () => {
@@ -50,4 +52,22 @@ describe(" explore band", () => {
expect(screen.queryByRole("link", { name: /auth\.explore-public-memos/ })).not.toBeInTheDocument();
});
+
+ it.each([undefined, "/logo.webp"])("uses a themeable small logo for the default %s", (logoUrl) => {
+ settings.customProfile = { logoUrl };
+ const { container } = renderLayout();
+
+ expect(container.querySelector(".memos-mark")).toHaveAttribute("height", "32");
+ expect(screen.getByText("Memos")).toBeInTheDocument();
+ expect(container.querySelector("img")).toBeNull();
+ });
+
+ it("preserves custom logos and titles", () => {
+ settings.customProfile = { title: "Team Notes", logoUrl: "/custom-logo.svg" };
+ const { container } = renderLayout();
+
+ expect(container.querySelector("img")).toHaveAttribute("src", "/custom-logo.svg");
+ expect(container.querySelector(".memos-mark")).toBeNull();
+ expect(screen.getByText("Team Notes")).toBeInTheDocument();
+ });
});
diff --git a/web/tests/memos-logo.test.tsx b/web/tests/memos-logo.test.tsx
index 9b5b74838..a49547489 100644
--- a/web/tests/memos-logo.test.tsx
+++ b/web/tests/memos-logo.test.tsx
@@ -1,7 +1,9 @@
import { render, screen } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
-import fullLogoUrl from "@/assets/full-logo.webp?no-inline";
import MemosLogo from "@/components/MemosLogo";
+import { MemosMark } from "@/components/MemosMark";
+import standardSource from "../public/logo.svg?raw";
+import smallSource from "../public/logo-small.svg?raw";
const mockInstance = {
generalSetting: {} as { customProfile?: { title?: string; logoUrl?: string } },
@@ -16,18 +18,49 @@ describe("", () => {
mockInstance.generalSetting = {};
});
- it("uses the bundled logo when the instance has no custom logo", () => {
+ it.each([undefined, "", "/logo.webp", "/logo.svg"])("uses the inline logo for the built-in URL %s", (logoUrl) => {
+ mockInstance.generalSetting = { customProfile: { logoUrl } };
const { container } = render();
- expect(container.querySelector("img")).toHaveAttribute("src", fullLogoUrl);
+ expect(container.querySelector("img")).toBeNull();
+ expect(container.querySelector("svg")).toHaveAttribute("fill", "currentColor");
+ expect(container.querySelector("svg")).toHaveAttribute("aria-hidden", "true");
expect(screen.getByText("Memos")).toBeInTheDocument();
});
- it("uses custom instance branding when configured", () => {
- mockInstance.generalSetting = { customProfile: { title: "Team Notes", logoUrl: "/custom-logo.png" } };
+ it.each(["/custom-logo.png", "/custom-logo.svg", "https://example.com/logo.webp"])("preserves custom branding at %s", (logoUrl) => {
+ mockInstance.generalSetting = { customProfile: { title: "Team Notes", logoUrl } };
const { container } = render();
- expect(container.querySelector("img")).toHaveAttribute("src", "/custom-logo.png");
+ expect(container.querySelector("img")).toHaveAttribute("src", logoUrl);
+ expect(container.querySelector(".memos-mark")).toBeNull();
expect(screen.getByText("Team Notes")).toBeInTheDocument();
});
+
+ it("names the standalone mark when the title is collapsed", () => {
+ render();
+
+ expect(screen.getByRole("img", { name: "Memos" })).toBeInTheDocument();
+ });
+
+ it("names a custom standalone logo when the title is collapsed", () => {
+ mockInstance.generalSetting = { customProfile: { title: "Team Notes", logoUrl: "/custom-logo.svg" } };
+ render();
+
+ expect(screen.getByRole("img", { name: "Team Notes" })).toHaveAttribute("src", "/custom-logo.svg");
+ });
+});
+
+describe("", () => {
+ // Keep the inline paths aligned with the vendored upstream SVGs.
+ it.each([20, 24, 28, 32, 33, 48, 64])("uses the official contour at %ipx", (size) => {
+ const source = new DOMParser().parseFromString(size <= 32 ? smallSource : standardSource, "image/svg+xml");
+ const { container } = render();
+
+ expect(container.querySelector("svg")).toHaveAttribute("width", String(size));
+ expect(container.querySelector("svg")).toHaveAttribute("height", String(size));
+ expect(container.querySelector("g")).toHaveAttribute("transform", source.querySelector("g")?.getAttribute("transform"));
+ expect(container.querySelector("path")).toHaveAttribute("d", source.querySelector("path")?.getAttribute("d"));
+ expect(container.querySelector("path")).toHaveAttribute("fill-rule", "evenodd");
+ });
});
diff --git a/web/tests/space-switcher.test.tsx b/web/tests/space-switcher.test.tsx
index 7e632978d..ba5bf6f61 100644
--- a/web/tests/space-switcher.test.tsx
+++ b/web/tests/space-switcher.test.tsx
@@ -18,7 +18,7 @@ const state = vi.hoisted(() => ({
setMobileOpen: vi.fn(),
}));
-vi.mock("@/components/MemosLogo", () => ({ default: () => Memos }));
+vi.mock("@/contexts/InstanceContext", () => ({ useInstance: () => ({ generalSetting: {} }) }));
vi.mock("@/components/UserMenu", () => ({
default: () => ,
}));