Add Enable Dynamic Audio option to schedule blocks

This commit is contained in:
NeilClack
2026-09-11 18:41:53 -05:00
parent 468a65a688
commit 96a1342c10
9 changed files with 126 additions and 4 deletions
@@ -63,6 +63,7 @@ describe('schedule load', () => {
id: 'b1',
startMinutes: 360,
endMinutes: 480,
dynamicAudio: true,
proclamations: [
{
proclamation: {
@@ -78,9 +79,14 @@ describe('schedule load', () => {
]);
const result = (await load({ locals } as never)) as {
blocks: { id: string; proclamations: Record<string, unknown>[] }[];
blocks: {
id: string;
dynamicAudio: boolean;
proclamations: Record<string, unknown>[];
}[];
};
expect(result.blocks[0].dynamicAudio).toBe(true);
expect(result.blocks[0].proclamations[0]).toEqual({
id: 'p1',
name: 'Peace',
@@ -127,7 +133,8 @@ describe('schedule actions', () => {
request: createFormRequest({
startMinutes: '360',
endMinutes: '480',
proclamationIds: JSON.stringify(['p1', 'p2'])
proclamationIds: JSON.stringify(['p1', 'p2']),
dynamicAudio: 'true'
}),
locals
} as never);
@@ -136,10 +143,29 @@ describe('schedule actions', () => {
expect(createBlockMock).toHaveBeenCalledWith('user-1', {
startMinutes: 360,
endMinutes: 480,
proclamationIds: ['p1', 'p2']
proclamationIds: ['p1', 'p2'],
dynamicAudio: true
});
});
it('createBlock defaults dynamic audio to false when the field is absent', async () => {
createBlockMock.mockResolvedValue({ ok: true, id: 'b1' });
await actions.createBlock!({
request: createFormRequest({
startMinutes: '360',
endMinutes: '480',
proclamationIds: JSON.stringify(['p1'])
}),
locals
} as never);
expect(createBlockMock).toHaveBeenCalledWith(
'user-1',
expect.objectContaining({ dynamicAudio: false })
);
});
it('deleteBlock returns not found without an id', async () => {
const result = await actions.deleteBlock!({
request: createFormRequest({}),