mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-10 02:02:31 +08:00
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:
@@ -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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user