mirror of
https://github.com/wekan/wekan.git
synced 2026-11-20 09:45:04 -05:00
tests/playwright/specs/viewport-matrix.e2e.js opens WeKan as an iPhone 15, an unfolded Galaxy Z Fold 7, an iPad Pro 11, a 1366x768 laptop and a 55" 4K touch panel, each upright and on its side, and checks the board header, board menu -> Original positions, Problems -> Memory Usage and Disk usage, the Table, Calendar Mode, Time, Timeline and Map views, and dragscroll by mouse or by finger. It measures that icons and texts are on screen and not drawn in the colour behind them, that the page never scrolls sideways, that every column can be reached and stays readable; screenshots of each step go to .tools/log/viewports/. What it found, fixed: - iPhone: the header bar was width: 100% plus its side padding as a content box, 24px wider than the screen, and the sidebar hamburger sat past the right edge. It measures its padding inside now. - Admin Panel left menu on a phone: the list's disc bullets showed as a dot after every entry, and a rule between groups shrank to a dash beside an entry. No bullets, and each group starts a row of its own. - Admin tables: 13 equal columns were 25px each on a phone and 42px on an upright iPad, every header one letter per line. Up to 1024px a column keeps a readable floor and the table scrolls sideways in its wrapper. - Table view: the title-wrap and swimlane-group toggles were white icons on white - two empty squares - stretched to 72px by the global button padding. And on an upright iPad or foldable, Members, Labels and the date columns lay past the edge of an overflow-hidden board with nothing to scroll; the view scrolls sideways itself now. A swipe that starts beside a list's resize handle resizes the list, as it should, so the dragscroll check starts where a person pans. The file runs in Chromium only: device emulation and the touch swipe exist only there. Thanks to xet7 !
69 lines
3.5 KiB
JavaScript
69 lines
3.5 KiB
JavaScript
'use strict';
|
|
|
|
// Board Table view's two toggle buttons ("wrap card titles" and "group by
|
|
// swimlane") had bare one-word tooltips ({{_ 'card'}}, {{_ 'swimlane'}}) that
|
|
// did not say what clicking the button actually does, or which of the two
|
|
// states is currently on. Run: node tests/tableViewToggleTooltips.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const root = path.join(__dirname, '..');
|
|
const read = file => fs.readFileSync(path.join(root, file), 'utf8');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
|
|
|
console.log('tableViewToggleTooltips:');
|
|
|
|
const jade = read('client/components/boards/tableView.jade');
|
|
const en = JSON.parse(read('imports/i18n/data/en.i18n.json'));
|
|
|
|
const TOGGLES = [
|
|
{ cls: 'js-table-view-toggle-card-title-wrap', flag: 'wrapCardTitles', onKey: 'board-table-card-title-wrap-on', offKey: 'board-table-card-title-wrap-off' },
|
|
{ cls: 'js-table-view-toggle-swimlane-groups', flag: 'groupBySwimlane', onKey: 'board-table-group-by-swimlane-on', offKey: 'board-table-group-by-swimlane-off' },
|
|
];
|
|
|
|
TOGGLES.forEach(({ cls, flag, onKey, offKey }) => {
|
|
test(`.${cls} has a descriptive tooltip for both states`, () => {
|
|
const at = jade.indexOf(cls);
|
|
assert.ok(at !== -1, `${cls} exists in tableView.jade`);
|
|
const tag = jade.slice(jade.lastIndexOf('button', at), jade.indexOf(')', at) + 1);
|
|
assert.match(tag, new RegExp(`title="\\{\\{#if ${flag}\\}\\}\\{\\{_ '${onKey}'\\}\\}\\{\\{else\\}\\}\\{\\{_ '${offKey}'\\}\\}\\{\\{/if\\}\\}"`),
|
|
'the title switches between the on/off translation key with the toggle state');
|
|
assert.match(tag, new RegExp(`aria-label="\\{\\{#if ${flag}\\}\\}\\{\\{_ '${onKey}'\\}\\}\\{\\{else\\}\\}\\{\\{_ '${offKey}'\\}\\}\\{\\{/if\\}\\}"`),
|
|
'aria-label mirrors the same descriptive text, not just the bare word');
|
|
assert.ok(typeof en[onKey] === 'string' && en[onKey].length > 10, `${onKey} has a real English sentence`);
|
|
assert.ok(typeof en[offKey] === 'string' && en[offKey].length > 10, `${offKey} has a real English sentence`);
|
|
// Each explains BOTH what is true now and what clicking it does.
|
|
assert.match(en[onKey], /click/i);
|
|
assert.match(en[offKey], /click/i);
|
|
});
|
|
});
|
|
|
|
test('the bare {{_ \'card\'}}/{{_ \'swimlane\'}} tooltips are gone from these buttons (negative)', () => {
|
|
TOGGLES.forEach(({ cls }) => {
|
|
const at = jade.indexOf(cls);
|
|
const tag = jade.slice(jade.lastIndexOf('button', at), jade.indexOf(')', at) + 1);
|
|
assert.ok(!/title="\{\{_ '(card|swimlane)'\}\}"/.test(tag),
|
|
`${cls} no longer uses the bare one-word tooltip`);
|
|
});
|
|
});
|
|
|
|
// The global `button` rule (forms.css) pads every button 35px a side and paints
|
|
// its text white; on these white toggles the icon was white on white and the
|
|
// box 72px wide. tests/playwright/specs/viewport-matrix.e2e.js checks the colour
|
|
// in a browser.
|
|
test('the toggles draw a dark icon on their white face, at their own size', () => {
|
|
const css = read('client/components/boards/tableView.css').replace(/\/\*[\s\S]*?\*\//g, '');
|
|
const at = css.indexOf('.table-view-controls .js-table-view-toggle-card-title-wrap,\n.table-view-controls .js-table-view-toggle-swimlane-groups {');
|
|
assert.ok(at !== -1, 'the toggle rule exists');
|
|
const body = css.slice(at, css.indexOf('}', at));
|
|
assert.match(body, /background:\s*#fff/);
|
|
assert.match(body, /color:\s*#333/, 'a dark icon, not the global white');
|
|
assert.match(body, /padding:\s*0/, 'no 35px global padding');
|
|
});
|
|
|
|
console.log(`\ntableViewToggleTooltips: ${passed} tests passed`);
|