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