1 parent
82f740d128
commit
6a17af13ed
13 files changed
+346
-250
No files matched your search
@@ -5,7 +5,7 @@ import { compileFunction } from 'node:vm'
|
||||
import { computed, reactive, ref } from './vue.mjs'
|
||||
|
||||
const source = readFileSync(new URL('../../frontend/src/views/components/ConfigSettings/ConfigNavigation.js', import.meta.url), 'utf8')
|
||||
const components = ['BaseConfig', 'EmailConfig', 'SslConfig', 'PluginsConfig', 'ConfigMaintenance']
|
||||
const components = ['BaseConfig', 'EmailConfig', 'SslConfig', 'ConfigMaintenance']
|
||||
const createNavigation = compileFunction(
|
||||
source.replace(/^import .*$/gm, '').replace('export function useNavigation', 'function useNavigation') + '\nreturn useNavigation()',
|
||||
['computed', 'nextTick', 'ref', 'useGlobalStatusStore', ...components]
|
||||
@@ -18,20 +18,14 @@ function fixture(capabilities = ['config.read']) {
|
||||
return { page, allowed }
|
||||
}
|
||||
|
||||
test('配置菜单包含三个独立插件三级页面,无权限的维护入口不可打开', async () => {
|
||||
test('配置管理只保留服务配置与维护入口,不再包含插件菜单', async () => {
|
||||
const { page, allowed } = fixture()
|
||||
assert.equal(new Set(page.sectionOptions.value.map(item => item.component)).size, 4)
|
||||
assert.deepEqual(page.sectionOptions.value.map(item => item.value), ['base', 'mail', 'ssl', 'plugins'])
|
||||
const children = page.sectionOptions.value.find(item => item.value === 'plugins').children
|
||||
assert.deepEqual(children.map(item => item.value), ['spam_block', 'telegram_push', 'wechat_push'])
|
||||
await page.selectSection('plugins')
|
||||
assert.equal(page.selectedSection.value, 'spam_block')
|
||||
assert.equal(page.activePage.value.label, '垃圾邮件拦截')
|
||||
await page.selectSection('telegram_push')
|
||||
assert.equal(page.activePage.value.label, 'Telegram 推送')
|
||||
await page.selectSection('plugins')
|
||||
assert.equal(page.selectedSection.value, 'telegram_push')
|
||||
await page.selectSection('base')
|
||||
assert.equal(new Set(page.sectionOptions.value.map(item => item.component)).size, 3)
|
||||
assert.deepEqual(page.sectionOptions.value.map(item => item.value), ['base', 'mail', 'ssl'])
|
||||
for (const value of ['plugins', 'spam_block', 'telegram_push', 'wechat_push']) {
|
||||
await page.selectSection(value)
|
||||
assert.equal(page.selectedSection.value, 'base')
|
||||
}
|
||||
assert.equal(page.maintenanceOptions.value.length, 0)
|
||||
await page.selectSection('audit')
|
||||
await page.selectSection('invalid')
|
||||
@@ -44,15 +38,15 @@ test('配置菜单包含三个独立插件三级页面,无权限的维护入
|
||||
assert.equal(page.activePage.value, undefined)
|
||||
})
|
||||
|
||||
test('插件三级菜单切换保留离开确认及权限检查', async () => {
|
||||
test('配置页面切换保留离开确认及权限检查', async () => {
|
||||
const { page, allowed } = fixture()
|
||||
await page.selectSection('wechat_push')
|
||||
await page.selectSection('ssl')
|
||||
page.currentPage.value = { beforeLeave: async () => false }
|
||||
await page.selectSection('spam_block')
|
||||
assert.equal(page.selectedSection.value, 'wechat_push')
|
||||
await page.selectSection('base')
|
||||
assert.equal(page.selectedSection.value, 'ssl')
|
||||
page.currentPage.value = { beforeLeave: async () => { allowed.delete('config.read'); return true } }
|
||||
await page.selectSection('telegram_push')
|
||||
assert.equal(page.selectedSection.value, 'wechat_push')
|
||||
await page.selectSection('mail')
|
||||
assert.equal(page.selectedSection.value, 'ssl')
|
||||
assert.equal(page.activePage.value, undefined)
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user