fix admin dashboard permission scope display
This commit is contained in:
@@ -5,6 +5,7 @@ const ts = require('../admin-web/node_modules/typescript');
|
||||
|
||||
(async () => {
|
||||
let pending = 2;
|
||||
let workbench = null;
|
||||
const responses = {
|
||||
'/operator/analytics/dashboard': { totalUsers: 12, approvedProfiles: 10 },
|
||||
'/operator/analytics/v11-dashboard': { localEligibility: { pending: 99 } },
|
||||
@@ -18,7 +19,7 @@ const ts = require('../admin-web/node_modules/typescript');
|
||||
vm.runInNewContext(ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS } }).outputText, {
|
||||
exports,
|
||||
require: () => ({ default: { get: async url => ({ success: true, data:
|
||||
url === '/operator/reviews/stats' ? { pending, processing: 1 } : responses[url] }) } }),
|
||||
url === '/operator/workbench/dashboard' ? workbench : (url === '/operator/reviews/stats' ? { pending, processing: 1 } : responses[url]) }) } }),
|
||||
});
|
||||
const perms = ['analytics.view', 'activity.view', 'matchmaker.view', 'matchmaker.assign', 'review.view'];
|
||||
let model = await exports.loadDashboard(perms);
|
||||
@@ -30,6 +31,16 @@ const ts = require('../admin-web/node_modules/typescript');
|
||||
pending = 1;
|
||||
model = await exports.loadDashboard(perms);
|
||||
assert.equal(model.metrics.find(m => m.key === 'pending_reviews').value, 2);
|
||||
workbench = { metrics: {
|
||||
pendingReviews: { value: 7, available: false },
|
||||
matchmakerTodos: { value: 0, available: true },
|
||||
} };
|
||||
model = await exports.loadDashboard(perms);
|
||||
const unavailableReview = model.metrics.find(m => m.key === 'pending_reviews');
|
||||
assert.equal(unavailableReview.value, 7);
|
||||
assert.equal(unavailableReview.available, false);
|
||||
assert.equal(unavailableReview.route, '');
|
||||
assert.equal(model.metrics.find(m => m.key === 'matchmaker_todos').value, 0);
|
||||
assert.match(fs.readFileSync('admin-web/src/views/DashboardView.vue', 'utf8'), /onActivated\(retryLoad\)/);
|
||||
console.log('PASS: 审核队列真实计数、审核后减一、管理服务待办与跟进、缓存返回刷新');
|
||||
})().catch(error => { console.error(error); process.exitCode = 1; });
|
||||
|
||||
Reference in New Issue
Block a user