mirror of
https://github.com/wekan/wekan.git
synced 2026-11-20 09:45:04 -05:00
Admin Panel / Settings / Shared labels chose a colour from a dropdown of colour names. The board label popup's picker - the palette swatches and the custom colour wheel - is its own template now, labelColorPicker, and the popup and every Shared labels row use it; a custom colour is saved as its hex, which the server already accepted. A pick reaches the row through an object with set(), because Spacebars calls a function argument instead of passing it. The swatches grow to fill their row, so on the wide admin page their width followed the window. There they have the size they have in an opened card's label popup, 54 x 33px, at every window width. tests/sharedLabelsColorPicker.test.cjs pins the shared picker and the size; tests/playwright/specs/shared-labels-color-picker.e2e.js picks a swatch and a custom colour, saves both, and measures the swatches at 1366, 1920 and 2560px. Thanks to xet7 !
50 lines
2.4 KiB
JavaScript
50 lines
2.4 KiB
JavaScript
'use strict';
|
|
|
|
// Admin Panel / Settings / Shared labels picks a colour with the board labels'
|
|
// own picker - labelColorPicker, the palette swatches and the custom colour
|
|
// wheel - instead of a dropdown of colour names, and its swatches have the size
|
|
// they have in an opened card's label popup at every window width.
|
|
// tests/playwright/specs/shared-labels-color-picker.e2e.js drives it in a browser.
|
|
//
|
|
// Run: node tests/sharedLabelsColorPicker.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const read = rel => fs.readFileSync(path.join(__dirname, '..', rel), 'utf8');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
|
|
|
console.log('sharedLabelsColorPicker:');
|
|
|
|
test('one picker template, used by the board label popup and by Shared labels', () => {
|
|
const labels = read('client/components/cards/labels.jade');
|
|
assert.match(labels, /template\(name="labelColorPicker"\)/);
|
|
assert.match(labels, /template\(name="formLabel"\)[\s\S]*?\+labelColorPicker\(color=color\)/);
|
|
const shared = read('client/components/settings/sharedLabelsSettings.jade');
|
|
assert.match(shared, /\+labelColorPicker\(color=color onChange=colorSink\)/);
|
|
assert.ok(!/select\.js-shared-label-color/.test(shared), 'no dropdown of colour names (negative)');
|
|
assert.ok(!/colorOptions/.test(read('client/components/settings/sharedLabelsSettings.js')));
|
|
});
|
|
|
|
test('a pick reaches the Shared labels row through an object, not a function argument', () => {
|
|
const js = read('client/components/settings/sharedLabelsSettings.js');
|
|
assert.match(js, /colorSink: \{ set: color => change\(tpl, id, 'color', color\) \}/);
|
|
const picker = read('client/components/cards/labels.js');
|
|
assert.match(picker, /typeof onChange\.set === 'function'\) onChange\.set\(color\)/);
|
|
});
|
|
|
|
test('the swatches have the label popup\'s size, not the window\'s (negative: no growth)', () => {
|
|
const css = read('client/components/cards/labels.css').replace(/\/\*[\s\S]*?\*\//g, '');
|
|
const at = css.indexOf('.shared-label-color .palette-colors .palette-color {');
|
|
assert.ok(at !== -1);
|
|
const body = css.slice(at, css.indexOf('}', at));
|
|
for (const rule of [/flex:\s*0 0 auto/, /box-sizing:\s*content-box/, /width:\s*36px/, /height:\s*25px/, /padding:\s*3px 8px/]) {
|
|
assert.match(body, rule);
|
|
}
|
|
});
|
|
|
|
console.log(`\nsharedLabelsColorPicker: ${passed} tests passed`);
|