test: 测试用例测试html文件有没有向用户展示
This commit is contained in:
parent
a9f98aaf71
commit
72a92707ca
|
|
@ -1,11 +1,13 @@
|
|||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import {
|
||||
PRIMARY_THREAD_ID,
|
||||
THREAD_WITH_ARTIFACTS,
|
||||
THREAD_WITH_HTML_ARTIFACT,
|
||||
THREAD_WITH_IMAGE_ARTIFACT,
|
||||
openChat,
|
||||
reuseThreadChatEntry,
|
||||
sendMessage,
|
||||
skipIfMissingThread,
|
||||
waitForAnyMessages,
|
||||
waitForMessageListReady,
|
||||
|
|
@ -87,8 +89,22 @@ test.describe("聊天工作台 / Artifact 面板", () => {
|
|||
(await htmlFile.count()) === 0,
|
||||
"当前线程没有 HTML artifact。",
|
||||
);
|
||||
|
||||
const htmlArtifactResponsePromise = page.waitForResponse((response) => {
|
||||
const url = decodeURIComponent(response.url());
|
||||
return (
|
||||
response.status() === 200 &&
|
||||
/\/api\/threads\/[^/]+\/artifacts\//.test(url) &&
|
||||
/\.html?($|\?)/i.test(url)
|
||||
);
|
||||
});
|
||||
|
||||
await htmlFile.click();
|
||||
|
||||
const htmlArtifactResponse = await htmlArtifactResponsePromise;
|
||||
expect(htmlArtifactResponse.headers()["content-disposition"] ?? "").toContain(
|
||||
"attachment;",
|
||||
);
|
||||
await expect(page.getByTitle(/Artifact preview(?::.*)?$/i)).toBeVisible();
|
||||
});
|
||||
|
||||
|
|
@ -117,4 +133,32 @@ test.describe("聊天工作台 / Artifact 面板", () => {
|
|||
await expect(page.getByTestId("artifacts-open-button")).toBeVisible();
|
||||
await expect(page.getByRole("log").first()).toBeVisible();
|
||||
});
|
||||
|
||||
test("DF-ART-005 生成简单 HTML 后出现 artifact-file-card", async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
test.setTimeout(180_000);
|
||||
skipIfMissingThread(testInfo, PRIMARY_THREAD_ID, "FRONTEND_E2E_THREAD_ID");
|
||||
|
||||
await openChat(page, reuseThreadChatEntry(PRIMARY_THREAD_ID!));
|
||||
await waitForMessageListReady(page, { requireMessages: false });
|
||||
|
||||
await sendMessage(page, "生成一个简单的html文件");
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => await page.getByTestId("artifacts-open-button").count(),
|
||||
{ timeout: 120_000 },
|
||||
)
|
||||
.toBeGreaterThan(0);
|
||||
|
||||
await page.getByTestId("artifacts-open-button").click();
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => await page.getByTestId("artifact-file-card").count(),
|
||||
{ timeout: 30_000 },
|
||||
)
|
||||
.toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue