Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/email/templates/giftCard.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <strong>{{code}}</strong>
Use this code at checkout to receive the ${{amount}} credit: <strong>{{code}}</strong>

This code expires in a month, so [click here to use it now.]({{ link }})

Expand Down
18 changes: 18 additions & 0 deletions tests/testGiftCardTemplate.ts
Original file line number Diff line number Diff line change
@@ -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',
);
});
Loading