v4ConversationTimelineScrollbarGutter.test.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. import { readFileSync } from "node:fs";
  2. import { describe, expect, it } from "vitest";
  3. // Windows 工作区经 git autocrlf 是 CRLF,断言按 LF 编写;读取后归一化行尾,Linux 上是无操作。
  4. const readTimelineSource = () =>
  5. readFileSync("packages/ui/src/v4/ConversationTimeline.tsx", "utf8").replaceAll("\r\n", "\n");
  6. describe("ConversationTimeline scrollbar gutter", () => {
  7. it("reserves stable scrollbar space on the shared conversation viewport", () => {
  8. const source = readTimelineSource();
  9. expect(source).toContain("overflow-y-auto [scrollbar-gutter:stable]");
  10. });
  11. it("exposes and applies the share selection scroll lock", () => {
  12. const source = readTimelineSource();
  13. expect(source).toContain(
  14. 'data-v4-timeline-scroll-locked={backgroundScrollLocked ? "true" : "false"}',
  15. );
  16. expect(source).toContain('backgroundScrollLocked && "!overflow-y-hidden"');
  17. });
  18. it("share selection mode hides the turn navigator so the share flow owns the left rail", () => {
  19. const source = readTimelineSource();
  20. const navigatorIndex = source.indexOf("<ConversationTurnNavigator\n");
  21. expect(navigatorIndex).toBeGreaterThan(-1);
  22. expect(source.slice(navigatorIndex - 120, navigatorIndex)).toContain(
  23. "hideTurnNavigator ? null : (",
  24. );
  25. });
  26. });