fix(webui): keep Markdown table diffs inline
This commit is contained in:
@@ -61,4 +61,41 @@ describe("DiffSyntaxHighlight with Prism", () => {
|
||||
expect(highlighted).toHaveAttribute("data-language", "tsx");
|
||||
expect(highlighted.querySelectorAll("tbody tr")).toHaveLength(4);
|
||||
});
|
||||
|
||||
it("preserves markdown table line boundaries", async () => {
|
||||
const lines = [
|
||||
"## 发布安排",
|
||||
"",
|
||||
"| 日期 | 角色 | 方向 | 是否进实验 |",
|
||||
"| --- | --- | --- | --- |",
|
||||
"| 7/22 | trust / core | data-driven | yes |",
|
||||
];
|
||||
|
||||
render(
|
||||
<ThemeProvider theme="light">
|
||||
<DiffSyntaxHighlight
|
||||
language="markdown"
|
||||
lines={lines.map((content, index) => ({
|
||||
kind: "add" as const,
|
||||
old_lineno: null,
|
||||
new_lineno: 20 + index,
|
||||
content,
|
||||
}))}
|
||||
/>
|
||||
</ThemeProvider>,
|
||||
);
|
||||
|
||||
const highlighted = await screen.findByTestId(
|
||||
"syntax-highlighted-diff-hunk",
|
||||
{},
|
||||
{ timeout: 10_000 },
|
||||
);
|
||||
const rows = [...highlighted.querySelectorAll("tbody tr")];
|
||||
|
||||
expect(rows).toHaveLength(lines.length);
|
||||
expect(rows.map((row) => row.querySelector("td:last-child")?.textContent)).toEqual(
|
||||
lines.map((line) => line || " "),
|
||||
);
|
||||
expect(highlighted.querySelector(".token.table")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user