diff --git a/src/email/templates/giftCard.md b/src/email/templates/giftCard.md index 37d8876..41f20f3 100644 --- a/src/email/templates/giftCard.md +++ b/src/email/templates/giftCard.md @@ -7,7 +7,7 @@ In recognition, we'd like to send you [{{ featuredProduct }}]({{link}}). (Or you In recognition, we're sending you a ${{ amount }} giftcard for [the CodeDay Store]({{link}}). {{/if}} -Use this code at checkout to receive the ${{amount}} credit with free shipping: {{code}} +Use this code at checkout to receive the ${{amount}} credit: {{code}} This code expires in a month, so [click here to use it now.]({{ link }}) diff --git a/tests/testGiftCardTemplate.ts b/tests/testGiftCardTemplate.ts new file mode 100644 index 0000000..fa566ac --- /dev/null +++ b/tests/testGiftCardTemplate.ts @@ -0,0 +1,18 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { readFile } from 'fs/promises'; +import path from 'path'; + +// The mentor-giftcard Shopify discount is a `discountCodeBasicCreate` amount-off +// discount, which only reduces the eligible item subtotal and CANNOT waive the +// shipping line. The gift email must therefore never promise "free shipping", +// or mentors will be asked to pay an unexpected shipping charge at checkout for +// a "free" gift. This guard fails if that false promise is re-introduced. +test('giftCard.md does not promise free shipping (Shopify discountAmount cannot waive shipping)', async () => { + const src = (await readFile(path.join(__dirname, '..', 'src', 'email', 'templates', 'giftCard.md'))).toString(); + assert.equal( + /free\s+shipping/i.test(src), + false, + 'giftCard.md must not promise "free shipping": the issued discountCodeBasicCreate discountAmount only applies to the item subtotal, not the shipping line', + ); +});