mirror of
https://github.com/wekan/wekan.git
synced 2026-11-20 15:45:01 -05:00
Who sees and may use what was spread over three tabs: the feature switches and feature profiles sat in Settings / Visibility beside the logo and colours, and three settings (Security, Delete, Notifications) sat in Problems among the reports, where they had landed when the Features tab was removed. - Settings / Visibility is Appearance (how this WeKan looks); its Features and Feature profiles groups are panes of their own. One template renders all three by `part`, so every field and Save is unchanged. - Problems / Security, Delete and Notifications are Settings / Security, Delete and "Activities and notifications". Problems is Summary, Backup and the Reports. - Every old address redirects (MOVED_PANES / movedPanePath in models/lib/adminUrls.js, applied by config/router.js). - People, Teams and Organizations show the feature profile that applies, so a profile can be found from either side. - Two new labels, Appearance and Activities and notifications, are translated into every language. tests/adminPanelStructure.test.cjs and admin-panel-structure.e2e.js cover the order, the redirects and that no feature switch is left in Appearance or Problems; older guards and specs follow the new panes. Thanks to xet7 !
83 lines
5.0 KiB
JavaScript
83 lines
5.0 KiB
JavaScript
'use strict';
|
|
// 2026-11-19: the Admin Panel answers one question per tab. Settings = what this
|
|
// WeKan offers and how it looks (Appearance, Features, Feature profiles, Security,
|
|
// Activities and notifications, Delete, ...); People = who may sign in and what
|
|
// they may do; Problems = what is going wrong (Summary, Backup, Reports). The
|
|
// settings that sat in Problems and the features that sat in Visibility moved,
|
|
// and every old address redirects.
|
|
// Run: node --test tests/adminPanelStructure.test.cjs
|
|
const test = require('node:test');
|
|
const assert = require('node:assert');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const urls = require('../models/lib/adminUrls');
|
|
|
|
const read = rel => fs.readFileSync(path.join(__dirname, '..', rel), 'utf8');
|
|
const settingsMenu = (() => {
|
|
const js = read('client/components/settings/settingBody.js');
|
|
const body = js.slice(js.indexOf('function settingsMenu('), js.indexOf('// Multitenancy option D', js.indexOf('function settingsMenu(')));
|
|
return [...body.matchAll(/\{ id: '([\w-]+)'/g)].map(m => m[1]);
|
|
})();
|
|
|
|
test('Settings: how it looks, then what it offers and who sees it, then the server-wide switches', () => {
|
|
assert.deepStrictEqual(settingsMenu.slice(0, 7), ['version-setting', 'tableVisibilityMode-setting', 'features-setting',
|
|
'feature-profiles-setting', 'privacy-security-setting', 'activities-setting', 'delete-setting']);
|
|
for (const [slug, pane] of [['appearance', 'tableVisibilityMode-setting'], ['features', 'features-setting'],
|
|
['feature-profiles', 'feature-profiles-setting'], ['security', 'privacy-security-setting'],
|
|
['activities', 'activities-setting'], ['delete', 'delete-setting']]) {
|
|
assert.strictEqual(urls.paneIdForSlug('settings', slug), pane, slug);
|
|
}
|
|
});
|
|
|
|
test('every moved pane redirects to a pane that exists, and nothing else redirects', () => {
|
|
for (const [page, moved] of Object.entries(urls.MOVED_PANES)) {
|
|
for (const [slug, [toPage, toSlug]] of Object.entries(moved)) {
|
|
assert.ok(urls.paneIdForSlug(toPage, toSlug), `${page}/${slug} -> ${toPage}/${toSlug} exists`);
|
|
assert.strictEqual(urls.paneIdForSlug(page, slug), null, `${page}/${slug} is not still a pane`);
|
|
assert.strictEqual(urls.movedPanePath(page, slug), `/admin/${toPage}/${toSlug}`);
|
|
}
|
|
}
|
|
// Negative: a live pane, an unknown slug and an unknown page are not redirected.
|
|
for (const [page, slug] of [['settings', 'version'], ['problems', 'summary'], ['settings', 'nope'], ['nope', 'security']]) {
|
|
assert.strictEqual(urls.movedPanePath(page, slug), null, `${page}/${slug}`);
|
|
}
|
|
const router = read('config/router.js');
|
|
assert.match(router, /triggersEnter: \[\s*redirectMovedPane\('settings'\),/);
|
|
assert.match(router, /triggersEnter: \[\s*redirectMovedPane\('problems'\),/);
|
|
});
|
|
|
|
test('negative: no feature switch or server-wide setting is left in Appearance or Problems', () => {
|
|
const jade = read('client/components/settings/settingBody.jade');
|
|
const tpl = jade.slice(jade.indexOf("template(name='tableVisibilityModeSettings')"), jade.indexOf("template(name='announcementSettings')"));
|
|
const appearance = tpl.slice(tpl.indexOf(' else\n'));
|
|
for (const cls of ['js-feature-row', 'js-feature-profile', 'js-optional-api-row', 'js-toggle-rules-read-only', 'js-toggle-sqrl']) {
|
|
assert.ok(!appearance.includes(cls), `${cls} is not in Appearance`);
|
|
}
|
|
const problems = read('client/components/settings/adminProblems.jade');
|
|
for (const tpl2 of ['+featuresSecurity', '+featuresDelete', '+featuresNotifications']) {
|
|
assert.ok(!problems.includes(tpl2), `${tpl2} is not rendered on Problems`);
|
|
}
|
|
});
|
|
|
|
test('People, Teams and Organizations show the feature profile that applies', () => {
|
|
const js = read('client/components/settings/peopleBody.js');
|
|
for (const cols of ['PEOPLE_COLUMNS', 'TEAM_COLUMNS', 'ORG_COLUMNS']) {
|
|
const block = js.slice(js.indexOf(`const ${cols} = [`), js.indexOf('];', js.indexOf(`const ${cols} = [`)));
|
|
assert.match(block, /labelKey: 'feature-profiles'/, cols);
|
|
}
|
|
const jade = read('client/components/settings/peopleBody.jade');
|
|
for (const cls of ['td.people-feature-profile', 'td.team-feature-profile', 'td.org-feature-profile']) assert.ok(jade.includes(cls), cls);
|
|
assert.match(read('server/publications/people.js'), /featureProfileId: 1,/);
|
|
});
|
|
|
|
test('the docs mirror it, and explain the layers in one place', () => {
|
|
for (const page of ['Appearance', 'Features', 'Feature-Profiles', 'Security', 'Activities-and-Notifications', 'Delete']) {
|
|
assert.ok(fs.existsSync(path.join(__dirname, '..', `docs/Features/Admin-Panel/Settings/${page}.md`)), page);
|
|
}
|
|
assert.ok(!fs.existsSync(path.join(__dirname, '..', 'docs/Features/Admin-Panel/Settings/Visibility.md')), 'Visibility.md became Appearance.md');
|
|
const map = read('docs/Features/Admin-Panel/Who-Sees-What.md');
|
|
for (const link of ['Settings/Features.md', 'Settings/Feature-Profiles.md', '../Board-Sidebar/Members/Members.md', '../Lists/List-Permissions.md']) {
|
|
assert.ok(map.includes(link), link);
|
|
}
|
|
});
|