test(web): cover plugin settings tab states

This commit is contained in:
ZiyaZhang
2026-08-12 02:18:11 -07:00
parent 7f058284fa
commit 14e70b1bf4
3 changed files with 22 additions and 5 deletions
@@ -83,9 +83,21 @@ describe('ui-plugin-config apply', () => {
const section = slots.entries('settings.section')[0]!
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: '插件配置' },
])
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]!
expect((tab.inject as unknown as () => ConfigurablePluginsTabInjected)()).toEqual({ cardCount: 3 })
for (const entry of slots.entries('settings.plugin.item')) {
@@ -105,6 +105,10 @@ describe('PluginConfigSection', () => {
expect(all.getAttribute('aria-selected')).toBe('true')
expect(screen.getByText('all')).toBeTruthy()
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', () => {