refactor(frontend): update test config and optimize components
- Update vitest config to use new test directory structure - Optimize Dashboard, RoleManagement, UserManagement components - Improve signature utility with better error handling - Enhance component error handling and user feedback
This commit is contained in:
@@ -33,13 +33,12 @@ export function generateSignatureHeaders(
|
||||
const nonce = generateNonce()
|
||||
|
||||
const { path, query } = parseUrl(url)
|
||||
const bodyString = body ? JSON.stringify(body) : ''
|
||||
|
||||
const signature = generateSignature(
|
||||
method.toUpperCase(),
|
||||
path,
|
||||
query || '',
|
||||
bodyString,
|
||||
'',
|
||||
timestamp,
|
||||
nonce
|
||||
)
|
||||
|
||||
@@ -199,10 +199,10 @@ const fetchStats = async () => {
|
||||
request.get('/logs/operation/count')
|
||||
])
|
||||
|
||||
stats.userCount = userCountRes.status === 'fulfilled' ? (userCountRes.value || 0) : 0
|
||||
stats.roleCount = roleCountRes.status === 'fulfilled' ? (roleCountRes.value || 0) : 0
|
||||
stats.todayLogin = todayLoginRes.status === 'fulfilled' ? (todayLoginRes.value || 0) : 0
|
||||
stats.operationLog = operationLogRes.status === 'fulfilled' ? (operationLogRes.value || 0) : 0
|
||||
stats.userCount = userCountRes.status === 'fulfilled' ? Number(userCountRes.value || 0) : 0
|
||||
stats.roleCount = roleCountRes.status === 'fulfilled' ? Number(roleCountRes.value || 0) : 0
|
||||
stats.todayLogin = todayLoginRes.status === 'fulfilled' ? Number(todayLoginRes.value || 0) : 0
|
||||
stats.operationLog = operationLogRes.status === 'fulfilled' ? Number(operationLogRes.value || 0) : 0
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch stats:', error)
|
||||
} finally {
|
||||
|
||||
@@ -282,7 +282,7 @@ const fetchData = async () => {
|
||||
roleName: searchKeyword.value || undefined
|
||||
})
|
||||
dataSource.value = res.content
|
||||
pagination.total = res.totalElements
|
||||
pagination.total = Number(res.totalElements) || 0
|
||||
} catch (error) {
|
||||
handleApiError(error)
|
||||
} finally {
|
||||
|
||||
@@ -294,7 +294,7 @@ const fetchData = async () => {
|
||||
keyword: searchKeyword.value || undefined
|
||||
})
|
||||
dataSource.value = res.content
|
||||
pagination.total = res.totalElements
|
||||
pagination.total = Number(res.totalElements) || 0
|
||||
} catch (error) {
|
||||
handleApiError(error)
|
||||
} finally {
|
||||
@@ -433,6 +433,7 @@ const handleAssignRolesOk = async () => {
|
||||
roleDialogVisible.value = false
|
||||
fetchData()
|
||||
} catch (error) {
|
||||
roleDialogVisible.value = false
|
||||
handleApiError(error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export default defineConfig({
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'jsdom',
|
||||
setupFiles: ['./src/test/setup.ts'],
|
||||
setupFiles: ['./src/__tests__/setup.ts'],
|
||||
pool: 'threads',
|
||||
poolOptions: {
|
||||
threads: {
|
||||
@@ -17,7 +17,7 @@ export default defineConfig({
|
||||
useAtomics: true,
|
||||
},
|
||||
},
|
||||
include: ['src/test/**/*.{test,spec}.{js,ts}'],
|
||||
include: ['src/__tests__/**/*.{test,spec}.{js,ts}'],
|
||||
exclude: [
|
||||
'node_modules/',
|
||||
'dist/',
|
||||
@@ -31,7 +31,7 @@ export default defineConfig({
|
||||
reporter: ['text', 'json', 'html', 'lcov'],
|
||||
exclude: [
|
||||
'node_modules/',
|
||||
'src/test/',
|
||||
'src/__tests__/',
|
||||
'**/*.d.ts',
|
||||
'**/*.config.*',
|
||||
'**/mockData',
|
||||
@@ -65,7 +65,7 @@ export default defineConfig({
|
||||
enabled: true,
|
||||
},
|
||||
benchmark: {
|
||||
include: ['src/test/**/*.{bench,benchmark}.{js,ts}'],
|
||||
include: ['src/__tests__/**/*.{bench,benchmark}.{js,ts}'],
|
||||
exclude: ['node_modules/', 'dist/'],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -7,10 +7,8 @@ export default defineConfig({
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'jsdom',
|
||||
setupFiles: ['./src/test/setup.ts'],
|
||||
// 明确指定包含单元测试文件和角色定义测试
|
||||
setupFiles: ['./src/__tests__/setup.ts'],
|
||||
include: [
|
||||
'src/test/**/*.{test,spec}.{js,ts,jsx,tsx}',
|
||||
'src/__tests__/**/*.{test,spec}.{js,ts,jsx,tsx}'
|
||||
],
|
||||
// 明确排除E2E测试文件
|
||||
@@ -27,7 +25,6 @@ export default defineConfig({
|
||||
reporter: ['text', 'json', 'html', 'lcov'],
|
||||
exclude: [
|
||||
'node_modules/',
|
||||
'src/test/',
|
||||
'src/__tests__/',
|
||||
'**/*.d.ts',
|
||||
'**/*.config.*',
|
||||
|
||||
Reference in New Issue
Block a user