个人扫码绑定实现前检查点;补充权限与账户隔离回归用例,业务实机验收尚未执行。
This commit is contained in:
1 parent
39ac7d2d2c
commit
2a532b2224
9 files changed
+196
-19
No files matched your search
@@ -55,10 +55,19 @@ function fixture(get, pageKey = 'base', options = {}) {
|
||||
get: path => path.endsWith('/pending') && !options.pendingGet ? Promise.resolve({ errorNo: 0, data: null }) : get(path),
|
||||
...options.http
|
||||
},
|
||||
() => ({ hasCapability: options.hasCapability || (() => true) }), pageKey, callback => { dispose = callback })
|
||||
() => ({ role: options.role || 'super_admin', hasCapability: options.hasCapability || (() => true) }), pageKey, callback => { dispose = callback })
|
||||
return { page, messages, successes, dispose: () => dispose() }
|
||||
}
|
||||
|
||||
for (const pageKey of ['telegram_push', 'wechat_push']) {
|
||||
for (const role of ['super_admin', 'admin', 'user']) {
|
||||
test(`${role} 的 ${pageKey} 系统配置写权限只对超级管理员开放`, () => {
|
||||
const { page } = fixture(async () => ({ errorNo: 0, data: {} }), pageKey, { role })
|
||||
assert.equal(page.canWrite.value, role === 'super_admin')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function deferred() {
|
||||
let resolve
|
||||
let reject
|
||||
|
||||
@@ -11,16 +11,44 @@ const createPage = compileFunction(
|
||||
['computed', 'nextTick', 'onMounted', 'onBeforeUnmount', 'ref', 'http', 'useGlobalStatusStore']
|
||||
)
|
||||
|
||||
function fixture(capabilities = ['config.read', 'plugin.read_global', 'plugin.read', 'plugin.write_own'], get = async () => ({ errorNo: 0, data: [] })) {
|
||||
function fixture(capabilities = ['config.read', 'plugin.read_global', 'plugin.read', 'plugin.write_own'], get = async () => ({ errorNo: 0, data: [] }), role = 'super_admin') {
|
||||
const allowed = reactive(new Set(capabilities))
|
||||
const store = reactive({ role, hasCapability: value => allowed.has(value) })
|
||||
const requests = []
|
||||
let mount, dispose
|
||||
const page = createPage(computed, async () => {}, fn => { mount = fn }, fn => { dispose = fn }, ref,
|
||||
{ get: async url => { requests.push(url); return get(url) } },
|
||||
() => ({ hasCapability: value => allowed.has(value) }))
|
||||
return { page, allowed, requests, mount, dispose }
|
||||
() => store)
|
||||
return { page, allowed, requests, mount, dispose, store }
|
||||
}
|
||||
|
||||
for (const role of ['super_admin', 'admin', 'user']) {
|
||||
test(`${role} 保留本人通知入口,只有超级管理员可进入系统公众号和机器人配置`, async () => {
|
||||
const capabilities = role === 'user'
|
||||
? ['plugin.read', 'plugin.write_own']
|
||||
: ['plugin.read_global', 'plugin.read', 'plugin.write_own']
|
||||
const { page } = fixture(capabilities, undefined, role)
|
||||
assert.deepEqual(page.sectionOptions.value.map(item => item.value), role === 'super_admin'
|
||||
? ['spam_block', 'telegram_push', 'wechat_push']
|
||||
: role === 'admin' ? ['spam_block'] : [])
|
||||
assert.deepEqual(page.accountOptions.value.map(item => item.value), ['telegram-user'])
|
||||
await page.selectSection('telegram-user')
|
||||
assert.equal(page.activePage.value.kind, 'account')
|
||||
await page.selectSection('wechat_push')
|
||||
assert.equal(page.selectedSection.value, role === 'super_admin' ? 'wechat_push' : 'telegram-user')
|
||||
})
|
||||
}
|
||||
|
||||
test('超级管理员降级后隐藏系统通知配置但保留本人通知入口', async () => {
|
||||
const { page, store } = fixture()
|
||||
await page.selectSection('telegram_push')
|
||||
store.role = 'admin'
|
||||
assert.equal(page.activePage.value, undefined)
|
||||
assert.deepEqual(page.sectionOptions.value.map(item => item.value), ['spam_block'])
|
||||
await page.selectSection('telegram-user')
|
||||
assert.equal(page.activePage.value.kind, 'account')
|
||||
})
|
||||
|
||||
test('独立插件配置包含三个运行配置页,停用插件不依赖运行列表也能配置', async () => {
|
||||
const { page, mount } = fixture()
|
||||
assert.deepEqual(page.sectionOptions.value.map(item => item.value), ['spam_block', 'telegram_push', 'wechat_push'])
|
||||
|
||||
Reference in new issue
Block a user