Files
wekan/server/lib/tests/titleChangeActivity.tests.js
T
Lauri OjansivuandClaude Opus 4.8 9aa97ab8ff Fix #3619: updating a card title fires the outgoing webhook
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>
2026-06-20 17:47:56 +03:00

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);
});
});
});