feat: 实现大模型模型列表与供应商管理,并接入 Playwright 测试

补齐 LLM 子菜单路由,落地模型列表与供应商管理页面交互,同时引入功能与视觉回归用例以便后续页面持续验证。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-26 02:01:40 +08:00
parent a09dcef3f1
commit c4872891f8
23 changed files with 1117 additions and 7 deletions

View File

@@ -0,0 +1,54 @@
import { expect, test } from '../fixtures/auth';
test.describe('大模型 / 供应商管理', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/llm/providers');
await page.getByRole('table').waitFor();
});
test('展示列表及主要操作', async ({ page }) => {
await expect(page.getByRole('button', { name: '新增供应商' })).toBeVisible();
await expect(page.getByRole('table')).toBeVisible();
await expect(page.getByText('OpenAI', { exact: true })).toBeVisible();
await expect(page.getByText('https://api.openai.com/v1')).toBeVisible();
});
test('可搜索供应商', async ({ page }) => {
await page.getByPlaceholder('搜索供应商名称').fill('DeepSeek');
await expect(page.getByText('DeepSeek', { exact: true })).toBeVisible();
await expect(page.getByText('OpenAI', { exact: true })).toHaveCount(0);
});
test('可新增供应商', async ({ page }) => {
await page.getByRole('button', { name: '新增供应商' }).click();
const dialog = page.getByRole('dialog', { name: '新增供应商' });
await expect(dialog).toBeVisible();
await dialog.getByLabel('供应商名称').fill('测试供应商');
await dialog.getByLabel('Base URL').fill('https://api.test.com/v1');
await dialog.getByRole('button', { name: '保 存' }).click();
await expect(page.getByText('测试供应商', { exact: true })).toBeVisible();
});
test('可切换供应商状态并测试连通', async ({ page }) => {
const statusSwitch = page.getByRole('switch', { name: 'OpenAI状态' });
await expect(statusSwitch).toBeChecked();
await statusSwitch.click();
await expect(statusSwitch).not.toBeChecked();
const row = page.getByRole('row').filter({ hasText: 'OpenAI' });
await row.getByRole('button', { name: '测试连通' }).click();
await expect(page.getByText('OpenAI 连通正常')).toBeVisible();
});
test('可编辑凭证', async ({ page }) => {
const row = page.getByRole('row').filter({ hasText: 'DeepSeek' });
await row.getByRole('button', { name: '编辑凭证' }).click();
const dialog = page.getByRole('dialog', { name: '编辑供应商' });
await expect(dialog).toBeVisible();
await dialog.getByLabel('API Key').fill('sk-test-key');
await dialog.getByRole('button', { name: '保 存' }).click();
await expect(page.getByText('供应商已更新')).toBeVisible();
});
});