mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 17:45:18 -05:00
- The permanent delete hint now says Admin Panel / Settings / Delete: the tests that pinned the old path say the new one, and the audited Wu, Corsican and Latin corrections record the change, so the repair tool keeps it. - calendarBaseOptions: the board calendar's editable follows Utils.canModifyBoard() since the write gate. - OAUTH2_RESPONSE_MODE and OAUTH2_CLAIMS_IN_ID_TOKEN are read as process.env (they are environment-only) and named as such in the login catalog test. - The attachment search text strips tags until nothing more is removed, as tests/tagStrippingFixedPoint.test.cjs requires. - Login-Problems.md links sandstorm.org (sandstormOrgHosts). Thanks to xet7 !
61 lines
2.6 KiB
JavaScript
61 lines
2.6 KiB
JavaScript
'use strict';
|
|
|
|
// models/lib/calendarBaseOptions.js: the FullCalendar options the Calendar and
|
|
// Multi Board Calendar views share. Each view used to write them out; they are
|
|
// built once now, and each view adds only what differs.
|
|
//
|
|
// Run: node tests/calendarBaseOptions.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { calendarBaseOptions } = require('../models/lib/calendarBaseOptions.js');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
|
|
|
const base = over => calendarBaseOptions({
|
|
id: 'calendar-view', displayOptions: {}, firstDay: 1,
|
|
weekNumberOf: (date, firstDay) => `w${firstDay}`, translate: key => `T:${key}`,
|
|
locale: 'fi', rtl: false, ...over,
|
|
});
|
|
|
|
console.log('calendarBaseOptions:');
|
|
|
|
test('the shared options carry the user\'s first day into the week numbers', () => {
|
|
const o = base({ firstDay: 0 });
|
|
assert.strictEqual(o.firstDay, 0);
|
|
assert.strictEqual(o.weekNumberCalculation(new Date()), 'w0');
|
|
assert.strictEqual(o.initialView, 'dayGridMonth');
|
|
assert.strictEqual(o.locale, 'fi');
|
|
assert.strictEqual(o.buttonText.today, 'T:today');
|
|
});
|
|
|
|
test('a display option overrides the default view, and RTL sets the direction', () => {
|
|
assert.strictEqual(base({ displayOptions: { initialView: 'selectedCalendarMonth' } }).initialView, 'selectedCalendarMonth');
|
|
assert.strictEqual(base({ rtl: true }).direction, 'rtl');
|
|
assert.strictEqual(base().direction, 'ltr');
|
|
});
|
|
|
|
test('an untranslated label falls back to English, never the key (negative)', () => {
|
|
const o = base({ translate: key => key });
|
|
assert.strictEqual(o.buttonText.prev, 'Previous');
|
|
assert.strictEqual(o.buttonText.list, 'List');
|
|
assert.ok(!('editable' in o) && !('selectable' in o) && !('navLinks' in o),
|
|
'what differs between the two views is left to each view');
|
|
});
|
|
|
|
test('both views build on it and set only what differs', () => {
|
|
// The board's calendar writes only for who may write on the board
|
|
// (tests/calendarWriteGate.test.cjs); the multi-board one never does.
|
|
for (const [file, editable] of [['client/components/boards/boardBody.js', 'Utils\\.canModifyBoard\\(\\)'],
|
|
['client/components/boards/multiboardCalendarView.js', false]]) {
|
|
const src = fs.readFileSync(path.join(__dirname, '..', file), 'utf8');
|
|
assert.match(src, /\.\.\.calendarBaseOptions\(\{/, `${file} uses the shared options`);
|
|
assert.match(src, new RegExp(`editable: ${editable},`), `${file} keeps editable: ${editable}`);
|
|
assert.ok(!src.includes('headerToolbar:'), `${file} has no second copy of the toolbar`);
|
|
}
|
|
});
|
|
|
|
console.log(`\ncalendarBaseOptions: ${passed} tests passed`);
|