diff --git a/src/pages/options/routes/ScriptEditor/EditorTabs.test.tsx b/src/pages/options/routes/ScriptEditor/EditorTabs.test.tsx index 8b1bdc968..2872e5892 100644 --- a/src/pages/options/routes/ScriptEditor/EditorTabs.test.tsx +++ b/src/pages/options/routes/ScriptEditor/EditorTabs.test.tsx @@ -37,19 +37,6 @@ function renderTabs() { } describe("EditorTabs「+」新建菜单", () => { - it("hover「+」展开脚本类型选择菜单", async () => { - renderTabs(); - const plusBtn = screen.getByLabelText("新建脚本"); - - await act(async () => { - fireEvent.mouseEnter(plusBtn); - }); - - expect(screen.getByText("新建普通脚本")).toBeInTheDocument(); - expect(screen.getByText("新建后台脚本")).toBeInTheDocument(); - expect(screen.getByText("新建定时脚本")).toBeInTheDocument(); - }); - it("点击「新建后台脚本」以 background 模板回调 onNew", async () => { renderTabs(); const plusBtn = screen.getByLabelText("新建脚本"); diff --git a/src/pages/options/routes/ScriptEditor/EditorToolbar.test.tsx b/src/pages/options/routes/ScriptEditor/EditorToolbar.test.tsx index 9e8c7a0ce..2c474c8b4 100644 --- a/src/pages/options/routes/ScriptEditor/EditorToolbar.test.tsx +++ b/src/pages/options/routes/ScriptEditor/EditorToolbar.test.tsx @@ -37,20 +37,6 @@ const openSub = async (el: HTMLElement) => { }; describe("EditorToolbar 桌面端编辑器工具栏", () => { - it("应保留原汉堡图标按钮作为菜单入口", () => { - const { getByLabelText } = render(); - expect(getByLabelText("更多")).toBeInTheDocument(); - }); - - it("展开后应是「文件」「编辑」「运行」二级子菜单而非全部平铺", async () => { - const { getByLabelText, getByText } = render(); - await openRoot(getByLabelText("更多")); - // 顶层只暴露分组(子菜单触发器),具体操作收纳在二级子菜单里,默认不可见 - expect(getByText("文件")).toBeInTheDocument(); - expect(getByText("编辑")).toBeInTheDocument(); - expect(getByText("运行")).toBeInTheDocument(); - }); - it("文件 → 保存 应回调 onSave", async () => { const props = baseProps(); const { getByLabelText, getByText } = render(); diff --git a/src/pages/options/routes/ScriptEditor/MobileEditor.test.tsx b/src/pages/options/routes/ScriptEditor/MobileEditor.test.tsx index 606b86e45..38cf28990 100644 --- a/src/pages/options/routes/ScriptEditor/MobileEditor.test.tsx +++ b/src/pages/options/routes/ScriptEditor/MobileEditor.test.tsx @@ -40,15 +40,6 @@ const baseProps = () => ({ }); describe("MobileEditor 移动端编辑器外壳", () => { - it("应显示脚本标题", () => { - const { getByText } = render( - -
{"editor"}
-
- ); - expect(getByText("Bilibili Evolved")).toBeTruthy(); - }); - it("点击返回按钮应回调 onBack", () => { const props = baseProps(); const { getByLabelText } = render( diff --git a/src/pages/options/routes/ScriptEditor/tabs/SettingsPane.test.tsx b/src/pages/options/routes/ScriptEditor/tabs/SettingsPane.test.tsx index 731bd3790..3b98ef8b0 100644 --- a/src/pages/options/routes/ScriptEditor/tabs/SettingsPane.test.tsx +++ b/src/pages/options/routes/ScriptEditor/tabs/SettingsPane.test.tsx @@ -165,7 +165,7 @@ describe("SettingsPane 运行设置", () => { const trigger = screen.getAllByRole("combobox")[comboIndex]; fireEvent.keyDown(trigger, { key: "Enter" }); await act(() => Promise.resolve()); - fireEvent.click(screen.getAllByRole("option").find((o) => o.textContent === optionText)!); + fireEvent.click(screen.getByRole("option", { name: optionText })); await act(() => Promise.resolve()); }; @@ -180,6 +180,13 @@ describe("SettingsPane 运行设置", () => { expect(screen.getAllByRole("combobox")[1]).not.toHaveTextContent("early-start"); }); + it("运行时机应提供 context-menu 并保存为用户覆盖", async () => { + render(); + await screen.findByText("alpha"); + await pickOption(1, "context-menu"); + expect(updateMetadata).toHaveBeenCalledWith("u1", "run-at", ["context-menu"]); + }); + it("运行环境选「默认」应以 undefined 撤销覆盖而非写入空数组", async () => { fetchScript.mockResolvedValue({ ...sampleScript(), diff --git a/src/pages/options/routes/ScriptEditor/tabs/SettingsPane.tsx b/src/pages/options/routes/ScriptEditor/tabs/SettingsPane.tsx index f413fc271..01d222f07 100644 --- a/src/pages/options/routes/ScriptEditor/tabs/SettingsPane.tsx +++ b/src/pages/options/routes/ScriptEditor/tabs/SettingsPane.tsx @@ -28,11 +28,19 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@ import { createPreloadableQuery } from "@App/pages/preloadable-query"; const RUN_IN_OPTIONS = ["default", "all", "normal-tabs", "incognito-tabs"]; -const RUN_AT_OPTIONS = ["default", "document-start", "document-body", "document-end", "document-idle", "early-start"]; +const RUN_AT_OPTIONS = [ + "default", + "document-start", + "document-body", + "document-end", + "document-idle", + "context-menu", + "early-start", +]; const PERMISSION_TYPES = ["cors", "cookie"]; const PERMISSION_LABEL: Record = { cors: "CORS", cookie: "Cookie" }; -// 运行环境/运行时机下拉项的本地化文案;运行时机的 document-* / early-start 保持原始字面值(与 v1.4 一致) +// 运行环境/运行时机下拉项的本地化文案;运行时机保持原始字面值(与 v1.4 一致) const runInLabel = (o: string, t: TFunction) => o === "default" ? t("settings:script_setting.default") : t(`settings:script_run_env.${o}`); const runAtLabel = (o: string, t: TFunction) => (o === "default" ? t("settings:script_setting.default") : o); diff --git a/src/pages/options/routes/ScriptEditor/tabs/StoragePane.test.tsx b/src/pages/options/routes/ScriptEditor/tabs/StoragePane.test.tsx index aea349feb..15c2fcab3 100644 --- a/src/pages/options/routes/ScriptEditor/tabs/StoragePane.test.tsx +++ b/src/pages/options/routes/ScriptEditor/tabs/StoragePane.test.tsx @@ -198,10 +198,4 @@ describe("StoragePane 储存面板", () => { ); expect(await screen.findByText("newKey")).toBeInTheDocument(); }); - - it("无数据时应展示空状态", async () => { - getScriptValue.mockResolvedValue({}); - render(); - expect(await screen.findByText(t("no_data"))).toBeInTheDocument(); - }); });