Files
Agent-Workbench/scripts/ui-navigation.mjs
T

15 lines
1.1 KiB
JavaScript

// Keep acceptance drivers on the product's real navigation after the Orven redesign.
// This opens a visible entry or the searchable toolbox; it never bypasses the UI.
export async function openWorkbenchTool(page, name) {
const aliases = { '打开模型中心': '选择与管理模型', '项目MCP工具': '项目 MCP 工具' };
const direct = page.getByRole('button', { name: aliases[name] ?? name, exact: true });
// The sidebar becomes inert after a responsive resize. The persistent
// toolbox is the model-center entry at both desktop and narrow widths.
if (name !== '打开模型中心' && await direct.first().isVisible()) { await direct.first().click(); return; }
await page.getByRole('button', { name: '打开工具箱', exact: true }).click();
const toolbox = page.getByRole('dialog', { name: '工具箱', exact: true });
const actionName = name === '打开模型中心' ? '模型中心' : aliases[name] ?? name;
await toolbox.getByLabel('搜索工作台工具').fill(actionName);
await toolbox.getByRole('button', { name: actionName, exact: true }).click();
}