mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Title changes did not create an activity, so no outgoing webhook fired (unlike description/dueAt changes). Log an a-changedTitle activity in the Cards before.update hook, mirroring the timing-field activities, so the existing Activities.after.insert webhook hook fires. Pure titleChanged helper + tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
45 lines
1.7 KiB
JavaScript
45 lines
1.7 KiB
JavaScript
/* eslint-env mocha */
|
|
import { expect } from 'chai';
|
|
import { titleChanged } from '../titleChangeActivity';
|
|
|
|
describe('titleChangeActivity', function() {
|
|
describe(titleChanged.name, function() {
|
|
it('returns true when the modifier changes title to a different value', function() {
|
|
const oldDoc = { title: 'Old title' };
|
|
const modifier = { $set: { title: 'New title' } };
|
|
expect(titleChanged(oldDoc, modifier)).to.equal(true);
|
|
});
|
|
|
|
it('returns false when title is absent from the modifier', function() {
|
|
const oldDoc = { title: 'Old title' };
|
|
const modifier = { $set: { description: 'changed' } };
|
|
expect(titleChanged(oldDoc, modifier)).to.equal(false);
|
|
});
|
|
|
|
it('returns false when the title is unchanged', function() {
|
|
const oldDoc = { title: 'Same title' };
|
|
const modifier = { $set: { title: 'Same title' } };
|
|
expect(titleChanged(oldDoc, modifier)).to.equal(false);
|
|
});
|
|
|
|
it('returns true when a title is set on a card that had none', function() {
|
|
const oldDoc = {};
|
|
const modifier = { $set: { title: 'First title' } };
|
|
expect(titleChanged(oldDoc, modifier)).to.equal(true);
|
|
});
|
|
|
|
it('returns false for falsy / malformed modifiers', function() {
|
|
expect(titleChanged({ title: 'x' }, undefined)).to.equal(false);
|
|
expect(titleChanged({ title: 'x' }, null)).to.equal(false);
|
|
expect(titleChanged({ title: 'x' }, {})).to.equal(false);
|
|
expect(titleChanged({ title: 'x' }, { $set: {} })).to.equal(false);
|
|
});
|
|
|
|
it('tolerates a missing oldDoc', function() {
|
|
const modifier = { $set: { title: 'New title' } };
|
|
expect(titleChanged(undefined, modifier)).to.equal(true);
|
|
expect(titleChanged(null, modifier)).to.equal(true);
|
|
});
|
|
});
|
|
});
|