deer-flow/frontend/tests/e2e/thread-history-mermaid.spec.ts
AnoobFeng 446fa03801
fix(context): resolve context compress bug (#4065)
* fix(runtime): persist original human input outside model sanitization

* refactor(history): load thread messages by global event sequence

* fix(frontend): make summarization rescue a transient history bridge

* fix(frontend): old message not append tail

1. add identity anchor
2. add bridgeOrder

* fix(frontend): lint error fix

* fix: address review feedback and harden pagination coverage

- defer transient history ref writes until after render commit
- cover large middleware-only history scans
- verify infinite-query refetch recalculates page cursors
- document AI event types and anchor-weaving differences

* fix: harden message pagination and enrichment

- append unmatched live tails after canonical history
- warn and stop when pagination has_more lacks a cursor
- deep-copy restored UI messages to isolate model-facing content
- log invalid event sequence and non-advancing cursor errors
- pass user_id explicitly through event-store history queries
- cover middleware-only AI runs across memory, JSONL, and DB stores

* fix: address pagination review feedback

* fix(frontend): checkpoint has unknow redener content, optimize the anchor policy

* fix(frontend): unit test issue missed previously, remove the TanStack cache trimming

* fix(gateway): harden message history queries and provenance

- reject externally forged original_user_content metadata
- validate provenance metadata in upload and sanitization middleware
- make run lookups fail closed by default
- batch feedback queries by run ID
- align memory message filtering with persistent stores
2026-07-14 10:43:13 +08:00

91 lines
2.2 KiB
TypeScript

import { expect, test } from "@playwright/test";
import {
mockLangGraphAPI,
MOCK_RUN_ID,
MOCK_THREAD_ID,
} from "./utils/mock-api";
const mermaidContent = `Here is a relationship diagram.
\`\`\`mermaid
flowchart TD
A[Lin<br/>protagonist]
F[Gu<br/>daughter]
A -- "sealed memory" -.-> F
\`\`\`
`;
test("historical run messages preview labelled dotted Mermaid arrows", async ({
page,
}) => {
mockLangGraphAPI(page, {
threads: [
{
thread_id: MOCK_THREAD_ID,
title: "Mermaid history",
updated_at: "2026-05-24T04:47:01.123949+00:00",
},
],
});
await page.route(/\/api\/langgraph\/threads\/[^/]+\/runs(\?|$)/, (route) =>
route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify([
{
run_id: MOCK_RUN_ID,
thread_id: MOCK_THREAD_ID,
status: "success",
created_at: "2026-05-24T04:46:42.565307+00:00",
updated_at: "2026-05-24T04:47:01.123949+00:00",
},
]),
}),
);
await page.route(`**/api/threads/${MOCK_THREAD_ID}/messages/page`, (route) =>
route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
data: [
{
thread_id: MOCK_THREAD_ID,
run_id: MOCK_RUN_ID,
event_type: "llm.ai.response",
category: "message",
content: {
content: mermaidContent,
additional_kwargs: {},
response_metadata: {},
type: "ai",
name: null,
id: "lc_run--issue-3193",
tool_calls: [],
invalid_tool_calls: [],
},
seq: 720,
created_at: "2026-05-24T04:47:01.123949+00:00",
metadata: {
caller: "lead_agent",
content_is_json: true,
content_is_dict: true,
},
},
],
has_more: false,
next_before_seq: null,
}),
}),
);
await page.goto(`/workspace/chats/${MOCK_THREAD_ID}`);
await expect(page.getByLabel("Mermaid chart")).toBeVisible({
timeout: 15_000,
});
await expect(page.getByText("Mermaid Error:")).toHaveCount(0);
});