diff --git a/backend/src/emailTemplates.ts b/backend/src/emailTemplates.ts index 60c1a8c..68594d0 100644 --- a/backend/src/emailTemplates.ts +++ b/backend/src/emailTemplates.ts @@ -281,7 +281,10 @@ export const SAMPLE_VALUES: Record = { regenerateUrl: 'https://example.com/api/intake-actions/1/regenerate?expires=0&sig=sample', discardUrl: 'https://example.com/api/intake-actions/1/discard?expires=0&sig=sample', expiresIn: 'one hour', - holdDuration: '24 hours' + holdDuration: '24 hours', + submitUrl: 'https://example.com/submit/sample-token', + label: 'Autumn drop-off', + submissionsAllowed: '25 items' }; export interface StoredTemplate { diff --git a/backend/tests/unit/emailTemplates.test.ts b/backend/tests/unit/emailTemplates.test.ts index 302c533..0d9935a 100644 --- a/backend/tests/unit/emailTemplates.test.ts +++ b/backend/tests/unit/emailTemplates.test.ts @@ -8,14 +8,11 @@ import { SAMPLE_VALUES } from '../../src/emailTemplates'; -const KEYS: TemplateKey[] = [ - 'verification', - 'passwordReset', - 'favoriteSold', - 'favoriteWithdrawn', - 'cartReminder', - 'emailChanged' -]; +// Derived from TEMPLATES rather than hardcoded, so a new template is covered +// by every it.each below the moment it is added. A hardcoded list silently +// stops covering anything added after it was written — which is exactly how +// intakeDraft and uploadLink went untested by the SAMPLE_VALUES guard below. +const KEYS = Object.keys(TEMPLATES) as TemplateKey[]; describe('the built-in templates', () => { it.each(KEYS)('%s has a default subject and body', (key) => { @@ -268,7 +265,22 @@ describe('greeting, built from the configured format', () => { }); describe('every template can address the customer', () => { - it.each(KEYS)('%s offers greeting, firstName and lastName', (key) => { + // Not KEYS: this is an invariant of the six customer-facing templates only. + // intakeDraft and uploadLink notify the shop and a contributor respectively, + // not a customer with a name on file, so they are deliberately not held to + // it — a hardcoded list is correct here rather than a staleness risk, + // because the set of templates this claim applies to does not grow just + // because TEMPLATES does. + const CUSTOMER_FACING_KEYS: TemplateKey[] = [ + 'verification', + 'passwordReset', + 'favoriteSold', + 'favoriteWithdrawn', + 'cartReminder', + 'emailChanged' + ]; + + it.each(CUSTOMER_FACING_KEYS)('%s offers greeting, firstName and lastName', (key) => { expect(TEMPLATES[key].available).toEqual( expect.arrayContaining(['greeting', 'firstName', 'lastName']) );