import assert from 'node:assert/strict' import { promises as fs } from 'node:fs' import { resolve } from 'node:path' import { renderToStaticMarkup } from 'react-dom/server' import type { LibrarySnapshot } from '../src/shared/library' import type { LibraryArtifactEntry } from '../src/shared/library' import LibraryPage, { LibraryHomeContent, LocalArtifactsView, relativeTimeLabel } from '../src/renderer/src/library/LibraryPageParity' import { groupLibraryEntries } from '../src/renderer/src/library/catalog' const now = Date.UTC(2026, 9, 17, 12, 0, 0) const entry: LibraryArtifactEntry = { id: 'artifact:session-a:report', sessionId: 'session-a', workspaceId: 'workspace-a', workspaceName: 'YCode', workspaceRoot: 'C:\\workspace', sourceSessionTitle: '查看当前项目', messageId: 'message-a', sourceKind: 'write', name: 'project-report.md', path: 'C:\\workspace\\project-report.md', kind: 'document', availability: 'available', size: 11_264, createdAt: now - 4_000, updatedAt: now - 60_000, recentAt: now - 120_000, favorite: true } const snapshot: LibrarySnapshot = { artifacts: [entry], generatedAt: now } const api = { async getSnapshot(): Promise { return snapshot }, async setFavorite() { return { version: 1 as const, favoriteArtifactIds: [entry.id], recent: [] } }, async recordRecent() { return { version: 1 as const, favoriteArtifactIds: [entry.id], recent: [] } } } async function main(): Promise { const homePage = renderToStaticMarkup( undefined} /> ) assert.match(homePage, /class="library-page library-page--home"/) assert.match(homePage, /class="library-sidebar knowledge-sidebar-pc"/) assert.match(homePage, /最近访问/) assert.match(homePage, /我分享的/) assert.match(homePage, /与我共享/) assert.match(homePage, /个人资料尚未接入/) assert.match(homePage, /团队资料尚未接入/) assert.doesNotMatch(homePage, /library-local-panel/) const homeContent = renderToStaticMarkup( undefined} onKindChange={() => undefined} onOpen={() => undefined} /> ) assert.match(homeContent, /class="library-home-main main-layout-content-pc"/) assert.match(homeContent, />名称所有者位置最近访问 undefined} onKindChange={() => undefined} onQueryChange={() => undefined} onFavoritesOnlyChange={() => undefined} onSort={() => undefined} onToggleWorkspace={() => undefined} onToggleTask={() => undefined} onOpen={() => undefined} onFavorite={() => undefined} /> ) assert.match(local, /class="library-local-panel my-files-panel"/) assert.match(local, /aria-label="返回资料库"/) assert.match(local, /搜索文件、任务或工作空间/) assert.match(local, />类型更新人更新时间大小— { console.error(error) process.exitCode = 1 })