feat: 设置页「添加插件」推荐目录 + 复制安装命令;移除内置 Office 预览
- 设置页侧边栏内容/文件预览两个网格末尾各增虚线卡片,弹出对应 kind 的插件弹窗 - 弹窗:GitHub topic 按钮(新标签页)+ 推荐插件目录(plugins-tabs.ts / plugins-viewers.ts) - 每条目「跳转」(window.open 新标签页直达仓库)与「复制」(writeClipboard + 已复制反馈) - 不做终端预填流:不关闭弹窗、不打开终端、无失败路径(install/installNotice/installError* 文案删除) - 内置 Office 预览(docx/xlsx/pptx)整体移除,chunk 白名单 5→2(terminal/editor) - 文案「内置插件」→「推荐插件」;AGENTS.md/README/设计文档同步
This commit is contained in:
1 parent
1b0b382edc
commit
cbc28473a0
40 files changed
+942
-1128
No files matched your search
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Built-in plugin catalog data-integrity tests (both files: the TAB
|
||||
* catalog in plugins-tabs.ts and the FILE-PREVIEWER catalog in
|
||||
* plugins-viewers.ts). Every entry must be installable as data — a unique
|
||||
* id (npm package name), a GitHub URL, a non-empty localized description
|
||||
* (string or () => string), and an install script that mentions the dsh
|
||||
* plugin CLI. The catalogs are the discovery surface of the two "add
|
||||
* plugin" modals; a malformed entry would break the install flow, so the
|
||||
* shape is pinned here.
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { builtinTabPlugins } from '../src/client/plugins-tabs.ts'
|
||||
import { builtinViewerPlugins } from '../src/client/plugins-viewers.ts'
|
||||
import type { PluginEntry } from '../src/client/plugins-shared.ts'
|
||||
|
||||
/** Resolve an i18n-friendly string-or-function value (mirror of textOf). */
|
||||
function textOf(value: string | (() => string)): string {
|
||||
return typeof value === 'function' ? value() : value
|
||||
}
|
||||
|
||||
const catalogs: Array<[string, readonly PluginEntry[]]> = [
|
||||
['tab catalog', builtinTabPlugins],
|
||||
['viewer catalog', builtinViewerPlugins],
|
||||
]
|
||||
|
||||
describe('builtin plugin catalogs', () => {
|
||||
it('the viewer catalog has the seeded office plugin, the tab catalog does not', () => {
|
||||
const ids = (list: readonly PluginEntry[]): string[] => list.map(p => p.id)
|
||||
expect(ids(builtinViewerPlugins)).toContain('@huanlin/dsh-plugin-better-sidebar-plugin-office')
|
||||
expect(ids(builtinTabPlugins)).not.toContain('@huanlin/dsh-plugin-better-sidebar-plugin-office')
|
||||
})
|
||||
|
||||
for (const [name, list] of catalogs) {
|
||||
describe(name, () => {
|
||||
it('every entry has a unique id (the npm package name)', () => {
|
||||
const ids = list.map(p => p.id)
|
||||
expect(new Set(ids).size).toBe(ids.length)
|
||||
for (const id of ids) {
|
||||
expect(id.length).toBeGreaterThan(0)
|
||||
expect(id).not.toContain(' ')
|
||||
}
|
||||
})
|
||||
|
||||
it('every entry has a name, a GitHub URL, and an install script', () => {
|
||||
for (const entry of list) {
|
||||
expect(entry.name.length).toBeGreaterThan(0)
|
||||
expect(entry.url.startsWith('https://github.com/')).toBe(true)
|
||||
expect(entry.install.length).toBeGreaterThan(0)
|
||||
expect(entry.install).toContain('dsh plugin')
|
||||
}
|
||||
})
|
||||
|
||||
it('every description resolves to a non-empty localized string', () => {
|
||||
for (const entry of list) {
|
||||
expect(textOf(entry.description).length).toBeGreaterThan(0)
|
||||
}
|
||||
})
|
||||
|
||||
it('every install script starts at the DSH home (cd ~/.dsh) as the modal promises', () => {
|
||||
for (const entry of list) {
|
||||
expect(entry.install.startsWith('cd ~/.dsh')).toBe(true)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user