test: 新增新用户的创建逻辑用例
This commit is contained in:
parent
c9116e2fb2
commit
0c1a293fbd
|
|
@ -1,15 +1,22 @@
|
||||||
import { expect, test } from "@playwright/test";
|
import { expect, test } from "@playwright/test";
|
||||||
|
import { v4 as uuid } from "uuid";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
THREAD_FOR_WELCOME,
|
THREAD_FOR_WELCOME,
|
||||||
newChatEntry,
|
newChatEntry,
|
||||||
openChat,
|
openChat,
|
||||||
reuseThreadChatEntry,
|
reuseThreadChatEntry,
|
||||||
|
sendMessage,
|
||||||
skipIfMissingThread,
|
skipIfMissingThread,
|
||||||
waitForAnyMessages,
|
waitForAnyMessages,
|
||||||
waitForMessageListReady,
|
waitForMessageListReady,
|
||||||
} from "./support/chat-helpers";
|
} from "./support/chat-helpers";
|
||||||
|
|
||||||
|
test.use({
|
||||||
|
screenshot: "on",
|
||||||
|
video: "on",
|
||||||
|
});
|
||||||
|
|
||||||
test.describe("线程路由(无 isnew)", () => {
|
test.describe("线程路由(无 isnew)", () => {
|
||||||
test("/new 始终走欢迎态,发送后进入具体 thread 路由", async ({ page }, testInfo) => {
|
test("/new 始终走欢迎态,发送后进入具体 thread 路由", async ({ page }, testInfo) => {
|
||||||
skipIfMissingThread(testInfo, THREAD_FOR_WELCOME, "FRONTEND_E2E_THREAD_ID");
|
skipIfMissingThread(testInfo, THREAD_FOR_WELCOME, "FRONTEND_E2E_THREAD_ID");
|
||||||
|
|
@ -29,4 +36,46 @@ test.describe("线程路由(无 isnew)", () => {
|
||||||
await expect(page).toHaveURL(new RegExp(`/workspace/chats/${THREAD_FOR_WELCOME!}`));
|
await expect(page).toHaveURL(new RegExp(`/workspace/chats/${THREAD_FOR_WELCOME!}`));
|
||||||
await expect(page.locator(".is-user, .is-assistant").first()).toBeVisible();
|
await expect(page.locator(".is-user, .is-assistant").first()).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("/new 使用 uuid thread_id 发送后触发 stream(cod=0) 并进入 thread 路由", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
const threadId = uuid();
|
||||||
|
const text = `e2e-${threadId.slice(0, 8)}`;
|
||||||
|
|
||||||
|
await openChat(page, newChatEntry(threadId));
|
||||||
|
await expect(page.getByTestId("welcome-suggestions")).toBeVisible();
|
||||||
|
|
||||||
|
const streamRequestPromise = page.waitForRequest(
|
||||||
|
(request) => {
|
||||||
|
const url = request.url();
|
||||||
|
if (!url.includes("/stream")) return false;
|
||||||
|
if (!url.includes(threadId)) return false;
|
||||||
|
try {
|
||||||
|
const parsed = new URL(url);
|
||||||
|
return parsed.searchParams.get("cancel_on_disconnect") === "0";
|
||||||
|
} catch {
|
||||||
|
return url.includes("cancel_on_disconnect=0");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ timeout: 30_000 },
|
||||||
|
);
|
||||||
|
|
||||||
|
await sendMessage(page, text);
|
||||||
|
await expect(page.locator(".is-user").filter({ hasText: text })).toHaveCount(1);
|
||||||
|
await expect
|
||||||
|
.poll(
|
||||||
|
async () => await page.locator(".is-assistant").count(),
|
||||||
|
{ timeout: 30_000 },
|
||||||
|
)
|
||||||
|
.toBeGreaterThan(0);
|
||||||
|
|
||||||
|
const streamRequest = await streamRequestPromise;
|
||||||
|
expect(streamRequest.url()).toContain("cancel_on_disconnect=0");
|
||||||
|
|
||||||
|
await expect(page).toHaveURL(
|
||||||
|
new RegExp(`/workspace/chats/${threadId}\\?is_chatting=true`),
|
||||||
|
{ timeout: 30_000 },
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue