feat: 限制历史操作为管理员可见
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { ref } from 'vue'
|
||||
import { mount, flushPromises } from '@vue/test-utils'
|
||||
import { createRouter, createMemoryHistory } from 'vue-router'
|
||||
import HistoryView from '../views/HistoryView.vue'
|
||||
@@ -22,6 +23,15 @@ function createMockRouter() {
|
||||
})
|
||||
}
|
||||
|
||||
function mountHistory(admin = false) {
|
||||
return mount(HistoryView, {
|
||||
global: {
|
||||
plugins: [createMockRouter()],
|
||||
provide: { isAdmin: ref(admin) },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
describe('HistoryView.vue', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
@@ -129,10 +139,7 @@ describe('HistoryView.vue', () => {
|
||||
})
|
||||
|
||||
it('已完成任务显示下载按钮', async () => {
|
||||
const router = createMockRouter()
|
||||
const wrapper = mount(HistoryView, {
|
||||
global: { plugins: [router] },
|
||||
})
|
||||
const wrapper = mountHistory(true)
|
||||
await flushPromises()
|
||||
|
||||
// 第一行(App1, completed)应该有 dSYM 和下载按钮
|
||||
@@ -143,6 +150,15 @@ describe('HistoryView.vue', () => {
|
||||
expect(firstRow.find('.qr-thumb').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('普通用户不显示历史操作按钮', async () => {
|
||||
const wrapper = mountHistory(false)
|
||||
await flushPromises()
|
||||
|
||||
expect(wrapper.find('.action-btns').exists()).toBe(false)
|
||||
expect(wrapper.text()).not.toContain('删除')
|
||||
expect(wrapper.text()).not.toContain('日志')
|
||||
})
|
||||
|
||||
it('空列表显示提示', async () => {
|
||||
fetch.mockResolvedValue({ json: () => Promise.resolve([]) })
|
||||
const router = createMockRouter()
|
||||
@@ -181,10 +197,7 @@ describe('HistoryView.vue', () => {
|
||||
})
|
||||
|
||||
it('点击查看日志打开日志弹窗', async () => {
|
||||
const router = createMockRouter()
|
||||
const wrapper = mount(HistoryView, {
|
||||
global: { plugins: [router] },
|
||||
})
|
||||
const wrapper = mountHistory(true)
|
||||
await flushPromises()
|
||||
|
||||
const logBtn = wrapper.findAll('.action-btn').find(b => b.text() === '日志')
|
||||
|
||||
Reference in New Issue
Block a user