Add a per-event "tickets mailed" flag and mention Abendkasse pickup in the confirmation email
New event_ticket_settings.tickets_mailed column (default false, since no event mails physical tickets today). When false, the redemption confirmation email tells the guest their tickets await pickup at the Abendkasse under their name instead. Read directly by sendRedemptionConfirmation from event_ticket_settings, so both send paths (redeem flow, admin resend) pick it up without either caller changing. Also fixes docker/init/03-tickets-schema.sql, found missing the SOURCE line for migration 003 while adding 004 - local tickets dev databases have been silently missing confirmation_email_status. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -47,11 +47,19 @@ const RECIPIENT = {
|
||||
guestNames: ['Erika Mustermann', 'Hans Mustermann']
|
||||
};
|
||||
|
||||
// Default: no event_ticket_settings row, same "absence over sentinels" case
|
||||
// as everywhere else - ticketsAreMailed reads this as false (not mailed).
|
||||
const makeSettingsConn = (ticketsMailed?: boolean) => ({
|
||||
query: vi.fn().mockResolvedValue(ticketsMailed === undefined ? [] : [{tickets_mailed: ticketsMailed ? 1 : 0}]),
|
||||
end: vi.fn().mockResolvedValue(undefined)
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockGetEvent.mockResolvedValue(EVENT);
|
||||
mockToIcal.mockResolvedValue('BEGIN:VCALENDAR\nEND:VCALENDAR');
|
||||
mockSendMail.mockResolvedValue(true);
|
||||
mockGetConnection.mockResolvedValue(makeSettingsConn());
|
||||
});
|
||||
|
||||
describe('sendRedemptionConfirmation', () => {
|
||||
@@ -95,6 +103,32 @@ describe('sendRedemptionConfirmation', () => {
|
||||
|
||||
expect(await sendRedemptionConfirmation(RECIPIENT)).toBe(false);
|
||||
});
|
||||
|
||||
it('adds the Abendkasse pickup notice when the event does not mail tickets', async () => {
|
||||
mockGetConnection.mockResolvedValue(makeSettingsConn(false));
|
||||
|
||||
await sendRedemptionConfirmation(RECIPIENT);
|
||||
|
||||
const body = mockSendMail.mock.calls[0][2];
|
||||
expect(body).toContain('Abendkasse');
|
||||
expect(body).toContain('Erika Mustermann');
|
||||
});
|
||||
|
||||
it('adds the pickup notice when there is no ticket-shop settings row at all', async () => {
|
||||
mockGetConnection.mockResolvedValue(makeSettingsConn());
|
||||
|
||||
await sendRedemptionConfirmation(RECIPIENT);
|
||||
|
||||
expect(mockSendMail.mock.calls[0][2]).toContain('Abendkasse');
|
||||
});
|
||||
|
||||
it('omits the pickup notice when the event mails tickets', async () => {
|
||||
mockGetConnection.mockResolvedValue(makeSettingsConn(true));
|
||||
|
||||
await sendRedemptionConfirmation(RECIPIENT);
|
||||
|
||||
expect(mockSendMail.mock.calls[0][2]).not.toContain('Abendkasse');
|
||||
});
|
||||
});
|
||||
|
||||
describe('recordConfirmationEmailResult', () => {
|
||||
|
||||
Reference in New Issue
Block a user