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
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ describe('checkout flow', () => {
await settle();
});

it('refund window closes after 30 days', async () => {
it('refund window closes after the grace period', async () => {
const now = new Date('2026-10-01T12:00:00Z');
expect(canRefund(new Date(now.getTime() - 30 * DAY_MS), now)).toBe(true);
expect(canRefund(new Date(now.getTime() - 31 * DAY_MS), now)).toBe(false);
expect(canRefund(new Date(now.getTime() - 32 * DAY_MS), now)).toBe(true);
expect(canRefund(new Date(now.getTime() - 33 * DAY_MS), now)).toBe(false);
await settle();
});

Expand Down
16 changes: 12 additions & 4 deletions apps/pr-reviewer/fixtures/demo-pr/refund-window.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ describe('canRefund', () => {
expect(canRefund(daysAgo(30), now)).toBe(true);
});

it('refuses a refund one millisecond past 30 days', () => {
expect(canRefund(new Date(daysAgo(30).getTime() - 1), now)).toBe(false);
it('allows a refund during the 2-day grace period', () => {
expect(canRefund(daysAgo(31), now)).toBe(true);
});

it('refuses a refund after 31 days', () => {
expect(canRefund(daysAgo(31), now)).toBe(false);
it('allows a refund exactly 32 days after delivery', () => {
expect(canRefund(daysAgo(32), now)).toBe(true);
});

it('refuses a refund one millisecond past the grace period', () => {
expect(canRefund(new Date(daysAgo(32).getTime() - 1), now)).toBe(false);
});

it('refuses a refund after 33 days', () => {
expect(canRefund(daysAgo(33), now)).toBe(false);
});

it('refuses a refund after a year', () => {
Expand Down
5 changes: 4 additions & 1 deletion apps/pr-reviewer/fixtures/demo-pr/refund-window.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const REFUND_WINDOW_DAYS = 30;
const GRACE_PERIOD_DAYS = 2;

export function canRefund(deliveredAt: Date, now = new Date()): boolean {
const days = (now.getTime() - deliveredAt.getTime()) / 86_400_000;
return days <= 30;
return days <= REFUND_WINDOW_DAYS + GRACE_PERIOD_DAYS;
}
Loading