fix(webui): keep syntax highlighting chunks acyclic
This commit is contained in:
@@ -43,9 +43,11 @@ describe("DiffSyntaxHighlight with Prism", () => {
|
||||
const highlighted = await screen.findByTestId("syntax-highlighted-diff-hunk");
|
||||
await waitFor(
|
||||
() => {
|
||||
expect(highlighted.querySelectorAll('td:last-child span[style*="color"]')).not.toHaveLength(
|
||||
0,
|
||||
const tokens = highlighted.querySelectorAll<HTMLElement>(
|
||||
'td:last-child span[style*="color"]',
|
||||
);
|
||||
expect(tokens).not.toHaveLength(0);
|
||||
expect(new Set([...tokens].map((token) => token.style.color)).size).toBeGreaterThan(1);
|
||||
},
|
||||
{ timeout: 10_000 },
|
||||
);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { webuiManualChunk } from "../../vite.config";
|
||||
|
||||
describe("webuiManualChunk", () => {
|
||||
it("keeps Refractor's selector parser in the syntax highlighting chunk", () => {
|
||||
expect(
|
||||
webuiManualChunk("/repo/node_modules/hast-util-parse-selector/index.js"),
|
||||
).toBe("syntax-highlight");
|
||||
});
|
||||
|
||||
it("keeps markdown-only hast utilities in the markdown chunk", () => {
|
||||
expect(
|
||||
webuiManualChunk("/repo/node_modules/hast-util-to-jsx-runtime/lib/index.js"),
|
||||
).toBe("markdown-vendor");
|
||||
});
|
||||
|
||||
it("leaves language grammars as independently loaded chunks", () => {
|
||||
expect(webuiManualChunk("/repo/node_modules/refractor/lang/python.js")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user