feat: add Keycloak authentication

This commit is contained in:
2026-08-19 12:11:18 +08:00
parent bdd5eff776
commit d08cf2abc1
27 changed files with 533 additions and 128 deletions
+14 -9
View File
@@ -1,10 +1,22 @@
import type { Page } from "@playwright/test";
type MockAgentApiOptions = {
model?: {
id: string;
label: string;
description: string;
icon: "bolt" | "sparkle";
};
sessions?: Array<Record<string, unknown>>;
};
export async function mockAgentApi(page: Page, options: MockAgentApiOptions = {}) {
const model = options.model ?? {
id: "test/model",
label: "测试模型",
description: "Playwright 浏览器测试",
icon: "bolt" as const
};
await page.route("**/api/v1/agent/chat/**", async (route) => {
const pathname = new URL(route.request().url()).pathname;
@@ -37,15 +49,8 @@ export async function mockAgentApi(page: Page, options: MockAgentApiOptions = {}
if (pathname.endsWith("/models")) {
await route.fulfill({
json: {
default_model: "test/model",
models: [
{
id: "test/model",
label: "测试模型",
description: "Playwright 浏览器测试",
icon: "bolt"
}
]
default_model: model.id,
models: [model]
}
});
return;