test: 测试用例测试html文件有没有向用户展示
This commit is contained in:
parent
863ea39a47
commit
9417593ea7
|
|
@ -1,11 +1,13 @@
|
||||||
import { expect, test } from "@playwright/test";
|
import { expect, test } from "@playwright/test";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
PRIMARY_THREAD_ID,
|
||||||
THREAD_WITH_ARTIFACTS,
|
THREAD_WITH_ARTIFACTS,
|
||||||
THREAD_WITH_HTML_ARTIFACT,
|
THREAD_WITH_HTML_ARTIFACT,
|
||||||
THREAD_WITH_IMAGE_ARTIFACT,
|
THREAD_WITH_IMAGE_ARTIFACT,
|
||||||
openChat,
|
openChat,
|
||||||
reuseThreadChatEntry,
|
reuseThreadChatEntry,
|
||||||
|
sendMessage,
|
||||||
skipIfMissingThread,
|
skipIfMissingThread,
|
||||||
waitForAnyMessages,
|
waitForAnyMessages,
|
||||||
waitForMessageListReady,
|
waitForMessageListReady,
|
||||||
|
|
@ -87,8 +89,22 @@ test.describe("聊天工作台 / Artifact 面板", () => {
|
||||||
(await htmlFile.count()) === 0,
|
(await htmlFile.count()) === 0,
|
||||||
"当前线程没有 HTML artifact。",
|
"当前线程没有 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();
|
await htmlFile.click();
|
||||||
|
|
||||||
|
const htmlArtifactResponse = await htmlArtifactResponsePromise;
|
||||||
|
expect(htmlArtifactResponse.headers()["content-disposition"] ?? "").toContain(
|
||||||
|
"attachment;",
|
||||||
|
);
|
||||||
await expect(page.getByTitle(/Artifact preview(?::.*)?$/i)).toBeVisible();
|
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.getByTestId("artifacts-open-button")).toBeVisible();
|
||||||
await expect(page.getByRole("log").first()).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