markdownTableLayoutRoot.test.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132
  1. import { readFileSync } from "node:fs";
  2. import { describe, expect, it } from "vitest";
  3. /**
  4. * 读取仓库源码用于文本契约断言。
  5. *
  6. * Bugfix:下面断言里有跨行片段(`turnNavigatorHasLayoutRoom &&\n "..."`),
  7. * 而仓库只对 *.mjs / *.sh 声明了 `eol=lf`,其余源码在 `core.autocrlf=true` 的 Windows
  8. * 检出里是 CRLF,`toContain` 的 `\n` 匹配不到 `\r\n`,用例在 Windows 上必然失败。
  9. * 它想断言的是源码内容契约,与换行字节无关,统一归一成 LF 再比对。
  10. */
  11. const readSource = (path: string) => readFileSync(path, "utf8").replaceAll("\r\n", "\n");
  12. describe("markdown table layout root", () => {
  13. it("connects V4 timeline tables to the expanded-scroll layout boundary", () => {
  14. const tableSource = readSource("packages/ui/src/components/ai-elements/markdown-table.tsx");
  15. const timelineSource = readSource("packages/ui/src/v4/ConversationTimeline.tsx");
  16. expect(tableSource).toContain('[data-markdown-table-layout-root="true"]');
  17. expect(tableSource).toContain('[data-testid="chat-view"]');
  18. expect(timelineSource).toContain('data-markdown-table-layout-root="true"');
  19. expect(timelineSource).toContain(
  20. "[--markdown-table-layout-left-inset:16px] [--markdown-table-layout-right-inset:16px]",
  21. );
  22. expect(timelineSource).toContain(
  23. 'turnNavigatorQueryRowIds.size >= 2 &&\n "@min-[864px]/conversation:[--markdown-table-layout-left-inset:48px]"',
  24. );
  25. expect(timelineSource.indexOf('data-markdown-table-layout-root="true"')).toBeLessThan(
  26. timelineSource.indexOf('data-v4-timeline-content-column="true"'),
  27. );
  28. });
  29. });