Files
wekan/tests/actionButtonsUseThemeClass.test.cjs
T
Lauri Ojansivu 95147fc999 Add an LDAP Sync now button to Admin Panel / People / LDAP.
ldap_sync_now existed in packages/wekan-ldap/server/syncUser.js, but nothing
imported that file, so the method was never defined. It also imported every
directory user regardless of the sync settings. Per the maintainer decision of
2026-10-08 it is now loaded and wired to a Sync LDAP users now button. It runs
the background sync once with the settings in effect: import new users and/or
keep existing users updated, without needing the schedule to be on. Only an
active site administrator can run it, and with neither setting on it says
there is nothing to sync. The button and the scheduled job share one run at a
time, and a failed run reports the directory's error instead of success.

New text is added in English, pending Transifex.

Thanks to xet7 !
2026-10-08 10:59:21 +03:00

52 lines
2.5 KiB
JavaScript

'use strict';
// Regression guard: reported directly - on an opened card the Flowtime "Add
// Interruption" button rendered as an unthemed default button beside "Start
// Pomodoro", and the Timeline view's "Restore to this state" button the same
// way. WeKan's action buttons take their colors from the `.primary` (or
// `.negate` for destructive) theme class; a `button` with neither is the
// browser default, which looks like a different, unstyled control next to a
// themed one.
//
// This pins every labelled action button added by recent features to the
// `.primary` class. Pagination arrows, sort headers, icon-only toggles and the
// vote/poker buttons have their own deliberate styling and are not action
// buttons in this sense, so they are not listed.
//
// Run: node tests/actionButtonsUseThemeClass.test.cjs
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const ROOT = path.join(__dirname, '..');
let passed = 0;
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
const BUTTONS = [
['client/components/cards/cardFlowtime.jade', 'js-add-flow-interruption', 'Flowtime "Add Interruption"'],
['client/components/cards/cardFlowtime.jade', 'js-start-flow', 'Flowtime "Start"'],
['client/components/cards/cardPomodoro.jade', 'js-start-pomodoro', 'Pomodoro "Start"'],
['client/components/boards/timelineView.jade', 'js-restore-card-timeline', 'Timeline "Restore to this state"'],
['client/components/lists/listHeader.jade', 'js-list-sync-now', 'List "Sync now"'],
// Moved with the LDAP section to the catalog form's own template.
['client/components/settings/authProviderSettings.jade', 'js-ldap-test-connection', 'Admin Panel "Test LDAP Connection"'],
['client/components/settings/authProviderSettings.jade', 'js-ldap-sync-now', 'Admin Panel "Sync LDAP users now"'],
];
console.log('actionButtonsUseThemeClass:');
for (const [rel, cls, label] of BUTTONS) {
test(`${label} carries the .primary theme class`, () => {
const src = fs.readFileSync(path.join(ROOT, rel), 'utf8');
const line = src.split('\n').find(l => new RegExp(`^\\s*button[^\\s(]*\\.${cls}(?![\\w-])`).test(l));
assert.ok(line, `${rel} must still have a button.${cls}`);
const classChain = /^\s*button([.#][^\s(]*)/.exec(line)[1];
assert.ok(classChain.split('.').includes('primary'),
`${label} (${rel}) is an unthemed default button: ${line.trim()}`);
});
}
console.log(`\nactionButtonsUseThemeClass: ${passed} tests passed`);