mirror of
https://github.com/wekan/wekan.git
synced 2026-11-26 20:45:07 -05:00
Fourth of the header restructure. This page had the last second header bar with controls in it, and it now has none: the first bar names the page, and every control is a row of the right sidebar the page already had. Only two things actually needed moving. Sort and the Lists/Table view menu become sidebar rows, keeping what made them worth looking at - Sort still shows emphasis while a sort other than the custom order is on, and the view row still names the CURRENT view rather than itself. Search and Multi-Selection did NOT move: the sidebar's home view has offered both as rows since it was written, so carrying the header buttons across would have listed each of them twice. The handlers moved with their markup, because a Blaze event map only sees events inside its own template, and the bar's helpers went with the bar. One consequence worth naming: headerSearchButton and headerMultiSelectionButton were written for TWO bars, and there is one left. The board header is the only user now. They stay shared rather than being folded back into it, because the board's bar is the next one to be emptied - but the guards say plainly that the sharing has one side today, instead of asserting a parity that no longer exists. Six guards followed. The control-order test has now followed these controls three times - `.path-right`, then the header bar, then nowhere - and says so; the Public page's "do not print the title twice" test names the FIRST header bar as what prints it; and the All Boards tests read the sidebar where they used to read the bar. Remaining: the board's own second bar, and the Admin Panel's tab bar. Thanks to xet7 !
80 lines
3.9 KiB
JavaScript
80 lines
3.9 KiB
JavaScript
'use strict';
|
|
|
|
// The All Boards Multi-Selection button should look the same as in the Swimlanes
|
|
// View (board header): an icon + a text label, with the reset X nested inside the
|
|
// button. This guards that parity and that the nested reset stops event propagation
|
|
// (otherwise the click bubbles to the activate handler and re-enables it).
|
|
//
|
|
// Run: node tests/multiSelectionButton.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const repoRoot = path.resolve(__dirname, '..');
|
|
const read = rel => fs.readFileSync(path.join(repoRoot, rel), 'utf8');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
fn();
|
|
passed += 1;
|
|
console.log(' ok -', name);
|
|
}
|
|
|
|
// The Multi-Selection button is ONE template now, headerBarControls.jade, which
|
|
// both bars include. Parity used to be a thing to check, because there were two
|
|
// copies of the markup and they had already drifted - the tooltip on the ✕
|
|
// differed. It is now structural, so this checks the structure: one definition,
|
|
// both users, and the definition still icon + label + nested reset.
|
|
const controls = read('client/components/boards/headerBarControls.jade');
|
|
const block = controls.slice(controls.indexOf('template(name="headerMultiSelectionButton")'));
|
|
|
|
test('the button is defined once, and the board header includes it', () => {
|
|
// It was written for TWO bars, and it still is one template - but All Boards
|
|
// has no header bar any more, so the board is the only user left. All Boards
|
|
// offers Multi-Selection as a sidebar ROW, which is where this restructure
|
|
// puts a control. Kept shared because the board's bar is next to be emptied.
|
|
const header = read('client/components/boards/boardHeader.jade');
|
|
assert.ok(/\+headerMultiSelectionButton\(isActive=MultiSelection\.isActive\)/.test(header),
|
|
'the board header includes the shared button, with its own isActive');
|
|
assert.ok(!/js-multiselection-activate/.test(header),
|
|
'and does not write the button out again');
|
|
|
|
const boards = read('client/components/boards/boardsList.jade');
|
|
assert.ok(!/\+headerMultiSelectionButton/.test(boards),
|
|
'All Boards has no header bar to include it in');
|
|
const sidebar = read('client/components/boards/allBoardsSidebar.jade');
|
|
assert.ok(/js-all-boards-sidebar-multiselection/.test(sidebar),
|
|
'it offers Multi-Selection as a sidebar row instead');
|
|
});
|
|
|
|
test('and it is an icon + a text label with the reset nested inside', () => {
|
|
assert.ok(/i\.fa\.fa-check-square-o/.test(block), 'check-square icon');
|
|
assert.ok(/span \{\{#if isActive\}\}\{\{_ 'multi-selection-on'\}\}\{\{else\}\}\{\{_ 'multi-selection'\}\}/.test(block),
|
|
'a text label, not an icon-only button');
|
|
assert.ok(/js-multiselection-reset/.test(block) && /fa-times-thin/.test(block),
|
|
'nested reset with the thin ✕');
|
|
// NEGATIVE: the old icon-only wrapper / fat ✕.
|
|
assert.ok(!/span\.emoji-icon\s*\n\s*i\.fa\.fa-check-square-o/.test(block),
|
|
'no emoji-icon wrapper around the check icon');
|
|
// The ✕ turns Multi-Selection OFF; it used to say "Clear filter" on the board
|
|
// header, which is what a different control does.
|
|
assert.ok(/js-multiselection-reset\(title="\{\{_ 'multi-selection-off'\}\}"\)/.test(block),
|
|
'and its tooltip names what it does');
|
|
});
|
|
|
|
test('the nested reset stops propagation so it does not re-activate', () => {
|
|
// One handler per page, each on the bar that renders its copy: a Blaze event
|
|
// map catches events from the templates inside it.
|
|
for (const js of ['client/components/boards/boardsList.js',
|
|
'client/components/boards/boardHeader.js']) {
|
|
const src = read(js);
|
|
const i = src.indexOf("'click .js-multiselection-reset'");
|
|
assert.notStrictEqual(i, -1, `${js} must handle the reset`);
|
|
assert.ok(/stopPropagation\(\)/.test(src.slice(i, i + 400)),
|
|
`${js}: reset must not bubble to activate`);
|
|
}
|
|
});
|
|
|
|
console.log(`\nAll ${passed} multi-selection button tests passed`);
|