feat(webui): unify the Apps catalog (#6700)
* feat(webui): unify the Apps catalog * fix(webui): serve all channel branding locally * fix(webui): refine Apps navigation and sidebar
This commit is contained in:
1 parent
5997a714f2
commit
2b232c9133
89 files changed
+1576
-1024
No files matched your search
@@ -45,7 +45,7 @@ export function AppsFixture() {
|
||||
return <main className="mx-auto max-w-4xl p-6" style={connectionLayout ? { maxWidth: 800 } : undefined}><AppsCatalogSettings
|
||||
cliApps={{ apps: [], installed_count: 0 }}
|
||||
mcpPresets={{ presets, installed_count: connectionLayout ? Number(parameters.has("runtime")) : managing ? 0 : 3 }}
|
||||
cliAppsLoading={false} mcpPresetsLoading={false} query="" filter={managing || connectionLayout ? "mcp" : "ready"}
|
||||
cliAppsLoading={false} mcpPresetsLoading={false} query="" filter={{ kind: managing || connectionLayout ? "mcp" : "all", status: managing || connectionLayout ? "all" : "ready" }}
|
||||
cliActionKey={null} mcpActionKey={null}
|
||||
mcpOAuthFlow={connecting ? { flow_id: "fixture", name: "linear", status: "authorization_required", expires_in: 300 } : null}
|
||||
mcpOAuthPopupBlocked={false}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { FilePreviewPanelView } from "@/components/FilePreviewPanelView";
|
||||
import { SkillsCatalogSettings } from "@/components/settings/SkillsCatalogSettings";
|
||||
import { SkillsMarketplace } from "@/components/settings/SkillsMarketplace";
|
||||
import { MarketplaceProviderFilter, SkillsMarketplace } from "@/components/settings/SkillsMarketplace";
|
||||
import { CatalogControls, CatalogSearch, CatalogToolbar } from "@/components/settings/shared/CatalogToolbar";
|
||||
import { ModelIdPicker } from "@/components/settings/shared/ModelControls";
|
||||
import { AppsCatalogSettings, DEFAULT_CUSTOM_MCP_FORM } from "@/components/settings/system/AppsSettings";
|
||||
import { ChannelsSettings } from "@/components/settings/system/ChannelsSettings";
|
||||
@@ -11,7 +13,7 @@ import { WorkspaceProjectPicker } from "@/components/thread/WorkspaceControls";
|
||||
import { settings } from "@/dev/gallery/settings";
|
||||
import { useReadingTypography } from "@/hooks/useReadingTypography";
|
||||
import { fetchWorkspaceDirectories } from "@/lib/api";
|
||||
import type { McpPresetInfo, NanobotFeatureInfo } from "@/lib/types";
|
||||
import type { MarketplaceProvider, McpPresetInfo, NanobotFeatureInfo } from "@/lib/types";
|
||||
|
||||
const noop = () => {};
|
||||
const names = ["Search documentation", "Read repository", "List projects", "Inspect changes", "Review results", "Write notes"];
|
||||
@@ -24,6 +26,9 @@ const preset: McpPresetInfo = {
|
||||
|
||||
export function SkeletonFixture({ surface, loading }: { surface: string; loading: boolean }) {
|
||||
useReadingTypography();
|
||||
const { t } = useTranslation();
|
||||
const [query, setQuery] = useState("");
|
||||
const [provider, setProvider] = useState<MarketplaceProvider>("all");
|
||||
const [model, setModel] = useState("");
|
||||
const [previewLoading, setPreviewLoading] = useState(loading);
|
||||
const feature: NanobotFeatureInfo = {
|
||||
@@ -42,7 +47,7 @@ export function SkeletonFixture({ surface, loading }: { surface: string; loading
|
||||
available: false, status: "not_installed", skill_installed: false,
|
||||
})) : [], installed_count: 0 }}
|
||||
mcpPresets={loading ? null : { presets: names.map((name, index) => ({ ...preset, name: `docs-${index}`, display_name: name })), installed_count: 6 }}
|
||||
cliAppsLoading={loading} mcpPresetsLoading={loading} query="" filter={surface === "cli" ? "cli" : "mcp"}
|
||||
cliAppsLoading={loading} mcpPresetsLoading={loading} query="" filter={{ kind: surface === "cli" ? "cli" : "mcp", status: "all" }}
|
||||
cliActionKey={null} mcpActionKey={null} mcpOAuthFlow={null} mcpOAuthPopupBlocked={false}
|
||||
mcpOAuthCallbackUrl="" mcpOAuthCompleting={false} mcpOAuthCallbackError={null}
|
||||
cliMessage={null} cliError={null} cliFocusName={null} mcpMessage={null} mcpError={null}
|
||||
@@ -53,13 +58,21 @@ export function SkeletonFixture({ surface, loading }: { surface: string; loading
|
||||
onMcpOAuthCallbackUrlChange={noop} onMcpOAuthComplete={noop} onDismissStatus={noop}
|
||||
onBackToChat={noop} onMcpFieldChange={noop} onCustomMcpFormChange={noop}
|
||||
onMcpConfigImportChange={noop} onSaveCustomMcp={noop} onImportMcpConfig={noop} onMcpToolsChange={noop}
|
||||
/> : surface === "channels" ? <ChannelsSettings
|
||||
token="fixture" nanobotFeatures={loading ? null : { features: names.map((name, index) => ({ ...feature, name: `channel-${index}`, display_name: name })), enabled_count: 6, requires_restart: false }}
|
||||
loading={loading} actionKey={null} showBrandLogos={false} error={null} requiresRestartPending={false}
|
||||
onAction={noop} onFeaturesUpdate={noop} onDismissStatus={noop}
|
||||
/> : surface === "skills" ? <SkillsCatalogSettings loading={loading} skills={loading ? [] : names.map((name) => ({
|
||||
/> : surface === "channels" ? <div className="apps-catalog-layout">
|
||||
<CatalogSearch type="search" value={query} onChange={(event) => setQuery(event.target.value)} placeholder={t("settings.channels.search")} />
|
||||
<ChannelsSettings query={query}
|
||||
token="fixture" nanobotFeatures={loading ? null : { features: names.map((name, index) => ({ ...feature, name: `channel-${index}`, display_name: name })), enabled_count: 6, requires_restart: false }}
|
||||
loading={loading} actionKey={null} showBrandLogos={false} error={null} requiresRestartPending={false}
|
||||
onAction={noop} onFeaturesUpdate={noop} onDismissStatus={noop}
|
||||
/>
|
||||
</div> : surface === "skills" ? <SkillsCatalogSettings loading={loading} skills={loading ? [] : names.map((name) => ({
|
||||
name, description: "Search, inspect and maintain the project.", source: "builtin", available: true, enabled: true,
|
||||
}))} /> : surface === "marketplace" ? <SkillsMarketplace installedSkills={[]} installing="" onInstallingChange={noop} />
|
||||
}))} /> : surface === "marketplace" ? <div className="catalog-section">
|
||||
<CatalogToolbar search={{ value: query, onChange: (event) => setQuery(event.target.value), placeholder: t("settings.skills.marketplaceSearchPlaceholder") }}>
|
||||
<CatalogControls><MarketplaceProviderFilter value={provider} onChange={setProvider} /></CatalogControls>
|
||||
</CatalogToolbar>
|
||||
<SkillsMarketplace query={query} provider={provider} installedSkills={[]} installing="" onInstallingChange={noop} />
|
||||
</div>
|
||||
: surface === "models" || surface === "models-compact" ? <ModelIdPicker token="fixture"
|
||||
settings={{ ...settings, providers: settings.providers.map((provider) => provider.name === "openai" ? { ...provider, model_catalog: "official" } : provider) }}
|
||||
provider={surface === "models-compact" ? "openai" : "anthropic"}
|
||||
|
||||
@@ -51,6 +51,9 @@ for (const width of [390, 1440]) {
|
||||
for (const [surface, [loadedSelector, loadingSelector]] of Object.entries(catalogRows)) {
|
||||
await page.goto(fixture(surface));
|
||||
const loaded = page.locator(loadedSelector).first();
|
||||
const search = await box(page.locator(".catalog-search input"));
|
||||
const toolbarControls = page.locator(".catalog-controls");
|
||||
const controls = await box(toolbarControls);
|
||||
const row = await box(loaded);
|
||||
const icon = await box(surface === "channels" ? loaded.locator('[data-testid^="channel-logo"]')
|
||||
: loaded.locator(surface === "apps" ? ":scope > :first-child > :first-child" : ":scope > :first-child"));
|
||||
@@ -58,6 +61,8 @@ for (const width of [390, 1440]) {
|
||||
const action = width === 1440 || surface !== "skills" ? await box(loaded.locator(":scope > :last-child")) : null;
|
||||
await page.goto(fixture(surface, true));
|
||||
const skeleton = status(page).locator(loadingSelector).first();
|
||||
sameBox(await box(page.locator(".catalog-search input")), search);
|
||||
sameBox(await box(toolbarControls), controls);
|
||||
sameBox(await box(skeleton), row);
|
||||
sameBox(await box(skeleton.locator(surface === "apps" ? ":scope > :first-child > :first-child" : ":scope > :first-child")), icon);
|
||||
const placeholder = await box(skeleton.locator(surface === "apps"
|
||||
@@ -88,8 +93,10 @@ for (const width of [390, 1440]) {
|
||||
const requested = page.waitForRequest(view === "search" ? "**/api/webui/skills/search?**" : "**/api/webui/skills/trending?**");
|
||||
try {
|
||||
await page.goto(fixture("marketplace"));
|
||||
if (view === "single") await page.getByRole("tab", { name: "skills.sh", exact: true }).click();
|
||||
if (view === "search") await page.locator("input").fill("project");
|
||||
if (view === "single") {
|
||||
await page.getByRole("radio", { name: "skills.sh", exact: true }).locator("..").click();
|
||||
}
|
||||
if (view === "search") await page.getByRole("textbox").fill("project");
|
||||
await requested;
|
||||
const skeletons = status(page).locator(".py-3\\.5");
|
||||
const count = view === "single" ? 5 : 10;
|
||||
|
||||
@@ -3,16 +3,27 @@ import { expect, test } from "@playwright/test";
|
||||
for (const width of [412, 1440]) {
|
||||
test.describe(`${width}px document startup skeleton`, () => {
|
||||
test.use({ viewport: { width, height: 922 }, reducedMotion: "reduce" });
|
||||
for (const surface of ["skills", "apps", "channels", "automations", "settings", "chat"]) {
|
||||
test(`${surface} paints before the application and stylesheet download`, async ({ page }) => {
|
||||
for (const route of ["skills", "apps", "channels", "apps?section=skills", "apps?section=channels", "automations", "settings", "chat"]) {
|
||||
const surface = route.includes("section=") ? route.split("section=")[1] : route;
|
||||
test(`${route} paints before the application and stylesheet download`, async ({ page }) => {
|
||||
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
|
||||
// Neither React nor the app stylesheet may supply this first paint.
|
||||
await page.route(/\/(?:src\/main\.tsx|assets\/index-[^/]+\.(?:js|css))$/, (route) => route.abort());
|
||||
await page.goto(`/#/${surface === "chat" ? "chat/websocket%3Aexample" : surface}`, { waitUntil: "domcontentloaded" });
|
||||
await page.goto(`/#/${surface === "chat" ? "chat/websocket%3Aexample" : route}`, { waitUntil: "domcontentloaded" });
|
||||
const shell = page.locator(".startup-shell");
|
||||
await expect(shell).toHaveAttribute("data-startup-surface", surface);
|
||||
await expect(shell).toHaveAttribute("aria-busy", "true");
|
||||
await expect(shell.locator(surface === "chat" ? ".startup-composer" : ".startup-page")).toBeVisible();
|
||||
if (["apps", "skills", "channels"].includes(surface)) {
|
||||
const search = (await shell.locator(".startup-search").boundingBox())!;
|
||||
const controls = (await shell.locator(".startup-controls").boundingBox())!;
|
||||
const tabs = (await shell.locator(".startup-tabs").boundingBox())!;
|
||||
expect(search.x).toBe(tabs.x);
|
||||
expect(search.y).toBe(controls.y + controls.height + (width === 1440 ? 12 : 8));
|
||||
expect(search.width).toBe(controls.x + controls.width - tabs.x);
|
||||
if (width === 1440) expect(controls.y).toBe(tabs.y);
|
||||
else expect(tabs.width).toBe(search.width);
|
||||
}
|
||||
const blocks = shell.locator(".startup-block:visible");
|
||||
expect(await blocks.count()).toBeGreaterThan(5);
|
||||
const box = await blocks.first().boundingBox();
|
||||
|
||||
@@ -63,11 +63,11 @@ function ThemeChatFixture({ theme, toggle }: { theme: "light" | "dark"; toggle:
|
||||
if (new URLSearchParams(location.search).has("split")) panes.push({ key: "theme-secondary", title: "Secondary chat" });
|
||||
return <main data-theme-surface className="flex bg-background" style={{ height: "100vh" }}>
|
||||
<aside className="hidden w-64 shrink-0 sm:block">
|
||||
<Sidebar sessions={sessions} activeKey={activeKey} onSelect={setActiveKey} loading={false} newChatActive={false}
|
||||
<Sidebar sessions={sessions} activeKey={activeKey} onSelect={setActiveKey} loading={false}
|
||||
onNewChat={noop} onRequestDelete={noop} onTogglePin={noop} onRequestRename={async () => {}}
|
||||
onToggleArchive={noop} onToggleGroup={noop} onRequestRenameProject={noop} onNewChatInProject={noop}
|
||||
onOpenSettings={noop} onOpenApps={noop} onOpenSkills={noop} onOpenAutomations={noop}
|
||||
onOpenChannels={noop} onOpenSearch={noop} onToggleArchived={noop} />
|
||||
onOpenSettings={noop} onOpenApps={noop} onOpenAutomations={noop}
|
||||
onOpenSearch={noop} onToggleArchived={noop} />
|
||||
</aside>
|
||||
<div className="min-w-0 flex-1">
|
||||
<PaneWorkbench panes={panes} activePaneKey="theme" layout="columns"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { SettingsView } from "@/components/settings/SettingsView";
|
||||
import { StartupSkeleton } from "@/components/StartupSkeleton";
|
||||
import "@/components/startup-skeleton.css";
|
||||
import { settings } from "@/dev/gallery/settings";
|
||||
|
||||
export function installToolsCatalogPreviewApi() {
|
||||
@@ -12,14 +14,20 @@ export function installToolsCatalogPreviewApi() {
|
||||
|
||||
export function ToolsCatalogFixture() {
|
||||
const [open, setOpen] = useState(true);
|
||||
return <main>
|
||||
<button onClick={() => setOpen(value => !value)}>{open ? "Leave settings" : "Open settings"}</button>
|
||||
const params = new URLSearchParams(location.search);
|
||||
const requested = params.get("section");
|
||||
const section = requested === "skills" || requested === "channels" || requested === "automations" ? requested : "apps";
|
||||
if (params.has("startup")) return <StartupSkeleton embedded surface={section} sidebarExpanded={false} />;
|
||||
return <main className={params.has("layout") ? "h-dvh" : undefined}>
|
||||
{!params.has("layout") && <button onClick={() => setOpen(value => !value)}>{open ? "Leave settings" : "Open settings"}</button>}
|
||||
{open && <SettingsView
|
||||
initialSection="apps"
|
||||
initialSection={section}
|
||||
initialSettings={settings}
|
||||
showSidebar={false}
|
||||
themePreference="light"
|
||||
onChangeTheme={() => {}}
|
||||
onModelNameChange={() => {}}
|
||||
onStartAutomationChat={section === "automations" ? () => {} : undefined}
|
||||
onBackToChat={() => setOpen(false)}
|
||||
/>}
|
||||
</main>;
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
async function selectRadio(page: Page, group: string, name: string) {
|
||||
const radio = page.getByRole("radiogroup", { name: group }).getByRole("radio", { name, exact: true });
|
||||
await radio.locator("..").click();
|
||||
await expect(radio).toBeChecked();
|
||||
await expect(radio).toBeFocused();
|
||||
}
|
||||
|
||||
async function selectToolType(page: Page, name: string) {
|
||||
await selectRadio(page, "Tool type", name);
|
||||
}
|
||||
|
||||
async function showAllTools(page: Page) {
|
||||
const readyOnly = page.getByRole("switch", { name: "Ready only" });
|
||||
if (await readyOnly.isChecked()) await readyOnly.click();
|
||||
await expect(readyOnly).not.toBeChecked();
|
||||
}
|
||||
|
||||
test("settings reentry reuses tools immediately and refreshes expired catalogs without hiding rows", async ({ page }) => {
|
||||
const clockStart = Date.now();
|
||||
await page.clock.setFixedTime(clockStart);
|
||||
const counts = { cli: 0, mcp: 0 };
|
||||
let refresh = false;
|
||||
let release!: () => void;
|
||||
@@ -26,57 +45,126 @@ test("settings reentry reuses tools immediately and refreshes expired catalogs w
|
||||
});
|
||||
await page.goto("/browser/fixture.html?case=tools-catalog");
|
||||
await expect(page.getByRole("heading", { name: "Fixture CLI", exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Ready", exact: true })).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(page.getByRole("switch", { name: "Ready only" })).toBeChecked();
|
||||
await expect(page.getByRole("heading", { name: "Fixture plugin", exact: true })).toHaveCount(0);
|
||||
await page.getByRole("button", { name: "CLI Apps", exact: true }).click();
|
||||
await selectToolType(page, "CLI Apps");
|
||||
await expect(page.getByRole("heading", { name: "Fixture CLI", exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "Fixture plugin", exact: true })).toHaveCount(0);
|
||||
await page.getByRole("button", { name: "Agent Plugins", exact: true }).click();
|
||||
await selectToolType(page, "Agent Plugins");
|
||||
await showAllTools(page);
|
||||
await expect(page.getByRole("heading", { name: "Fixture plugin", exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "Fixture CLI", exact: true })).toHaveCount(0);
|
||||
expect(counts).toEqual({ cli: 1, mcp: 1 });
|
||||
await page.getByRole("button", { name: "Leave settings", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Open settings", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Agent Plugins", exact: true }).click();
|
||||
await selectToolType(page, "Agent Plugins");
|
||||
await showAllTools(page);
|
||||
await expect(page.getByRole("heading", { name: "Fixture plugin", exact: true })).toBeVisible();
|
||||
expect(counts).toEqual({ cli: 1, mcp: 1 });
|
||||
await page.getByRole("button", { name: "Leave settings", exact: true }).click();
|
||||
refresh = true;
|
||||
await page.clock.setFixedTime(new Date(Date.now() + 31_000));
|
||||
await page.clock.setFixedTime(clockStart + 31_000);
|
||||
await page.getByRole("button", { name: "Open settings", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Agent Plugins", exact: true }).click();
|
||||
await selectToolType(page, "Agent Plugins");
|
||||
await showAllTools(page);
|
||||
await expect.poll(() => counts).toEqual({ cli: 2, mcp: 2 });
|
||||
await expect(page.getByRole("heading", { name: "Fixture plugin", exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("status", { name: "Loading apps…", exact: true })).toHaveCount(0);
|
||||
release();
|
||||
await expect(page.getByRole("heading", { name: "Updated plugin", exact: true })).toBeVisible();
|
||||
await page.getByRole("button", { name: "CLI Apps", exact: true }).click();
|
||||
await selectToolType(page, "CLI Apps");
|
||||
await expect(page.getByRole("heading", { name: "Updated CLI", exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
|
||||
test("shows all category labels on narrow screens in each locale", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 320, height: 800 });
|
||||
test("reveals MCP tools hidden by Ready only without switching tool type", async ({ page }) => {
|
||||
await page.route("**/api/settings/cli-apps", route => route.fulfill({ json: { apps: [{
|
||||
name: "fixture-cli", display_name: "Fixture CLI", category: "tools", description: "Fixture app",
|
||||
requires: "", source: "catalog", entry_point: "fixture-cli", install_supported: true,
|
||||
installed: true, available: true, status: "installed", skill_installed: false,
|
||||
}], installed_count: 1 } }));
|
||||
await page.route("**/api/settings/mcp-presets", route => route.fulfill({ json: { presets: [{
|
||||
name: "fixture-mcp", display_name: "Fixture MCP", category: "tools", description: "Fixture MCP tool",
|
||||
requires: "", transport: "stdio", source: "builtin", install_supported: true,
|
||||
installed: true, configured: true, enabled: false, available: false, status: "disabled",
|
||||
required_fields: [], docs_url: "", note: "", connection_summary: "",
|
||||
}], installed_count: 1 } }));
|
||||
await page.goto("/browser/fixture.html?case=tools-catalog&layout&lang=zh-CN");
|
||||
await expect(page.getByRole("heading", { name: "Fixture CLI", exact: true })).toBeVisible();
|
||||
const ready = page.getByRole("switch", { name: "仅显示就绪" });
|
||||
await expect(ready).toBeChecked();
|
||||
await selectRadio(page, "工具类型", "MCP");
|
||||
await expect(page.getByText("还没有就绪的工具", { exact: true })).toBeVisible();
|
||||
const search = page.getByRole("textbox", { name: "搜索工具" });
|
||||
await search.fill("fixture");
|
||||
await ready.click();
|
||||
await expect(search).toHaveValue("fixture");
|
||||
await expect(ready).not.toBeChecked();
|
||||
await expect(page.getByRole("radio", { name: "MCP", exact: true })).toBeChecked();
|
||||
await expect(page.getByRole("heading", { name: "Fixture MCP", exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "Fixture CLI", exact: true })).toHaveCount(0);
|
||||
});
|
||||
|
||||
|
||||
test("keeps Apps section controls usable on narrow screens in each locale", async ({ page }) => {
|
||||
const width = 320;
|
||||
await page.setViewportSize({ width, height: 800 });
|
||||
await page.route("**/api/settings/cli-apps", route => route.fulfill({ json: { apps: [], installed_count: 0 } }));
|
||||
await page.route("**/api/settings/mcp-presets", route => route.fulfill({ json: { presets: [], installed_count: 0 } }));
|
||||
for (const locale of ["en", "es", "fr", "id", "ja", "ko", "pt-BR", "vi", "zh-CN", "zh-TW"]) {
|
||||
await page.goto(`/browser/fixture.html?case=tools-catalog&lang=${locale}`);
|
||||
const control = page.locator(".segmented-control").filter({ has: page.getByRole("button", { name: "CLI Apps", exact: true }) });
|
||||
await expect(control).toBeVisible();
|
||||
const geometry = await control.evaluate(element => {
|
||||
await page.route("**/api/settings/nanobot-features", route => route.fulfill({ json: { features: [], enabled_count: 0 } }));
|
||||
await page.route("**/api/webui/skills/trending?**", route => route.fulfill({ json: { skills: [] } }));
|
||||
const controls = page.locator(".catalog-controls");
|
||||
async function expectControlsFit(locale: string, count: number) {
|
||||
const targets = page.locator(".catalog-tabs > button, .catalog-controls label");
|
||||
await expect(targets).toHaveCount(count);
|
||||
const geometry = await targets.evaluateAll(elements => elements.map(element => {
|
||||
const bounds = element.getBoundingClientRect();
|
||||
return {
|
||||
label: element.textContent,
|
||||
left: bounds.left,
|
||||
right: bounds.right,
|
||||
buttons: Array.from(element.querySelectorAll("button"), button => ({
|
||||
text: button.textContent,
|
||||
fits: button.scrollWidth <= button.clientWidth,
|
||||
})),
|
||||
fits: element.scrollWidth <= element.clientWidth
|
||||
&& (!element.matches("button") || element.scrollHeight <= element.clientHeight),
|
||||
};
|
||||
});
|
||||
expect(geometry.left, locale).toBeGreaterThanOrEqual(0);
|
||||
expect(geometry.right, locale).toBeLessThanOrEqual(320);
|
||||
expect(geometry.buttons, locale).toHaveLength(4);
|
||||
expect(geometry.buttons.every(button => button.fits), locale).toBe(true);
|
||||
}));
|
||||
expect(geometry.filter(item => item.left < 0 || item.right > width || !item.fits), locale).toEqual([]);
|
||||
}
|
||||
for (const locale of ["en", "es", "fr", "id", "ja", "ko", "pt-BR", "vi", "zh-CN", "zh-TW"]) {
|
||||
await page.goto(`/browser/fixture.html?case=tools-catalog&lang=${locale}`);
|
||||
const types = page.getByRole("radiogroup").getByRole("radio");
|
||||
const status = controls.getByRole("switch");
|
||||
await expect(types).toHaveCount(4);
|
||||
await expect(status).not.toBeChecked();
|
||||
await expectControlsFit(locale, 8);
|
||||
const cli = types.nth(1);
|
||||
await cli.locator("..").click();
|
||||
await expect(cli).toBeChecked();
|
||||
await expect(cli).toBeFocused();
|
||||
await page.keyboard.press("ArrowRight");
|
||||
await expect(types.nth(2)).toBeChecked();
|
||||
await expect(types.nth(2)).toBeFocused();
|
||||
await page.keyboard.press("Tab");
|
||||
await expect(status).toBeFocused();
|
||||
await page.keyboard.press("Space");
|
||||
await expect(status).toBeChecked();
|
||||
await status.locator("..").locator(":scope > span").click();
|
||||
await expect(status).not.toBeChecked();
|
||||
await expect(status).toBeFocused();
|
||||
|
||||
const sections = page.locator(".catalog-tabs").getByRole("button");
|
||||
await sections.nth(1).click();
|
||||
await expectControlsFit(locale, 8);
|
||||
const marketplace = controls.getByRole("radio").nth(1);
|
||||
await marketplace.locator("..").click();
|
||||
await expect(marketplace).toBeFocused();
|
||||
await expect(marketplace).toBeChecked();
|
||||
await expectControlsFit(locale, 8);
|
||||
|
||||
await sections.nth(2).click();
|
||||
await expectControlsFit(locale, 4);
|
||||
await status.locator("..").locator(":scope > span").click();
|
||||
await expect(status).toBeChecked();
|
||||
await expect(status).toBeFocused();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -100,3 +188,225 @@ test("opens the generated plugin from its CLI app", async ({ page }) => {
|
||||
await expect(page.getByRole("dialog", { name: "Generated plugin" })).toBeVisible();
|
||||
await expect(page.getByRole("dialog").getByRole("button", { name: "Disable" })).toBeVisible();
|
||||
});
|
||||
|
||||
|
||||
test("keeps navigation, control slots and full-width search stable when switching Apps sections", async ({ page }) => {
|
||||
await page.route("**/api/settings/cli-apps", route => route.fulfill({ json: { apps: [], installed_count: 0 } }));
|
||||
await page.route("**/api/settings/mcp-presets", route => route.fulfill({ json: { presets: [], installed_count: 0 } }));
|
||||
await page.route("**/api/settings/nanobot-features", route => route.fulfill({ json: { features: [], enabled_count: 0 } }));
|
||||
await page.goto("/browser/fixture.html?case=tools-catalog");
|
||||
await page.route("**/api/webui/skills/trending?**", route => route.fulfill({ json: { skills: [] } }));
|
||||
const sections = page.getByRole("group", { name: "Apps" });
|
||||
const selected = sections.getByRole("button", { pressed: true });
|
||||
const tools = sections.getByRole("button", { name: "Tools" });
|
||||
await tools.focus();
|
||||
for (const key of ["ArrowRight", "ArrowLeft"]) {
|
||||
await page.keyboard.press(key);
|
||||
await expect(tools).toBeFocused();
|
||||
await expect(tools).toHaveAttribute("aria-pressed", "true");
|
||||
}
|
||||
const field = page.locator(".catalog-search input");
|
||||
await expect(field).toBeVisible();
|
||||
const searchNode = (await field.elementHandle())!;
|
||||
for (const width of [1440, 800, 375, 320]) {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await tools.click();
|
||||
const wide = width >= 800;
|
||||
let toolsSearch: Awaited<ReturnType<typeof catalogGeometry>>[0] | undefined;
|
||||
const names = ["Tools", "Skills", "Channels"];
|
||||
for (const [index, name] of names.entries()) {
|
||||
await expect(selected).toHaveText(name);
|
||||
await expect(selected).toBeFocused();
|
||||
await expect(field).toBeVisible();
|
||||
expect(await searchNode.evaluate(element => element === document.querySelector(".catalog-search input"))).toBe(true);
|
||||
await page.locator("[data-testid=settings-section-transition]").evaluate(async element => {
|
||||
await Promise.all(element.getAnimations().map(animation => animation.finished));
|
||||
});
|
||||
const geometry = await catalogGeometry(page);
|
||||
const [search, controls] = geometry;
|
||||
const navigation = (await sections.boundingBox())!;
|
||||
expect(search.x).toBe(navigation.x);
|
||||
expect(search.x + search.width).toBe(controls.x + controls.width);
|
||||
expect(search.y).toBe(controls.y + controls.height + (wide ? 12 : 8));
|
||||
if (name === "Tools") toolsSearch = search;
|
||||
else if (wide || name === "Skills") expect(search, `${width}px ${name}`).toEqual(toolsSearch);
|
||||
else {
|
||||
expect(controls.height).toBe(36);
|
||||
expect(search.y).toBeLessThan(toolsSearch!.y);
|
||||
}
|
||||
if (wide) expect(controls.y).toBe(navigation.y);
|
||||
else expect(navigation.width).toBe(search.width);
|
||||
expect(search.height).toBe(36);
|
||||
expect(search.radius).toBe("12px");
|
||||
expect(geometry.every(control => control.x >= 0 && control.x + control.width <= width)).toBe(true);
|
||||
if (name === "Skills") {
|
||||
await selectRadio(page, "Skills views", "Marketplace");
|
||||
const sources = page.getByRole("radiogroup", { name: "Skill source" });
|
||||
await expect(sources.getByRole("radio", { name: "All", exact: true })).toBeChecked();
|
||||
await page.keyboard.press("Tab");
|
||||
await expect(sources.getByRole("radio", { name: "All", exact: true })).toBeFocused();
|
||||
await page.keyboard.press("ArrowRight");
|
||||
await expect(sources.getByRole("radio", { name: "skills.sh" })).toBeFocused();
|
||||
await expect(sources.getByRole("radio", { name: "skills.sh" })).toBeChecked();
|
||||
await selectRadio(page, "Skill source", "All");
|
||||
expect(await catalogGeometry(page)).toEqual(geometry);
|
||||
expect(await searchNode.evaluate(element => element === document.querySelector(".catalog-search input"))).toBe(true);
|
||||
await selectRadio(page, "Skills views", "Installed");
|
||||
await selected.focus();
|
||||
}
|
||||
const next = names[index + 1];
|
||||
if (next) {
|
||||
await page.keyboard.press("Tab");
|
||||
await expect(sections.getByRole("button", { name: next })).toBeFocused();
|
||||
await page.keyboard.press("Enter");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("keeps channel names, local marks and click focus on a narrow viewport", async ({ page, baseURL }) => {
|
||||
await page.setViewportSize({ width: 320, height: 800 });
|
||||
const origin = new URL(baseURL!).origin;
|
||||
const externalImages: string[] = [];
|
||||
await page.route(url => url.origin !== origin, route => {
|
||||
if (route.request().resourceType() === "image") externalImages.push(route.request().url());
|
||||
return route.abort();
|
||||
});
|
||||
await page.route("**/api/settings/nanobot-features", route => route.fulfill({ json: {
|
||||
enabled_count: 1,
|
||||
features: [{
|
||||
name: "whatsapp_agent", display_name: "WhatsApp Agent Platform", type: "channel",
|
||||
enabled: true, installed: true, runtime_status: "failed", status: "enabled",
|
||||
install_supported: false, requires_restart: false,
|
||||
}, {
|
||||
name: "telegram", display_name: "Telegram", type: "channel",
|
||||
enabled: false, installed: false, status: "not_installed",
|
||||
install_supported: true, requires_dependencies: true, requires_restart: false,
|
||||
}, {
|
||||
name: "email", display_name: "Email", type: "channel",
|
||||
enabled: false, installed: true, configured: false, status: "not_enabled",
|
||||
install_supported: false, requires_restart: false,
|
||||
}, ...[
|
||||
["linear", "Linear"], ["mattermost", "Mattermost"], ["qq", "QQ"], ["slack", "Slack"],
|
||||
].map(([name, display_name]) => ({
|
||||
name, display_name, type: "channel",
|
||||
enabled: false, installed: true, status: "not_enabled",
|
||||
install_supported: false, requires_restart: false,
|
||||
}))],
|
||||
} }));
|
||||
await page.goto("/browser/fixture.html?case=tools-catalog&layout§ion=channels");
|
||||
const name = page.getByRole("heading", { name: "WhatsApp Agent Platform", exact: true });
|
||||
await expect(name).toBeVisible();
|
||||
const settings = page.getByRole("button", { name: /View WhatsApp Agent Platform/ });
|
||||
await expect(settings).toHaveAccessibleDescription("Failed");
|
||||
expect(await name.evaluate(element => element.scrollWidth <= element.clientWidth && element.scrollHeight <= element.clientHeight)).toBe(true);
|
||||
const mark = page.locator("[data-testid=channel-logo-whatsapp_agent] img");
|
||||
await expect.poll(() => mark.evaluate(image => (image as HTMLImageElement).naturalWidth)).toBeGreaterThan(0);
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Channels" });
|
||||
await settings.click();
|
||||
await expect(dialog).toBeFocused();
|
||||
await dialog.getByRole("button", { name: "Close", exact: true }).click();
|
||||
await expect(settings).toBeFocused();
|
||||
|
||||
const enabledOnly = page.getByRole("switch", { name: "Enabled only" });
|
||||
await expect(enabledOnly).toBeChecked();
|
||||
await enabledOnly.click();
|
||||
await expect(enabledOnly).not.toBeChecked();
|
||||
await expect(enabledOnly).toBeFocused();
|
||||
for (const channel of ["linear", "mattermost", "qq"]) {
|
||||
const image = page.getByTestId(`channel-logo-${channel}`).locator("img");
|
||||
await image.scrollIntoViewIfNeeded();
|
||||
await expect(image).toHaveAttribute("src", `/brand/channels/${channel}.svg`);
|
||||
await expect.poll(() => image.evaluate(element => (element as HTMLImageElement).naturalWidth)).toBeGreaterThan(0);
|
||||
}
|
||||
const slackMark = page.getByTestId("channel-logo-slack");
|
||||
await slackMark.scrollIntoViewIfNeeded();
|
||||
await expect(slackMark).toHaveText("SL");
|
||||
const emailSwitch = page.getByRole("switch", { name: /Email/ });
|
||||
await emailSwitch.click();
|
||||
await expect(dialog).toBeFocused();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(emailSwitch).toBeFocused();
|
||||
|
||||
const telegram = page.getByRole("button", { name: /View Telegram/ });
|
||||
const install = page.getByRole("button", { name: "Install Telegram" });
|
||||
await telegram.click();
|
||||
await expect(telegram).toBeFocused();
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(install).toBeFocused();
|
||||
|
||||
const skills = page.getByRole("group", { name: "Apps" }).getByRole("button", { name: "Skills" });
|
||||
await skills.click();
|
||||
await expect(page.getByLabel("Search installed skills")).toBeVisible();
|
||||
await expect(skills).toBeFocused();
|
||||
expect(externalImages).toEqual([]);
|
||||
});
|
||||
|
||||
async function catalogGeometry(page: Page, startup = false) {
|
||||
const selectors = startup
|
||||
? [".startup-search", ".startup-controls"]
|
||||
: [".catalog-search input", ".catalog-controls"];
|
||||
return Promise.all(selectors.map(selector => page.locator(selector).evaluate(element => {
|
||||
const rect = element.getBoundingClientRect();
|
||||
return { x: rect.x, y: rect.y, width: rect.width, height: rect.height, radius: getComputedStyle(element).borderRadius };
|
||||
})));
|
||||
}
|
||||
|
||||
for (const width of [390, 1440]) test(`Apps startup skeleton shares the loaded toolbar geometry at ${width}px`, async ({ page }) => {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||||
await page.route("**/api/settings/cli-apps", route => route.fulfill({ json: { apps: [], installed_count: 0 } }));
|
||||
await page.route("**/api/settings/mcp-presets", route => route.fulfill({ json: { presets: [], installed_count: 0 } }));
|
||||
await page.route("**/api/settings/nanobot-features", route => route.fulfill({ json: { features: [], enabled_count: 0 } }));
|
||||
for (const section of ["apps", "skills", "channels"]) {
|
||||
const url = `/browser/fixture.html?case=tools-catalog&layout§ion=${section}`;
|
||||
await page.goto(url);
|
||||
await expect(page.locator(".catalog-search input")).toBeVisible();
|
||||
const loaded = await catalogGeometry(page);
|
||||
await page.goto(`${url}&startup`);
|
||||
await expect(page.locator(".startup-search")).toBeVisible();
|
||||
expect(await catalogGeometry(page, true), section).toEqual(loaded);
|
||||
}
|
||||
});
|
||||
|
||||
for (const width of [390, 1440]) test(`Apps and Automations share the conversation column at ${width}px`, async ({ page }) => {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||||
await page.route("**/api/settings/cli-apps", route => route.fulfill({ json: { apps: [], installed_count: 0 } }));
|
||||
await page.route("**/api/settings/mcp-presets", route => route.fulfill({ json: { presets: [], installed_count: 0 } }));
|
||||
await page.route("**/api/webui/automations", route => route.fulfill({ json: { jobs: [] } }));
|
||||
|
||||
const bounds = async (selector: string) => {
|
||||
const target = page.locator(selector);
|
||||
await expect(target).toBeVisible();
|
||||
const { x, width } = (await target.boundingBox())!;
|
||||
return { x, width };
|
||||
};
|
||||
const fixture = "/browser/fixture.html?case=tools-catalog&layout";
|
||||
await page.goto(fixture);
|
||||
const apps = await bounds(".catalog-search input");
|
||||
await page.goto(`${fixture}§ion=automations`);
|
||||
expect(await bounds(".automation-panel")).toEqual(apps);
|
||||
expect(await bounds(".automation-create-composer .thread-composer-surface")).toEqual(apps);
|
||||
await expect(page.locator(width === 1440 ? ".automation-calendar-grid" : ".automation-calendar-agenda")).toBeVisible();
|
||||
await page.goto(`${fixture}§ion=automations&startup`);
|
||||
expect(await bounds(".startup-calendar")).toEqual(apps);
|
||||
|
||||
if (width === 1440) {
|
||||
await page.route("**/api/commands", route => route.fulfill({ json: { commands: [] } }));
|
||||
await page.route("**/api/sessions/*/webui-thread?*", route => route.fulfill({ json: {
|
||||
schemaVersion: 3, projection: "events", events: [], has_more: false,
|
||||
} }));
|
||||
await page.routeWebSocket("**/answer-order-socket", route => route.onMessage(raw => {
|
||||
const frame = JSON.parse(String(raw));
|
||||
if (frame.type !== "attach") return;
|
||||
route.send(JSON.stringify({ event: "attached", chat_id: frame.chat_id }));
|
||||
route.send(JSON.stringify({ event: "user_message", chat_id: frame.chat_id,
|
||||
turn_id: "layout-turn", text: "An existing conversation", starts_turn: true,
|
||||
}));
|
||||
}));
|
||||
await page.goto("/browser/fixture.html?case=answer-order");
|
||||
expect(await bounds('[data-layout="thread"] .thread-composer-surface')).toEqual(apps);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user