refactor(web): simplify AI integration settings

This commit is contained in:
tianma-if committed 2026-09-04 10:04:06 +08:00
1 parent c651f0b31d
commit 60d56103af
2 files changed
+22 -12

No files matched your search

-4
View File
@@ -21,7 +21,6 @@ import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/ca
import type { EditorContentAlignment, ShortcutSettings } from "@/lib/app-helpers";
import { WORKSPACE_PAGE_TITLE_CLASSNAME } from "@/lib/workspace-ui";
import { cn } from "@/lib/utils";
import { AdvancedPlayCard } from "./settings/AdvancedPlayCard";
import { AccountInfoCard } from "./settings/AccountInfoCard";
import { DataExportCard } from "./settings/DataExportCard";
import { DesktopLocalDataCard } from "./settings/DesktopLocalDataCard";
@@ -34,7 +33,6 @@ import { PasswordCard } from "./settings/PasswordCard";
import { UserManagementCard } from "./settings/UserManagementCard";
import { ObjectStorageCard } from "./settings/ObjectStorageCard";
import { AiModelCard } from "./settings/AiModelCard";
import { AiPromptsCard } from "./settings/AiPromptsCard";
import { AiTagSuggestionPromptCard } from "./settings/AiTagSuggestionPromptCard";
import { ThemeToggle } from "./ThemeToggle";
import type { AuthUser } from "@edgeever/shared";
@@ -267,8 +265,6 @@ export const SettingsPane = ({
<SettingsGroup>
<AiModelCard />
<McpConfigCard />
<AiPromptsCard onOpenLibrary={onOpenAiPrompts} />
<AdvancedPlayCard />
</SettingsGroup>
);
case "advanced":
+22 -8
View File
@@ -65,14 +65,17 @@ const createPrompt = async (
return (await response.json() as { prompt: Prompt }).prompt;
};
const openSettingsAiTab = async (page: Page) => {
await ensureAuthenticatedPage(page);
await page.getByRole("button", { name: "个人中心", exact: true }).click();
const openPromptLibrary = async (page: Page) => {
await page.setViewportSize({ width: 390, height: 844 });
await login(page.request);
await page.goto("/");
const profileButton = page.getByRole("button", { name: "我的", exact: true });
await expect(profileButton).toBeVisible({ timeout: 20_000 });
await profileButton.click();
await expect(page.getByRole("heading", { name: "我的", exact: true })).toBeVisible();
await page.getByRole("button", { name: "AI集成", exact: true }).click();
await expect(page.getByRole("heading", { name: "AI 指令", exact: true })).toBeVisible();
await page.getByRole("button", { name: "打开指令库", exact: true }).click();
await page.getByRole("button", { name: "指令", exact: true }).click();
await expect(page.getByRole("heading", { name: "指令库", exact: true })).toBeVisible();
await page.setViewportSize({ width: 1280, height: 720 });
};
const openMemoAssistant = async (page: Page, memoId: string, notebookName: string) => {
@@ -133,6 +136,17 @@ test.describe("AI custom prompts", () => {
return memo;
};
test("keeps secondary content out of AI integration settings", async ({ page }) => {
await ensureAuthenticatedPage(page);
await page.getByRole("button", { name: "个人中心", exact: true }).click();
await page.getByRole("button", { name: "AI集成", exact: true }).click();
await expect(page.getByRole("heading", { name: "外部 AI 模型", exact: true })).toBeVisible();
await expect(page.getByRole("heading", { name: "API Token 与 MCP 配置", exact: true })).toBeVisible();
await expect(page.getByRole("heading", { name: "AI 指令", exact: true })).toHaveCount(0);
await expect(page.getByRole("heading", { name: "进阶玩法", exact: true })).toHaveCount(0);
});
test("opens the inline composer from /ai and the configurable shortcut", async ({ page }) => {
const memo = await createMemo(page, `e2e-ai-inline-${Date.now()}`, "用于测试内联 AI 入口。");
await ensureAuthenticatedPage(page);
@@ -562,7 +576,7 @@ test.describe("AI custom prompts", () => {
const promptName = `e2e-设置指令-${Date.now()}`;
const instruction = "把笔记提炼成三条要点,使用 Markdown 列表。";
await openSettingsAiTab(page);
await openPromptLibrary(page);
await page.getByRole("button", { name: "新建指令", exact: true }).click();
const editor = page.locator("form").filter({ has: page.getByRole("heading", { name: "新建指令", exact: true }) });
await expect(editor).toBeVisible();
@@ -674,7 +688,7 @@ test.describe("AI custom prompts", () => {
});
createdPromptIds.push(created.id);
await openSettingsAiTab(page);
await openPromptLibrary(page);
const row = page.getByRole("article").filter({ has: page.getByRole("heading", { name: originalName, exact: true }) });
await expect(row.getByText(originalName, { exact: true })).toBeVisible();
await row.getByRole("button", { name: "编辑指令", exact: true }).click();