import { readFileSync } from "node:fs"; import { readFile } from "node:fs/promises"; import { describe, expect, it } from "vitest"; /** * R3-ISSUE-018:远程 UI 的原型像素值不能绕过设计系统直接进入组件 class。 * 只扫描本次远程 UI 入口,避免把历史遗留组件的迁移工作混入本 issue。 * continuity panel 的 var token、已登记的响应式断点和动画 opacity 不属于本规则。 */ const remoteUiSources = [ "../src/RemoteConnectionDialogContent.tsx", "../src/lib/remoteConnectionPresentation.ts", "../src/remote-connection/RemoteConnectionTags.tsx", "../src/remote-connection/RemoteConnectionStateIcon.tsx", "../src/WorkspaceSidebar/RemoteProjectConnectionDetails.tsx", "../src/SettingsPage.tsx", "../src/remote-connection/RemoteConnectionConnectingStep.tsx", "../src/remote-connection/RemoteLinkRail.tsx", "../src/RemoteConnectionFields.tsx", "../src/remote-connection/RemotePasswordInput.tsx", "../src/project-sidebar/WorkspaceDragOverlay.tsx", "../src/WorkspaceSidebar/WorkspacePurposeSection.tsx", "../src/RemoteConnectionWizardChrome.tsx", "../src/remote-connection/RemoteConnectionSelection.tsx", "../src/remote-connection/RemoteConnectionHistoryInput.tsx", "../src/remote-connection-flow/ui/RemoteConnectionProgress.tsx", "../src/remote-connection/RemoteConnectionNavigationDot.tsx", "../src/remote-connection/EditConnectionProfileDialog.tsx", "../src/settings/SourceServerManagementPanel.tsx", "../src/settings/SourceServerUpdateActivity.tsx", "../src/WorkspaceSidebar/RemoteProjectDetailsPopover.tsx", "../src/project-sidebar/RemoteProjectMenu.tsx", ] as const; const forbiddenPatterns = [ /\btext-(?:xs|sm|base|lg|xl|[2-9]xl)\b/u, /\btext-\[\d+(?:\.\d+)?(?:px|rem)\]/u, /\b(?:bg|text|border)-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-\d+/u, /\b(?:bg|text|border)-\[(?:#|rgba?\(|hsla?\()/u, /\bsize-(?:2\.5|4\.5|7|9)\b/u, /\brounded(?:\s|["'])/u, /\brounded-\[\d+(?:\.\d+)?(?:px|rem)\]/u, /\bsize-\[\d+(?:\.\d+)?(?:px|rem)\]/u, /\b(?:min|max)-[wh]-\[\d+(?:\.\d+)?(?:px|rem)\]/u, /\b(?:border|bg|text)-(?:success|warning|destructive|foreground-subtle|popover)\/\d+\b/u, ] as const; describe("remote UI design token conformance", () => { it("preserves the responsive settings heading size through scalable semantic tokens", async () => { const [source, styles] = await Promise.all([ readFile(new URL("../src/SettingsPage.tsx", import.meta.url), "utf8"), readFile(new URL("../src/styles.css", import.meta.url), "utf8"), ]); const headingClass = source.match(/