test(admin): PluginsView and settings paths
- PluginsView: tab switching, one request per typing burst and a blank search without q, name fallback on cards, copied state clearing, a refused clipboard write, a failed marketplace request - useSettings: settingsPath prefers path, then controller, then the singleton form; settingsEntryForPath
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
setSettings,
|
||||
settings,
|
||||
settingsEntry,
|
||||
settingsEntryForPath,
|
||||
settingsGroups,
|
||||
settingsLinkFor,
|
||||
settingsPath,
|
||||
@@ -56,6 +57,25 @@ describe('useSettings (D-21)', () => {
|
||||
expect(useSettings().settingsPath).toBe(settingsPath)
|
||||
})
|
||||
|
||||
it('prefers an entry path, then its controller, then the singleton form (34-05)', () => {
|
||||
const base = settingsFixture.list.data[0]!
|
||||
expect(settingsPath({ ...base, code: 'plugins', model: '', controller: 'acme.demo.locales', path: '/system/plugins' })).toBe(
|
||||
'/system/plugins',
|
||||
)
|
||||
expect(settingsPath({ ...base, code: 'plugins', model: '', controller: 'acme.demo.locales', path: '' })).toBe('/acme/demo/locales')
|
||||
expect(settingsPath({ ...base, code: 'mail', controller: '', path: undefined })).toBe('/settings/mail')
|
||||
expect(settingsPath({ ...base, code: 'mail', controller: '', path: '' })).toBe('/settings/mail')
|
||||
})
|
||||
|
||||
it('finds the entry of an admin screen by its path', () => {
|
||||
const plugins = { ...settingsFixture.list.data[0]!, code: 'plugins', model: '', controller: '', path: '/system/plugins' }
|
||||
setSettings([...settingsFixture.list.data, plugins])
|
||||
expect(settingsEntryForPath('/system/plugins')?.code).toBe('plugins')
|
||||
expect(settingsEntryForPath('/system/other')).toBeNull()
|
||||
expect(settingsEntryForPath('')).toBeNull()
|
||||
expect(useSettings().settingsEntryForPath).toBe(settingsEntryForPath)
|
||||
})
|
||||
|
||||
it('finds the link entry that opens a controller, never a singleton', () => {
|
||||
const link = { ...settingsFixture.list.data[0]!, code: 'locales', model: '', controller: 'acme.demo.locales' }
|
||||
setSettings([...settingsFixture.list.data, link])
|
||||
|
||||
Reference in New Issue
Block a user