mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
The newest test run had two failures. tests/changelogFormat.test.cjs failed on "the binaries table follows the summary": the Upcoming section written after v10.71 had lost the binaries table that every release section carries. It is restored from what v10.71 shipped, and two group lines that had wrapped onto a second line are one line again, which is what the grouping guard requires. The mocha stage did not run at all. client/lib/tests/boardTriggersClass.tests.js reads boardTriggers.jade and boardTriggers.js off disk with fs and path, which worked only while node-polyfill-webpack-plugin's browser shims were in the client bundle; the @meteorjs/rspack 2.1.0 update dropped that plugin and the client build stopped with "Cannot find module 'path' for matched aliased key 'path'". That is not one suite failing - the bundle does not build, so every mocha suite is skipped and the stage reports a crash where its results should be. The suite was on the wrong side rather than wrong: it now lives in server/lib/tests, and tests/clientTestsNoNodeBuiltins.test.cjs is the mirror of the existing guard that keeps browser-only packages out of the server bundle. Issue #6274, "export includes only comments from current year", and its fix in PR #6275 were then checked against the current source. The fix is intact and survived the streaming-export rewrite that came after it: both exporters select comments by cardId and activities by boardId OR cardId. The follow-up its reporter left on that PR - "the export is now missing the lists part" - is not reproducible: result.lists has been written by the JSON exporter continuously since the CSV/TSV export was added, both JSON writers emit the same fourteen sections, and the flat formats carry each list's name on the card's own row. So no export code changed; what was missing was the guard, and tests/exportBoardSections.test.cjs pins the section list, that the two JSON writers agree on it, that no exporter selects comments by board again, and the two smaller fixes from that PR. Not run here: this sandbox has no node, meteor or any other JS runtime, so the new and changed guards were verified by porting them assertion-for-assertion to Python and running that against the same files - changelogFormat 16/16, the export and client-bundle guards clean. The mocha suites behind the fixed build have not executed yet; the next run is what shows them. Thanks to Tuphal, KhaoulaMaleh and xet7 !
91 lines
3.2 KiB
JavaScript
91 lines
3.2 KiB
JavaScript
/* eslint-env mocha */
|
|
/* global describe, it */
|
|
|
|
// Regression guard for WeKan issue #5188:
|
|
// "Rule 'When a card is moved to Archive' can not be activated".
|
|
//
|
|
// Root cause was a CSS class-name drift between the jade template and the JS
|
|
// event handler: the jade used `js-add-arch-trigger` while the handler listened
|
|
// on `js-add-arc-trigger` (missing the 'h'), so the click handler never fired.
|
|
//
|
|
// This test reads both files from disk and asserts that every
|
|
// `js-add-*-trigger` class referenced in the jade template has a matching
|
|
// event-handler selector in the JS file. It is self-contained (only uses the
|
|
// node `fs`/`path` builtins plus chai).
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { expect } = require('chai');
|
|
|
|
// Find the repo root by walking up from process.cwd()/PWD, NOT from the bare `__dirname`
|
|
// global: under `meteor test` referencing `__dirname` makes Meteor inject a
|
|
// `const __dirname` that collides with the one its CommonJS module wrapper already
|
|
// provides, crashing the whole server bundle at boot with "Identifier '__dirname' has
|
|
// already been declared" (same fix as server/lib/tests/dependencies.openapi.tests.js).
|
|
function findRepoRoot(marker) {
|
|
const seeds = [process.cwd(), process.env.PWD, process.env.OLDPWD].filter(Boolean);
|
|
for (const seed of seeds) {
|
|
let dir = seed;
|
|
for (let i = 0; i < 12; i += 1) {
|
|
try { fs.accessSync(path.join(dir, marker)); return dir; } catch (e) { /* walk up */ }
|
|
const parent = path.dirname(dir);
|
|
if (parent === dir) break;
|
|
dir = parent;
|
|
}
|
|
}
|
|
return process.cwd();
|
|
}
|
|
const repoRoot = findRepoRoot(path.join('client', 'components', 'rules', 'triggers', 'boardTriggers.jade'));
|
|
const jadePath = path.join(
|
|
repoRoot,
|
|
'client',
|
|
'components',
|
|
'rules',
|
|
'triggers',
|
|
'boardTriggers.jade',
|
|
);
|
|
const jsPath = path.join(
|
|
repoRoot,
|
|
'client',
|
|
'components',
|
|
'rules',
|
|
'triggers',
|
|
'boardTriggers.js',
|
|
);
|
|
|
|
// Collect every distinct `js-add-<name>-trigger` token in a file.
|
|
function triggerClasses(contents) {
|
|
const re = /js-add-[a-z-]*?-trigger/g;
|
|
return new Set(contents.match(re) || []);
|
|
}
|
|
|
|
describe('boardTriggers template/handler class wiring (#5188)', function() {
|
|
const jade = fs.readFileSync(jadePath, 'utf8');
|
|
const js = fs.readFileSync(jsPath, 'utf8');
|
|
|
|
const jadeClasses = triggerClasses(jade);
|
|
const jsClasses = triggerClasses(js);
|
|
|
|
it('jade and js both define trigger classes', function() {
|
|
expect(jadeClasses.size).to.be.greaterThan(0);
|
|
expect(jsClasses.size).to.be.greaterThan(0);
|
|
});
|
|
|
|
it('every jade js-add-*-trigger class has a matching js handler selector', function() {
|
|
const missing = [...jadeClasses].filter(cls => !jsClasses.has(cls));
|
|
expect(
|
|
missing,
|
|
`These trigger classes are referenced in boardTriggers.jade but have no matching handler in boardTriggers.js: ${missing.join(
|
|
', ',
|
|
)}`,
|
|
).to.deep.equal([]);
|
|
});
|
|
|
|
it('archive trigger class is present in BOTH files (the #5188 regression)', function() {
|
|
expect(jade).to.contain('js-add-arch-trigger');
|
|
expect(js).to.contain('js-add-arch-trigger');
|
|
// The old, mismatched spelling must not reappear.
|
|
expect(js).to.not.contain('js-add-arc-trigger');
|
|
});
|
|
});
|