mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
The new runner ran all 260 suites for the first time: 20 failed. Four were real
defects in the app, the rest were guards pinning a spelling or a design that had
since changed - each of them written when it was true, and none of them run
since, because npm stopped the chain at the first failure.
The app fixes:
* models/lib/themeAccents.js: accentOf('constructor') returned Object's
constructor - a FUNCTION - because a plain lookup answers from
Object.prototype. A board colour named after any prototype member would have
written a function into a stylesheet. Only the map's own keys are themes now.
* RTL: the dependency overlay and its connect handle each set a physical
left/right AFTER the logical property, so the physical one won and both were
pinned to the LTR side in an Arabic or Hebrew layout. The skip link, the
avatar's account badge, the stats value column and the theme-category label
were physical too. All logical now (inset-inline-*, text-align: start/end).
The guards, each corrected to what the code actually does now, with the reason:
* addBoardTileHeight, publicationArgumentGuard: a fixed-size slice
(jade + 3000, source + 1400) that a grown comment pushed the subject out of.
Both now take the whole block they are about.
* adminCheckboxStyle: the Grey Icons feature is gone; asserts its REMOVAL.
* boardsVisibilitySettings: the separator count was pinned at 3; the site-theme
picker group made it 4. Asserts the shape - one Save per section, none for
the picker that applies immediately.
* changelogFormat: "# Upcoming WeKan ® release" is a legitimate heading.
* dbConformanceWiring: the log directory honours WEKAN_LOGDIR now.
* domainTablePage: the default page is the app-wide 10, not 25.
* ferretdbOplogGating: the exec runs under the CPU launcher.
* leftMenu: peopleMenu takes the user (multitenancy option D).
* loginEmailPanesMoved: the board-member restriction is two checkboxes in
Organizations and Teams now; asserted there.
* mobileAllBoardsFit: the bell and the avatar are two rules with variants.
* narrowWindowLayout: the hamburger is the last button in the flow, not pinned.
* rulesApiTriggerNormalize: #6491 made a missing matching field mean "any
value", so the #2674 "can never match" case now matches - and removeMember
iterates assignees, not members.
* securityLog: the new-problems selector moved to models/lib/eventLogProblems.
* tablePage: the Cards report renders the page the SERVER named.
* tenantWiring: the site colour is read in two places; the autorun is the one.
* themeAccents: see above - the guard was right, the code was not.
* translationPane: the "no hand-written table" regex matched the +tablePage
include it also requires.
* uiDensity: admin table cells wrap in one td+th rule now.
* rtl: the dir attribute comes from a helper, `!important` is not part of a
value, and the scanner read CSS COMMENTS as declarations - the comment
explaining why `left: 50%` needs no RTL variant was reported as a violation.
Thanks to xet7 !
111 lines
5.0 KiB
JavaScript
111 lines
5.0 KiB
JavaScript
'use strict';
|
|
|
|
// Plain-Node unit test (no Meteor) for the Admin Panel Domains table paging.
|
|
// Run: node tests/domainTablePage.test.cjs
|
|
//
|
|
// The Domains table now behaves like the Board Table view: only one small page
|
|
// is sent to the browser, ordered by a column and filtered by a search term.
|
|
// paginateDomains() is the server-side search + sort + slice that backs it.
|
|
|
|
const assert = require('assert');
|
|
const { paginateDomains } = require('../models/lib/domainTablePage');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
fn();
|
|
passed += 1;
|
|
console.log(' ok -', name);
|
|
}
|
|
|
|
const rows = [
|
|
{ domain: 'gmail.com', count: 5 },
|
|
{ domain: 'example.com', count: 12 },
|
|
{ domain: 'apple.com', count: 3 },
|
|
{ domain: 'zeta.org', count: 12 },
|
|
{ domain: 'beta.io', count: 1 },
|
|
];
|
|
const names = r => r.rows.map(x => x.domain);
|
|
|
|
// --- Pagination (only a page is returned) -----------------------------------
|
|
test('returns only one page and the correct total', () => {
|
|
const r = paginateDomains(rows, { perPage: 2, page: 1, sortField: 'domain', sortDirection: 1 });
|
|
assert.strictEqual(r.total, 5);
|
|
assert.strictEqual(r.totalPages, 3);
|
|
assert.strictEqual(r.rows.length, 2);
|
|
});
|
|
|
|
test('page 2 returns the next slice; page beyond range clamps to the last page', () => {
|
|
// sorted asc: apple.com, beta.io, example.com, gmail.com, zeta.org
|
|
const p2 = paginateDomains(rows, { perPage: 2, page: 2, sortField: 'domain', sortDirection: 1 });
|
|
assert.deepStrictEqual(names(p2), ['example.com', 'gmail.com']);
|
|
const clamped = paginateDomains(rows, { perPage: 2, page: 99, sortField: 'domain', sortDirection: 1 });
|
|
assert.strictEqual(clamped.page, 3);
|
|
assert.strictEqual(clamped.rows.length, 1);
|
|
});
|
|
|
|
// --- Column sorting ----------------------------------------------------------
|
|
test('sort by domain ascending / descending', () => {
|
|
const asc = paginateDomains(rows, { perPage: 25, sortField: 'domain', sortDirection: 1 });
|
|
assert.deepStrictEqual(names(asc), ['apple.com', 'beta.io', 'example.com', 'gmail.com', 'zeta.org']);
|
|
const desc = paginateDomains(rows, { perPage: 25, sortField: 'domain', sortDirection: -1 });
|
|
assert.deepStrictEqual(names(desc), ['zeta.org', 'gmail.com', 'example.com', 'beta.io', 'apple.com']);
|
|
});
|
|
|
|
test('sort by count descending, tie-broken by domain name', () => {
|
|
const r = paginateDomains(rows, { perPage: 25, sortField: 'count', sortDirection: -1 });
|
|
// 12/12 tie -> example.com before zeta.org, then 5, 3, 1
|
|
assert.deepStrictEqual(names(r), ['example.com', 'zeta.org', 'gmail.com', 'apple.com', 'beta.io']);
|
|
});
|
|
|
|
test('an unknown sortField falls back to sorting by domain', () => {
|
|
const r = paginateDomains(rows, { perPage: 25, sortField: 'bogus', sortDirection: 1 });
|
|
assert.deepStrictEqual(names(r), ['apple.com', 'beta.io', 'example.com', 'gmail.com', 'zeta.org']);
|
|
});
|
|
|
|
// --- Search ------------------------------------------------------------------
|
|
test('search filters by domain substring (case-insensitive) and adjusts total', () => {
|
|
const r = paginateDomains(rows, { perPage: 25, search: 'COM', sortField: 'domain', sortDirection: 1 });
|
|
assert.deepStrictEqual(names(r), ['apple.com', 'example.com', 'gmail.com']);
|
|
assert.strictEqual(r.total, 3);
|
|
});
|
|
|
|
// --- NEGATIVE / edges --------------------------------------------------------
|
|
test('a search with no matches returns an empty page and total 0', () => {
|
|
const r = paginateDomains(rows, { perPage: 25, search: 'no-such-domain' });
|
|
assert.deepStrictEqual(r.rows, []);
|
|
assert.strictEqual(r.total, 0);
|
|
assert.strictEqual(r.totalPages, 1);
|
|
});
|
|
|
|
test('non-array / empty input is handled without throwing', () => {
|
|
assert.deepStrictEqual(paginateDomains(undefined).rows, []);
|
|
assert.deepStrictEqual(paginateDomains(null).rows, []);
|
|
const empty = paginateDomains([]);
|
|
assert.strictEqual(empty.total, 0);
|
|
assert.strictEqual(empty.page, 1);
|
|
});
|
|
|
|
test('perPage is clamped to a sane range (>=1, <=200)', () => {
|
|
// The default is the app's ONE rows-per-page (10, TABLE_PAGE_ROWS_PER_PAGE in
|
|
// models/lib/tablePage.js and docs/Design/Page/Table.md) - it used to be 25
|
|
// here alone, which is exactly the drift that setting exists to stop.
|
|
// models/lib/tablePage.js is an ES module, so read the constant out of it
|
|
// rather than require() it - the same thing tests/tablePage.test.cjs does.
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const src = fs.readFileSync(path.join(__dirname, '..', 'models/lib/tablePage.js'), 'utf8');
|
|
const TABLE_PAGE_ROWS_PER_PAGE = Number(
|
|
src.match(/TABLE_PAGE_ROWS_PER_PAGE\s*=\s*(\d+)/)[1]);
|
|
assert.strictEqual(TABLE_PAGE_ROWS_PER_PAGE, 10, 'the app-wide rows per page');
|
|
assert.strictEqual(paginateDomains(rows, { perPage: 0 }).perPage, TABLE_PAGE_ROWS_PER_PAGE);
|
|
assert.strictEqual(paginateDomains(rows, { perPage: 9999 }).perPage, 200);
|
|
assert.strictEqual(paginateDomains(rows, { perPage: -5 }).perPage, TABLE_PAGE_ROWS_PER_PAGE);
|
|
});
|
|
|
|
test('page is never below 1', () => {
|
|
const r = paginateDomains(rows, { perPage: 2, page: -3 });
|
|
assert.strictEqual(r.page, 1);
|
|
});
|
|
|
|
console.log(`\n${passed} tests passed`);
|