test(web): cover plugin settings tab states
This commit is contained in:
@@ -83,9 +83,21 @@ describe('ui-plugin-config apply', () => {
|
|||||||
|
|
||||||
const section = slots.entries('settings.section')[0]!
|
const section = slots.entries('settings.section')[0]!
|
||||||
const sectionFace = (section.inject as unknown as () => PluginConfigSectionInjected)()
|
const sectionFace = (section.inject as unknown as () => PluginConfigSectionInjected)()
|
||||||
expect(sectionFace.hooks.tabs.getSnapshot()).toEqual([
|
const initialTabs = sectionFace.hooks.tabs.getSnapshot()
|
||||||
|
expect(initialTabs).toEqual([
|
||||||
{ id: 'configurable', order: 0, label: '插件配置' },
|
{ id: 'configurable', order: 0, label: '插件配置' },
|
||||||
])
|
])
|
||||||
|
expect(sectionFace.hooks.tabs.getSnapshot()).toBe(initialTabs)
|
||||||
|
|
||||||
|
const listener = vi.fn()
|
||||||
|
const unsubscribe = sectionFace.hooks.tabs.subscribe(listener)
|
||||||
|
slots.register({ name: 'settings.plugins.tab', id: 'plain' } as never, () => null)
|
||||||
|
expect(sectionFace.hooks.tabs.getSnapshot()).toEqual([
|
||||||
|
{ id: 'configurable', order: 0, label: '插件配置' },
|
||||||
|
{ id: 'plain', order: 0, label: '' },
|
||||||
|
])
|
||||||
|
unsubscribe()
|
||||||
|
|
||||||
const tab = slots.entries('settings.plugins.tab')[0]!
|
const tab = slots.entries('settings.plugins.tab')[0]!
|
||||||
expect((tab.inject as unknown as () => ConfigurablePluginsTabInjected)()).toEqual({ cardCount: 3 })
|
expect((tab.inject as unknown as () => ConfigurablePluginsTabInjected)()).toEqual({ cardCount: 3 })
|
||||||
for (const entry of slots.entries('settings.plugin.item')) {
|
for (const entry of slots.entries('settings.plugin.item')) {
|
||||||
|
|||||||
@@ -105,6 +105,10 @@ describe('PluginConfigSection', () => {
|
|||||||
expect(all.getAttribute('aria-selected')).toBe('true')
|
expect(all.getAttribute('aria-selected')).toBe('true')
|
||||||
expect(screen.getByText('all')).toBeTruthy()
|
expect(screen.getByText('all')).toBeTruthy()
|
||||||
expect(screen.getByText('configurable').closest('[role="tabpanel"]')).toHaveProperty('hidden', true)
|
expect(screen.getByText('configurable').closest('[role="tabpanel"]')).toHaveProperty('hidden', true)
|
||||||
|
|
||||||
|
fireEvent.click(configurable)
|
||||||
|
expect(configurable.getAttribute('aria-selected')).toBe('true')
|
||||||
|
expect(screen.getByText('all').closest('[role="tabpanel"]')).toHaveProperty('hidden', true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('leads with its own heading and intro', () => {
|
it('leads with its own heading and intro', () => {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ const SNAPSHOT = {
|
|||||||
{ entryId: 'loading', moduleName: '@fixture/loading-name', enabled: true, fiberPhase: 'loading' },
|
{ entryId: 'loading', moduleName: '@fixture/loading-name', enabled: true, fiberPhase: 'loading' },
|
||||||
{ entryId: 'failed', moduleName: '@fixture/failed-name', enabled: true, fiberPhase: 'failed' },
|
{ entryId: 'failed', moduleName: '@fixture/failed-name', enabled: true, fiberPhase: 'failed' },
|
||||||
{ entryId: 'unloading', moduleName: '@fixture/unloading-name', enabled: true, fiberPhase: 'unloading' },
|
{ entryId: 'unloading', moduleName: '@fixture/unloading-name', enabled: true, fiberPhase: 'unloading' },
|
||||||
|
{ entryId: 'unobserved', moduleName: '@fixture/unobserved-name', enabled: true, fiberPhase: null },
|
||||||
{ entryId: 'disabled-entry', moduleName: '@deepseek-ai/dsh-host-directory-picker-native', enabled: false, fiberPhase: null },
|
{ entryId: 'disabled-entry', moduleName: '@deepseek-ai/dsh-host-directory-picker-native', enabled: false, fiberPhase: null },
|
||||||
],
|
],
|
||||||
} as unknown as Snapshot
|
} as unknown as Snapshot
|
||||||
@@ -42,9 +43,9 @@ describe('PluginSettingsSection', () => {
|
|||||||
expect(list).toHaveBeenCalledOnce()
|
expect(list).toHaveBeenCalledOnce()
|
||||||
expect(screen.getByRole('searchbox', { name: en.search })).toBeTruthy()
|
expect(screen.getByRole('searchbox', { name: en.search })).toBeTruthy()
|
||||||
expect(screen.getByRole('heading', { name: en.catalog })).toBeTruthy()
|
expect(screen.getByRole('heading', { name: en.catalog })).toBeTruthy()
|
||||||
expect(view.container.querySelector('[data-plugin-count]')?.textContent).toBe('6')
|
expect(view.container.querySelector('[data-plugin-count]')?.textContent).toBe('7')
|
||||||
expect(screen.getAllByRole('listitem')).toHaveLength(6)
|
expect(screen.getAllByRole('listitem')).toHaveLength(7)
|
||||||
expect(screen.getAllByText(en.enabledTag)).toHaveLength(5)
|
expect(screen.getAllByText(en.enabledTag)).toHaveLength(6)
|
||||||
expect(screen.getByText(en.disabledTag)).toBeTruthy()
|
expect(screen.getByText(en.disabledTag)).toBeTruthy()
|
||||||
for (const value of [
|
for (const value of [
|
||||||
'Mounted',
|
'Mounted',
|
||||||
@@ -52,10 +53,10 @@ describe('PluginSettingsSection', () => {
|
|||||||
'Loading',
|
'Loading',
|
||||||
'Mount failed',
|
'Mount failed',
|
||||||
'Unloading',
|
'Unloading',
|
||||||
|
'Not mounted',
|
||||||
]) {
|
]) {
|
||||||
expect(screen.getByRole('img', { name: value })).toBeTruthy()
|
expect(screen.getByRole('img', { name: value })).toBeTruthy()
|
||||||
}
|
}
|
||||||
expect(screen.queryByRole('img', { name: 'Not mounted' })).toBeNull()
|
|
||||||
const active = screen.getByRole('button', { name: 'hmr, Mounted, Enabled' })
|
const active = screen.getByRole('button', { name: 'hmr, Mounted, Enabled' })
|
||||||
expect(active.getAttribute('aria-expanded')).toBe('false')
|
expect(active.getAttribute('aria-expanded')).toBe('false')
|
||||||
fireEvent.click(active)
|
fireEvent.click(active)
|
||||||
|
|||||||
Reference in New Issue
Block a user