catalog: add dsh-video-preview (video previewer) to the file-previewer recommended plugins (#126)
* catalog: add dsh-video-preview to the file-previewer recommended plugins Adds the video preview plugin (dsh-video-preview) to the "add preview plugin" modal catalog, with zh/en descriptions. Data integrity is guarded by tests/plugin-list.spec.ts. * test: make add-plugin-modal window.open count catalog-driven The test pinned the viewer catalog to a single entry (2 "Open:" buttons). Adding a second recommended plugin (dsh-video-preview) renders 4 buttons and broke the hardcoded assertion. Derive the expected count from builtinViewerPlugins so adding/removing plugins keeps the test honest.
This commit is contained in:
1 parent
fc4031e65f
commit
5c138ca851
3 files changed
+24
-8
No files matched your search
@@ -155,7 +155,7 @@ describe('PluginListBody copy click (interactive)', () => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('both the name button and the jump button open the repo in a NEW browser tab (window.open, not a link)', () => {
|
||||
it('the name and jump buttons open each catalog entry in a NEW browser tab (window.open, not a link)', () => {
|
||||
const store = createSidebarStore()
|
||||
const service = createBetterSidebarService(store)
|
||||
const opened: Array<[string, string, string]> = []
|
||||
@@ -171,14 +171,21 @@ describe('PluginListBody copy click (interactive)', () => {
|
||||
act(() => {
|
||||
root.render(createElement(PluginListBody, { service, kind: 'viewer' }))
|
||||
})
|
||||
// Two window.open buttons per catalog entry — the name button and the
|
||||
// jump button. The expected count is catalog-driven so adding or
|
||||
// removing recommended plugins keeps the test honest instead of
|
||||
// pinning a hardcoded total.
|
||||
const jumpButtons = [...container.querySelectorAll('button[aria-label^="Open:"]')]
|
||||
expect(jumpButtons).toHaveLength(2) // the name + the jump button
|
||||
act(() => { (jumpButtons[0] as HTMLButtonElement).click() })
|
||||
act(() => { (jumpButtons[1] as HTMLButtonElement).click() })
|
||||
expect(opened).toEqual([
|
||||
[officeEntry.url, '_blank', 'noopener'],
|
||||
[officeEntry.url, '_blank', 'noopener'],
|
||||
])
|
||||
expect(jumpButtons).toHaveLength(builtinViewerPlugins.length * 2)
|
||||
for (const button of jumpButtons) {
|
||||
act(() => { (button as HTMLButtonElement).click() })
|
||||
}
|
||||
expect(opened).toEqual(
|
||||
builtinViewerPlugins.flatMap((entry) => [
|
||||
[entry.url, '_blank', 'noopener'],
|
||||
[entry.url, '_blank', 'noopener'],
|
||||
]),
|
||||
)
|
||||
act(() => { root.unmount() })
|
||||
container.remove()
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user