Release v2.5.6
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const {
|
||||
buildDuplicateTimetableGroupName,
|
||||
buildDuplicateTimetableGroup,
|
||||
buildDuplicateTimetableEntry
|
||||
} = require('../src/web/routes/data-sources/timetables/duplicate');
|
||||
const { buildTimetableGroupFormViewModel } = require('../src/web/routes/data-sources/timetables/form-view-model');
|
||||
|
||||
test('timetable duplicate helper copies group and entry fields', () => {
|
||||
const group = {
|
||||
id: 5,
|
||||
name: 'Morning Shift',
|
||||
short_description: 'Weekday events'
|
||||
};
|
||||
const entry = {
|
||||
id: 12,
|
||||
schedule_group_id: 5,
|
||||
title: 'Opening',
|
||||
short_description: 'Doors open',
|
||||
start_datetime: '2026-08-04T08:00:00.000Z',
|
||||
end_datetime: '2026-08-04T09:00:00.000Z'
|
||||
};
|
||||
|
||||
const duplicateGroup = buildDuplicateTimetableGroup(group, buildDuplicateTimetableGroupName(group.name));
|
||||
const duplicateEntry = buildDuplicateTimetableEntry(entry);
|
||||
|
||||
assert.equal(duplicateGroup.id, null);
|
||||
assert.equal(duplicateGroup.name, 'Copy of Morning Shift');
|
||||
assert.equal(duplicateGroup.short_description, 'Weekday events');
|
||||
assert.equal(duplicateGroup.shortDescription, 'Weekday events');
|
||||
assert.equal(duplicateEntry.id, null);
|
||||
assert.equal(duplicateEntry.schedule_group_id, null);
|
||||
assert.equal(duplicateEntry.title, 'Opening');
|
||||
assert.equal(duplicateEntry.short_description, 'Doors open');
|
||||
assert.equal(duplicateEntry.start_datetime, '2026-08-04T08:00:00.000Z');
|
||||
assert.equal(duplicateEntry.end_datetime, '2026-08-04T09:00:00.000Z');
|
||||
});
|
||||
|
||||
test('timetable duplicate form model keeps info toast variant and secondary actions', () => {
|
||||
const model = buildTimetableGroupFormViewModel(
|
||||
{ id: null, name: 'Morning Shift', shortDescription: 'Weekday events' },
|
||||
[],
|
||||
'Review the copied values and save when ready.',
|
||||
{ permissionKeys: ['timetables.create'] },
|
||||
false,
|
||||
{ messageVariant: 'info' }
|
||||
);
|
||||
|
||||
assert.equal(model.messageVariant, 'info');
|
||||
assert.equal(model.showSaveSecondaryActions, true);
|
||||
});
|
||||
|
||||
test('timetable list template includes duplicate action', () => {
|
||||
const template = fs.readFileSync(path.join(__dirname, '..', 'src', 'web', 'views', 'data-sources', 'timetables', 'list.hbs'), 'utf8');
|
||||
|
||||
assert.match(template, /\/data-sources\/timetables\/{\{id\}\}\/duplicate/);
|
||||
assert.match(template, />Dupe<\/a>/);
|
||||
});
|
||||
Reference in New Issue
Block a user