mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Turns the flagged manual checks into automated tests and covers the newest
dependency ("Red Strings") features that lacked tests.
Mocha (server/lib/tests, registered in index.js):
- dependencies.metadata.tests.js: normalizeDependency (legacy string upgrade,
defaults, invalid type), direction meta (blocks/fixes forward,
is-blocked-by/is-fixed-by reversed, related-to undirected), inverse map.
- dependencies.openapi.tests.js: every WebApp.handlers dependency route has
@operation/@tag Dependencies/@summary, no undocumented route, unique ids
(guards "OpenAPI picks up new routes" without running the python generator).
Mocha (client/lib/tests):
- filter.dependencies.tests.js: Filter.cardDependencies toggles and builds a
cardDependencies.type mongo selector.
Playwright e2e:
- 28-dependencies-rest.e2e.js: REST CRUD with type/color/icon, board-level
list, update-in-place, validation (bad type, self-link), auth — exercises the
cardDependencies SimpleSchema via real $push and positional ($) updates on the
live server (the schema manual-check).
- 27-red-strings.e2e.js: added minicard badge, copyCard same-board preservation
(type/color), and importBoardDependencies card matching by number and title.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
97 lines
3.5 KiB
JavaScript
97 lines
3.5 KiB
JavaScript
/* eslint-env mocha */
|
|
import { expect } from 'chai';
|
|
import {
|
|
DEFAULT_DEPENDENCY_COLOR,
|
|
DEFAULT_DEPENDENCY_ICON,
|
|
DEFAULT_DEPENDENCY_TYPE,
|
|
DEPENDENCY_TYPE_IDS,
|
|
DEPENDENCY_TYPE_INVERSE,
|
|
dependencyTypeMeta,
|
|
normalizeDependency,
|
|
normalizeDependencies,
|
|
} from '/models/metadata/dependencies';
|
|
|
|
// #3392: pure-logic tests for the typed card-dependency ("Red Strings") helpers.
|
|
describe('dependencies metadata', function () {
|
|
describe('normalizeDependency', function () {
|
|
it('upgrades a legacy bare-string card id to a full object', function () {
|
|
expect(normalizeDependency('card123')).to.deep.equal({
|
|
cardId: 'card123',
|
|
type: DEFAULT_DEPENDENCY_TYPE,
|
|
color: DEFAULT_DEPENDENCY_COLOR,
|
|
icon: DEFAULT_DEPENDENCY_ICON,
|
|
});
|
|
});
|
|
|
|
it('fills missing fields with defaults', function () {
|
|
expect(normalizeDependency({ cardId: 'c1' })).to.deep.equal({
|
|
cardId: 'c1',
|
|
type: DEFAULT_DEPENDENCY_TYPE,
|
|
color: DEFAULT_DEPENDENCY_COLOR,
|
|
icon: DEFAULT_DEPENDENCY_ICON,
|
|
});
|
|
});
|
|
|
|
it('keeps a valid type/color/icon', function () {
|
|
expect(
|
|
normalizeDependency({ cardId: 'c1', type: 'blocks', color: '#2196f3', icon: 'lock' }),
|
|
).to.deep.equal({ cardId: 'c1', type: 'blocks', color: '#2196f3', icon: 'lock' });
|
|
});
|
|
|
|
it('falls back to the default type for an unknown type', function () {
|
|
expect(normalizeDependency({ cardId: 'c1', type: 'bogus' }).type).to.equal(
|
|
DEFAULT_DEPENDENCY_TYPE,
|
|
);
|
|
});
|
|
|
|
it('returns null for entries without a card id', function () {
|
|
expect(normalizeDependency(null)).to.equal(null);
|
|
expect(normalizeDependency({})).to.equal(null);
|
|
expect(normalizeDependency('')).to.equal(null);
|
|
});
|
|
});
|
|
|
|
describe('normalizeDependencies', function () {
|
|
it('normalizes a mixed legacy/object array and drops invalid entries', function () {
|
|
const out = normalizeDependencies(['a', { cardId: 'b', type: 'fixes' }, {}, null]);
|
|
expect(out).to.have.length(2);
|
|
expect(out[0].cardId).to.equal('a');
|
|
expect(out[1]).to.deep.include({ cardId: 'b', type: 'fixes' });
|
|
});
|
|
|
|
it('returns [] for undefined', function () {
|
|
expect(normalizeDependencies(undefined)).to.deep.equal([]);
|
|
});
|
|
});
|
|
|
|
describe('dependencyTypeMeta direction', function () {
|
|
it('blocks / fixes are directed and forward', function () {
|
|
expect(dependencyTypeMeta('blocks')).to.include({ directed: true, forward: true });
|
|
expect(dependencyTypeMeta('fixes')).to.include({ directed: true, forward: true });
|
|
});
|
|
|
|
it('is-blocked-by / is-fixed-by are directed and reversed', function () {
|
|
expect(dependencyTypeMeta('is-blocked-by')).to.include({ directed: true, forward: false });
|
|
expect(dependencyTypeMeta('is-fixed-by')).to.include({ directed: true, forward: false });
|
|
});
|
|
|
|
it('related-to is undirected', function () {
|
|
expect(dependencyTypeMeta('related-to').directed).to.equal(false);
|
|
});
|
|
|
|
it('an unknown type falls back to the default type meta', function () {
|
|
expect(dependencyTypeMeta('nope').id).to.equal(DEFAULT_DEPENDENCY_TYPE);
|
|
});
|
|
});
|
|
|
|
describe('DEPENDENCY_TYPE_INVERSE', function () {
|
|
it('maps every type to a valid inverse, and inverting twice is identity', function () {
|
|
DEPENDENCY_TYPE_IDS.forEach(id => {
|
|
const inv = DEPENDENCY_TYPE_INVERSE[id];
|
|
expect(DEPENDENCY_TYPE_IDS).to.include(inv);
|
|
expect(DEPENDENCY_TYPE_INVERSE[inv]).to.equal(id);
|
|
});
|
|
});
|
|
});
|
|
});
|