- /api (v1) answers 410 API_V1_REMOVED, except provider webhooks (/api/webhooks/*, /api/whatsapp/webhook) and links in sent messages (308s, one-click POST). 43 v1 route files and deprecation.ts removed; /docs redirects to /docs/v2; API_DOCUMENTATION.md points there. - Read-only and impersonation lists name v2 paths only. The campus scope route test now runs over v2 routes (v2CampusScope.test.ts). - Passwords hashed with Argon2id (@node-rs/argon2); bcrypt hashes still sign in and are re-hashed at the next sign-in. - e2e on /api/v2 only (v2() helper); Playwright waits on /api/v2. - MIGRATING-TO-2.md with the full v1 -> v2 table. - Two documented response shapes corrected. Backend 690 tests and e2e 102/102 (PayFast sandbox skipped) pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.8 KiB
JavaScript
32 lines
1.8 KiB
JavaScript
jest.mock('../src/config/db', () => ({}));
|
|
const { costCopies, setsToCopy } = require('../src/utils/eventClone');
|
|
const { isBlocked } = require('../src/hub/readOnly');
|
|
|
|
describe('event cloning', () => {
|
|
test('costs move to the new option with the same name, else to the whole event', () => {
|
|
const costs = [
|
|
{ id: 'c1', label: 'Venue', costType: 'fixed', amount: 5000, paidFromMethod: null, notes: null, eventOptionId: null, eventOption: null },
|
|
{ id: 'c2', label: 'Meals', costType: 'per_person', amount: 120, paidFromMethod: 'cash', notes: 'x', eventOptionId: 'old-a', eventOption: { name: 'Adult ' } },
|
|
{ id: 'c3', label: 'T-shirts', costType: 'per_person', amount: 80, paidFromMethod: null, notes: null, eventOptionId: 'old-b', eventOption: { name: 'Leader' } },
|
|
];
|
|
const out = costCopies(costs, [{ id: 'new-a', name: 'adult' }, { id: 'new-c', name: 'Child' }]);
|
|
expect(out).toEqual([
|
|
{ label: 'Venue', costType: 'fixed', amount: 5000, paidFromMethod: null, notes: null, eventOptionId: null },
|
|
{ label: 'Meals', costType: 'per_person', amount: 120, paidFromMethod: 'cash', notes: 'x', eventOptionId: 'new-a' },
|
|
{ label: 'T-shirts', costType: 'per_person', amount: 80, paidFromMethod: null, notes: null, eventOptionId: null },
|
|
]);
|
|
// Nothing of the source rows' identity is carried over.
|
|
for (const c of out) expect(c.id).toBeUndefined();
|
|
});
|
|
|
|
test('kids rooms are not copied', () => {
|
|
const sets = [{ id: 'rooms' }, { id: 'kids' }, { id: 'buses' }];
|
|
expect(setsToCopy(sets, 'kids').map(s => s.id)).toEqual(['rooms', 'buses']);
|
|
expect(setsToCopy(sets, null)).toHaveLength(3);
|
|
});
|
|
|
|
test('copying setup is blocked in licence read-only mode', () => {
|
|
expect(isBlocked('POST', '/api/v2/events/abc/copy-from')).toBe(true);
|
|
});
|
|
});
|