refactor(webui): separate presentation views and expand component gallery (#6179)
* refactor(webui): organize shared components with an internal gallery * refactor(webui): decouple views and expand component gallery * fix(docker): include channel sources in WebUI build * refactor(webui): cover all channel interfaces in gallery * docs(webui): remove manual paragraph wrapping
This commit is contained in:
1 parent
db804ef94a
commit
30e43aec82
109 files changed
+7874
-3459
No files matched your search
@@ -1,10 +1,12 @@
|
||||
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { expect, it, vi } from "vitest";
|
||||
import { HostNavigationContext } from "@/components/remote/HostSwitcher";
|
||||
import { AboutSettings } from "@/components/settings/overview/OverviewSettings";
|
||||
import { AboutSettings, AppearanceSettings } from "@/components/settings/overview/OverviewSettings";
|
||||
import { VersionCheckRowView } from "@/components/settings/overview/VersionCheckRowView";
|
||||
import { NanobotClient } from "@/lib/nanobot-client";
|
||||
import { ClientProvider } from "@/providers/ClientProvider";
|
||||
import type { SettingsPayload } from "@/lib/types";
|
||||
import { DEFAULT_LOCAL_PREFS } from "@/lib/local-preferences";
|
||||
import { jsonResponse, settingsPayload, renderSettingsView, installSettingsViewTestHooks } from "@/tests/settings-test-utils";
|
||||
|
||||
const thirdPartyBrandNotice =
|
||||
@@ -13,6 +15,31 @@ import { jsonResponse, settingsPayload, renderSettingsView, installSettingsViewT
|
||||
describe("Settings overview and appearance", () => {
|
||||
installSettingsViewTestHooks();
|
||||
|
||||
it("displays a caller-owned version result and delegates checking without a client provider", () => {
|
||||
const check = vi.fn();
|
||||
render(<VersionCheckRowView currentVersion="0.3.5" checking={false}
|
||||
result={{ type: "update", latestVersion: "0.3.6", pypiUrl: "https://pypi.org/project/nanobot-ai/" }} onCheck={check} />);
|
||||
expect(screen.getByText("Update available v0.3.6")).toBeVisible();
|
||||
expect(screen.getByRole("link", { name: "PyPI" })).toHaveAttribute("href", "https://pypi.org/project/nanobot-ai/");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Check for updates" }));
|
||||
expect(check).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it.each(["granted", "denied"])("updates task notifications only after browser permission is %s", async (permission) => {
|
||||
const requestPermission = vi.fn().mockResolvedValue(permission);
|
||||
vi.stubGlobal("Notification", { permission: "default", requestPermission });
|
||||
const changePreferences = vi.fn();
|
||||
render(<AppearanceSettings theme="light" onToggleTheme={vi.fn()} localPrefs={DEFAULT_LOCAL_PREFS} onChangeLocalPrefs={changePreferences} />);
|
||||
fireEvent.click(screen.getByRole("switch", { name: "Task notifications" }));
|
||||
expect(changePreferences).not.toHaveBeenCalled();
|
||||
await waitFor(() => expect(requestPermission).toHaveBeenCalledTimes(1));
|
||||
await act(async () => { await Promise.resolve(); });
|
||||
if (permission === "granted") {
|
||||
expect(changePreferences).toHaveBeenCalledTimes(1);
|
||||
expect(changePreferences.mock.calls[0][0](DEFAULT_LOCAL_PREFS).browserNotifications).toBe(true);
|
||||
} else expect(changePreferences).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
it("links the host's short commit beside its version", () => {
|
||||
const commit = "abcdef12".repeat(5);
|
||||
|
||||
Reference in new issue
Block a user