refactor: extract shared test helpers and improve error assertions

- Create tests/e2e/lib/helpers.ts with shared SSE mock functions
- Add proper error UI assertions to error-handling.spec.ts
- Remove waitForTimeout calls in favor of real assertions
- Update 6 test files to use shared helpers
This commit is contained in:
dayuan.jiang
2026-01-04 21:14:08 +09:00
parent ddc35e1bb2
commit 6ce7e3378b
8 changed files with 137 additions and 231 deletions

View File

@@ -1,36 +1,5 @@
import { expect, test } from "@playwright/test"
// Helper to create SSE response
function createMockSSEResponse(xml: string, text: string) {
const messageId = `msg_${Date.now()}`
const toolCallId = `call_${Date.now()}`
const textId = `text_${Date.now()}`
const events = [
{ type: "start", messageId },
{ type: "text-start", id: textId },
{ type: "text-delta", id: textId, delta: text },
{ type: "text-end", id: textId },
{ type: "tool-input-start", toolCallId, toolName: "display_diagram" },
{
type: "tool-input-available",
toolCallId,
toolName: "display_diagram",
input: { xml },
},
{
type: "tool-output-available",
toolCallId,
output: "Successfully displayed the diagram",
},
{ type: "finish" },
]
return (
events.map((e) => `data: ${JSON.stringify(e)}\n\n`).join("") +
"data: [DONE]\n\n"
)
}
import { createMockSSEResponse } from "./lib/helpers"
test.describe("Iframe Interaction", () => {
test("draw.io iframe loads successfully", async ({ page }) => {