workspaceShellWindowChrome.test.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. resolveWorkspaceShellPanelRadiusPx,
  4. resolveWorkspaceShellResizeHandleInsetPx,
  5. resolveWorkspaceShellWindowChromeClass,
  6. } from "../src/app-shell/workspaceShellWindowChrome.js";
  7. describe("resolveWorkspaceShellWindowChromeClass", () => {
  8. it("uses 6px corners on macOS Sequoia and earlier", () => {
  9. expect(
  10. resolveWorkspaceShellWindowChromeClass({
  11. isMacDesktop: true,
  12. macOSMajorVersion: 15,
  13. isWindowsDesktop: false,
  14. isWindowsMaximized: false,
  15. supportsNativeRoundedCorners: false,
  16. }),
  17. ).toBe("rounded-md border border-border");
  18. });
  19. it("uses 12px corners on macOS Tahoe and later", () => {
  20. expect(
  21. resolveWorkspaceShellWindowChromeClass({
  22. isMacDesktop: true,
  23. macOSMajorVersion: 26,
  24. isWindowsDesktop: false,
  25. isWindowsMaximized: false,
  26. supportsNativeRoundedCorners: false,
  27. }),
  28. ).toBe("rounded-xl border border-border");
  29. });
  30. it("uses 6px corners in Windows 11 normal windows", () => {
  31. expect(
  32. resolveWorkspaceShellWindowChromeClass({
  33. isWindowsDesktop: true,
  34. isWindowsMaximized: false,
  35. supportsNativeRoundedCorners: true,
  36. }),
  37. ).toBe("rounded-md border border-border");
  38. });
  39. it("squares only the outer corners and preserves the full border on Windows 10", () => {
  40. expect(
  41. resolveWorkspaceShellWindowChromeClass({
  42. isWindowsDesktop: true,
  43. isWindowsMaximized: false,
  44. supportsNativeRoundedCorners: false,
  45. }),
  46. ).toBe("rounded-l-md border border-border");
  47. });
  48. it("preserves the existing appearance while Windows capability is unknown", () => {
  49. expect(
  50. resolveWorkspaceShellWindowChromeClass({
  51. isWindowsDesktop: true,
  52. isWindowsMaximized: false,
  53. supportsNativeRoundedCorners: null,
  54. }),
  55. ).toBe("rounded-md border border-border");
  56. });
  57. });
  58. it("uses the settings xl corners on Linux", () => {
  59. expect(
  60. resolveWorkspaceShellWindowChromeClass({
  61. isLinuxDesktop: true,
  62. isWindowsDesktop: false,
  63. isWindowsMaximized: false,
  64. supportsNativeRoundedCorners: false,
  65. }),
  66. ).toBe("rounded-xl border border-border");
  67. });
  68. describe("workspace shell resize handle inset", () => {
  69. it.each([
  70. ["macOS Sequoia", { isMacDesktop: true, macOSMajorVersion: 15 }, 6, 10],
  71. ["unknown macOS", { isMacDesktop: true, macOSMajorVersion: null }, 6, 10],
  72. ["macOS Sonoma", { isMacDesktop: true, macOSMajorVersion: 14 }, 6, 10],
  73. ["Web", {}, 12, 16],
  74. ["macOS Tahoe", { isMacDesktop: true, macOSMajorVersion: 26 }, 12, 16],
  75. ["Windows", { isWindowsDesktop: true }, 6, 12],
  76. ["Linux", { isLinuxDesktop: true }, 12, 16],
  77. ] as const)(
  78. "aligns %s handle with the start of the straight edge",
  79. (_name, platform, radius, inset) => {
  80. expect(resolveWorkspaceShellPanelRadiusPx(platform)).toBe(radius);
  81. expect(resolveWorkspaceShellResizeHandleInsetPx(platform)).toBe(inset);
  82. },
  83. );
  84. });