markdownTableStickyScrollbar.test.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. resolveMarkdownTableStickyScrollbarMode,
  4. resolveMarkdownTableStickyScrollbarOffset,
  5. } from "@/components/ai-elements/markdown-table.js";
  6. describe("resolveMarkdownTableStickyScrollbarMode", () => {
  7. it("enables sticky markdown table scrollbars for tall content", () => {
  8. expect(
  9. resolveMarkdownTableStickyScrollbarMode({
  10. stickyScrollbarDisabled: false,
  11. viewportHeight: 800,
  12. dockHeight: 200,
  13. tableHeight: 500,
  14. }),
  15. ).toBe(true);
  16. });
  17. it("disables sticky markdown table scrollbars for opted-out subagent content", () => {
  18. expect(
  19. resolveMarkdownTableStickyScrollbarMode({
  20. stickyScrollbarDisabled: true,
  21. viewportHeight: 256,
  22. dockHeight: 200,
  23. tableHeight: 220,
  24. }),
  25. ).toBe(false);
  26. });
  27. });
  28. describe("resolveMarkdownTableStickyScrollbarOffset", () => {
  29. it("pins a long table scrollbar to the visible timeline bottom", () => {
  30. expect(
  31. resolveMarkdownTableStickyScrollbarOffset({
  32. frameTop: -87,
  33. frameBottom: 1211,
  34. scrollbarHeight: 26,
  35. viewportBottom: 921,
  36. }),
  37. ).toBe(-290);
  38. });
  39. it("keeps the scrollbar inside the current table boundaries", () => {
  40. expect(
  41. resolveMarkdownTableStickyScrollbarOffset({
  42. frameTop: 950,
  43. frameBottom: 2248,
  44. scrollbarHeight: 26,
  45. viewportBottom: 921,
  46. }),
  47. ).toBe(-1272);
  48. expect(
  49. resolveMarkdownTableStickyScrollbarOffset({
  50. frameTop: -1400,
  51. frameBottom: -102,
  52. scrollbarHeight: 26,
  53. viewportBottom: 921,
  54. }),
  55. ).toBe(0);
  56. });
  57. });